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

Prevent moveit_servo transforms between fixed frames from causing timeout #2418

Merged
merged 2 commits into from
Nov 20, 2020

Conversation

nbbrooks
Copy link
Contributor

@nbbrooks nbbrooks commented Nov 18, 2020

Description

Currently, if target_pose must be transformed to be in planning_frame (in targetPoseCallback function), and a URDF transform from the current frame to planning_frame is available, then TransformStamped time returned by lookupTransform will be 0. 0 is then copied into target_pose_'s stamp by doTransform. This will result in the timestamp checking in haveRecentTargetPose to cause moveToPose to always abort because it doesn't think it has received a target_pose recently.

Two examples of when users could experience this behavior:

  • They publish target_pose in world frame, but planning_frame is configured to be base_link (and world to base_link is defined in the URDF)
  • They are running in a noise-less simulation, and in this simulation have the object they are servoing to as part of the URDF

Solution:
I don't think we can assume that a TransformStamped timestamp of 0 will always means that it was a URDF defined transform. So instead of checking for that, I am simply copying back the target_pose's original timestamp back if a transform has to be applied. I think this is fine as the purpose of the timestamp checking in haveRecentTargetPose is to see if the pose was received recently, rather than how recent the transform is. The TransformException catch will still flag failures to get any transform in the provided time window.

This work is sponsored by RE2 Robotics.

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

…causing target_pose timeout

If target_pose must be transformed to be in planning_frame, and a URDF transform
from the current frame to planning_frame is available, target_pose's timestamp
was updated to 0, causing timeout aborts
Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

Seems like a straightforward fix! I tested on one of our projects. No issues.

@codecov
Copy link

codecov bot commented Nov 18, 2020

Codecov Report

Merging #2418 (ba5f1de) into master (bd53490) will increase coverage by 0.37%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2418      +/-   ##
==========================================
+ Coverage   60.22%   60.58%   +0.37%     
==========================================
  Files         351      351              
  Lines       26434    26435       +1     
==========================================
+ Hits        15916    16013      +97     
+ Misses      10518    10422      -96     
Impacted Files Coverage Δ
moveit_ros/moveit_servo/src/pose_tracking.cpp 46.72% <100.00%> (+0.36%) ⬆️
moveit_core/planning_scene/src/planning_scene.cpp 58.01% <0.00%> (+0.11%) ⬆️
...dl_kinematics_plugin/src/kdl_kinematics_plugin.cpp 76.55% <0.00%> (+0.45%) ⬆️
...e/collision_detection_fcl/src/collision_common.cpp 80.32% <0.00%> (+0.63%) ⬆️
...raint_samplers/src/default_constraint_samplers.cpp 82.25% <0.00%> (+0.73%) ⬆️
...on/pick_place/src/approach_and_translate_stage.cpp 72.96% <0.00%> (+0.82%) ⬆️
...kinematic_constraints/src/kinematic_constraint.cpp 74.24% <0.00%> (+0.85%) ⬆️
...e/src/parameterization/model_based_state_space.cpp 72.80% <0.00%> (+2.40%) ⬆️
moveit_core/robot_model/src/joint_model_group.cpp 65.44% <0.00%> (+2.47%) ⬆️
...eit_ros/manipulation/pick_place/src/pick_place.cpp 94.45% <0.00%> (+5.56%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd53490...ba5f1de. Read the comment docs.

@@ -238,6 +238,9 @@ void PoseTracking::targetPoseCallback(const geometry_msgs::PoseStampedConstPtr&
geometry_msgs::TransformStamped target_to_planning_frame = transform_buffer_.lookupTransform(
planning_frame_, target_pose_.header.frame_id, ros::Time(0), ros::Duration(0.1));
tf2::doTransform(target_pose_, target_pose_, target_to_planning_frame);

// Prevent doTransform from copying a stamp of 0, which will cause the haveRecentTargetPose check to fail servo motions
target_pose_.header.stamp = msg->header.stamp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the target pose and planning frame are guaranteed to be different frames and transform between the frames is the latest possible (since ros::Time(0) is used), there are two cases here.

Either the transform is fixed or the transform is one between two moving frames. However, in both cases, the latest transform is used and the target pose is transformed into the planning frame. So, after the transform, isn't the situation equivalent to us having a target pose in the planning frame with a timestamp of ros::Time::now()?

Suppose we had a target pose in odom at timestamp 10, and we received it at timestamp 100 and transformed it to base_link with the latest transform, wouldn't the correct timestamp for the pose be 100 instead of 10? Probably doesn't make a world of difference... perhaps it doesn't make any difference, but it feels like it is more correct nonetheless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. I don't think it will have impact here, but is the pattern people should follow elsewhere where it could make an impact.

@tylerjw tylerjw merged commit 712a73a into moveit:master Nov 20, 2020
@tylerjw tylerjw mentioned this pull request Apr 9, 2021
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request Apr 29, 2021
@tylerjw tylerjw mentioned this pull request Apr 29, 2021
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants