getWorldTransform returns NAN in Debug mode

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Droid999
Posts: 1
Joined: Wed May 09, 2018 12:26 pm

getWorldTransform returns NAN in Debug mode

Post by Droid999 »

Hi

When running my program in normal mode - everything works fine - I can control my camera, and world collision is spot on.

When running in Debug mode the same code generates a NAN for each element below:

Code: Select all

//------------------------------------------------------------
//
// Return position of the camera after physics world processed
glm::vec3 bul_returnCameraPosition()
//------------------------------------------------------------
{
	glm::vec3   tempPosition;

	btTransform trans;
	playerRigidBody->getMotionState()->getWorldTransform ( trans );

	tempPosition.x = trans.getOrigin().getX();
	tempPosition.y = trans.getOrigin().getY();
	tempPosition.z = trans.getOrigin().getZ();

	return tempPosition;
}
This causes an assertion failure in GLM as it is passed an invalid value to work with. 'tempPosition' above , when in Debug mode contains three NAN's.

I am using the latest compile version from Github ( as of yesterday ).

My camera starts off with the correct position in Release mode. It starts above the map floor, and gravity brings it down to land on the plane. Collision detection then keeps it on that plane - but only in Release mode.

My main loop looks like this:

Code: Select all

			// Return the direction vector and turn this into velocity for physics
			bul_setCameraVelocity(cam3_getVelocity());

			bul_processPhysics ( 60.0f );

			vel = bul_returnCameraPosition();	// this contains NAN in Debug mode
			
			cam3_Position = vel;
			
			cam3_CreateViewMatrix(cam3_Position);	// causing an error in GLM due to bad values
			
			
Any advice on how to fix this?

Thanks
JJWong
Posts: 3
Joined: Tue May 23, 2017 8:08 pm

Re: getWorldTransform returns NAN in Debug mode

Post by JJWong »

Oh I have heard of this before, I am too wondering
Mr.Rabbit
Posts: 1
Joined: Tue Jan 29, 2019 6:34 pm

Re: getWorldTransform returns NAN in Debug mode

Post by Mr.Rabbit »

I encountered the same bug, but in my case I get NAN in Release mode.

They are generated after stepSimulation().

If I disable compiler optimizations the nan disappears. Have you found the reason for this strange behaviour?

Edit: I stumbled upon this remark https://stackoverflow.com/questions/281 ... ausing-nan . I checked if my local inertia value were correctly setup. They weren't. After I changed it to ensure a default inertia value, the simulation step dosn't generate any NAN's anymore.
Post Reply