Skip to content
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

Merged
merged 14 commits into from
Mar 21, 2023

Conversation

VX792
Copy link
Contributor

@VX792 VX792 commented Feb 4, 2023

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.

Copy link
Member

@bmagyar bmagyar left a 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...

VX792 and others added 2 commits February 18, 2023 08:58
Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
…er.hpp

Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
Copy link
Member

@destogl destogl left a 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.

@@ -510,6 +510,65 @@ class ControllerManager : public rclcpp::Node
};

SwitchParams switch_params_;

class ControllerThreadWrapper
Copy link
Member

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.

Copy link
Contributor Author

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

@bmagyar
Copy link
Member

bmagyar commented Mar 3, 2023

@destogl , @VX792 could we get this merged soon guys? What do we need to unstuck the conversation?

@bmagyar bmagyar added the iron label Mar 14, 2023
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants