From 785da5811a0f7187c8bae5c53a2733c3190d7c10 Mon Sep 17 00:00:00 2001 From: Jim Morris Date: Sun, 24 Apr 2016 23:28:18 -0700 Subject: [PATCH] Attempt to correct last milestone after an ON_HALT if queue was not empty. --- src/libs/Kernel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/Kernel.cpp b/src/libs/Kernel.cpp index c0256897..c351010b 100644 --- a/src/libs/Kernel.cpp +++ b/src/libs/Kernel.cpp @@ -234,12 +234,21 @@ void Kernel::register_for_event(_EVENT_ENUM id_event, Module *mod){ // Call a specific event with an argument void Kernel::call_event(_EVENT_ENUM id_event, void * argument){ + bool was_idle= true; if(id_event == ON_HALT) { this->halted= (argument == nullptr); + was_idle= conveyor->is_queue_empty(); // see if we were doing anything like printing } + + // send to all registered modules for (auto m : hooks[id_event]) { (m->*kernel_callback_functions[id_event])(argument); } + + if(id_event == ON_HALT && !was_idle) { + // we need to try to correct current positions if we were running + this->robot->reset_position_from_current_actuator_position(); + } } // These are used by tests to test for various things. basically mocks -- 2.20.1