Vehicle rolls too much, could you help me ?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
zeralph
Posts: 3
Joined: Tue May 19, 2009 8:26 pm

Vehicle rolls too much, could you help me ?

Post by zeralph »

Hi everybody.
First, congratulations for the very good work made with BepuPhysics. This is really impressive and usefull.
Let me introduce myself. I'm a videogame programmer, but as far as I use to work on DS or PSP, I'm quit a noob about physics...
For the fun I thought about creating a little engine with Xna, and decided to use Bepu. My fisrt goal is to create a little tank game, but I'm quite disappointed with Vehicle class.
I have a rought terrain on which I try to move a tank with 4 spheres as wheels. I tried many setups, but my tank never stops rolling a lot. So I decided to copy the VehicleInput of the demo program to test it. I'm quite disappointed cos it rolls a lot too ! My terrain is setuped as the one in the demo, bepuspace too.
I tested increasing the upright constraint, the tank mass, lowering the multiplication values of the inertia matrix, playing with the suspensions, offseting the gravity center of the vehicle's body really really low, but the tank always roll a lot. I'd like to have a fast vehicle (aroung 20~25) but heavy and "glued" to the ground.
Could you help me finding where my problem is ?
I posted a picture to help understanding the whole thing. The vehicle physic body is the same as the vehicleInput, as the wheels (even if here, they are drawed as spheres).

Image

Thank you very much for your help.
Zeralph
User avatar
Zukarakox
Not a Site Admin
Posts: 426
Joined: Mon Jul 10, 2006 4:28 am

Re: Vehicle rolls too much, could you help me ?

Post by Zukarakox »

Apparently Norbo disappeared, sorry for the long wait.

I'm not terribly familiar with the vehicle class, but try increasing the friction coefficient of the wheels to something fairly high (1 or higher) and make sure the ground has friction. (~1)

If that doesn't work, make the mass of the tank higher and the vector for gravity decently high. If you don't want to edit the gravity for the entire game, add a downward force.
i has multiple toes
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle rolls too much, could you help me ?

Post by Norbo »

Sorry, the router burned out and it took a few days to get it replaced :D

Starting with an unmodified VehicleInput, pretty much all of the vehicle's rolling tendencies were removed by only modifying the mass offset like so:

Code: Select all

vehicle.body.centerOfMassOffset = new Vector3(0, -1, 0);
Keeping everything else the same as the VehicleInput except for the above, does your car behave better?

In further testing, I also got a 'heavier' feel to the vehicle by reducing the suspension spring constant and boosting the damping (constant of 22, damping of .95f).
zeralph
Posts: 3
Joined: Tue May 19, 2009 8:26 pm

Re: Vehicle rolls too much, could you help me ?

Post by zeralph »

Hello !
Thank you for your answers. Don't be worry about the time, I don't have much to spend on my project yet, so I'm not in a hurry !.
So I tried all your stuff. I had better results, but there is always a time, when things are getting high (high speed or little abrupt terrain) where everything goes wrong. It is almost like if, in a turn, the "outside" wheels were suddently stuck, and the tank to start rising.
I have noticed two or three things that I could miss :
- the boucness or the wieght of the wheels : do they affect the simulation ?
- I think I use suspensions out of there limits : when I try to make them harder by increasing maxSuspension and damp, my vehicle does not want to run anymore, I must increase the acceleration force. Is that normal ?
- My wheel really often goes through the ground, even with a collisionMargin of 0.f for both them and the terrain.

I don't have much time now, but I will prospect to see really were I missed the stuff, I really start thinking I copied something badly.

Thank you again for your attention !
Lucas
zeralph
Posts: 3
Joined: Tue May 19, 2009 8:26 pm

Re: Vehicle rolls too much, could you help me ?

Post by zeralph »

Okaaay, I restarted from scratch and now it's quite good. No roll anymore !
But ....
I'd like to have a sphere for the body, in the middle of the wheels (each at the same (little) distance from the body). It seems this configuration makes things ... crazy.

I'm gonna prospect more.

Thank you, I will send you my results.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Vehicle rolls too much, could you help me ?

Post by Norbo »

To answer some of the first questions:
-The wheel shapes are only used for swept collision detection; properties like mass/bounciness are not taken into account.
-The maximum suspension force has no hard upper limit, but the damping should stay below 1. A value of 1 for damping will attempt to stop all motion.
-What was the shape of the wheel like when it went through the ground and how large were the triangles? Large size ratios (on the order of 1:100) between objects can cause problems for collision detection.


A different body shape will have a different inertia tensor which will cause everything to behave differently. Concentrating most of the mass into a smaller sphere could have strange results, especially depending on where the wheels are placed. One trick you can use is to pick your own inertia tensor. If the previous box-like car seemed to work, you can create that entity, grab its local space inertia tensor, and set the new body's local space inertia tensor to it. This might not address the whole problem, but it should help.
Post Reply