-
Notifications
You must be signed in to change notification settings - Fork 568
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
Fix planning_scene_monitor sync when passed empty robot state #3187
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3187 +/- ##
==========================================
- Coverage 46.01% 45.66% -0.34%
==========================================
Files 714 714
Lines 62302 62280 -22
Branches 7531 7530 -1
==========================================
- Hits 28659 28433 -226
- Misses 33477 33680 +203
- Partials 166 167 +1 ☔ View full report in Codecov by Sentry. |
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.
Seems to make sense, though I don't know enough about MoveIt's guts to tell you if there's a better way. So I'd prefer for someone who knows more had the final approve here.
Besides my usual nitpicks in the comments, it seems like every other piece of code in this file that uses current_state_monitor_
first checks whether the pointer is not null. So would recommend also including that in your if-condition.
moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
Outdated
Show resolved
Hide resolved
EDITED: I was also going to say we may need to check that the CSM also has a current state... the following isn't quite what you need on second thought, but maybe some of the logic can extend? moveit2/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp Line 1500 in 06b171f
|
moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
Outdated
Show resolved
Hide resolved
I updated the logic here to first attempt to use 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.
LGTM -- would still appreciate a second look.
Also, backport to Jazzy and Humble ok here?
👍 to Jazzy! I don't see any issues backporting this to Humble, but FYI I did not see this sync issue when running Humble (and Iron) binaries because it is missing other updates that have been applied to 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.
I think this makes sense but I am not sure about back porting it since this is a breaking change. Before this, sending a planning scene diff means the rest of the maintained scene is reset (world, robot state, acm ...). Now, we're not resetting robot states if the current_state monitor holds a value. @rhaschke @henningkayser Do you have any thoughts?
I am wondering though, why this is fixing your issue in MTC. Isn't this code block only executed when the scene is not a diff? All planning scene changes that are propagated from MTC to the move group are applied as diffs:
https://github.com/moveit/moveit_task_constructor/blob/325c4012f56208e37010cc85d94b4dca92f34345/capabilities/src/execute_task_solution_capability.cpp#L191
So wouldn't that mean this code is not executed in the error case you're describing?
That line of code is setting |
Oh you're right sorry. I did not look carefully enough. The field in the message is explicitly called scene_diff, we should make sure that is always the case. Do you think that is relatively easy to fix based on your investigation so far |
Sorry I'm not following, I don't know of a message parameter called
|
I am talking the MTC trajectory execution action: https://github.com/moveit/moveit_task_constructor/blob/master/msgs/action/ExecuteTaskSolution.action The reason I am bringing this up is that while this patch fixes your problem, I don't think it necessarily fixes the root cause in MTC. |
Sorry for the confusion, that makes sense. The reason I think this change is still applicable is it that someone could 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.
You're right, looking into setCurrentState() and the functions it calls, it will re-use the probably outdated parent scene to set the robot state rather than the most recent value. Thanks for your patience and explanations. Let's get this in. Do you mind opening an issue in MTC about the planning scene not always being a diff?
* Fix planning_scene_monitor sync when passed empty robot state * address review * check for null current_state_monitor_ and fall back to diff scene_ if needed --------- Co-authored-by: Sebastian Jahr <[email protected]> (cherry picked from commit 80c7f61)
* Fix planning_scene_monitor sync when passed empty robot state * address review * check for null current_state_monitor_ and fall back to diff scene_ if needed --------- Co-authored-by: Sebastian Jahr <[email protected]> (cherry picked from commit 80c7f61)
Sorry for being late to the party. Originally, MTC was sending diffs only - therefore the message member |
} | ||
else | ||
{ | ||
parent_scene_->setCurrentState(scene_->getCurrentState()); |
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.
Why didn't you simply use this line only? All you wanted to achieve is to not loose RobotState information from existing planning scene diffs.
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.
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.
If we go to the single line would it be better to push the diffs to the parent scene? Could there be other changes in the diff that might need to be applied before we replace the scene?
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.
We need to deal with both issues separately.
This PR was about correctly maintaining the RobotState from the diffs. If the planning scene didn't have newer updates from the state monitor yet, we shouldn't care to pull them in early.
That the scene is not updated at a constant rate is another issue. Updates to the PSM's scene are only performed if 1) there are new updates received by CSM and 2) the throttling frequency is met. If both was true in your tests, then their is an issue with those updates, which should get fixed.
As far as I understood, you were observing issues with rviz' PlanningScene. This is updated from move_group's (PSM's) planning scene via a separate topic at a low rate of 2Hz:
moveit2/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
Line 448 in 80c7f61
void PlanningSceneMonitor::scenePublishingThread() |
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 suggest to cleanup this PR as I did for the MoveIt1 backport (moveit/moveit#3683).
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.
We need to deal with both issues separately.
That is what I though too which is why I did not include any of those changes here. I will work on investigating the update rate and try to include a test to ensure it is working as expected.
As far as I understood, you were observing issues with rviz' PlanningScene. This is updated from move_group's (PSM's) planning scene via a separate topic at a low rate of 2Hz:
Yes this issues is visible in Rviz but is also effects future plans because the parent_scene
contained stale robot state data after executing a move causing it to jump to the last known position on the next motion plan (shown in the plot below).
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.
Sure. This is fixed with the present PR. However, the other issue, i.e. the scene not being updated regularly, is a different story.
That's good to know, thanks! |
…#3203) Co-authored-by: Marq Rasmussen <[email protected]>
…#3204) Co-authored-by: Marq Rasmussen <[email protected]>
Simplified Backport of moveit/moveit2#3187 Co-authored-by: v4hn <[email protected]>
Description
Fixes issue #3174.
When motion planning and executing solutions with MTC I have stages where objects are attached/removed and deleted from the scene at the beginning or end of a task. I have been having issues with the planning scene not updating correctly and the final state of the robot in the planning scene having offsets compared to the final state of trajectory given.
When executing an MTC solution that contains changes to the planning scene they are sent to the
planning_scene_monitor_
with no robot_state information. When MoveIt receives thisnewPlanningSceneMessage
that is not marked as a scene_diff (because things are being added or removed from the scene) the first thing is does is clear out the maintained diffscene_
. The problem with this approach is that theplanning_scene_monitor_
is only updating it'sparent_scene_
at a 2Hz rate. Depending on when the trajectory finishes vs the last time theparent_scene_
was updated it could contain stale robot state information and by calling scene_->clearDiffs() we throw all of our updated robot state information away before wesetPlanningSceneMsg
with a message that does not contain robot_state so it uses the old values it had from the last sync.To fix the issue this PR checks if the
newPlanningSceneMessage
contains a robot_state. If it does not it updates theparent_scene_
with the latest information from thecurrent_state_monitor_
before callingsetPlanningSceneMsg(scene)
to ensure that the new scene is applied with the most up to date robot_state information.