getting_started:practical_problems:abort
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
getting_started:practical_problems:abort [2017/09/25 07:41] – graf | getting_started:practical_problems:abort [2024/02/16 08:16] (current) – ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Shutting down a System ====== | + | ====== Shutting down a System |
How does a robot control system properly shut down? In general it does never stop. Pressing an emergency button might switch to a emergency safety level. From there it might restart again after certain steps are taken. \\ However, in a system under development it is often desirable to end an application. That usually means to switch to a specific safety level where the necessary steps for a well controlled stopping of the application takes place. Only after this happened the executor stops running and returns control to the main program, which then stops as well. \\ | How does a robot control system properly shut down? In general it does never stop. Pressing an emergency button might switch to a emergency safety level. From there it might restart again after certain steps are taken. \\ However, in a system under development it is often desirable to end an application. That usually means to switch to a specific safety level where the necessary steps for a well controlled stopping of the application takes place. Only after this happened the executor stops running and returns control to the main program, which then stops as well. \\ | ||
- | The following example shows how this can be accomplished. The code can be found in [[getting_started: | + | The following example shows how this can be accomplished. The code can be found in [[getting_started: |
<code cpp> | <code cpp> | ||
#include " | #include " | ||
Line 8: | Line 8: | ||
void signalHandler(int signum) { | void signalHandler(int signum) { | ||
SafetySystem:: | SafetySystem:: | ||
- | Sequencer:: | ||
} | } | ||
Line 33: | Line 32: | ||
In the example this function triggers a safety event '' | In the example this function triggers a safety event '' | ||
- | After pressing '' | + | After pressing '' |
The system will stay in the level as long as the shutting down will take. This could include a whole sequence of steps such as applying brakes or driving to a safe position. As soon as this point is reached another safety event, '' | The system will stay in the level as long as the shutting down will take. This could include a whole sequence of steps such as applying brakes or driving to a safe position. As soon as this point is reached another safety event, '' | ||
<code cpp> | <code cpp> | ||
- | slOff.setLevelAction([& | + | slOff.setLevelAction([& |
+ | | ||
+ | Sequencer:: | ||
+ | }); | ||
+ | </ | ||
+ | This will cause the executor to stop running and return control to the main programm. Further, any running sequences will terminate and the main program will exit. | ||
+ | |||
+ | ===== Define Signal Handler when using ROS ===== | ||
+ | If you use ROS you have to keep in mind to register the signal handler only after the ROS node is created and initialized, | ||
+ | <code cpp> | ||
+ | |||
+ | int main() { | ||
+ | ... | ||
+ | // init ROS node | ||
+ | |||
+ | signal(SIGINT, | ||
+ | ... | ||
+ | } | ||
</ | </ | ||
- | This will cause the executor to stop running and return control to the main programm which in turns will exit. |
getting_started/practical_problems/abort.1506318096.txt.gz · Last modified: 2017/09/25 07:41 by graf