How to calculate deceleration needed to reach a certain speed over a certain distance?
Asked Answered
S

6

9

I've tried the typical physics equations for this but none of them really work because the equations deal with constant acceleration and mine will need to change to work correctly. Basically I have a car that can be going at a large range of speeds and needs to slow down and stop over a given distance and time as it reaches the end of its path.

So, I have:
V0, or the current speed
Vf, or the speed I want to reach (typically 0)
t, or the amount of time I want to take to reach the end of my path
d, or the distance I want to go as I change from V0 to Vf

I want to calculate
a, or the acceleration needed to go from V0 to Vf

The reason this becomes a programming-specific question is because a needs to be recalculated every single timestep as the car keeps stopping. So, V0 constantly is changed to be V0 from last timestep plus the a that was calculated last timestep. So essentially it will start stopping slowly then will eventually stop more abruptly, sort of like a car in real life.

EDITS:
All right, thanks for the great responses. A lot of what I needed was just some help thinking about this. Let me be more specific now that I've got some more ideas from you all:

I have a car c that is 64 pixels from its destination, so d=64. It is driving at 2 pixels per timestep, where a timestep is 1/60 of a second. I want to find the acceleration a that will bring it to a speed of 0.2 pixels per timestep by the time it has traveled d.
d = 64 //distance
V0 = 2 //initial velocity (in ppt)
Vf = 0.2 //final velocity (in ppt)

Also because this happens in a game loop, a variable delta is passed through to each action, which is the multiple of 1/60s that the last timestep took. In other words, if it took 1/60s, then delta is 1.0, if it took 1/30s, then delta is 0.5. Before acceleration is actually applied, it is multiplied by this delta value. Similarly, before the car moves again its velocity is multiplied by the delta value. This is pretty standard stuff, but it might be what is causing problems with my calculations.

Selma answered 6/7, 2009 at 17:3 Comment(4)
Sorry, I think your understanding of physics is confused. F = ma tells you that a changing acceleration has to do with a changing force. A car doesn't stop "more abruptly" in real life unless you increase the braking force by stepping on the pedal harder.Leonardaleonardi
@duffymo: technically, you feel that jerk at the end of deceleration when things go from slow to stop, as dynamic friction gives way to static friction; static friction is larger than dynamic friction.Aun
...But if you want to get that detailed, you'll have to model the transmission and the springiness between road&tires and between tires & chassis.Aun
@Jason S: There is also the effect of the suspension springing back as the real deceleration drops to zero. Combined with the static friction bit this makes the experience of the passenger fairly complicated.Abram
M
10

Linear acceleration a for a distance d going from a starting speed Vi to a final speed Vf:

a = (Vf*Vf - Vi*Vi)/(2 * d)

EDIT:

After your edit, let me try and gauge what you need...

If you take this formula and insert your numbers, you get a constant acceleration of -0,0309375. Now, let's keep calling this result 'a'.

What you need between timestamps (frames?) is not actually the acceleration, but new location of the vehicle, right? So you use the following formula:

Sd = Vi * t + 0.5 * t * t * a

where Sd is the current distance from the start position at current frame/moment/sum_of_deltas, Vi is the starting speed, and t is the time since the start.

With this, your decceleration is constant, but even if it is linear, your speed will accomodate to your constraints.

If you want a non-linear decceleration, you could find some non-linear interpolation method, and interpolate not acceleration, but simply position between two points.

location = non_linear_function(time);
Moiramoirai answered 6/7, 2009 at 17:24 Comment(1)
Formula, as well as few typos fixed, additional idea added.Moiramoirai
O
6

The four constraints you give are one too many for a linear system (one with constant acceleration), where any three of the variables would suffice to compute the acceleration and thereby determine the fourth variables. However, the system is way under-specified for a completely general nonlinear system -- there may be uncountably infinite ways to change acceleration over time while satisfying all the constraints as given. Can you perhaps specify better along what kind of curve acceleration should change over time?

Using 0 index to mean "at the start", 1 to mean "at the end", and D for Delta to mean "variation", given a linearly changing acceleration

  a(t) = a0 + t * (a1-a0)/Dt

where a0 and a1 are the two parameters we want to compute to satisfy all the various constraints, I compute (if there's been no misstep, as I did it all by hand):

DV = Dt * (a0+a1)/2
Ds = Dt * (V0 + ((a1-a0)/6 + a0/2) * Dt)

Given DV, Dt and Ds are all given, this leaves 2 linear equations in the unknowns a0 and a1 so you can solve for these (but I'm leaving things in this form to make it easier to double check on my derivations!!!).

If you're applying the proper formulas at every step to compute changes in space and velocity, it should make no difference whether you compute a0 and a1 once and for all or recompute them at every step based on the remaining Dt, Ds and DV.

Ostrogoth answered 6/7, 2009 at 17:9 Comment(2)
You're right - I probably should be using a linear system. As long as it looks natural, I don't care much about the why or the how, so keeping it simpler will be better. When you propose it as a curve and I really think about it, needing a curve is unlikely in any case. I can't think of an exponential graph that would match what I'm looking for, but I can think of several linear ones. If I use a linear deceleration, do I need to calculate it only once (when t==0) or will it still work if I recalculate every time step?Selma
editing my answer to respond to these further questions in a well formatted wayOstrogoth
L
5

If you're trying to simulate a time-dependent acceleration in your equations, it just means that you should assume that. You have to integrate F = ma along with the acceleration equations, that's all. If acceleration isn't constant, you just have to solve a system of equations instead of just one.

So now it's really three vector equations that you have to integrate simultaneously: one for each component of displacement, velocity, and acceleration, or nine equations in total. The force as a function of time will be an input for your problem.

If you're assuming 1D motion you're down to three simultaneous equations. The ones for velocity and displacement are both pretty easy.

Leonardaleonardi answered 6/7, 2009 at 17:11 Comment(2)
Hey duffymo, thanks for the response. I was indeed referring to the way people typically drive - start with your foot on the brake slightly when you are far from the stop, then press it hard when you are about to reach it, causing a small "lurch" typically as the momentum of the car carries its weight forward. Force and mass are unimportant (I think) to my problem; I only care about acceleration as the change of velocity over time, m/s/s. You can assume every car has a mass of 1, so that the force is essentially just the velocity.Selma
"Force and mass are unimportant (I think) to my problem; I only care about acceleration as the change of velocity over time, m/s/s. You can assume every car has a mass of 1, so that the force is essentially just the velocity." - I disagree. You might be arguing that you want to take an empirical approach that isn't 100% faithful to the physics, but let's acknowledge it for what it is. Acceleration is ONLY one thing - the rate of change of velocity with respect to time, a first order tensor. There is no other definition.Leonardaleonardi
N
1

In real life, a car's stopping ability depends on the pressure on the brake pedal, any engine braking that's going on, surface conditions, and such: also, there's that "grab" at the end when the car really stops. Modeling that is complicated, and you're unlikely to find good answers on a programming website. Find some automotive engineers.

Aside from that, I don't know what you're asking for. Are you trying to determine a braking schedule? As in there's a certain amount of deceleration while coasting, and then applying the brake? In real driving, the time is not usually considered in these maneuvers, but rather the distance.

As far as I can tell, your problem is that you aren't asking for anything specific, which suggests that you really haven't figured out what you actually want. If you'd provide a sample use for this, we could probably help you. As it is, you've provided the bare bones of a problem that is either overdetermined or way underconstrained, and there's really nothing we can do with that.

Northing answered 6/7, 2009 at 17:28 Comment(1)
There are lots of levels of faithfulness that you can embed into a model. If a 1D constant acceleration is one extreme in the spectrum, yours seems a bit too far in the other direction (although not even close to the most complex). I think the non-physics, empirical approach is what s/he's looking for here.Leonardaleonardi
S
1

if you need to go from 10m/s to 0m/s in 1m with linear acceleration you need 2 equations. first find the time (t) it takes to stop.

v0 = initial velocity
vf = final velocity
x0 = initial displacement
xf = final displacement
a = constant linear acceleration

(xf-x0)=.5*(v0-vf)*t
t=2*(xf-x0)/(v0-vf)
t=2*(1m-0m)/(10m/s-0m/s)
t=.2seconds

next to calculate the linear acceleration between x0 & xf

(xf-x0)=(v0-vf)*t+.5*a*t^2
(1m-0m)=(10m/s-0m/s)*(.2s)+.5*a*((.2s)^2)
1m=(10m/s)*(.2s)+.5*a*(.04s^2)
1m=2m+a*(.02s^2)
-1m=a*(.02s^2)
a=-1m/(.02s^2)
a=-50m/s^2

in terms of gravity (g's)

a=(-50m/s^2)/(9.8m/s^2)
a=5.1g over the .2 seconds from 0m to 10m
Samsara answered 23/6, 2014 at 23:41 Comment(0)
A
0

Problem is either overconstrained or underconstrained (a is not constant? is there a maximum a?) or ambiguous.

Simplest formula would be a=(Vf-V0)/t

Edit: if time is not constrained, and distance s is constrained, and acceleration is constant, then the relevant formulae are s = (Vf+V0)/2 * t, t=(Vf-V0)/a which simplifies to a = (Vf2 - V02) / (2s).

Aun answered 6/7, 2009 at 17:10 Comment(3)
ooooookay. Please tell us the constraints that would help to determine acceleration, if not constant.Aun
F(t) = ma(t), where force and accelerations are both vector functions of time, of course.Leonardaleonardi
OP gave constraints on V0, Vf, d, t. If a is constant and V0, Vf, and t are independent variables, then a = (Vf-V0)/t. I don't care about the 2 point hit, but I do care about being downvoted w/o comment for making an honest effort towards an answer. Otherwise why spend the time trying to give answers on this site?Aun

© 2022 - 2024 — McMap. All rights reserved.