Skip to content

Enforce singularity threshold when moving away from a singularity - #620

Merged
AndyZe merged 22 commits into
moveit:mainfrom
nbbrooks:always-enforce-singularity-thresholds
Aug 15, 2022
Merged

AndyZe merged 22 commits into
moveit:mainfrom
nbbrooks:always-enforce-singularity-thresholds

Conversation

@nbbrooks

@nbbrooks nbbrooks commented Aug 18, 2021 •

Copy link
Copy Markdown
Collaborator

Description

I have updated this description to reflect the final behavior.

Currently the singularity threshold behavior is only enforced if the manipulator is moving further into singularity. If a different mode of operation is used (e.x. joint servoing) which puts the manipulator into/beyond the singularity region and then the user switches to Cartesian servoing, the velocity scaling/singularity halting behavior will not take effect if they are servoing away from the singularity (e.g. dot < 0). This can result in wild motion.

This PR makes 2 opt-in changes

  1. Enforce singularity behavior regardless of whether they are moving into/away from singularity
  2. Don't reduce the velocity as much for movement near, but moving away from a singularity (compared to if it was moving further into singularity)

The behavior of 2 uses a new parameter leaving_singularity_threshold_multiplier and is described in the below graphic. By default leaving_singularity_threshold_multiplier is 2.0
Servo singularity threshold behavior

TODO:

  • Default the new approaching_stop_singularity_threshold param to hard_stop_singularity_threshold so this doesn't break existing implementations (e.g. make this opt in)
  • Add tests checking approach and hard stop conditions

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

@AndyZe

AndyZe commented Aug 20, 2021 •

Copy link
Copy Markdown
Member

I like these things. Both very useful for debugging:

Publish singularity condition to topic servo_server/condition
Add status code to distinguish between velocity scaling when moving towards/away from the singularity

I don't like this. Several people have complained in the past when the robot could only move away from singularity slowly:

Enforce singularity behavior regardless of whether they are moving into/away from singularity

Instead of that, I like the idea you brought up privately:

Add a 3rd threshold that is inbetween the current two. This will be the "approaching_singularity_hard_stop". It won't let you move past that if you are moving into the singularity, but still lets you move away

@AndyZe

AndyZe commented Aug 20, 2021

Copy link
Copy Markdown
Member

If you want to reduce the scope of this PR so it only does this two things, I'd approve:

Publish singularity condition to topic servo_server/condition
Add status code to distinguish between velocity scaling when moving towards/away from the singularity

@nbbrooks
nbbrooks force-pushed the always-enforce-singularity-thresholds branch 2 times, most recently from 7c0382e to c539886 Compare September 22, 2021 15:22
@nbbrooks nbbrooks changed the title WIP: Enforce singularity threshold behavior even when moving away from a singularity Enforce singularity threshold when moving away from a singularity Sep 22, 2021
@nbbrooks
nbbrooks requested review from AndyZe and felixvd September 22, 2021 15:27
@nbbrooks

Copy link
Copy Markdown
Collaborator Author

@AndyZe I moved the singularity topic publishing to separate PR #695

I did not include the new status code for servoing away from singularity to that PR, as currently we don't enforce singularity when moving away so that status code would never be used.

@nbbrooks
nbbrooks force-pushed the always-enforce-singularity-thresholds branch from 9af403e to 004d538 Compare September 24, 2021 23:12
…ingularity

- Prevent uncontrolled behavior when servo starts close to a singularity and then servos away from it
- Scale velocity at a different rate when approaching/leaving singularity
- Add status code to distinguish between velocity scaling when moving towards/away from the singularity
@nbbrooks
nbbrooks force-pushed the always-enforce-singularity-thresholds branch from 004d538 to fabc2e2 Compare November 8, 2021 14:30
@codecov

codecov Bot commented Nov 8, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #620 (de97459) into main (1d67b51) will increase coverage by 0.04%.
The diff coverage is 87.88%.

❗ Current head de97459 differs from pull request most recent head 52a77b7. Consider uploading reports for the commit 52a77b7 to get more accurate results

@@            Coverage Diff             @@
##             main     #620      +/-   ##
==========================================
+ Coverage   51.10%   51.13%   +0.04%     
==========================================
  Files         380      380              
  Lines       31737    31755      +18     
==========================================
+ Hits        16217    16236      +19     
+ Misses      15520    15519       -1     
Impacted Files Coverage Δ
...veit_servo/include/moveit_servo/servo_parameters.h 100.00% <ø> (ø)
moveit_ros/moveit_servo/src/servo_parameters.cpp 86.53% <71.43%> (-0.78%) ⬇️
moveit_ros/moveit_servo/src/servo_calcs.cpp 68.25% <100.00%> (+0.81%) ⬆️
moveit_core/robot_state/src/robot_state.cpp 47.44% <0.00%> (+0.08%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@nbbrooks nbbrooks changed the title Enforce singularity threshold when moving away from a singularity WIP: Enforce singularity threshold when moving away from a singularity Nov 8, 2021
@nbbrooks
nbbrooks marked this pull request as draft November 9, 2021 01:58
@nbbrooks
nbbrooks marked this pull request as ready for review November 9, 2021 02:01
@henningkayser
henningkayser marked this pull request as draft February 3, 2022 17:12
@nbbrooks
nbbrooks marked this pull request as ready for review June 29, 2022 19:38
@nbbrooks nbbrooks changed the title WIP: Enforce singularity threshold when moving away from a singularity Enforce singularity threshold when moving away from a singularity Jun 29, 2022
@henrygerardmoore

henrygerardmoore commented Aug 5, 2022 •

Copy link
Copy Markdown
Contributor

@nbbrooks @AndyZe Just updated to the latest design, take a look when you have a chance and let me know if I should change anything (especially with the style of the deprecation warning and how I checked for the parameter's existence before getting it).
Servo tests still pass locally, but should we add a test to make sure the scaling is working as expected? Mathematically it makes sense to me, I was just wondering if that might be warranted.
Also, is linking to a PR in a comment bad style? I could maybe link directly to the diagram or just try to write an explanation if that would be better.

@AndyZe
AndyZe self-requested a review August 10, 2022 19:45
@AndyZe

AndyZe commented Aug 10, 2022

Copy link
Copy Markdown
Member

Almost there.

Also, is linking to a PR in a comment bad style?

IMO that's fine

@henrygerardmoore

Copy link
Copy Markdown
Contributor

Thanks for the review, Andy! I think it should be good to go now. Made your changes and cleaned some stuff up as well as adding defaults for the panda .yaml files.

@tylerjw tylerjw left a comment

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.

I like the approach of keeping old configs working and using a warning to inform them of new/better behavior they can take advantage of through a config change.

I would like to see logic moved out of sevo_calcs and into free functions that can be tested independently of all of the state in servo_calcs but will not block this PR for that.

@AndyZe
AndyZe merged commit d4b3294 into moveit:main Aug 15, 2022
@henrygerardmoore

henrygerardmoore commented Aug 15, 2022 •

Copy link
Copy Markdown
Contributor

Is one of the new tests flaky? 52a77b7 failed CI while 0f2a6ca didn't even though the only change was the warning text 😓

@AndyZe

AndyZe commented Aug 15, 2022

Copy link
Copy Markdown
Member

See #1499

Feel free to debug that if you have time. That would be awesome.

@tylerjw tylerjw added the backport-humble Mergify label that triggers a PR backport to Humble label Oct 28, 2022
mergify Bot pushed a commit that referenced this pull request Oct 28, 2022
* Enforce singularity threshold behavior even when moving away from a singularity

- Prevent uncontrolled behavior when servo starts close to a singularity and then servos away from it
- Scale velocity at a different rate when approaching/leaving singularity
- Add status code to distinguish between velocity scaling when moving towards/away from the singularity

* Work on expanding servo singularity tests

* Pre-commit

* removed duplicate input checking

* added 2 other tests

* undid changes to singularity test

* Update moveit_ros/moveit_servo/src/servo_calcs.cpp with Nathan's suggestion

Co-authored-by: Nathan Brooks <[email protected]>

* readability changes and additional servo parameter check

* updating to newest design

* added warning message

* added missing semicolon

* made optional parameter nicer

* Remove outdated warning

Co-authored-by: AndyZe <[email protected]>

* Removing inaccurate comment

Co-authored-by: AndyZe <[email protected]>

* making Andy's suggested changes, added some comments and defaults, moved code block next to relevant singularity code

* removed part of comment that does not apply any more

* Mention "deprecation" in the warning

Co-authored-by: Henry Moore <[email protected]>
Co-authored-by: Henry Moore <[email protected]>
Co-authored-by: AndyZe <[email protected]>
Co-authored-by: AndyZe <[email protected]>
(cherry picked from commit d4b3294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-humble Mergify label that triggers a PR backport to Humble

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants