"Bottoming out"

sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

"Bottoming out"

Post by sparkprime »

I've had lots of success with raycast suspension. I have a nice critically damped system that can withstand lots of abuse and drives realistically. I have a friction model and everything. But there is one thing I have yet to solve.

Currently I apply a force in the direction of the ground normal (Incidently, I have to normalise the ground normal. Is that a bug?) at the contact point, whose magnitude is derived from the amount of compression of the suspension spring (and some damping). However if you go round a corner too fast or hit a bump, it is possible to push the spring further than it is meant to go.

If one casts a ray from the top of the suspension, this could result in the ray start position being below the ground. This is fixable by shooting the ray from a bit further back and compensating for this extra distance when calculating the extension.

However even if I do know that the suspension is at its limit, I do not know how much force to apply. The rules have changed since when car suspension bottoms out, its behaviour should be that of a rigid system, not a spring. Hooke's law should not be used.

The problem is really that I need Bullet to kick in and do its usual thing here, but there is no rigid body and no contact point because I'm using raycast suspension and the chassis of the car is effectively hovering above the ground.

So what do I do? Should I work out some impulse and apply that? I've tried a bunch of hacky things like a constant amount of impulse or clamping the magnitude of the impulse at the maximum compression of the spring but it didn't work very well. Should I try and reuse bullet's collision detection functionality? Can I add a constraint to simulate a contact point?

The car body is a gimpact triangle mesh shape with wheel arches but no obviously no wheels.
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: "Bottoming out"

Post by ola »

In my vehicle model I had a similar problem. I also use raycasts to model wheels and suspension.

For the bottoming out part, I added a small cylinder shape for each wheel, like the wheel hub, if you like, in the bottomed out position. The cylinders were added to the car rigid body collision shape which is a compound shape. This way bullet takes over once we hit the ground too hard. I don't know how realistic it really is but for my application it was enough :-)

One more thing, it's useful to have the raycast configured to not report hits against the car.

Hope that helps you a bit further!

Best regards,
Ola
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: "Bottoming out"

Post by sparkprime »

I considered adding a wheel but the problem there was that it would also have friction which would interfere with my tyre friction model. Is it possible to set friction to 0 for a subpart of a compound object? If so this would seem like the easiest solution. One final problem though is that it is possible for the car to impact the ground so hard that the wheels go right through and you end up with it jammed with the wheels below the ground and the car body above the ground. Maybe if the wheels are up in the wheel arches then this would be less likely to occur. In my initial experiments I had a big bus which was a box and 4 cylinders for wheels in the bottomed out position but it kept getting jammed in the landscape.

About the raycast hitting the car -- yeah it is easy to filter out these results but for some collision shapes (e.g. box) it wasn't necessary because if you shoot from inside the box, you escape without hitting the box it seems. Of course if you add a wheel then it will hit the wheel :) Also with gimpact you cannot shoot a ray from inside to outside without it hitting the mesh shell so you need to filter the result then, or just shoot the ray from just below the car body (rather than inside it).

Thanks for your experience
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: "Bottoming out"

Post by ola »

Hey, individual friction settings within the compound shape is a good idea. I'll look into that, maybe it can be done by creating some custom friction model and compound shape. I'll look into it :-)

I made sure that the cylinders didn't go down below the car chassis, and haven't had any tunneling problems yet, even though most of my vehicles have the wheels out in the open. But I guess it also has to do with the environment you are driving around in, and at what speeds. Maybe you can use the continuous collision detection feature that was introduced not too long ago? Haven't looked into that myself.

Best regards,
Ola
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: "Bottoming out"

Post by sparkprime »

Maybe the subpart parameter of the contact added callback is the way to do custom friction for compound objects. I'm not sure how it works if you have a nesting of compound shapes though, or a triangle mesh inside a compound object.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: "Bottoming out"

Post by Erwin Coumans »

The car body is a gimpact triangle mesh shape
Avoid using gimpact when you can, and use a btCompoundShape with convex parts. Also, make sure this extra cylinder is smaller than the actual wheel, so it doesn't hit the ground during normal driving. Then you don't need to worry about its friction.
sparkprime wrote:Maybe the subpart parameter of the contact added callback is the way to do custom friction for compound objects. I'm not sure how it works if you have a nesting of compound shapes though, or a triangle mesh inside a compound object.
Yes, using the subpart is one way to customize friction. In such case, avoid using nested compounds and compounds with triangle mesh children.

Hope this helps,
Erwin
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: "Bottoming out"

Post by sparkprime »

Erwin Coumans wrote: Avoid using gimpact when you can, and use a btCompoundShape with convex parts. Also, make sure this extra cylinder is smaller than the actual wheel, so it doesn't hit the ground during normal driving. Then you don't need to worry about its friction.
Is btCompoundShape filled with compound hulls preferred over the gimpact convex decomposition shape?

I was intending to fix the wheel right at the top of the suspension, as I don't think I can move it around and still share btCompoundShape instances? I'm not 100% sure how serious the extra friction (when bottoming out) would be, and
sparkprime wrote:Maybe the subpart parameter of the contact added callback is the way to do custom friction for compound objects. I'm not sure how it works if you have a nesting of compound shapes though, or a triangle mesh inside a compound object.
In such case, avoid using nested compounds and compounds with triangle mesh children.
Hmm can I walk my way up the tree manually, in the callback?

I was thinking of trying primitive shapes inside the gimpact mesh in order to help stop tunneling (i.e. put some spheres inside at carefully chosen places to help penetrations get bounced out again). Is this a bad idea?