I'm running an experiment in Bullet Physics, so I was hoping to speeding up the simulation so I can collect all the data in a reasonable time. I've tried to follow the information from here http://gafferongames.com/game-physics/f ... -timestep/, but I'm not sure how to port the format he uses over to the Bullet Physics clientMoveAndDisplay().
Here's my interpretation of what I should be doing:
Code: Select all
void RagdollDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
bool decouples = true;
//simple dynamics world doesn't handle fixed-time-stepping
float ms = getDeltaTimeMicroseconds();
float minFPS = 90000.f/60.f;
const double dt = .01;
if (ms > minFPS)
ms = minFPS;
accumulator += ms;
if (m_dynamicsWorld)
{
if (!pause || (pause && oneStep))
{
//reseting touches
for (int f=0;f<10;f++)
{
touches[f] = 0;
}
// run next step
// Code that de-couples rendering and stepping
if (decouple)
{
while (accumulator >= dt)
{
accumulator -= dt;
m_dynamicsWorld->stepSimulation(ms/90000.f);
if (timeStep%10==0)
{
for (int j=0;j<8;j++)
{
double motorCommand;
motorCommand = 0;
for(int i=0;i<4;i++)
{
int sensor = i+5;
motorCommand =+ (touches[sensor] * weights[i][j]);
motorCommand = tanh(motorCommand);
motorCommand = motorCommand*45;
ActuateJoint(j, motorCommand, ms / 90000.f);
}
}
}
timeStep++;
if (timeStep==250)
{break;}
}
}
}
The problem is that I get different data from that code than from the code below, and I think that if I was doing it right I would be getting the same data if I increased the rate correctly. The faster-than-real-time simulation is consistent to itself, but it doesn't match the real-time simulation.
Code: Select all
if (!decouple)
{
if (timeStep%10==0)
{
for (int j=0;j<8;j++)
{
double motorCommand;
motorCommand = 0;
for(int i=0;i<4;i++)
{
int sensor = i+5;
motorCommand =+ (touches[sensor] * weights[i][j]);
motorCommand = tanh(motorCommand);
motorCommand = motorCommand*45;
ActuateJoint(j, motorCommand, ms / 90000.f);
}
}
}
timeStep++;
//end of coupled code
}
//terminate in 250 timesteps
if (timeStep == 250)
{
Save_Position(0);
exit(0);
}
Thank you for your time,
Josh