orocos-toolchain / rtt

Orocos Real-Time Toolkit
http://www.orocos.org
Other
72 stars 79 forks source link

unloadStateMachine - orocos 2.8 #140

Open cfpperche2 opened 8 years ago

cfpperche2 commented 8 years ago

Hi, can one help me with how to unloadStateMachine when my component is in cleanupHook() state;

When I do

void TaskVilma::cleanupHook()
{
    RTT::log(RTT::Warning) << "TaskVilma cleaning up !" << RTT::endlog();

    scripting->stopStateMachine(state_machine_name_); // again in reactive mode, in final state
    scripting->deactivateStateMachine(state_machine_name_); // deactivate state machine
    scripting->unloadStateMachine(state_machine_name_); // unload state machine

    recover(); // go to PreOperational state
}

this block the component and lock the terminal.

snrkiwi commented 8 years ago

On Mar 02, 2016, at 02:39, cfpperche notifications@github.com wrote:

Hi, can one help me with how to unloadStateMachine when my component is in cleanupHook() state;

When I do

void TaskVilma::cleanupHook() { RTT::log(RTT::Warning) << "TaskVilma cleaning up !" << RTT::endlog();

scripting->stopStateMachine(state_machine_name_); // again in reactive mode, in final state
scripting->deactivateStateMachine(state_machine_name_); // deactivate state machine
scripting->unloadStateMachine(state_machine_name_); // unload state machine

recover(); // go to PreOperational state

} this block the component and lock the terminal.

I’ve found that you have to have gotten the state machine to the FINAL state, before you try any of the above. If not, you get things like lockups … it just doesn’t like it.

If you’re using the deployer then there is a way to catch the “quit” command and attach a script to that. We use that to catch quit, instruct all state machines to go to the FINAL state, and then let the deployer shutdown take care of the rest. And iIRC our component’s stopHook() does only a deactivate of the state machine.

HTH S