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

Fix totg bug giving invalid accelerations #1729

Merged
merged 10 commits into from
Dec 2, 2019

Conversation

JafarAbdi
Copy link
Contributor

Description

Fix: #1665

Regarding the epsilon value 1e-8 I picked it randomly, I think we should parameterize it depending on the time_step_ but I'm not sure how to do it exactly

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

Copy link
Contributor

@mlautman mlautman left a comment

Choose a reason for hiding this comment

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

see comments

@JafarAbdi
Copy link
Contributor Author

Travis is failing due to eigenpy see

@@ -538,6 +538,12 @@ bool Trajectory::integrateForward(std::list<TrajectoryStep>& trajectory, double

if (next_discontinuity != switching_points.end() && path_pos > next_discontinuity->first)
{
// Avoid having a TrajectoryStep with path_pos near a switching point which will cause an almost identical
// TrajectoryStep get added in the next run (https://github.com/ros-planning/moveit/issues/1665)
if (path_pos - next_discontinuity->first < time_step_ * 1e-5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to allow the trajectory steps to be much shorter than the time step? I worry slightly that this leaves the possibility for very rare errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that even with a timestep of 1e-8 an change of velocity of 1 will give an an acceleration of 100,000,000. Maybe when we eventually divide change in velocity by time-step, we cap the result to some maximum value?

Copy link
Member

Choose a reason for hiding this comment

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

This should be a parameter then so this can be adjusted to the corresponding setup. I'm afraid this would be a magic parameter, then

Copy link
Contributor

Choose a reason for hiding this comment

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

We could use EPS

if (path_pos - next_discontinuity->first < time_step_ * 1e-5)
{
continue;
}
path_vel = old_path_vel +
(next_discontinuity->first - old_path_pos) * (path_vel - old_path_vel) / (path_pos - old_path_pos);
path_pos = next_discontinuity->first;
Copy link
Contributor

@mlautman mlautman Nov 19, 2019

Choose a reason for hiding this comment

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

As an alternative

Suggested change
path_pos = next_discontinuity->first;
if (std::abs((path_vel - old_path_vel) / (path_pos - next_discontinuity->first)) > maximum_acceleration_)
continue;
path_pos = next_discontinuity->first;

Copy link
Contributor

Choose a reason for hiding this comment

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

This results in immediately dividing by zero

Copy link
Contributor

@mlautman mlautman Nov 22, 2019

Choose a reason for hiding this comment

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

My bad. If you moved this before the assignment it would work right?

Copy link
Contributor

Choose a reason for hiding this comment

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

You would need to set maximum_acceleration_ to something reasonable

@@ -538,6 +538,12 @@ bool Trajectory::integrateForward(std::list<TrajectoryStep>& trajectory, double

if (next_discontinuity != switching_points.end() && path_pos > next_discontinuity->first)
{
// Avoid having a TrajectoryStep with path_pos near a switching point which will cause an almost identical
// TrajectoryStep get added in the next run (https://github.com/ros-planning/moveit/issues/1665)
if (path_pos - next_discontinuity->first < time_step_ * 1e-5)
Copy link
Member

Choose a reason for hiding this comment

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

This should be a parameter then so this can be adjusted to the corresponding setup. I'm afraid this would be a magic parameter, then

@davetcoleman
Copy link
Member

Looks like this PR is close to ready, just need to expose the magic parameter?

@mlautman
Copy link
Contributor

@mikeferguson Can you take a look at this and let us know if there is an issue with this approach?

@mlautman
Copy link
Contributor

mlautman commented Dec 2, 2019

Merging since this has been considered at length already. If @mikeferguson has a better approach let us know.

@mlautman mlautman merged commit 5fab740 into moveit:master Dec 2, 2019
@JafarAbdi JafarAbdi deleted the pr-fix_totg_bug branch December 2, 2019 23:12
v4hn pushed a commit to v4hn/moveit that referenced this pull request Mar 30, 2020
v4hn pushed a commit to v4hn/moveit that referenced this pull request Mar 31, 2020
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.

totg timing algorithm sometimes gives invalid accelerations
5 participants