Ideas for a car braking system using a physics engine

Started by
3 comments, last by giovz481 10 months, 3 weeks ago

Hi all!

I'm developing a car racing game, with 2D physics, using the library Box2d. I'm trying to implement a realistic car brake. For this purpose I used a FrictionJoint between the wheel and its pivot point (which also works as a suspension). When I apply the brakes, this joint applies friction, which tends to equalize the rotation between the wheel and the pivot point (which cannot rotate, so the wheel tends to stop). That's the behavior I was expecting, but sometimes it shows like an oscillating behavior, mainly when the wheel is almost stopping. It kind of go forward and backward, oscillating, which is not a realistic behavior for a braking system. Anyone maybe have already had a similar problem? Or have an idea why this happens and how can I solve this? Or any different idea I can implement this brake system for an individual wheel, using joints or something like this? I said I'm using Box2d, but I think ideas used in other physics libraries can also help here. Thanks in advance!

Advertisement

It sounds like there might be some bad behavior of the Box2D constraint solver (overshoot/oscillation), which is surprising given its pedigree. Maybe you can try turning down the amount of friction and see if that helps? Another option if there is a “rigid” constraint in Box2D is that you could temporarily enable it while braking to keep relative motion of wheel and car to 0.

One thing that comes to mind is the possibility of tuning the friction parameters in Box2d. You could try adjusting the friction coefficient of the FrictionJoint to see if that helps stabilize the oscillations. Increasing the friction might provide more resistance and prevent the oscillating behavior. Another idea you can explore is using a different type of joint for the brake system. Have you considered implementing a RevoluteJoint or a WeldJoint instead? These joints can restrict rotation and might provide a more stable braking effect. Additionally, you could experiment with different damping settings for the joint to control the oscillations. Adjusting the angular damping could potentially help dampen any unwanted vibrations.

Thank you two for the answers! They are good ideias to explore, I'm gonna take them into account and make some tests here. I think box2d make some kind of controlling, as I set a “maximum friction torque” instead of the friction coefficient, and this attempt to control this torque cause this oscilllation. I will investigate this WeldJoint, and also see if I can control directly the FrictionJoint friction coef instead of the maximum friction torque parameter.

This topic is closed to new replies.

Advertisement