Repository navigation
Iterative cubic spline - #441
davetcoleman merged 27 commits into
Conversation
|
@rbbg, if you could please help with testing, I'd be much obliged. I haven't worked with robots/ros/moveit in years. If you plan to compare against 'optimal' methods such as TOPP, just disable jerk. |
|
I've been following this development and this is impressive. The 'staircases' in the jerk plots are very nice to see. One comment / question: should compile time switches like (en|dis)abling jerk limits (4b69254) and the default limits (1810abd) all be made configurable / runtime changeable (ultimately through ROS params / dyn reconfig)? I don't think we can choose a configuration / set of parameters that will suite every usecase or (robotic) setup, so it's probably worth it to make them user configurable. |
davetcoleman
left a comment
There was a problem hiding this comment.
Great code, fantastic contribution, small changes requested, thanks!
|
|
||
| #define VLIMIT 1.0 // default | ||
| #define ALIMIT 3.0 // default | ||
| #define JLIMIT 9.0 // default |
There was a problem hiding this comment.
These compiler flags are generally discouraged, could we use static const double VLIMIT = 1.0; instead?
| Increasing the jerk limits will reduce oscilation and speed up execution. | ||
| By default, this should be ENABLED. | ||
| */ | ||
| #define ENABLE_JERK |
There was a problem hiding this comment.
I'd rather see this run-time configurable.
| The downside is that if the limits are low, you will notice visible oscilation | ||
| around what you may expect as the 'optimal' velocity curve. | ||
| Increasing the jerk limits will reduce oscilation and speed up execution. | ||
| By default, this should be ENABLED. |
There was a problem hiding this comment.
Really great comments, thanks!
| double final_acceleration; | ||
| double max_velocity; | ||
| double max_acceleration; | ||
| double max_jerk; |
There was a problem hiding this comment.
Out of curiosity, is it possible to handle different min/max values for these limits? Its never been fully clear to me the use case for having this distinction, but parts of MoveIt! do support it
There was a problem hiding this comment.
Ok, I've added support for it. But if a min value is zero, I assume it is unset and set it to the negative of the max value.
| }; | ||
|
|
||
| IterativeSplineParameterization::IterativeSplineParameterization(double max_time_change_per_it, bool add_points) | ||
| : max_time_change_per_it_(1.0 + max_time_change_per_it), add_points_(add_points) |
There was a problem hiding this comment.
to make it a multiplicative factor. I changed the member variable name to reflect this.
|
|
||
| p0 = trajectory.getWayPointPtr(num_points - 2); | ||
| p1 = trajectory.getWayPointPtr(num_points - 1); | ||
| for (unsigned j = 0; j < num_joints; j++) |
| } | ||
| } | ||
|
|
||
| // Initiialize times |
| init_times(num_points, &time_diff[0], &t2[j].positions[0], t2[j].max_velocity); | ||
|
|
||
| // Fit initial spline (satisfies initial/final velocity) | ||
| int loop = 1; |
There was a problem hiding this comment.
bool would be a better datatype for clarity. i double checked performance indications and it seems they are the same
| * POSSIBILITY OF SUCH DAMAGE. | ||
| *********************************************************************/ | ||
|
|
||
| /* Author: Ken Anderson, based off add_iterative_spline_parameterization.cpp by Ioan Sucan */ |
There was a problem hiding this comment.
add_iterative_spline_parameterization should be add_time_parameterization
|
|
||
| namespace default_planner_request_adapters | ||
| { | ||
| class AddSplineParameterization : public planning_request_adapter::PlanningRequestAdapter |
There was a problem hiding this comment.
The name of this class conflicts with the other version that was recently added by @rbbg to the indigo-devel branch of moveit. A PR exists to cherry-pick it to kinetic-devel, but it has not been merged in.
Since yours is clearly an improvement, I think we should replace his with yours entirely. @rbbg is that ok with you? To make the code history make sense, I think we should still merge #428 then have this PR replace it?
There was a problem hiding this comment.
That's absolutely fine with me.
There was a problem hiding this comment.
|
@gavanderhoorn Yes, you are correct. I wasn't initially sure if disabling jerk would play nice with the controller problem in #160, but I believe it will. We just lose initial/final acceleration matching. So to that end, I've added arguments to the constructor for jerk enabling and setting the jerk limit. And I've added a jerk scaling factor similar to the velocity and acceleration scaling factors in computeTimeStamps(). This will allow reducing limit during operation without reconstructing the object. As for the default limits-- they are really just a fallback if the model doesn't provide them. This is the same behaviour as IPTP, so I'd prefer to leave that out of this pull request. |
|
@davetcoleman Your requested changes should be complete. Thanks for reviewing. |
|
This is great! I'll definitely try to test the performance as soon as I can. A decent comparison between this and the other available options will be a little more work, but I'd be happy to merge this as soon as it is confirmed that the controller won't do anything weird with this parameterization (which I really doubt). Seems like |
| #include <vector> | ||
|
|
||
| static const double VLIMIT = 1.0; // default if not specified in model | ||
| static const double ALIMIT = 3.0; // default if not specified in model |
There was a problem hiding this comment.
Just wondering: the defaults are currently both set to 1.0, I don't mind changing that but just wanted to point it out, especially since I've seen quite a number of moveit_configs that don't have the acceleration limit set.
There was a problem hiding this comment.
Good point. I agree. Done.
|
Waiting on @rbbg's testing |
| </description> | ||
| </class> | ||
|
|
||
| <class name="default_planner_request_adapters/AddIterativeSplineParameterization" type="default_planner_request_adapters::AddIterativeSplineParameterization" base_class_type="planning_request_adapter::PlanningRequestAdapter"> |
There was a problem hiding this comment.
I think this should be:
<class name="default_planner_request_adapters/AddSplineParameterization" type="default_planner_request_adapters::AddSplineParameterization" base_class_type="planning_request_adapter::PlanningRequestAdapter">
<description>
</description>
</class>
To match the names in add_iterative_spline_parameterization.cpp
There was a problem hiding this comment.
Good catch. I've changed the cpp class to match instead to avoid colliding with #382 . It also matches the cpp filename.
|
@mmoerdijk , @rbbg , @kennethanderson , @BrettHemes What is your current view on this issue? I assume there is no optimal solution to the acceleration spikes available in the near future. |
|
I haven't looked at this in a while. I'd probably hold off on #443 until there is actually something better available. It's not perfect the way it is, but at least it is an improvement from what was there before. |
|
Sorry guys, the only way I have been able to resolve to oscillations problem is to ignore the jerk constraints. Smoothing is a promising option, but I've run out of free time to continue working on this. So I've removed the jerk constraints from this trajectory fitter. This improves on IPTP in the ways you were expecting (it's velocity&acceleration-constrained at waypoints, it's 1st/2nd derivative are continuous, calculation time and trajectory length are on par with IPTP). I've tested on 3 sets of test trajectories provided by you. But could If I could get some more help testing, I'd be much obliged. |
|
Ping. This code should be ready for merging. |
|
@v4hn the code is ready, if you'd like to use it. It should solve the acceleration spikes issue. However, it looks like this PR has fallen off everyone's radar. |
|
Ping. |
|
@kennethanderson sorry, this is on my list and I'm interested to see this merged soon. |
|
I would like to merge this PR today. I have just reviewed all the previous comments as well as the previous spline approach graciously contributed by @rbbg that I merged in a month prior to @kennethanderson improved version in this PR. Here's what I think we should do and the rational: Revert @rbbg's temporary AddSplineParameterization
Merge this PR
Thanks @rbbg for starting this whole spline effort and @kennethanderson for putting in so much testing and research into a far superior approach for moveit! |
|
@davetcoleman I won't have the time to look over this today. Looking forward to see this improved! |
|
@davetcoleman wrote (#441 (comment)):
I think I can agree with your rationale, and I'm pretty sure @rbbg will agree as well. @kennethanderson's work is indeed very nice. Not perfect (as he wrote himself), but neither is the current IPTP. |
|
Can this be merged soon? |
|
I am waiting for @davetcoleman to look at this again and merge it. |
|
hurray! |
|
Should this be considered for backport to Indigo? The PR doesn't replace anything, so the current behaviour could be maintained. |
Feel free to file a pull-request. Sounds good to me. |
|
I have recently been having issues commanding a 6-DOF Kuka robot using the paths generated by moveit's motion planning pipeline. However, every now and again i will receive a slight jerk which will exceed the acceleration and torque limits of the physical robot. I was hoping that this new spline fitting method might help, however the trajectories outputs i obtained weren't great. This can be seen in below velocities plots. [blue-Planned= motion planning pipeline output , green-Desired= controller output, red-Actual = IGNORE] Please note that i didn't capture the exact same trajectory for the two cases above... but regardless the oscillation in the latter method is constant across all trajectories i tried. Any ideas on why this spline-fitting method is producing particular 'non-ideal' trajectories? Cheers! |
|
#809 (or: TOTG) is nice, but iirc, totg is also not jerk limited. |
* adding iterative spline time parameterization * add 2nd and 2nd-last points * move added points near endpoints, but not exactly the same. Fix math error. * add jerk comment * clang-formatting * prevent divide-by-zero. Fix out-of-bounds array write * fix variables * off by one error. change default limits * comments * fix for setting waypoint durations * comments * add time parameterization unit test * styling * add compile-time option to disable jerk * allow jerk to be enabled/disabled at runtime * make requested changes, the biggest of which is allowing for min and max constraints * add duration check to unit test * set default acceleration to 1.0 * fix class name * add migration notes * whitespace styling * set waypoint velocities/accelerations when unset. Increase default jerk limit. Modify test case to catch this. * improved handling of unspecified initial/final velocities/accelerations * change 0.01 constant to epsilon() * simplify tests * styling * Remove jerk, as it causes oscillations
* adding iterative spline time parameterization * add 2nd and 2nd-last points * move added points near endpoints, but not exactly the same. Fix math error. * add jerk comment * clang-formatting * prevent divide-by-zero. Fix out-of-bounds array write * fix variables * off by one error. change default limits * comments * fix for setting waypoint durations * comments * add time parameterization unit test * styling * add compile-time option to disable jerk * allow jerk to be enabled/disabled at runtime * make requested changes, the biggest of which is allowing for min and max constraints * add duration check to unit test * set default acceleration to 1.0 * fix class name * add migration notes * whitespace styling * set waypoint velocities/accelerations when unset. Increase default jerk limit. Modify test case to catch this. * improved handling of unspecified initial/final velocities/accelerations * change 0.01 constant to epsilon() * simplify tests * styling * Remove jerk, as it causes oscillations
|
Hi I am trying to use Iterative Spline parameterization for trajectory smoothing with Trajectory Optimization (TrajOpt) algorithm. As moveit do not support trajopt, I originally created a seperate robot model for moveit and used |


Description
Ruben's idea of fitting a cubic spline to a trajectory is a very good one: #382 . Forcing the trajectory to a cubic should prevent the controller from overfitting the data, the problem presented here: #160 .
I've taken the concept a little further by repeatedly fitting the spline and adjusting timestamps until all constraints are satisfied. This is similar to the way IPTP works, but instead of using local averages, the instantaneous values are used instead.
This technique is presented as another trajectory time parameterization class that can be used instead of IPTP. It also adds some simple unit tests. Initial/final velocity and acceleration can be specified. The constraints imposed are velocity, acceleration, and jerk. Here is a straight-line trajectory of 11 points:
Ruben graciously provided some sample trajectories using RRT-Connect with a Kuka IIWA in a fairly cluttered scene. The trajectories have between 25 and 70 waypoints. These are the resulting spline trajectories (this is the calculated/interpolated spline curves, it is not data from an executing robot or simulation).
Checklist
Thank you!