Skip to content

[Servo] Move enforcePositionLimits and enforceVelocityLimits to utilities#2180

Merged
AndyZe merged 10 commits intomoveit:mainfrom
ibrahiminfinite:cleanup3
May 24, 2023
Merged

[Servo] Move enforcePositionLimits and enforceVelocityLimits to utilities#2180
AndyZe merged 10 commits intomoveit:mainfrom
ibrahiminfinite:cleanup3

Conversation

@ibrahiminfinite
Copy link
Copy Markdown
Contributor

@ibrahiminfinite ibrahiminfinite commented May 16, 2023

Description

This PR moves the functions enforcePositionLimits and enforceVelocityLimits into utilities from servo_calcs.cpp and enforce_limits.cpp respectively.
The dependency of some of the utility functions on rclcpp:Clock has also been removed.

Checklist

@codecov
Copy link
Copy Markdown

codecov bot commented May 16, 2023

Codecov Report

Patch coverage: 75.81% and project coverage change: -0.03 ⚠️

Comparison is base (15b2331) 50.55% compared to head (d983053) 50.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2180      +/-   ##
==========================================
- Coverage   50.55%   50.51%   -0.03%     
==========================================
  Files         387      386       -1     
  Lines       31740    31735       -5     
==========================================
- Hits        16044    16029      -15     
- Misses      15696    15706      +10     
Impacted Files Coverage Δ
moveit_ros/moveit_servo/src/servo_calcs.cpp 71.08% <56.25%> (+0.81%) ⬆️
moveit_ros/moveit_servo/src/utilities.cpp 73.02% <82.61%> (-11.25%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

Is there a reason to not use RobotState::enforceBounds() or the alternatives for position/velocities?

@ibrahiminfinite
Copy link
Copy Markdown
Contributor Author

Is there a reason to not use RobotState::enforceBounds() or the alternatives for position/velocities?

Probably because of this (from PR #451 )

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.

Maybe @AndyZe can clarify more on this ?

Also @sea-bass , did you have any cases where you needed to use the override_velocity_scaling_factor parameter ?
If that is not useful, we can take that out as well.

@sea-bass
Copy link
Copy Markdown
Contributor

sea-bass commented May 17, 2023

We are currently using override_velocity_scaling_factor actively right now, so please keep it!

@ibrahiminfinite
Copy link
Copy Markdown
Contributor Author

@AndyZe
Can you clarify on this #2180 (review)

@AndyZe
Copy link
Copy Markdown
Member

AndyZe commented May 18, 2023

I agree with your comment there

@ibrahiminfinite
Copy link
Copy Markdown
Contributor Author

This PR is a cleanup PR, mostly to keep things cleaner in the current ServoCalcs and also pull out functions that can be reused into utilities so that it could be used in the upcoming refactor.

Copy link
Copy Markdown
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Just one comment here

Copy link
Copy Markdown
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Thanks for this! Found a few typos and suggestions.

@ibrahiminfinite ibrahiminfinite requested a review from sea-bass May 19, 2023 17:01
Copy link
Copy Markdown
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Almost there! I found a bug in the log message printing.

I think the remaining CI failure might just require updating your branch to main since SonarCloud was just added in a little while earlier.

Copy link
Copy Markdown
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Awesome!

@ibrahiminfinite
Copy link
Copy Markdown
Contributor Author

@sjahr @sea-bass
I think this can go in now, all tests passing

@sjahr
Copy link
Copy Markdown
Contributor

sjahr commented May 24, 2023

@AndyZe Do you mind giving a final review?

@AndyZe
Copy link
Copy Markdown
Member

AndyZe commented May 24, 2023

Still looks good to me. Let's merge it

@AndyZe AndyZe merged commit 8d319c5 into moveit:main May 24, 2023
@ibrahiminfinite ibrahiminfinite deleted the cleanup3 branch June 3, 2023 14:12
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.

5 participants