How should I get the contact state of a BulletWheel?

I am using BulletVehicle for a motorcycle. When the bike wheelies or dives off a curb, one wheel loses contact with the ground, and it can easily spin out of control. I’d like to apply some kind of stabilization when the bike is in a wheelie/endo.

In the original Bullet library, there is a variable m_isInContact you can use to determine whether a wheel is touching an object. Is there a similar function in Panda? Or should I use a workaround?

This is in the wrong forum. Try “scripting issues”, “general discussion”, or “panda features in development” in the panda bullet thread.

No workaround so far. I simply missed the whole structure btWheelInfo::RaycastInfo. I will check in code which exposes this structure this evening. Thanks for pointing me at this property.

That’s great, thanks enn0x. Sorry about the mispost, I was checking out lightmaps ATM.

Ok, checked in code which exposes the raycast info.

Terrific, I was just about to check. Do you know if I need to recompile everything, or can I just wait for the next build, download the SDK again, and start writing Python?

Pick up the next snapshot build. On the download page for the Panda3D SDK it is the topmost entry, named “devel”.

Bringing this topic back from the grave for what appears to be a bug. I set up a simple scene with a vehicle, ground plane and an object to drive over. The vehicle correctly reports whether its wheels are in contact with an object via isInContact(), but crashes the program when I try to identify the mesh with getGroundObject().

This works:

		for wheel in bike.getWheels():
			if wheel.getRaycastInfo().isInContact():
				print 'bike on ground'

This doesn’t:

		for wheel in bike.getWheels():
			if wheel.getRaycastInfo().isInContact():
				print 'bike touching',wheel.getRaycastInfo().getGroundObject() 

The only information I get is:

Fatal Python error: (pygame parachute) Segmentation Fault
Aborted

In the worst case, I can always fudge it with raycasts, but this is a pretty slick feature. Any ideas?

If have been tracing this in the Bullet source code (btRaycastVehicle.cpp):

void* object = m_vehicleRaycaster->castRay(source,target,rayResults);
wheel.m_raycastInfo.m_groundObject = 0;
if (object)
{
  ...
  wheel.m_raycastInfo.m_groundObject = &getFixedBody();
  //wheel.m_raycastInfo.m_groundObject = object;
}

...

btRigidBody& btActionInterface::getFixedBody()
{
  static btRigidBody s_fixed(0, 0,0);
  s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
  return s_fixed;
}

Seems like the “old” implementation (that is setting groundObject to object) has been replaced by a “new” implementation which simply returns a (static) dummy rigid body. This dummy rigid body does not have a Panda3D object associated with it, and hence the crash.

I don’t know why this Bullet feature has changed. The new implementation is useless, since it doesn’t provide any information about the object the vehicle is driving on.

What should we do?

  1. Remove the method from the Panda3D interface. This would be the “clean” solution.
  2. Leave it there, so people who compile Bullet (and then Panda3D) themselves can change the Bullet source code back to the old implementation. Just uncomment the commented line and comment the other one.