iron-ox / trajectory_smoothing

Apache License 2.0
9 stars 7 forks source link

Velocity projection between s-domain and joint domain #12

Open mahmoud-a-ali opened 4 years ago

mahmoud-a-ali commented 4 years ago

with the current implementation of s-variable, there are some issues when it comes to the non-zero velocity at waypoint:

f1

Example with numbers [ when we convert joint velocity to s-domain]:

I was wondering why the topp-ra method does not have the same issues, I found that they using s-variable in such a way that q(s) is a cubicspline [q(s)= as^3 + bs^2 + cs + d] , so [q`(s) = 3as^2 + 2bs + c], which mean that with the same rule (q_dot(s) = q`(s) * s_dot ), a single value of s_dot combined with the three variables (a, b, c) can result in non-related velocities in joint-domain. they are using piecewise cubic functions instead of piecewise linear functions.

f2

jonbinney commented 4 years ago

Thanks for the detailed explanation! If I understand correctly the 3 points are:

  1. The joints velocities are all related to each other by some constant ratio at each segment in the path. I'm not sure why this is a problem - in fact it must be true or else the arm would be leaving the chosen path, which could result in collisions.

  2. There are discontinuities where linear segments meet - this also is always going to be true for piecewise linear paths. Any S-parameterization of the path will have the same problem; fundamentally it is impossible for the robot to change direction in joint space instantly without having infinite instantaneous acceleration and jerk. The solution is that we must create smooth blends in the path before doing time parameterization - that's what I'm working on now.

  3. I don't think this will be a problem after we add blending to smooth transitions between segments. The joint whose velocity passes through zero will have dj/ds = 0 for the point where it changes direction. So ds/dt can still be nonzero while keeping dj/dt for that joint equal to zero.

mahmoud-a-ali commented 4 years ago

yes, you got the three points I want to discuss. I agree that the joints' velocities will be related to each other for each segment. but as you mentioned that "There are discontinuities where linear segments meet - this also is always going to be true for piecewise linear paths", I think this discontinuity can be removed if the joints are represented by a higher-order polynomial of S.

jonbinney commented 4 years ago

If the higher level polynomial follows the same geometric path as the piecewise linear path, then the only way it would avoid velocity discontinuities would be to have dj/ds = 0 for all joints at the points where the arm changes directions. That would mean no matter how you did the time parameterization ( ds/dt ), all joints will stop at every waypoint - so we'd be just as well off keeping the piecewise linear function of s for the joints, and using a time parameterization that stops the robot at every waypoint.

I'm pretty convinced that moving with the joints with non-zero velocity through the waypoints will require geometric change to the path, not just a change in the form of the parameterization.

mahmoud-a-ali commented 4 years ago

update after blending: A. Before:

B. After:

mahmoud-a-ali commented 4 years ago

@jonbinney we might need to change the project_limits_onto_s, this function takes only the first derivative of q(s) into account which is true for the original segments (as 2nd and 3rd derivative are zeros because it is linear in s), but it is not true for the blending segment. .... as the blending 2nd and 3rd dervative are not zeros, look at the following equations from paper: limit_projection_on_s

we were using equation number (2) to project velocity, acceleration, and jerk limits which is not right in the blending segment case

jonbinney commented 4 years ago

Yes, @mahmoud-a-ali you're right. project_limits_onto_s assumes a linear segment path. If we want to compute constant jerk/acceleration/velocity limits for the blending section, we'll have to take use the equations you listed and take the minimum (the limits are different at each point in the blending section).

jonbinney commented 4 years ago

Hmm... this is slightly trickier than i thought. This paper extends the paper you cited to include jerk constraints using sequential convex programming. They use the chain rule to get the jerk depending on q(s) and s(t): Screenshot from 2020-03-21 18-16-27

In the rest of this comment, I'm going to use the following nomenclature so that i can write in plain text: sd means sd, sdd means sdd sdd means sddd

Looking at these, it becomes clear that the constraints on sd, sdd, and sdd are not independent - meaning that the constraint on sdd depends on choice velocity and jerk, the constraint on sddd depends on the acceleration and velocity chosen, etc.

Put another way, if you plotted the region of valid values for sd, sdd, and sddd on the axes sd, sdd and sddd, that region would not be an axis-aligned rectangular prism. So we can't just return upper and lower limits on sd, sdd, and sddd for curved parts of the path - we have to return something more complicated. In the paper, they use the following representation for the jerk constraint: Screenshot from 2020-03-21 18-25-57 where: Screenshot from 2020-03-21 18-28-45

For their SCO approach, that is fine as long as the can use tricks to decompose the constraints into a set of convex constraints. For the kinds of approaches we've been pursuing this is more complex. My original thought was that we could require sd to be constant within the blending regions. This greatly simplifies the limits - you know that sdd and sddd are zero, so the upper and lower limits on sd only depend on s (where you are in the blended region). My hunch is that for a blend region that has constant curvature in joint space, the limits on sd will actually be constant across the entire blend region (the limit on sd only depends on the curvature). I still need to think through this though.

jonbinney commented 4 years ago

@mahmoud-a-ali @gavanderhoorn what do you think about me moving this repository to gitlab so that we can use latex math in issues, pull requests, and readme files? https://docs.gitlab.com/ee/user/markdown.html#math

jonbinney commented 4 years ago

Update: I tried out gitlab's markdown, and while it is almost exactly what we need, it is missing a couple of key features. Specifically, it doesn't have \dddot to denote the third derivative. I was able to create a def for it:

\def\dddot#1{#1^{\mathclap{\dotsb}}}
\dot{s} + \ddot{s} + \dddot{s}

But since each math block has its own scope, we would have to copy and paste that first line into every one. Overall I think it isn't worth the move. I'll look into latex to image renderers that we can use to create math images we can copy to github issues as a workaround.

gavanderhoorn commented 4 years ago

What about using d''' notation?

jonbinney commented 4 years ago

The TOPPRA authors use apostrophes to indicate the derivative with respect to s - so they have equations with a mix of dots and apostrophes: Screenshot from 2020-03-26 08-41-40

I'd suggest that in plain text we use d for dot so we could write the above equation as

qddd = q'''*sddd^3 + 3*q''*sdd*sd + q'*sddd