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

Refactor velocity limit enforcement and add a unit test #2260

Merged
merged 5 commits into from
Sep 15, 2020
Merged

Refactor velocity limit enforcement and add a unit test #2260

merged 5 commits into from
Sep 15, 2020

Conversation

AndyZe
Copy link
Member

@AndyZe AndyZe commented Aug 16, 2020

The way I was doing acceleration & velocity limit enforcement before had some flaws. It was only applied to one joint at a time, so it could affect the direction of motion of the robot. It was causing some serious direction swings.

This simplifies the whole limit checking, only enforcing velocity limits.

Also renamed the functions from enforceSRDFAccelVelLimits -> enforceVelLimits. I think this function name was misleading because limits actually get stored in joint_limits.yaml or the URDF, not the SRDF.

@codecov
Copy link

codecov bot commented Aug 16, 2020

Codecov Report

Merging #2260 into master will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2260      +/-   ##
==========================================
+ Coverage   57.85%   57.93%   +0.08%     
==========================================
  Files         327      327              
  Lines       25644    25639       -5     
==========================================
+ Hits        14834    14851      +17     
+ Misses      10810    10788      -22     
Impacted Files Coverage Δ
...os/moveit_servo/include/moveit_servo/servo_calcs.h 100.00% <ø> (ø)
moveit_ros/moveit_servo/src/servo_calcs.cpp 62.59% <100.00%> (+1.11%) ⬆️
...nning_scene_monitor/src/planning_scene_monitor.cpp 69.45% <0.00%> (-0.44%) ⬇️
...t_setup_assistant/src/tools/moveit_config_data.cpp 20.25% <0.00%> (-0.02%) ⬇️
moveit_core/robot_state/src/robot_state.cpp 47.40% <0.00%> (+0.10%) ⬆️
...raint_samplers/src/default_constraint_samplers.cpp 84.37% <0.00%> (+0.37%) ⬆️
...on/pick_place/src/approach_and_translate_stage.cpp 73.60% <0.00%> (+0.80%) ⬆️
...dl_kinematics_plugin/src/kdl_kinematics_plugin.cpp 79.38% <0.00%> (+1.80%) ⬆️
...meterization/work_space/pose_model_state_space.cpp 83.68% <0.00%> (+3.41%) ⬆️
... and 1 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 2ac4db9...ddf558f. Read the comment docs.

Copy link
Contributor

@nbbrooks nbbrooks left a comment

Choose a reason for hiding this comment

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

Mostly nits, but have a Q about the new test

@@ -50,6 +50,7 @@
#include <moveit_servo/make_shared_from_pool.h>

static const std::string LOGNAME = "servo_cpp_interface_test";
static constexpr double LARGEST_ALLOWABLE_PANDA_VEL = 2.8710; // to test joint velocity limit enforcement
Copy link
Contributor

@nbbrooks nbbrooks Aug 17, 2020

Choose a reason for hiding this comment

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

Where is this passed to servo so it knows what the vel limit is?

Copy link
Member Author

Choose a reason for hiding this comment

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

Servo gets it from:

joint_model_group_->getActiveJointModels();
const std::vector<moveit_msgs::JointLimits> limits = joint->getVariableBoundsMsg();

I guess I could make a getter method to access that more easily. Worth it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like scope creep, but that would be a nice contribution for a new MoveIt dev!

moveit_ros/moveit_servo/src/servo_calcs.cpp Outdated Show resolved Hide resolved
moveit_ros/moveit_servo/src/servo_calcs.cpp Show resolved Hide resolved
moveit_ros/moveit_servo/src/servo_calcs.cpp Show resolved Hide resolved
moveit_ros/moveit_servo/test/servo_cpp_interface_test.cpp Outdated Show resolved Hide resolved
moveit_ros/moveit_servo/src/servo_calcs.cpp Outdated Show resolved Hide resolved

// Store the scaling factor if it's the smallest yet
if (scaling_factor < velocity_limit_scaling_factor)
velocity_limit_scaling_factor = scaling_factor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I misunderstood but it looks to me like the function first looks for the smallest velocity limit scaling factor (which can end up being very small) and then, couple lines down, applies that lowest velocity limit to all the joints. What if there is a use case where someone wants, let's say limit the maximum velocity of the largest joint while keeping the other joints moving much faster. Wouldn't this approach then slow the whole robot down since one of the joints is limited to very low velocity?

Copy link
Member Author

@AndyZe AndyZe Aug 31, 2020

Choose a reason for hiding this comment

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

Yeah, the whole robot will slow down.

But, we want the robot to keep moving in the right direction. IMO that trumps speed. Here's a video of the bad way.

nonlinear_limit_clipping

@tylerjw
Copy link
Member

tylerjw commented Sep 4, 2020

Kinetic is causing your CI failure, if you rebase this on master it will get my change to stop testing on kinetic.

@AndyZe AndyZe changed the title Refactor velocity limit enforcement and add a unit test WIP: Refactor velocity limit enforcement and add a unit test Sep 8, 2020
@AndyZe AndyZe changed the title WIP: Refactor velocity limit enforcement and add a unit test Refactor velocity limit enforcement and add a unit test Sep 8, 2020
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.

I tested this and it works for me. Thank you for adding the test 🥇 🥇 🥇

@henningkayser
Copy link
Member

@AndyZe I'm fine with merging this as this version seems to be safer than the old implementation. In the future we should still check for acceleration values, though.

@henningkayser henningkayser merged commit 964ed5c into moveit:master Sep 15, 2020
@AndyZe AndyZe deleted the andyz/limit_enforcement2 branch September 18, 2020 13:32
@tylerjw tylerjw mentioned this pull request Oct 23, 2020
57 tasks
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request Oct 23, 2020
* Rework velocity limit enforcement, add unit test

* Test every command out of Servo

* Minor variable renaming

* Clang format & clang tidy

* Delete unused acceleration variable
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request Oct 27, 2020
* Rework velocity limit enforcement, add unit test

* Test every command out of Servo

* Minor variable renaming

* Clang format & clang tidy

* Delete unused acceleration variable
tylerjw pushed a commit that referenced this pull request Nov 19, 2020
* Rework velocity limit enforcement, add unit test

* Test every command out of Servo

* Minor variable renaming

* Clang format & clang tidy

* Delete unused acceleration variable
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

6 participants