-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add a service for enabling/disabling the collision monitor #5493
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
Add a service for enabling/disabling the collision monitor #5493
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.
Also check out the failing linting and DCO CI jobs and resolve their issues please!
How did you test these changes?
Although this solution seems like it should also work by disabling and enabling all polygons using this service I feel like a simpler solution could be a better one... Currently you must set a parameter for each polygon that is set up and if we have many polygons that could unnecessarily increase time needed for the service call execution... Also now you set the enabled param for all polygons to true or false but it could be very possible that some of those polygons should not be enabled as they were also disabled before the service call to toggle off. I would propose the following:
void CollisionMonitor::cmdVelInCallbackStamped(geometry_msgs::msg::TwistStamped::SharedPtr msg)
{
// If message contains NaN or Inf, ignore
if (!nav2_util::validateTwist(msg->twist)) {
RCLCPP_ERROR(get_logger(), "Velocity message contains NaNs or Infs! Ignoring as invalid!");
return;
}
if (enabled_){
process({msg->twist.linear.x, msg->twist.linear.y, msg->twist.angular.z}, msg->header);
} else {
// Republish the message
Action robot_action{DO_NOTHING, {msg->twist.linear.x, msg->twist.linear.y, msg->twist.angular.z}, ""};
publishVelocity(robot_action, msg->header);
}
} This way the node acts simply as a relay for cmd vel taking it from input and publishing it on output witouth doing any additional computation and not generating the polygons.
If your PC is not powerfull enough to run the sim you can firstly try running gazebo headless to reduce the load, secondly you can try the Loopback simulator which can be used so simple testing. |
I'm working on the changes/fixes suggested above by Steve, but your solution looks pretty good too. I'm not sure if the |
Something nice that running the full function does is still exercise this condition to check of sensor data is not updating correctly. Even if we disable the collision element of things, stopping due to hardware issues seems still useful. But, that could be abstracted into a lambda or function and used both here and in the @armgits can you make this change if you agree that there's nothing else in the
I do also generally agree with that. Instead, we could just update the enabled for each polygon with a new API instead of using dynamic parameter callbacks. But moot if we change the enabled globally
Why are you unable to test on your machine? If you have the compute resources to compile Nav2, you probably have all you need to simulate it too |
@armgits any update? |
I'm still working and here are some updates so far:
I made this change locally but some unit tests are failing after extracting the check condition into a function which I'm looking into. I noticed that the I was also thinking if we could have separate
This has been slowing me down. Gazebo isn’t running properly on either of my laptops (even in headless mode), so I’ve been testing with loopback simulation instead. Based on my testing with the old logic after sorting that out last week, I can confirm the service interface responded correctly to CLI requests, but haven't seen any polygons published or changes in robot's behavior with enabled/disabled states. (I'm testing with this tutorial Using Collision Monitor) |
That flags is for the lifecycle state transition, that it can process data because the node is in the Activate state to process data, versus in the process of being deactivated or configuring or so on. I think right here, here, and here you could just add a check for What's up with gazebo? You can also try the loopback simulator instead, we have launch files using those in the |
Sure! You could always just commit here and then pull in / rebase on main afterwards. We squash merge all PRs anyway so not having the cleanest git commit history is not a big deal (to me at least; we have so much more to focus on 😆 ) since it'll all get squashed into a single commit onto |
978bc74
to
9a53a82
Compare
@armgits something's gone wrong here, you have included all the recent commits from the Nav2 branch. That is not correct and the diff shows them in this PR versus only your changes. |
I tried to sign off only my commits and leave the following commits untouched first but the DCO didn't pass that way, so I had to sign off all the following commits too. I synced my branch with the main branch that brought in all the new commits, was that the mistake? |
I can roll back my branch to just before I made my first commit and reapply just my commits from there. That will not include other commits and diff would show only my changes. |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Yeah I'd grab your changes and many cherry pick them onto a clean branch or otherwise roll back to a state without all these excess commits and try again. You don't need to rebase beyond what's needed for DCO which shouldn't be pulling in changes |
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
…vice Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
Signed-off-by: Abhishekh Reddy <[email protected]>
9a53a82
to
4a6c7f4
Compare
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.
You missed one for notifyActionState
Signed-off-by: Abhishekh Reddy <[email protected]>
@armgits, your PR has failed to build. Please check CI outputs and resolve issues. |
After checking CircleCI console, the build stage keeps timing out after an hour. In the previous tests where this was successful, only the collision monitor package was selected to build but now a lot more, if not all the packages are built again which is taking a lot of time. |
Got it - I just retriggered and with the cache that should build. Let me know when you want me to to review again! |
Please review it today and let me know! The only thing I'd note is the |
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.
Did you test this after this change to make sure you see it functionally working?
LGTM!
Would you be interested in contributing some Behavior Tree Nodes in in order to use this feature from within behavior trees? You'd get your name here: https://docs.nav2.org/plugins/index.html#behavior-tree-nodes 😉 EnableCollisionMonitor
and DisableCollisionMonitor
to call the service.
Please add to the Kilted migration guide this new feature for the collision monitor so the community knows as they upgrade!
@SteveMacenski yes, I did test the change and can confirm that it functionally works. I've updated the testing part of it in the PR description. And I am very much interested in further working on this feature! Can I also pick other issues while this one's ongoing? |
@SteveMacenski @armgits I have the BT plugin already prepped and ready to ship, I am just waiting for this here to get all the green lights and to be merged so I can than open a PR with th BT plugins (as you recommended in the issue to keep the seperation for individual reviews). If that is no longer the case and want to do it in a single PR we can also do that. You also mentioned
but I would rather stick with ToggleCollisionMonitor for bt plugin and a input port Do we also want to add a |
Sure! What other areas are you interested in working on? I can come up with a few ideas. One that comes to mind is understanding and testing #5033 with its respective PR and/or implementing #4794 if you want something collision monitor related!
Great! I think you can open that as a draft now as long as you link it back here so we know to test it once this is merged (unless you've already tested from a fork of this branch?)
Sure! Add that in your PR :-) |
I opened a PR with the bt stuff, but I feel that keeping the param tied to this PR might be better. I would recommend that @armgits also includes the parameter change into this PR as that way we have 2 encased PRs that don't change the same files and should just be able to be merged one after another easier. @armgits are you okay with you adding the param? It has to be added into the param file in the bringup package (name wise is up to you if you want to stick with just
I did not test it directly on the fork of this branch, but I already did have a rudimentary implementation of this solution (as we discussed in the issue before) so I did have where to test it at. Also, as it is just a service called any service server that takes than the agreed upon |
I would like to minimize the additional changes requested to @armgits so we can get this merged in ASAP which would unblock the BT PR and another @armgits please make that one open change and we can merge. If you are open to contributing the |
This pull request is in conflict. Could you fix it @armgits? |
I think someone has already done that bit and now when I pushed my changes there's a merge conflict. Update: I just realized that change was already done on the main branch, I'll rewrite mine to exactly match the main branch and see if the merge conflict could be resolved. |
Understood 👍 @armgits you can than decide if you want to do a pr for the enabled param than or if I should. |
I will do the PR for enabled parameter once this gets merged. |
@armgits can you deal with the merge conflict? |
Signed-off-by: Abhishekh Reddy <[email protected]>
d8cc774
to
aa11e09
Compare
@SteveMacenski I tried, but there's still a small portion of code that's in conflict... Could it be manually resolved by accepting the incoming changes to the main branch? |
No - you need to hit the "Resolve Conflicts" button and resolve it manually before I can merge |
Signed-off-by: Abhishekh Reddy <[email protected]>
My bad! Just learnt that I could edit that and remove the markers, it should be good now. |
Great! Merged! The BT Nodes and Enabled Parameter are up next - thanks everyone! |
* Added std_srvs package to dependencies Signed-off-by: Abhishekh Reddy <[email protected]> * Declared service and callback for enabling/disabling collision monitor Signed-off-by: Abhishekh Reddy <[email protected]> * Declared a variable to store collision monitor enable/disable state Signed-off-by: Abhishekh Reddy <[email protected]> * Added initialization for collision monitor enable/disable service Signed-off-by: Abhishekh Reddy <[email protected]> * Implemented service callback for collision monitor enable/disable service Signed-off-by: Abhishekh Reddy <[email protected]> * Removed std_srvs package dependency Signed-off-by: Abhishekh Reddy <[email protected]> * Added Toggle interface Signed-off-by: Abhishekh Reddy <[email protected]> * Replaced Trigger interface with the new Toggle interface Signed-off-by: Abhishekh Reddy <[email protected]> * Added default initialization for enabled flag Signed-off-by: Abhishekh Reddy <[email protected]> * Fixed toggle service name Signed-off-by: Abhishekh Reddy <[email protected]> * Updated toggle logic for collision monitor Signed-off-by: Abhishekh Reddy <[email protected]> * Added a new line at the end of file Signed-off-by: Abhishekh Reddy <[email protected]> * Update nav2_collision_monitor/src/collision_monitor_node.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Abhishekh Reddy <[email protected]> * Update nav2_collision_monitor/src/collision_monitor_node.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Abhishekh Reddy <[email protected]> * Added enabled check for logging Signed-off-by: Abhishekh Reddy <[email protected]> * Added a unit test for toggle service Signed-off-by: Abhishekh Reddy <[email protected]> * Made the getter const and added a comment Signed-off-by: Abhishekh Reddy <[email protected]> * Replaced rclcpp::spin_some Signed-off-by: Abhishekh Reddy <[email protected]> --------- Signed-off-by: Abhishekh Reddy <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
* Fix dynamic param SmacPlannerLattice (#5478) * Fix SmacPlannerLattice dynamic parameter early exit Signed-off-by: Tony Najjar <[email protected]> * remove comment Signed-off-by: Tony Najjar <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]> * Fix duplicate poses with computePlanThroughPoses (#5488) * fix-duplicate-poses Signed-off-by: Tony Najjar <[email protected]> * Update nav2_planner/src/planner_server.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Tony Najjar <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]> Co-authored-by: Steve Macenski <[email protected]> * Fix seg fault (#5501) * Fix segmentation fault Signed-off-by: Tony Najjar <[email protected]> * fix linting Signed-off-by: Tony Najjar <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]> * Add a service for enabling/disabling the collision monitor (#5493) * Added std_srvs package to dependencies Signed-off-by: Abhishekh Reddy <[email protected]> * Declared service and callback for enabling/disabling collision monitor Signed-off-by: Abhishekh Reddy <[email protected]> * Declared a variable to store collision monitor enable/disable state Signed-off-by: Abhishekh Reddy <[email protected]> * Added initialization for collision monitor enable/disable service Signed-off-by: Abhishekh Reddy <[email protected]> * Implemented service callback for collision monitor enable/disable service Signed-off-by: Abhishekh Reddy <[email protected]> * Removed std_srvs package dependency Signed-off-by: Abhishekh Reddy <[email protected]> * Added Toggle interface Signed-off-by: Abhishekh Reddy <[email protected]> * Replaced Trigger interface with the new Toggle interface Signed-off-by: Abhishekh Reddy <[email protected]> * Added default initialization for enabled flag Signed-off-by: Abhishekh Reddy <[email protected]> * Fixed toggle service name Signed-off-by: Abhishekh Reddy <[email protected]> * Updated toggle logic for collision monitor Signed-off-by: Abhishekh Reddy <[email protected]> * Added a new line at the end of file Signed-off-by: Abhishekh Reddy <[email protected]> * Update nav2_collision_monitor/src/collision_monitor_node.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Abhishekh Reddy <[email protected]> * Update nav2_collision_monitor/src/collision_monitor_node.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Abhishekh Reddy <[email protected]> * Added enabled check for logging Signed-off-by: Abhishekh Reddy <[email protected]> * Added a unit test for toggle service Signed-off-by: Abhishekh Reddy <[email protected]> * Made the getter const and added a comment Signed-off-by: Abhishekh Reddy <[email protected]> * Replaced rclcpp::spin_some Signed-off-by: Abhishekh Reddy <[email protected]> --------- Signed-off-by: Abhishekh Reddy <[email protected]> Co-authored-by: Steve Macenski <[email protected]> * bump Jazzy to 1.3.9 for release Signed-off-by: SteveMacenski <[email protected]> * Change service type for collision monitor Signed-off-by: Steve Macenski <[email protected]> * Fix backport error Signed-off-by: SteveMacenski <[email protected]> * update Signed-off-by: SteveMacenski <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]> Signed-off-by: Abhishekh Reddy <[email protected]> Signed-off-by: SteveMacenski <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Co-authored-by: Tony Najjar <[email protected]> Co-authored-by: Abhishekh Reddy <[email protected]>
@armgits @DavidG-Develop thanks for all the effort to get this PR through! Im keen to test it in one of our use cases which is going live soon. |
Basic Info
Description of contribution in a few bullet points
Toggle
interface innav2_msgs
that is similar toSetBool
fromstd_srvs
Description of documentation updates required from your changes
Mentioning this interface in the Collision Monitor Node documentation if needed.
Description of how this change was tested
Future work that may be required in bullet points
For Maintainers:
backport-*
.