-
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
Async controller lifecycle #932
Async controller lifecycle #932
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.
Looks pretty good to me on first read, a few minor comments...
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
…er.hpp Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.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 am not sure I like the design of this.
Why not to add another controller class that has this functionality internally. I know that this means that we have a few additional lines in the controller manager, but it makes everything much cleaner.
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
@@ -510,6 +510,65 @@ class ControllerManager : public rclcpp::Node | |||
}; | |||
|
|||
SwitchParams switch_params_; | |||
|
|||
class ControllerThreadWrapper |
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 am not sure that this is the right place to add this class. Wound't make more sense to have this in a separate file in "controller_interface" package?
Also, about the name. I would call this "AsyncController" or something similar.
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.
Good point! I've been thinking about this for a while and my initial decision to put this in the controller manager was indeed because it results in less lines of code.
However, the reason I'm reluctant to create a ControllerInterface for this is that async controllers aren't inherently different from regular controllers, the only difference is how they are handled by thr ControllerManager - and that is really nothing more than excluding them from the control loop and accommodating the stored thread's lifecycle.
Also, if we are to implement an AsyncControllerInterface then we'd have to have an async version of the available controllers, as iirc they all inherit from the ControllerInterface class, which might be a bit tedious
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
controller_manager/include/controller_manager/controller_manager.hpp
Outdated
Show resolved
Hide resolved
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.
Thanks! Looks great!
This PR implements the lifecycle handling of asynchronous controllers by creating a wrapper class for their threads. The threads are started in the activate function and destroyed when the controller is unloaded. For now async controllers don't do anything and are excluded from the control loop.