Skip to content

Add time-optimal trajectory parameterization plugin - #809

Closed
mikeferguson wants to merge 3 commits into
moveit:indigo-develfrom
mikeferguson:totg
Closed

mikeferguson wants to merge 3 commits into
moveit:indigo-develfrom
mikeferguson:totg

Conversation

@mikeferguson

Copy link
Copy Markdown
Contributor

Description

This is a long-overdue request, implementing #160. This wraps/modifies the TOTG code from https://github.com/tobiaskunz/trajectories to work within MoveIt. Compared to the current Iterative Time Parameterization, this one actually does a pretty job enforcing the velocity/acceleration limits (although, based on some plotting, in some cases it probably produces a larger jerk).

There are two remaining "magic numbers" (the "tolerance" and the "resample" time) that need to be parameterized somewhere, but I'm not sure where. Before I went and implemented something, I figured I would see if anyone has a strong opinion about how similar we want these parameterization things to be (for instance, do we want to insist that they all have same function signature in computeTimeStamps?).

I produced this PR to Indigo, once we've OK'd that, I'll create a Kinetic version as well (it will be slightly different since it looks like we have TOPP in Kinetic, so some of the CMake changes will likely conflict).

Checklist

  • Required: Code is auto formatted using clang-format
  • Extended the tutorials / documentation, if necessary reference
  • Include a screenshot if changing a GUI
  • Optional: Created tests, which fail without this PR reference
  • Optional: Decide if this should be cherry-picked to other current ROS branches (Indigo, Jade, Kinetic)

@mikeferguson

Copy link
Copy Markdown
Contributor Author

A note on the commit history: it should be preserved, the first commit is the code AS IMPORTED, and so it is easy to see what has been changed in the second commit

@davetcoleman davetcoleman 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.

whew that's a lot of code!


virtual ~PathSegment()
{
}

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.

remove this empty function?

{
public:
/// @brief Generates a time-optimal trajectory
Trajectory(const Path& path, const Eigen::VectorXd& maxVelocity, const Eigen::VectorXd& maxAcceleration,

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.

camelCase -> under_score

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One thing to consider: how far do we want to diverge from the upstream codebase? It makes merging new upstream stuff tougher. I'd suggest not changing variable names of the code that is imported from Tobias

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'm curious - where is the upstream codebase?

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.

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.

Tobias hasn't updated that repository in 4 years, and he can't really do OSS anymore due to Waymo employment. Do we really think we'll be merging any new upstream stuff into here? The odds of that seem very low to me.

If you want to keep the original formatting just to save effort, however, I guess I can see that.


// Outputs the phase trajectory and the velocity limit curve in 2 files for
// debugging purposes.
// void outputPhasePlaneTrajectory() const;

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.

remove

}
double pathPos;
double pathVel;
double time;

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.

under_score var names


#include <limits>
//#include <fstream>
//#include <iostream>

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.

remove

if (maxVelocity == std::numeric_limits<double>::infinity())
maxVelocity = 10.0;
file1 << s << " " << maxVelocity << " " << getVelocityMaxPathVelocity(s)
<< endl;

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.

remove dead code

return false;
}

// Returns true if end of path is reached

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.

comments like this belong in header file

else if (pathVel < 0.0)
{
valid = false;
logError("error");

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.

more descriptive error

const double max_acceleration_scaling_factor)
{
double tolerance = 0.01; // TODO
double resample = 0.1; // TODO

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.

address this :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Did you have a preference of the question I mentioned, regarding computeTimeStamps signature?

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.

No preference

@@ -0,0 +1,1012 @@
/*

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.

would be ideal to split out some of these classes into separate files

@mikeferguson

Copy link
Copy Markdown
Contributor Author

@davetcoleman while it looks like a lot of code, most of it comes from the upstream repo. I've added some tests while cleaning up formatting/cmake in the 2nd commit, but the 3rd commit is the majority of the "new" code.

@davetcoleman

Copy link
Copy Markdown
Member

do we want to insist that they all have same function signature in computeTimeStamps?

I do not feel they need to be the same. Or, perhaps we can add the two additional parameters to the function signature with good default values in the header?

@hartmanndennis

Copy link
Copy Markdown
Contributor

This leads to much better time parametrization for me than the TOPP Pull Request. But I get a segmentation fault if I plan with target state = current state. I tested it with kinetic but I don't think that's the issue.

@RhysMcK

RhysMcK commented Apr 22, 2018

Copy link
Copy Markdown

Very keen to trial TOPP and TOTG, looks promising! @mikeferguson you mentioned TOPP has been implemented in Kinetic, which repo are you referring to?

Cheers 😀

@mikeferguson

Copy link
Copy Markdown
Contributor Author

@hartmanndennis -- thanks for the feedback and a heads up on the segfault -- that actually makes sense, I don't think we handle that case anywhere, I'll make sure to add a test and a fix for that before we merge.

@RhysMcK -- I believe I misspoke above about TOPP -- I was referring to #441, but I now see that is something different from TOPP (I vaguely followed the comments, and TOPP was mentioned several times, leading me to think it was TOPP itself being added).

@davetcoleman -- I haven't forgotten about this, just been away from my dev box. Will address changes sometime later this week.

@hartmanndennis

Copy link
Copy Markdown
Contributor

I have found another bug. Sometimes the last point of a trajectory has a significant non-zero velocity, causing extreme jerk and stopping the robot.

@hartmanndennis

Copy link
Copy Markdown
Contributor

Is there any progress on this?

@davetcoleman

Copy link
Copy Markdown
Member

@mikeferguson can you address my feedback and re-target this PR for melodic? Note the melodic branch compiles on ROS Kinetic, if that's an issue for you.

@henningkayser

Copy link
Copy Markdown
Member

@mikeferguson @davetcoleman this can be closed since #1365 is merged

@rhaschke

rhaschke commented Mar 7, 2019

Copy link
Copy Markdown
Contributor

Closed via #1365.

@rhaschke rhaschke closed this Mar 7, 2019
JafarAbdi added a commit to JafarAbdi/moveit that referenced this pull request Mar 24, 2022
Co-authored-by: Henning Kayser <[email protected]>
Co-authored-by: Jafar Abdi <[email protected]>
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.

7 participants