hi ,
Sorry for noob question , I'm integrating Bullet in a project Which use OpenSceneGraph .
I'm starting with a simple test : a cube That Falls on a plane under gravity force . The cube has a btBoxShape .
The problem is the follow : the cube do not falls straight on Z (I 'm using right-hand Z UP convention ) but During the fall the cube spins around X and Y ( planars axis) . I'm expect the cube falls straight on Z with no spin . The cube starts with position and rotation zerowed , all ( 0,0,0 ) : I've checked the getWorldTransform and the position and rotation passed are ( 0,0,0 ) effectively . Printing the setWorldTransform I Can See That for some stepSimulation , position and rotation Calculated are ( 0,0,0 ) effectively , but after some cycles they drift and start to spin the cube .
I'm very noob on bullet , I'm pretty sure this is a naive problem . Can you give me some ideas ? The world is initialized with the impulseConstraint , no particulars custom parameters.
I'm not sure bullet using same right-handed convention but I don't know if it can be the problem.
Many thanks, Bye
Object on gravity: unwanted spin (OSG integration)
Re: Object on gravity: unwanted spin (OSG integration)
In bullet, I believe that generally Y is considered up. However, it does not matter, since setting the gravity to (0,0,-9.81) causes gravity to apply in z axis direction. Look at the simple cube example in the example browser, it should provide you with a working example of your indended simulation. Also, I recommend to implement the debugdrawer for OpenSceneGraph which then provides you with a debugdrawing of your bullet world.
Re: Object on gravity: unwanted spin (OSG integration)
Thanks. Unfortunately I can't see relevant difference looking at BasicDemo. My world is initialized in same way and I've applied gravity on Z as you said (0,0,-9.81). Cube continue to spin....This is a very first part of quaternion logging, there are no others forces applied to the cube. As you can see it start well and then derives...
- Attachments
-
- log.txt
- (1.81 MiB) Downloaded 228 times
Re: Object on gravity: unwanted spin (OSG integration)
Interesting: in effect I have a difference. In my code, I've added explicitly the CollisionObject to the DiscreteDynamicWorld before adding RigidBody, using addCollisionObject. Something like this:
Removing first line (m_dynamics_world->addCollisionObject(p_object->collision_object)) now the object go straight on Z under gravity, but when collide with a terrain there is a segmentation fault. Using first line, collisions works apparently well, but the spin problem come up....
0x00007ffff78b6034 in btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy*, btBroadphaseProxy*) () from /usr/local/lib/libWorld.so
(gdb) bt
#0 0x00007ffff78b6034 in btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy*, btBroadphaseProxy*) () from /usr/local/lib/libWorld.so
#1 0x00007ffff78b4482 in btDbvtTreeCollider::Process(btDbvtNode const*, btDbvtNode const*) () from /usr/local/lib/libWorld.so
#2 0x00007ffff78ad304 in btDbvtBroadphase::setAabb(btBroadphaseProxy*, btVector3 const&, btVector3 const&, btDispatcher*) ()
from /usr/local/lib/libWorld.so
#3 0x00007ffff78be94a in btCollisionWorld::updateSingleAabb(btCollisionObject*) () from /usr/local/lib/libWorld.so
#4 0x00007ffff78beb46 in btCollisionWorld::updateAabbs() () from /usr/local/lib/libWorld.so
#5 0x00007ffff78bce84 in btCollisionWorld::performDiscreteCollisionDetection() () from /usr/local/lib/libWorld.so
#6 0x00007ffff7893479 in btDiscreteDynamicsWorld::internalSingleStepSimulation(float) () from /usr/local/lib/libWorld.so
#7 0x00007ffff789367a in btDiscreteDynamicsWorld::stepSimulation(float, int, float) () from /usr/local/lib/libWorld.so
Code: Select all
...
m_dynamics_world->addCollisionObject(p_object->collision_object);
...
double l_mass = p_object->getMass();
DynamicsType l_type = p_object->getDynamicsType();
PhyVector3 l_LocalInertia(0.0, 0.0, 0.0);
PhyCollisionShape* l_PhyShape = p_object->getPhyShape();
if(l_type == DYNAMIC && l_PhyShape != NULL) {
l_PhyShape->calculateLocalInertia(l_mass, l_LocalInertia);
}
PhyMotionState* l_MotionState = new PhyMotionState(p_object);
PhyRigidBody::btRigidBodyConstructionInfo l_ConstructionInfo(l_mass, l_MotionState, l_PhyShape, l_LocalInertia);
PhyRigidBody* l_PhyRigidBody = new PhyRigidBody(l_ConstructionInfo);
if(l_type == KINEMATIC) {
l_PhyRigidBody->setCollisionFlags(l_PhyRigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); l_PhyRigidBody->setActivationState(DISABLE_DEACTIVATION);
}
m_dynamics_world->addRigidBody(l_PhyRigidBody);
0x00007ffff78b6034 in btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy*, btBroadphaseProxy*) () from /usr/local/lib/libWorld.so
(gdb) bt
#0 0x00007ffff78b6034 in btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy*, btBroadphaseProxy*) () from /usr/local/lib/libWorld.so
#1 0x00007ffff78b4482 in btDbvtTreeCollider::Process(btDbvtNode const*, btDbvtNode const*) () from /usr/local/lib/libWorld.so
#2 0x00007ffff78ad304 in btDbvtBroadphase::setAabb(btBroadphaseProxy*, btVector3 const&, btVector3 const&, btDispatcher*) ()
from /usr/local/lib/libWorld.so
#3 0x00007ffff78be94a in btCollisionWorld::updateSingleAabb(btCollisionObject*) () from /usr/local/lib/libWorld.so
#4 0x00007ffff78beb46 in btCollisionWorld::updateAabbs() () from /usr/local/lib/libWorld.so
#5 0x00007ffff78bce84 in btCollisionWorld::performDiscreteCollisionDetection() () from /usr/local/lib/libWorld.so
#6 0x00007ffff7893479 in btDiscreteDynamicsWorld::internalSingleStepSimulation(float) () from /usr/local/lib/libWorld.so
#7 0x00007ffff789367a in btDiscreteDynamicsWorld::stepSimulation(float, int, float) () from /usr/local/lib/libWorld.so