ros2_control icon indicating copy to clipboard operation
ros2_control copied to clipboard

Proper way to shutdown the hardware_interface

Open MarqRazz opened this issue 4 years ago • 5 comments

Hello,

I'm implementing a driver for a new robot arm and have questions on how to properly shutdown the hardware interface node. When the user kills the node I want to return the control mode of the robot controller to a specified state and close communication with it. While I was implementing this I noticed if you shut down with ctrl-c the stop() method is not called. Should it be? I started with this example interface and have only added the parts to start(), stop() and read().

To fix this I added rclcpp::on_shutdown(std::bind(&MultiInterfaceHardware::stop, this)); to my hardware interface constructor and now it properly sets the controller to a safe mode and then closes communication when I kill the node. Is this the proper way to implement this or should we consider making this the default behavior and have the framework call the user defined stop() method?

MarqRazz avatar Jul 20 '21 23:07 MarqRazz

Can you ask this question on answers.ros.org? That's the best way to get answers as the documentation suggests. It's the way most questions for ROS are funneled for documentation and so there's a larger community to help out. Be sure to use the ros2_control tag so it's easy for maintainers to see.

jaron-l avatar Jul 29 '21 02:07 jaron-l

Hello @MarqRazz , have you found a solution on how to properly shut down the Controller Manager?

I have noticed too that stop() method is never used, in fact ros2_control/controller_manager/src/ros2_control_node.cpp (indirecly thru ros2_control/controller_manager/src/controller_manager.cpp) does never call stop_components().

Let me know if you found a solution or opened a ticket on the answers.ros.org website. Thank you :)

roncapat avatar Aug 25 '21 16:08 roncapat

It looks like a bug and it is still present. The on_deactivate callback is not called on CTRL-C. @MarqRazz's workaround works though.

lukicdarkoo avatar Mar 28 '22 12:03 lukicdarkoo

I'll try to set up a test for this and add a fix.

bmagyar avatar Mar 29 '22 07:03 bmagyar

Still seeing this issue in January of 2023.

swiz23 avatar Jan 29 '23 23:01 swiz23