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

Exit loop when position can't change. #2307

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

uavster
Copy link
Contributor

@uavster uavster commented Aug 17, 2023

Description

Fixes #2066. Infinite looping happens at Trajectory::integrateForward when three things concur:

  • The velocity at a trajectory point is zero
  • Any maximum acceleration component is zero
  • The corresponding component in the tangent at the point of the trajectory is not zero.

The changes in this PR are:

  • Break the loop when velocity and acceleration are zero
  • Unit test that times out without the fix and passes with it
  • Unit test that ensures the loop is not broken if the tangent is zero even if the maximum acceleration is

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

@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (a2f0183) 50.71% compared to head (46b7944) 50.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2307      +/-   ##
==========================================
+ Coverage   50.71%   50.73%   +0.02%     
==========================================
  Files         386      386              
  Lines       31914    31922       +8     
==========================================
+ Hits        16182    16192      +10     
+ Misses      15732    15730       -2     
Files Changed Coverage Δ
...cessing/src/time_optimal_trajectory_generation.cpp 86.37% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@uavster uavster marked this pull request as ready for review August 17, 2023 14:45
@uavster uavster requested a review from sea-bass August 17, 2023 14:45
Copy link
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.

Also, what happens in the case where time_step_ is zero? Should that be handled here as well?

Though I guess that will necessarily make path_vel zero so it's probably okay.

@uavster
Copy link
Contributor Author

uavster commented Aug 17, 2023

Ah right! My original fix does not catch that because time_step==0 makes velocity, but not acceleration. I've added an extra case at the constructor to check for that.

@uavster uavster force-pushed the fix-integrate-forward-hanging branch from 04b4f35 to cd167e9 Compare August 17, 2023 15:35
@uavster uavster force-pushed the fix-integrate-forward-hanging branch from cd167e9 to a67e15b Compare August 17, 2023 17:17
Copy link
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.

gah. The clang-tidy checks are failing because somehow MoveIt doesn't use the Google style of constant casing. Sorry :/

https://github.com/ros-planning/moveit2/actions/runs/5893944176/job/15986542597?pr=2307#step:12:9198

@uavster
Copy link
Contributor Author

uavster commented Aug 17, 2023

gah. The clang-tidy checks are failing because somehow MoveIt doesn't use the Google style of constant casing. Sorry :/

https://github.com/ros-planning/moveit2/actions/runs/5893944176/job/15986542597?pr=2307#step:12:9198

Oh, hahah. Linter-settled discussion.

@sea-bass
Copy link
Contributor

Oh, hahah. Linter-settled discussion.

It's specifically that in the bodies of functions, where things aren't constants, you have to use snake_case, whereas camelCase is okay for e.g. constexprs in anonymous namespaces.

So if you just use names like max_velocity instead of kMaxVelocity in the tests, should be good to go

@uavster uavster force-pushed the fix-integrate-forward-hanging branch from a67e15b to 46b7944 Compare August 17, 2023 19:10
@uavster
Copy link
Contributor Author

uavster commented Aug 17, 2023

Oh, hahah. Linter-settled discussion.

It's specifically that in the bodies of functions, where things aren't constants, you have to use snake_case, whereas camelCase is okay for e.g. constexprs in anonymous namespaces.

So if you just use names like max_velocity instead of kMaxVelocity in the tests, should be good to go

done

@uavster
Copy link
Contributor Author

uavster commented Aug 17, 2023

Oh, hahah. Linter-settled discussion.

It's specifically that in the bodies of functions, where things aren't constants, you have to use snake_case, whereas camelCase is okay for e.g. constexprs in anonymous namespaces.
So if you just use names like max_velocity instead of kMaxVelocity in the tests, should be good to go

done

BTW, are you ok with inlining the instantiations of Path and Trajectory?

@sea-bass
Copy link
Contributor

BTW, are you ok with inlining the instantiations of Path and Trajectory?

That's fine!

@sea-bass sea-bass merged commit 7c95367 into moveit:main Aug 18, 2023
8 checks passed
@sea-bass sea-bass added backport-humble Mergify label that triggers a PR backport to Humble backport-iron Mergify label that triggers a PR backport to Iron labels Aug 18, 2023
mergify bot pushed a commit that referenced this pull request Aug 18, 2023
mergify bot pushed a commit that referenced this pull request Aug 18, 2023
(cherry picked from commit 7c95367)

# Conflicts:
#	moveit_core/trajectory_processing/test/test_time_optimal_trajectory_generation.cpp
henningkayser pushed a commit that referenced this pull request Aug 22, 2023
(cherry picked from commit 7c95367)

Co-authored-by: Nacho Mellado <ignacio.mellado@gmail.com>
uavster added a commit to uavster/moveit2 that referenced this pull request Jan 5, 2024
henningkayser pushed a commit that referenced this pull request Jan 23, 2024
Co-authored-by: Sebastian Jahr <sebastian.jahr@picknik.ai>
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 backport-iron Mergify label that triggers a PR backport to Iron
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop in TOTG if zero max acceleration is specified
2 participants