[ODE] Fail to make a proper car's orientation via adding torque to its chassis

Dmitry Medvedev pegasi at inbox.ru
Tue Jul 31 01:21:51 MST 2007


 Hello, everybody.

 I have a simple floating in vacuum car( just a chassis, no wheels) and orthogonal view on the XY-plane. The steering force move the car in the goal point in XY-plane (chassis->addForce() is used). I know that it is unwise to directly set car's orientation via setRotation(), so I am trying to use addTorque() instead with no success like the following:
  T = I * dw/dt = I * (w2 - w1) / dt
  w2 = (theta2 - theta1) / dt
  theta2 = atan2f(mHeading.y, mHeading.x);
  theta2 = atan2f(mOldHeading.y, mOldHeading.x);  
 
T - torque (0, 0, Tz) as rotation take place in XY- plane only.
I - XY inertia component, is found from ODE like mChassis->getInertiaMatrix()[2*4 + 2]
w1, w2 - angular velocities in i-1 and i steps accordingly
theta1, theta2 - car's heading angles in i-1 and i steps accordingly 
mHeading = normalised(linearVelocity()) - vector2D
 
So, the aim is to find the amount of torque to add every time step to turn a car, so its orientation match new linear velocity direction. What could be wrong here or is any better approach to set car's orientation with addTorque() else?

 Thank you.

 In practice my car sometimes turn in wrong direction. 


More information about the ODE mailing list