#### Archived

This topic is now archived and is closed to further replies.

# Suspension/spring damping

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

## Recommended Posts

Hello all.. I''ve made some basic rigid body thing and trying to add some simple spring system to it to simulate wheel suspensions. The spring force is calculated something like this: force=(current_wheel_position - resting_wheel_position)*constant The current_position is where the wheel is after collision is perfomed, resting_position is where the wheel "wants to be". Then this force is added to the rigid body at the suspension point. Its working fairly ok, the problem is that it seldom stops to "wobble", the suspension keeps the rigid body oscillating all the time. So I think I need to damp the spring force somehow... How do I do that?

##### Share on other sites
hi,
I''m doing exactly the same...without much success, I''m afriad.
To add damping, you can use the following equation:
L - spring vector
l - length of the spring (scalar)
ks - spring constant
kd - damping constant
v1,v2 - velocities of spring''s ends
r - rest length of the spring

F = -{ks(l-r) + kd[(v1-v2)*L]/l}*L/l;
F - force acting on one verticle, -F - on another

But in my case, it''s still the same problem, it either jumps all the time or sticks to the floor

I also did collision response, maybe it wasn''t necessary.

btw, have you got demo of yur program?

##### Share on other sites
Oh!.. Did some searching now.. found your thread. And other similar threads. Seems sort of the same problem.

I see, I need to keep track of the velocity of the wheel, in respect to the spring vector/suspension axe. The greater movement/velocity in the spring system the greater dampening?..

Sounds logical, wonder if it is.

Well, gonna try it later today, at work now. If it looks ok, I''ll put out some demo example.

##### Share on other sites
I need to do the same thing soon too.
I did it once earlier but my project was destroyed due to hd crash. Now I'm back doing car physics and currently I'm working on rigid body system (using Hecker's tutorial).

quote:
Original post by AndersO The greater movement/velocity in the spring system the greater dampening?..

Basically yes, I think.

But it's very tricky. My car is jumping all the time, and get sudden impulses that makes it roll

[edited by - stefu on August 15, 2002 12:06:37 PM]

##### Share on other sites
Yep, that''s basically right. You need to divide the forces that take the wheel back to it''s original position in two. To a force affecting parallel to springs direction, and forces affecting to any other direction. You always offset the position of the wheel with these two velocities. The force that is non-parallel to the spring is always applied only once and as a whole right after calculating it. The other force (parallel to spring) is stored and kept track of (and also applied on each cycle). This force could then be something that takes the wheel to normal distance from car in for example 10 cycles.. It''s also then easy to add modifiers to this force, and you would implement dampening by multiplying this force vector with some dampening factor (like 0.5f, or something) on each cycle, causing the force to diminish over time.

##### Share on other sites
interesting... I use only forces acting along the spring and handle friction separately.
btw, how do you handle friction?

That''s what I do:
when I have contact with ground, I calculate friction force:

a - acceleration towards ground
tang - collision tangent, calculated like n^(n^Velocity)
mass - car mass

contact force = a * mass/(number of springs collided)
friction force = contact force*mu * tang

since there''s no use to apply it to spring''s end,
I apply force and moment directly to car

what do you do?

##### Share on other sites
I''ve been working on a spring system for a bit (although mine is a radial spring, not a linear spring). The dampening equation I''m using is just:

Force = Force - (Force * Dampening)

What I''m not sure exactly how things work in the physical world (which I will need to work out if I''m going to get my simulation going too. ack), but you could also try squaring the force:

Force = Force - (Force^2 * Dampening)

This will mean that a larger force will be dampened more than a smaller force. Which will probably help a spring settle down a bit.

There is an article at Gamasutra (Exploring Spring Models) which might help.

Trying is the first step towards failure.

##### Share on other sites
quote:
Original post by aash29
interesting... I use only forces acting along the spring and handle friction separately.
btw, how do you handle friction?

That''s what I do:
when I have contact with ground, I calculate friction force:

a - acceleration towards ground
tang - collision tangent, calculated like n^(n^Velocity)
mass - car mass

contact force = a * mass/(number of springs collided)
friction force = contact force*mu * tang

since there''s no use to apply it to spring''s end,
I apply force and moment directly to car

what do you do?

I divide velocity again to two parts. One that''s parallel to the normal of the ground, and other that''s parallel to the ground. I then multiply the vector that''s parallel to ground by a friction value (that can vary depending of the ground material), leaving the result as a new velocity.

Friction value range is of course 0 - 1.

##### Share on other sites
So you''ve got friction depending on velocity? I always thought it depends on acceleration, does it work well?

##### Share on other sites
quote:
Original post by aash29
So you''ve got friction depending on velocity? I always thought it depends on acceleration, does it work well?

Yeah. If you make it depend of acceleration, then the object doesn''t receive any friction when going at constant speed.

##### Share on other sites
Well, as along as body always has acceleration towards earth (g), it doesn''t

I meant it does

##### Share on other sites
http://www.racer.nl/links.htm - many useful links on subj. pity I missed it earlier

##### Share on other sites
Well, ain't got it working yet...

Doing something silly like this now:

force=(current_wheel_position - resting_wheel_position)*constant
force-=dampforce*dampconstant;
dampforce+=force*time;

And the suspension comes to rest after a while but it also makes the whole "chassi"/carbody to sink down to the ground after a while..

Its like the dampforce is making the suspension to weak.

[typos]

[edited by - AndersO on August 23, 2002 4:20:42 PM]

##### Share on other sites
Doh..

dampforce=force*time;

works better.. But its behaving a bit "nervous".. Going to do some number tweaking and see what happens.

##### Share on other sites
Hi!

This is from my current car physics:

// T is current spring pos, range [0...m_len]       	float f = T / t.m_susp.m_len;// now f is current spring pos in range [0...1]float force = (1-f)*t.m_susp.m_force[0] + (f)*t.m_susp.m_force[1];// now force is the spring force// t.m_susp.m_force[0] is the force when spring fulle compressed (for example 3000N)// t.m_susp.m_force[1] is the force when spring released (=0)float old_len = t.m_susp.m_cur_len;t.m_susp.m_cur_len = T;float dlt = t.m_susp.m_cur_len - old_len;// now dlt is spring movement from previous framefloat vel = dlt / m_delta_time;// velocity is spring change speed [m/s]// now apply damping forceforce -= vel * t.m_susp.m_damp_force;// t.m_susp.m_damp_force [N/(m/s)] for example 2000if( force<0 ) force=0; // spring force can''t force car downwards// apply force       	addForce(t.m_pos,t.m_up*force);// t.m_pos is tyre position where forces are applied// t.m_up is tyre up vector

##### Share on other sites
quote:
dampforce=force*time;

Adding a constant force to the spring will only shift the eqilibrium and maxima/minima points. All other aspects of the spring will remain constant.

Damping is usually related to velocity.
try: dampforce = k * |springvel|

##### Share on other sites

"Damping is usually related to velocity.
try: dampforce = k * |springvel|"

Yea.. I think its that I''m doing.. Only I''m using the constant before.

force-=dampforce*dampconstant
dampforce=force*time

A force multiplicated with time becomes.. A velocity.

##### Share on other sites
quote:
A force multiplicated with time becomes.. A velocity.

Almost, but not quite true. Acceleration times time is velocity. And, for constant mass, F = m * a. So, there is another factor in there, being the mass at the end of the spring (could be approximated by 1/4 the mass of the vehicle in this case).

But, by springvel, I mean the current velocity of one end of the spring relative to the other. Your calculated force*time [*mass] is a velocity, but from the standpoint of springvel, it is really the change in springvel since the last timestep (using Euler integration). This needs to be integrated to find the current springvel.

##### Share on other sites
quote:
Original post by aash29
btw, have you got demo of yur program?

Hi!!!
I put together a very simple car physics demo in case anyone is interested to test
Althought this is mainly physics demo, I''d like to know fps (found in stdout.txt after exit) just for interest and CPU+GPU info. I get 27 fps Celeron600+Voodoo3
It''d be nice to see other demos too.
I use here the physics I posted above.

##### Share on other sites
Nice little demo you got there stefu!

I got : 5156 frames in 69.04 seconds = 74.7 FPS

Running AMD 1900+ XP, GeForce3 Ti500 and 512MB PC2100 DDR

##### Share on other sites
cool
I''ve got 99.1 FPS on P-IV-1600, GeForce4mx
which weight and spring/damping constants did you use?

##### Share on other sites
Hi!!!
thanks for results.
quote:
Original post by aash29
which weight and spring/damping constants did you use?

In the demo: car mass = 600kg, spring force when fully compressed = 5000N and damping factor = 3000N/(m/s). Later I''ll put these values to load from ini-file.
I use physics based on Hecker''s rigid body tutorial. Collisions are currently too bouncy because of too big CoefficientOfRestitution value.

My goal here is to create (and finish this time!) a little multiplayer rallying game. Small terrain area, short tracks, more laps, fun racing.
I think that I''m not going to have any lod terrain (too much work for one person) and use brute force instead or lower overall detail for not hw TnL like Voodoo3.

##### Share on other sites
quote:
Original post by stefu
I think that I''m not going to have any lod terrain (too much work for one person) and use brute force instead or lower overall detail for not hw TnL like Voodoo3.

You should implement a quadtree for the terrain if you are using a regular grid for the terrain height etc. It''s not a lot of work, and you could have it done in a day or two. and maybe a day more to get it working with your current car/land collision detection.

Your frame rate will increase, and you can expand the landscape loads and not have to worry about falling frame rates.

You really should implement it.

##### Share on other sites
quote:
Original post by Hybrid
You should implement a quadtree for the terrain if you are using a regular grid for the terrain height etc. It''s not a lot of work, and you could have it done in a day or two. and maybe a day more to get it working with your current car/land collision detection.

Your frame rate will increase, and you can expand the landscape loads and not have to worry about falling frame rates.

You really should implement it.

Yeah, it''s good idea. Currently I use terrain size of 256x256 tiles in in 16x16 tile groups. I use frustum culling to check if each terrain cube is visible, but not quadtree.

For terrain collisions I don''t really need any quadtree since I get the colliding tile from coordinate directly.

But quadtree could be handy for other objects (collision and view culling).