I noticed that the resulting steering-angles of the ackermann-function are switched. The following code shows the corresponding part in the PxVehicleUpdate.cpp (Line 1779 - 1799)
PX_ASSERT(steer>=-1.01f && steer<=1.01f);
PX_ASSERT(steerGain<PxPi);
const PxF32 steerAngle=steer*steerGain;
if(0==steerAngle)
{
*leftAckermannSteerAngle=0;
*rightAckermannSteerAngle=0;
return;
}
//Work out the ackermann steer for +ve steer then swap and negate the steer angles if the steer is -ve.
//TODO: use faster approximate functions for PxTan/PxATan because the results don't need to be too accurate here.
const PxF32 rightSteerAngle=PxAbs(steerAngle);
const PxF32 dz=axleSeparation;
const PxF32 dx=width + dz/PxTan(rightSteerAngle);
const PxF32 leftSteerAnglePerfect=PxAtan(dz/dx);
const PxF32 leftSteerAngle=rightSteerAngle + ackermannAccuracy*(leftSteerAnglePerfect-rightSteerAngle);
*rightAckermannSteerAngle=physx::intrinsics::fsel(steerAngle, rightSteerAngle, -leftSteerAngle);
*leftAckermannSteerAngle=physx::intrinsics::fsel(steerAngle, leftSteerAngle, -rightSteerAngle);
In case of a positive steeering-input (steering to the left) the rightSteerAngle results in a greater angle than the leftSteerAngle. The opposite should be the case. Same is true for negative incoming steering-values.
I was able to fix the issue by changing the lines 1793-1797 like this, to keep the calculation comprehensible:
const PxF32 leftSteerAngle=PxAbs(steerAngle);
const PxF32 dz=axleSeparation;
const PxF32 dx=width + dz/PxTan(leftSteerAngle);
const PxF32 rightSteerAnglePerfect=PxAtan(dz/dx);
const PxF32 rightSteerAngle=leftSteerAngle + ackermannAccuracy*(rightSteerAnglePerfect-leftSteerAngle);
In the vehicle-sample and the vehicle-snippet, this is countered by negating the x-coordinate of the wheels position, so the left wheel is on the negative x-axis side and the right wheel is on the positive side. But in a right-handed coordination (like the rest is) with up-vector is the y-axis and forward equals the z-axis (like I have it configured for the vehicle-simulation), the left wheel should be on the positive x-axis-side.
Can someone else confirm this behaviour or did I miss something else?