-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MapServer
class' on_activate
should call LifecycleNode::on_activate(state)
#3710
Comments
This is the implementation of the lifecycle node’s on_activate function. If you implement your own derived class’ on_activate, you’re overriding this method. This is consistent with how all the Nav2 nodes operate. It seems to me that your derived class should actually call this method to start, then activate the newly added interfaces. That way your program has control over explicitly what’s being called. Sometimes order matters in these lifecycle methods so handling that behind the scenes for users wouldn’t generically work. Some will want the MapServer’s methods called first, others will want to have their own called first. Others yet will want some before and some after. Instead of registering Pre- and Post- callbacks for every single lifecycle transition (which seems like an overcomplication), its far more straight forward for derived implementations to simply use (or not use) the on_* as they see fit, since you’re overriding it, you’re taking responsibility for its specific implementation. Thoughts? |
The way we've been writing the on_activate function in my organization is that we call the When using I am sure there could niche cases where the order of activating managed entities could matter, but I think for 99.9% of ROS2 packages, the order in which managed entities is activated shouldn't matter, it should take a split second anyway. In light of this, I think a good design practice would be for |
Got it - I looked into it more and it looks like the When I say that the order matters, you're right that its lessor so to do with the publishers which that would deal with and more so to the other objects we need to manage the state of before / after others are transitioned up. If you look at the orders within the activate / deactivate methods in many of the servers, breaking that order would actually break the system due to their interconnectedness. With that in mind, I think it could make sense for us to update all of the Nav2 servers to call that base method at the start of the function to activate / deactivate the appropriate interfaces that the ROS 2 system wants to manage for us under the hood. For now, the publishers aren't particularly helpful, but I suppose we have to start somewhere before lifecycle subscriptions, services, clients, and actions are handled. There might be some issues with that, specifically where we have other objects with lifecycle transitions to be called which rely on the publishers to be "activate" within their scope, but I suppose that's a problem we can resolve during implementation by seeing if we pass a lifecycle publisher around (and deal with it as needed). @clalancette do you support that direction? If so, I think rather than just talking about the map server @udalmia94, we should apply this new pattern to all the nodes. That way in the future when lifecycle services / subscriptions / etc are handled, we get that for "free" everywhere and we just need to delete the manual transitions (which I'm sure will throw errors galore). Is this something you're interested in contributing @udalmia94 ? It would certainly get you some experience in all of the Nav2 servers 😆 |
MapServer
class' on_activate
should class LifecycleNode::on_activate(state)
MapServer
class' on_activate
should call LifecycleNode::on_activate(state)
I can help out if y'all decide to move forward with this. |
I spoke briefly with Chris and he expressed that the feature we're discussing with the base class is still a work in progress and he doesn't recommend that we move forward with this at this time until more of the lifecycle work is complete.
I tend to agree at this point if that's their viewpoint as well. Once the clients/services/subscriptions support it too, I think it would be extremely relevant to do. With that recommendation / context in mind, I think the best solution for now is to hold off on re-organizing all the servers until more of the lifecycle objects are supported and perhaps you should call Does that sound good to you? |
We started using |
Ok! Once you have subscribers in there (and perhaps services?) I’d be happy to make the change you’ve mentioned. Note that iRobot has some lifecycle changes its proposing in the coming weeks, so I’d just keep an eye out for that. |
FWIW, there is now a lifecycle subscriber PR in rclcpp, and I'll be working on adding more lifecycle objects over the next few weeks. ros2/rclcpp#2254 |
Bug report
Required Info:
Steps to reproduce issue
Expected behavior
Actual behavior
Additional information
https://github.com/ros-planning/navigation2/blob/main/nav2_map_server/src/map_server/map_server.cpp#L128C1-L144C2
The
on_activate()
function should call the base classLifecycleNode::on_activate(state)
function to activate all publishers rather than activating the publisher explicitly. This ensures anyLifecyclePublisher
s declared in a derived class of map server would also get activated.The text was updated successfully, but these errors were encountered: