-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release_interfaces when stopping controller #343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, probably fixing #345 too.
@destogl or @Karsten1987 please feel free to merge if you agree
Is this the intended behavior though?
so the issue can also be handled by clearing the interfaces in According to the roadmap the controller manager "manages (e.g., loading, activating, deactivating, unloading) controllers and from them required interfaces" (roadmap/ros2_control_documentation) which sounds to me as though it should also release the interfaces when no longer needed. |
I've moved the |
Intended and actually good and smooth may be two different things. I think leaving releasing interfaces to whoever implements the controllers is a problem, the controller manager is meant to manage controllers ;) |
as per @ssumoo comment:
I think both of the cases are valid. The beauty of the move semantic is that the command interfaces really only exist once and thus it doesn't really matter when they're released. @mahaarbo I think your patch is ok, however I am a bit shocked that we didn't have these scenarios covered in the existing tests for switching controllers. As @bmagyar mentioned over here I think this should definitely be covered by tests. I think the existing test should be eligible for adding another test case for switching controllers with potential resource conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the patch itself looks good, I am requesting changes due to a definitely needed test case. Let me know if you need assistance with it.
Essentially what I'd like to see in this test case:
- Load
controller_1
withcommand_interface_1
. - Load
controller_2
withcommand_interface_1
. - Start
controller_1
--> ok - Start
controller_2
--> false, resource conflict - Stop
controller_1
--> ok - Start
controller_2
--> ok - Stop
controller_2
--> ok - Start
controller_1
--> ok
2 cents: As Karsten said, let us know if you need help with the test, we'd like to get this in ASAP. |
Thanks for the comments, working on the test case described by @Karsten1987 at the moment. I'm not very well-versed with The existing Edit: I hadn't noticed that I need to call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mahaarbo Great job! Thanks!
P.S. just a few nitpicks if you are in the mood :)
controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.cpp
Outdated
Show resolved
Hide resolved
controller_manager/test/test_controller_with_interfaces/test_controller_with_interfaces.xml
Outdated
Show resolved
Hide resolved
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a small commit on top of your branch which highlights a bit more what's exactly being tested. I hope you don't mind, but I feel it helps for understanding what's going on.
Overall, thanks for picking up the test! Good job!
* release_interfaces when stopping controller * Moved release_interfaces after deactivate * First attempt at test_release_interfaces * Switched to std::async with cm_->update * Comment on resource conflict + remove old bit * Minor nitpick * add more test criteria Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com> Co-authored-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Following up on the comment by @olivier-stasse #322/comment, switching a controller does not appear to work as expected when there is a resource conflict between the controllers.
Reproduction instruction
In
ros2_control_demos
, add an additionalforward_position_controller2
to the config, that is basically a copy offorward_position_controller
. Launchrrbot_system_position_only.launch.py
, and run:Then running
ros2 control switch_controllers --start-controllers forward_position_controller2 --stop-controllers forward_position_controller
yields the error message:The same occurs if the command is split into two separate calls, one stopping the old and one starting the new controller.
Cause
There is no clearing of the
LoanedCommandInterface
when stopping a controller. The function exists (controller->release_interfaces()
) but it does not appear to be called by thecontroller_manager
. The only way to clear the interfaces at the moment is to unload the controller. I'm not sure if that is the desired behavior.Fix
Release the interfaces when stopping a controller.