Skip to content

Improvement on Servo enforcePositionLimits()#451

Merged
AndyZe merged 2 commits intomoveit:mainfrom
AndyZe:andyz/joint_limits2
May 14, 2021
Merged

Improvement on Servo enforcePositionLimits()#451
AndyZe merged 2 commits intomoveit:mainfrom
AndyZe:andyz/joint_limits2

Conversation

@AndyZe
Copy link
Copy Markdown
Member

@AndyZe AndyZe commented May 4, 2021

Previously, the incoming robot state velocity was used to check if the robot would move beyond the joint limit. That was a problem if the robot state did not contain velocity data, i.e. if "copy dynamics" hadn't been turned on.

This PR uses the prospective robot velocity from Servo itself to check if the joint would move beyond the position limit and halt, if so. This velocity should always be available regardless of whether "copy dynamics" is ON.

@codecov
Copy link
Copy Markdown

codecov bot commented May 4, 2021

Codecov Report

Merging #451 (f69148a) into main (289437b) will decrease coverage by 0.02%.
The diff coverage is 33.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #451      +/-   ##
==========================================
- Coverage   51.43%   51.42%   -0.01%     
==========================================
  Files         223      223              
  Lines       23339    23344       +5     
==========================================
  Hits        12002    12002              
- Misses      11337    11342       +5     
Impacted Files Coverage Δ
...veit_core/robot_model/src/revolute_joint_model.cpp 80.00% <ø> (ø)
moveit_ros/moveit_servo/src/servo_calcs.cpp 63.84% <33.34%> (-0.40%) ⬇️
...nning_scene_monitor/src/planning_scene_monitor.cpp 56.11% <0.00%> (-0.12%) ⬇️

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 a40239c...f69148a. Read the comment docs.

Copy link
Copy Markdown
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

Generally approve; left a couple of minor comments.

Comment on lines +837 to 845
// Check if pending velocity command is moving in the right direction
auto joint_itr =
std::find(joint_trajectory.joint_names.begin(), joint_trajectory.joint_names.end(), joint->getName());
auto joint_idx = std::distance(joint_trajectory.joint_names.begin(), joint_itr);

if ((joint_trajectory.points[0].velocities[joint_idx] < 0 &&
(joint_angle < (limits[0].min_position + parameters_->joint_limit_margin))) ||
(current_state_->getJointVelocities(joint)[0] > 0 &&
(joint_trajectory.points[0].velocities[joint_idx] > 0 &&
(joint_angle > (limits[0].max_position - parameters_->joint_limit_margin))))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a current test that tests the behavior of this? If not, could you extend the test to test this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good idea, done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@tylerjw please realize you are asking a lot here. The tests are currently commented with this note:

# TODO(henningkayser): Port tests to ROS2

So I effectively need to fix some other tests to add this one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Getting #428 merged would unblock this PR. The test we need (TestEnforcePosLimits) is already there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's get this merged and we are working to get TestEnforcePosLimits operational in #428.

Copy link
Copy Markdown
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

thank you for adding the test, this looks good to me 🥇

@AndyZe AndyZe force-pushed the andyz/joint_limits2 branch from c6e46bb to 93ee267 Compare May 5, 2021 04:11
Copy link
Copy Markdown
Contributor

@vatanaksoytezer vatanaksoytezer left a comment

Choose a reason for hiding this comment

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

I've read through the code and checked the failing CI. I left a small comment with a question

@AndyZe AndyZe force-pushed the andyz/joint_limits2 branch from 6597a58 to 7c511be Compare May 14, 2021 17:30
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.

3 participants