0
$\begingroup$

I have implemented a hardware interface in ros2_control and added code to free my hardware resources in the on_deactivate() method.

When I try to stop the controller with the command ros2 control set_controller_state diffbot_base_controller inactive and try to free the hardware, on_deactivate() doesn't seem to be called.

I can't find console output from deactivate, and the read/write method is still being called. Unlike before, only the value from hw_command_ is 0.

It's very confusing.Maybe I'm confused about the life cycle concept in controller_manager of ros2_control. I was hoping to get some tips or links to relevant materials.

$\endgroup$

1 Answer 1

0
$\begingroup$

Be aware that hardware components and controllers are different parts of ros2_control. You try to deactivate the controller -> this does not deactivate the hardware component.

Lifecycle of hardware components is not 100% implemented as by now, and there are some issues with the current implementation. Moreover, controller won't be deactivated currently if you deactivate the hardware_component, where the controller claimed the interfaces.

Have a look at this draft example, which should make things more clear.

$\endgroup$
4
  • $\begingroup$ I found the description about lifecycle of hardware on the site: Controller Manager — ROS2_Control: Humble Oct 2023 documentation. And it seems like there are no way to invoke the method on_deactivate() of hareware yet. $\endgroup$
    – Michael
    Commented Oct 25, 2023 at 3:13
  • $\begingroup$ no, the disclaimer of not being implemented is the automatic restart incl. controllers after returning false from read/write method of the hardware component. have you tried the service calls from the demo I linked above? $\endgroup$ Commented Oct 26, 2023 at 6:03
  • $\begingroup$ It works! Thanks, I learned how to control the hardware lifecycle. But I'm confused about read/write methods: methods are still called when the hardware is inactive. $\endgroup$
    – Michael
    Commented Oct 27, 2023 at 8:43
  • $\begingroup$ the design draft is to be not able to control joints but secondary stuff like gpio commands etc also in inactive state. $\endgroup$ Commented Oct 27, 2023 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.