2d car with simple suspension physics

Started by
10 comments, last by Cachinnus 12 years, 9 months ago

So if I understand you correct, I should not add a collision force/impulse to keep the car from the ground. Rather, I should just compress the spring. Next, this will result in the two masses connected to the spring each getting a force directed from each other, which should be equal in magnitude.

Strictly speaking "you" don't do anything explicitly in your code to compress the spring. The motion of the bodies should do this automagically.


Hmm, or perhaps not? The spring can store potential energy (like gravity) so it doesn't completely obey newton's third law. At least on some level of abstraction, if I understand it correct.
[/quote]
You should be worrying about "the equal and opposite" on a per joint basis.
IE: Wheel pushes on spring with 10N. Spring pushes on wheel with 10N.
Will you get 10N out the other side of the spring? Probably, but not always. What happens if you want to model your spring as having some mass?

You might want to look into the basics of drawing "free-body-diagrams". This might help you understand how forces interact between components.


The wheel will get the most acceleration because it is the lightest of the two bodies, so it will probably collide again. I suspect this will result in jittery motion. Maybe I should do the same calculations several times each frame to reduce this?
[/quote]
This is true of about any spring simulation. Doubly true where you have a maintained collision (resting contact). I would suggest using RK4 integration with a suitably small timestep, and using a damper (shock absorber to us 'mericans) along with your spring. Maybe someone can come along and make suggestions on how to make the collision response more robust.


With the springs having only one freedom of movement, the spring length will in some cases have to become infinitely long to get out of the ground. That is when the car is colliding with a surface perpendicular to the spring axis. What is the best way to deal with this? I am thinking in the lines of having an angular spring as well.
[/quote]
Springs don't work perpendicularly. You need another constraint to handle this. IE: Model a linkage that actually holds your wheel to the car, and then let the spring just worry about springynes. So when your wheel runs into this perpendicular surface, then load goes into this new constraint (and then into the body of the car, probably stopping it abruptly). The spring likely never deflects.


When compressing the spring, this will add energy to it. And since this energy is not based on the mechanical energy of the car, isn't there a danger for unstable and somewhat random motions? Proposed solution: Take the desired absorbed energy of the car, and use the spring constant to calculate the distance based on this energy. Artificially move rest of the car out of the collision area.
[/quote]
You put energy into your car to move it in the first place. Or it had some, as a byproduct of elevation. The spring is just storing some of this temporarily, and will give it back (minus any absorbed by the dampers) to the car body when it extends to original length.

In my opinion you are trying to over think this a bit. Model your components so that they behave individually. Now model constraints to glue them together. The details should sus themselves out.
Advertisement
Thanks for the answer, it's been very helpful.

This topic is closed to new replies.

Advertisement