Custom VehicleRaycaster

cameni
Posts: 2
Joined: Tue Sep 08, 2009 8:31 am

Custom VehicleRaycaster

Post by cameni »

Hi,
I'd like to implement a custom vehicle raycaster, but looking at the btVehicleRaycasterResult, I'm wondering what is the m_distFraction member. Can someone shed some light at it?
Thanks
jrk
Posts: 17
Joined: Tue Aug 18, 2009 2:48 pm

Re: Custom VehicleRaycaster

Post by jrk »

It is meant to determine the compressed length of the suspension. So you cast a ray that goes from the top of the "strut" or connection point of the suspension down the length of the suspension plus the length of the tire and this member stores the percentage of that length prior to hitting the ground. So, for example you have a suspension with a max length of 1 and a tire with radius 0.5 your ray length will be 1.5. If m_distRaction = 0.9 than the ground is 0.9*1.5 from the top of the strut. You use that to determined the compressed length of the suspension and therefor your spring force.

The problem I ran into is friction. The simple vehicle uses "engine force" and applies a force to the chassis. A car applies torque to the wheels and slip dictates whether the car is propelled forward or your tires spin out ( really some combination of that) .

This problem is not solved by using contact bodies for tires as the friction model there does not seem to be adequate either (for this problem) and the User friction stuff has been depricated.

Anyway, maybe you will have more success, but the forum seems interested in this issue :(
cameni
Posts: 2
Joined: Tue Sep 08, 2009 8:31 am

Re: Custom VehicleRaycaster

Post by cameni »

Thanks for the reply, jrk.
Hmm. There's already a suspension rest length and wheel radius passed into addWheel function. I thought that the compression could be computed from that and from the distance to the contact point. But you say "suspension max length" whereas the addWheel wants a rest length. Is it so that in the rest that m_distFraction member contains value < 1? What I'm otherwise missing is some sort of spring stiffness coefficient that would relate to that, although there could be a better way to express it, possibly ...

As for the friction - I see that engine force can be applied to particular wheel, which I understand is actually applied to the chassis at the corresponding connection or wheel center point. Perhaps the force could be computed dynamically from the known forces and some external friction model that would convert torque to forward force. I'll try something when I get there.