Force to distance traveled inaccurate?

Post Reply
Posts: 1
Joined: Wed Sep 25, 2019 1:30 am

Force to distance traveled inaccurate?

Post by zipkicker » Fri Sep 27, 2019 1:39 pm

I'm using a rigid body (box) with a mass of 1.0 as defined here:

Code: Select all

btBoxShape* colShape = new btBoxShape(btVector3(1, 1, 1));
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody* bulletRigidBody = new btRigidBody(1.0, myMotionState, colShape);
I'm using a gravity of (0.0,-10.0,0.0) in btDiscreteDynamicWorld:

Code: Select all

btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
DynamicWorld = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionConfiguration),
                                           new btDbvtBroadphase(),
                                           new btSequentialImpulseConstraintSolver(),
I've set up test cases to check that the simulation is running as expected for a single call to stepSimulation(). The first test case applies a central force of (0.0,10.0,0.0) equally opposing the gravity and, as expected, the body doesn't move.

The second test case increases the upward force by 5.0 to (0.0,15.0,0.0). In order to check velocity and distance travelled I'm using t(time) = (number of steps returned from stepSimulation)*(fixed substep time). My delta time is 0.02 and my fixed substep time is 0.004(1/250). So t = 0.02.

a(acceleration) = F(Force)/m(mass) but since m = 1.0 then a = F. So a = 5.0.

Since the initial velocity is 0, vf(final velocity) = F*t. So vf = 0.1 which is the same as the simulation.

Next d = 0.5*F*t^2. So d = 0.5*(5.0)*(0.02)^2 = 0.001. But when I check the center of mass position of the body after the run it is 0.0012 higher than the starting position. This suggests d = 0.5*(5.0*0.02)*0.024 = 0.5*0.1*0.024 = 0.0012. So the distance is being calculated with the correct velocity (0.1) for the actual current time but the time (0.024) is one substep ahead. I've made numerous additional calls to stepSimulation and this continues to hold true.

Is this a bug or am I missing something?

Post Reply