fix SharedMemory/test.c compile errors

This commit is contained in:
erwincoumans
2015-08-02 19:10:42 -07:00
parent eb6663ed4b
commit 49a89ab0e7

View File

@@ -14,21 +14,21 @@ struct test
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int ret ,allowSharedMemoryInitialization=0; int i, dofCount , posVarCount, dofIndex, ret ,numJoints, allowSharedMemoryInitialization=0;
int timeout = MAX_TIMEOUT; int timeout = MAX_TIMEOUT;
int sensorJointIndexLeft=-1; int sensorJointIndexLeft=-1;
int sensorJointIndexRight=-1; int sensorJointIndexRight=-1;
const char* urdfFileName = "r2d2.urdf"; const char* urdfFileName = "r2d2.urdf";
double gravx=0, gravy=0, gravz=-9.8; double gravx=0, gravy=0, gravz=-9.8;
double timeStep = 1./60.; double timeStep = 1./60.;
double startPosX, startPosY,startPosZ; double startPosX, startPosY,startPosZ;
b3Printf("timeout = %d\n",timeout);
SharedMemoryCommand_t command; SharedMemoryCommand_t command;
SharedMemoryStatus_t status; SharedMemoryStatus_t status;
b3PhysicsClientHandle sm; b3PhysicsClientHandle sm;
b3Printf("timeout = %d\n",timeout);
printf("hello world\n"); printf("hello world\n");
sm = b3ConnectSharedMemory( allowSharedMemoryInitialization); sm = b3ConnectSharedMemory( allowSharedMemoryInitialization);
@@ -55,8 +55,8 @@ int main(int argc, char* argv[])
while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {} while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {}
b3Printf("timeout = %d\n",timeout); b3Printf("timeout = %d\n",timeout);
int numJoints = b3GetNumJoints(sm); numJoints = b3GetNumJoints(sm);
for (int i=0;i<numJoints;i++) for (i=0;i<numJoints;i++)
{ {
struct b3JointInfo jointInfo; struct b3JointInfo jointInfo;
b3GetJointInfo(sm,i,&jointInfo); b3GetJointInfo(sm,i,&jointInfo);
@@ -103,14 +103,14 @@ int main(int argc, char* argv[])
timeout = MAX_TIMEOUT; timeout = MAX_TIMEOUT;
while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {} while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {}
int posVarCount =status.m_sendActualStateArgs.m_numDegreeOfFreedomQ; posVarCount =status.m_sendActualStateArgs.m_numDegreeOfFreedomQ;
int dofCount =status.m_sendActualStateArgs.m_numDegreeOfFreedomU; dofCount =status.m_sendActualStateArgs.m_numDegreeOfFreedomU;
b3Printf("posVarCount = %d\n",posVarCount); b3Printf("posVarCount = %d\n",posVarCount);
printf("dofCount = %d\n",dofCount); printf("dofCount = %d\n",dofCount);
b3JointControlCommandInit(&command, CONTROL_MODE_VELOCITY); b3JointControlCommandInit(&command, CONTROL_MODE_VELOCITY);
for (int dofIndex=0;dofIndex<dofCount;dofIndex++) for ( dofIndex=0;dofIndex<dofCount;dofIndex++)
{ {
b3JointControlSetDesiredVelocity(&command,dofIndex,1); b3JointControlSetDesiredVelocity(&command,dofIndex,1);
b3JointControlSetMaximumForce(&command,dofIndex,100); b3JointControlSetMaximumForce(&command,dofIndex,100);
@@ -120,7 +120,7 @@ int main(int argc, char* argv[])
while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {} while ((timeout-- > 0) && b3ProcessServerStatus(sm, &status)==0) {}
///perform some simulation steps for testing ///perform some simulation steps for testing
for (int i=0;i<100;i++) for ( i=0;i<100;i++)
{ {
ret = b3InitStepSimulationCommand(&command); ret = b3InitStepSimulationCommand(&command);
ret = b3SubmitClientCommand(sm, &command); ret = b3SubmitClientCommand(sm, &command);