# Jitter at low velocities

This topic is 5136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, how's it going? I have a car physics system in place which works really well. All I need some help with is that at low velocities, say 1-5mph, the car jitters all over the place (the suspension rocks all over and the velocity is unstable). I know this is a common problem but I'm not sure what controls I need in place to fix it. Any help is greatly appreciated.

##### Share on other sites
There are two things that immediately come to mind.

First, if you are using simple Euler integration, the suspension springs will make your simulation unstable. Simple Euler is almost never a good idea. Try Verlet instead, or even 2nd or 4th order Runge-Kutta.

You can make Euler semi-work by adding damping into your system. Everywhere you have a spring, you should also have a damper that applies a force in the opposite direction of the car velocity along the direction of the spring. The damper force is:

F_damper = -c * V * (V/fabsf(V));

where c is a damping coefficient, and V is the relative motion of the car to the other end of the spring. For example, if we're talking about a spring at the front right wheel, assuming the wheel stays planted on the ground, the velocity of the car at the front-right corner will be equal to the upward or downward velocity of the front-right corner of the car. The damping force will be in the opposite direction, e.g., if the car front-right is moving down, the damping force will be acting upward on the car at that point.

Damping can help stabilize Euler (and other) integration, but time step will still need to be fairly small.

Second, if you are using a Coulomb friction model, be careful how you deal with the transition between dynamic and static friction.

##### Share on other sites
How do you handle tire forces?
If you use a slipRatio type model for longitudinal forces, the equation will start to become worthless at low speeds. If you solve that with a differential system then you may still need a damper constant to avoid oscillations of wheel velocity. Maybe that is jerking the car around?

##### Share on other sites
also damping forces may make things unstable if you use Euler. The best way is, as Graham said, to swich to RK4 or Verlet.

If you have high damping force proportional to velocity (not velocity squared), that is, damping_force=-velocity*k;
it may make things be unstable if mass is small.

In that case, use
next_frame_velocity=velocity*exp(-dt*k/m)+acceleration_due_to_other_forces*dt;

- it's more precise result of damping over certain timestep.

##### Share on other sites
Quote:
 Original post by Dmytryalso damping forces may make things unstable if you use Euler. The best way is, as Graham said, to swich to RK4 or Verlet.

Damping is actually required to stabilize simple Euler if there are spring forces (which there are for a suspension system). If you have damping, then Euler becomes conditionally stable, meaning it will be stable if your time step is small enough. But, for any given time step---no matter how small, if you increase damping sufficiently, simpler Euler will become unstable----requiring that you further reduce time step to stabilize it again.

Quote:
 Original post by DmytryAnd as about dampipng. If you have high damping force proportional to velocity (not velocity squared), that is, damping_force=-velocity*k; it may make things be unstable if mass is smallIn that case, usenext_frame_velocity=velocity*exp(-dt*k/m)+acceleration_due_to_other_forces*dt;- it's more precise result of damping over certain timestep.

Good point! That accounts to the deterioration of velocity of the duration of the time step, thus minimizing the chance of velocity reversal, which is physically wrong.

##### Share on other sites
Quote:
Original post by grhodes_at_work
Quote:
 Original post by Dmytryalso damping forces may make things unstable if you use Euler. The best way is, as Graham said, to swich to RK4 or Verlet.

Damping is actually required to stabilize simple Euler if there are spring forces (which there are for a suspension system). If you have damping, then Euler becomes conditionally stable, meaning it will be stable if your time step is small enough. But, for any given time step---no matter how small, if you increase damping sufficiently, simpler Euler will become unstable----requiring that you further reduce time step to stabilize it again.

The even more practically important thing, for sufficiently small mass Euler will be unstable.
Quote:

Quote:
 Original post by DmytryAnd as about dampipng. If you have high damping force proportional to velocity (not velocity squared), that is, damping_force=-velocity*k; it may make things be unstable if mass is smallIn that case, usenext_frame_velocity=velocity*exp(-dt*k/m)+acceleration_due_to_other_forces*dt;- it's more precise result of damping over certain timestep.

Good point! That accounts to the deterioration of velocity of the duration of the time step, thus minimizing the chance of velocity reversal, which is physically wrong.

Yes, and velocity reversal due to this exp alone is inpossible, exp(-dt*k/m) is always <1 , so it always works as damper.

It's especially important for -v2 drag. In that case, for any timestep, if object have sufficiently high velocity, it will do bad things.

In that case,
next_frame_velocity=velocity*exp(-dt*Length(velocity)*k/m)+acceleration_due_to_other_forces*dt;
gives alot better results, i.e. no matter how big velocity is, it will damp Euler well, for small dt it gives exactly same result.

If it's possible to analitically solve
dv/dt=-a*v2
that would be even better.

In summary, using analitical solution, or even anything that works *like* analitical solution for given timestep without assuming it's very small gives alot better results. By "works *like*" i mean produces same results with very small dt and produces results that makes some sense with big dt. For instance, clamping damping results so velocity can't be negated by damping is bit better than straightforward approach. And analitical solution, formule with exp, is even better.

Recently there was thread about buoyancy, i found semi-analitical solution to be _very_ stable (instead of calculating impact forces i just did pulse conservation, taking into account added mass of water, like it's inelastic collision).
It's good not only for Euler, but for other integration methods as well. (it's not very simple to do with RK4, but definitely possible with modified RK4 that allows to have analitical/semi-analitical solutions for some variables)

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011319
• ### Who's Online (See full list)

There are no registered users currently online

×