harrison-lucas / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

btRaycastVehicle: Wrong wheel rotation #714

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When steering angle is too big (>45 deg) wheels are rotating too slow (about 90 
deg) or into wrong direction (>90) 

I'm using Bullet 2.81-rev2613

I have found what this issue caused by wrong vector fwd calculation in 
btRaycastVehicle::updateVehicle() function in btRaycastVehicle.cpp

fwd vector calculated as chassis forward vector instead of wheel forward 
vector. This leads to incorrect speed projection values and results into wrong 
wheel.m_deltaRotation value.

I've solved it by:
// fwd vector from updateWheelTransform()
btVector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
const btVector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
btVector3 fwd = up.cross(right);
fwd = fwd.normalize();
// rotate fwd vector using steering angle
btQuaternion steeringOrn(up, wheel.m_steering);
fwd = btTransform(steeringOrn)*fwd;         

/*
const btTransform&  chassisWorldTransform = getChassisWorldTransform();
btVector3 fwd (
chassisWorldTransform.getBasis()[0][m_indexForwardAxis],
chassisWorldTransform.getBasis()[1][m_indexForwardAxis],
chassisWorldTransform.getBasis()[2][m_indexForwardAxis]);
*/

check full file version into attachment

Original issue reported on code.google.com by vleush...@gmail.com on 23 May 2013 at 9:13

Attachments:

GoogleCodeExporter commented 9 years ago
I made some vids:
bug: http://youtu.be/oL84TvrK6FM
fixed: http://youtu.be/53UCu_CvhAo

Original comment by vleush...@gmail.com on 23 May 2013 at 9:38

GoogleCodeExporter commented 9 years ago
See https://github.com/bulletphysics/bullet3/issues/91

Original comment by erwin.coumans on 30 Mar 2014 at 6:07