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

Improvement on Servo enforcePositionLimits() #451

Merged
merged 2 commits into from May 14, 2021

Conversation

AndyZe
Copy link
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

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
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
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
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
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
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
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
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 🥇

Copy link
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

moveit_ros/moveit_servo/test/test_servo_status.cpp Outdated Show resolved Hide resolved
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

3 participants