Calculating acceleration and decelleration to reach a certain point in time

I did. I’m not sure what your point is.

Maybe I didn’t understand your post :wink:

I don’t want to interpolate values and my input values are at arbitrary times with arbitrary numbers.

I also might not get, if you think that the curve “jumps” are at sample occasions. If so, that’s not true. Assume that the square curve in my example has a period of 2s. So each state lasts for 1s. The values are sampled at a rate of 60 per seconds. So I get 60 0 values and 60 1 values. For every sample I want to return a smoothed value instead of the original 0 or 1 value from the input.

So correct me if misunderstand your proposal, but it seems, it would only work for interpolating between sampled inputs or if the inputs don’t change while the transition is calculated. Another problem might be, if I use a sinusidal transition, I can’t lineary “sweep over” samples lying on the interpolation path without getting an ease in and ease out effect.

I think this may be the source of confusion. How do you know the value of the curve other than at sample points? Could you redo your diagram showing where samples are taken?

Maybe this sentence wasn’t clear. See the second post with an attachment. The red dots are the input samples.

Ah, looking at the maths in the post with the second attachment I think I see what you’re trying to do.

At time t0 you have velocity v0.
You accelerate until t0 + t with acceleration a1. You then accelerate until t0 + T with acceleration a2. At t0 + T the velocity is zero.
The distance travelled from t0 to t0 + T is s.

Then s = v0 t + ½ a1 t² + ½ (T - t) (v0 + a1 t)
and (T - t) a2 = - (v0 + a1 t)

Since a1 > 0 and a2 < 0, |a1| + |a2| is a1 - a2 = (a1 T + v0) / (T - t).
Rearrange the expression for s to get a1 as a function of t - if I’m not mistaken it’s a1 = (2 s - 3 v0 t + T) / (Tt).
Substitute in: the expression you want to minimise is now (2 s - 2 v0 t + T) / (Tt - t²)
Differentiate with respect to t and set equal to zero and you should have a quadratic in t to solve.

Is the absence of response an indication that the problem is solved or that you didn’t notice my last post?

I didn’t notice your last post. The forums “show unread posts” is notoriously broken… thanks for the input. I’ll try it on the weekand and will give some feedback.

If I’ve read those graphs correctly, in the second diagram attached the final velocity is not zero. It is equal to the starting velocity of the next segment. Also, A1 > 0 is not necessarily true, since he’s shown it moving downward as well =(

As it’s described there is an infinite number of solutions. Some extra constraints, like t = T/2 (make the acceleration and deceleration times the same) might help, but depending on the number of segments may still have no unique solution.

As it stands I’d get all the constraints together and find the least squares solution: en.wikipedia.org/wiki/Least_squares

Edit: Just re-read the first post and noticed that you want min(|ac|+|dc|). Least squares isn’t right here… this is a linear programming problem.

I just did this the other day, actually, and needed to spend 20 minutes figuring it out with pencil and paper. :stuck_out_tongue:

However, my case was a little simpler so I just used a summation to find it.

d = v + v-a + v-2a + v-3a + v-4a …

Basically because you’re decelerating by a every time then each timestep you velocity will be a multiple of a smaller. That ends up simplifying to
d = nv - s(n-1)*a

Where s(n-1) is the summation (sigma) from n-1 to 1. Then I could easily solve for the deceleration knowing the distance I wanted, or I could also solve for a depending upon how long I wanted to take to stop by knowing that v = d/t.

Yeah, that’s the discrete (sampled) version of the formula pjt33 posted earlier: s = ut + (1/2)*at^2

The summation s(n-1) can be simplified to n(n-1)/2, and then the relation between the two equations becomes more obvious.

Yes, indeed. That’s why I said “Looking at the maths in the post…”, which say “v(T)=0” and are inconsistent with the diagram.

The final velocity after T is 0, but only in case there are no more updates til t = T is reached. Otherwise I would take the current velocity as v0 and restart the calculation. I still had no time to have another shot on this, but I will post with the results of the various strategies in this thread, if I get at it again.

Ah, sorry if I took that out of context.

So the second diagram doesn’t show a sequence of locations that were known ahead of time… it’s showing the results of a sequence of moves where v(T) was expected to be 0, but were often interrupted by the next move. If that’s the case - where you just have to solve it one move at a time - then it looks like pjt33 has pretty much got that sorted.

I get the feeling that even when v(0) > 0 the min(|A1|+|A2|) is when A1 = -A2. If so, the equation will simplify a lot.

Hm, so what about an equation to compute acceleration needed to go from one velocity to another in a given distance? It seems like you should be able to use the above but I’m having trouble solving for it.

Basically, at t(0) the object has v(0), and after going d it has v(f). Those 4 values are known, but I need to know an a that can get me there. I guess it’s all a matter of simplifying v to d/t and a to d/t^2 but I’m still having trouble. Any help?

V=V0+t*A

knowing V,V0 and t maybe something like that ?

A=(V-V0)/t

EDIT:

forget. I miss something in reading … :slight_smile:

EDIT2:

not sure you can solve it for a distance and a time at the same time, cause acceleration give the velocity and is not related to distance, if you compute acceleration based on distance as an input you will need to use V0 , and so you can compute for a given distance and time but also a given initial velocity:

A=(2*(d-V0*t))/t²

or

A=(V-V0)/t

Hm I don’t think V = V0 + tA is correct. It should be V = V0 + A + V0 + 2A + V0 + 3A … v0 + tA which simplifies to V = tV0 + ((t * (t+1))/2) * A .

Even so that doesn’t really help, because d is nowhere in this equation.

Like say I have the following values:
v(0) = 10 m/s
v(f) = 2 m/s
d = 51 m

When we are at t(0), our position is 0. When we are at t(f), our position is 100. Because I had this pre-calculated, you can see that with an acceleration of -1 m/s we end up at v(f) when we reach d. Time is nowhere in the equation - we don’t care how long it takes.

v(0) = 10
d(0) = 0

v(1) = 10
d(1) = 9

v(2) = 8
d(2) = 19

v(3) = 7
d(3) = 27

v(4) = 6
d(4) = 33

v(5) = 5
d(5) = 39

v(6) = 4
d(6) = 44

v(7) = 3
d(7) = 48

v(8) = 2
d(8) = 51

Maybe someone else can see some pattern in that? It’s easy to figure out d or t, but not a when given a d - at least I’m having trouble with it.

Yeah, that’s as far as I got but I don’t want to use time as an input, instead I want to replace that input with V(f). But naturally to find how long it takes to get from V(0) to V(f) I need to know A in the first place. :stuck_out_tongue:

So I don’t think I can use this equation.

[quote]Hm I don’t think V = V0 + tA is correct. It should be V = V0 + A + V0 + 2A + V0 + 3A … v0 + tA which simplifies to V = tV0 + ((t * (t+1))/2) * A .
[/quote]
V=V0 + t*A

this is ok, why not ? this is just derivated by t => instant velocity

EDIT :

this one may work ??? …

A=-0.5*(V0-V)*(V+V0)/D

Thinking about it, I guess I do need t, because you could decelerate very very slowly to get to a certain point, or very very quickly. Like the above example I have you could increase the time if you wanted to just decelerate half as quickly. So I guess once I know that all that’s really missing is the final velocity I want, which I suppose I can probably figure out the place for. The equation above really calculates the value to bring the from 0 to the passed amount, no?

I think yes, if you want V=50 unit/s and D=215 unit and V0=10 unit/s :

A=-0.5*(V0-V)*(V+V0)/D

A=5.58

t is :

A=(V-V0)/t
t=(V-V0)/A
t=7.16

the solution is at t=7.16

Verification :

D at t=7.16 :

(D0 is removed because it is a constant/offset)

D=V0t+0.5A
D=10
7.16+0.55.587.16²
D= 72+143
D=215

and V at t=7.16 :

V=V0+tA
V=10
+7.16*5.68
V=50

good that’s all right !