Create a PhysicsLoopBack that includes both PhysicsClient and PhysicsServer over shared memory.
Add a test for PhysicsLoopBack.
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
//#include "SharedMemoryCommands.h"
|
||||
#include "PhysicsClientC_API.h"
|
||||
|
||||
#ifdef PHYSICS_LOOP_BACK
|
||||
#include "PhysicsLoopbackC_API.h"
|
||||
#endif //PHYSICS_LOOP_BACK
|
||||
|
||||
#include "SharedMemoryPublic.h"
|
||||
#include "Bullet3Common/b3Logging.h"
|
||||
#include <string.h>
|
||||
|
||||
struct test
|
||||
{
|
||||
int unused;
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -24,12 +25,18 @@ int main(int argc, char* argv[])
|
||||
int imuLinkIndex = -1;
|
||||
|
||||
|
||||
b3PhysicsClientHandle sm;
|
||||
b3PhysicsClientHandle sm=0;
|
||||
int bodyIndex = -1;
|
||||
|
||||
printf("hello world\n");
|
||||
|
||||
#ifdef PHYSICS_LOOP_BACK
|
||||
sm = b3ConnectPhysicsLoopback(SHARED_MEMORY_KEY);
|
||||
#else
|
||||
sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (b3CanSubmitCommand(sm))
|
||||
{
|
||||
{
|
||||
@@ -150,35 +157,35 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
{
|
||||
b3SubmitClientCommandAndWaitStatus(sm, b3RequestActualStateCommandInit(sm));
|
||||
}
|
||||
b3SharedMemoryStatusHandle state = b3SubmitClientCommandAndWaitStatus(sm, b3RequestActualStateCommandInit(sm));
|
||||
|
||||
if (sensorJointIndexLeft>=0)
|
||||
{
|
||||
|
||||
struct b3JointSensorState sensorState;
|
||||
b3GetJointState(sm,state,sensorJointIndexLeft,&sensorState);
|
||||
|
||||
b3Printf("Sensor for joint [%d] = %f,%f,%f\n", sensorJointIndexLeft,
|
||||
sensorState.m_jointForceTorque[0],
|
||||
sensorState.m_jointForceTorque[1],
|
||||
sensorState.m_jointForceTorque[2]);
|
||||
|
||||
}
|
||||
|
||||
if (sensorJointIndexRight>=0)
|
||||
{
|
||||
struct b3JointSensorState sensorState;
|
||||
b3GetJointState(sm,state,sensorJointIndexRight,&sensorState);
|
||||
|
||||
b3GetJointInfo(sm,bodyIndex,sensorJointIndexRight,&sensorState);
|
||||
b3Printf("Sensor for joint [%d] = %f,%f,%f\n", sensorJointIndexRight,
|
||||
sensorState.m_jointForceTorque[0],
|
||||
sensorState.m_jointForceTorque[1],
|
||||
sensorState.m_jointForceTorque[2]);
|
||||
|
||||
if (sensorJointIndexLeft>=0)
|
||||
{
|
||||
|
||||
struct b3JointSensorState info;
|
||||
|
||||
b3GetJointInfo(sm,bodyIndex,sensorJointIndexLeft,&info);
|
||||
b3Printf("Sensor for joint [%d] = %f,%f,%f\n", sensorJointIndexLeft,
|
||||
info.m_jointForceTorque[0],
|
||||
info.m_jointForceTorque[1],
|
||||
info.m_jointForceTorque[2]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sensorJointIndexRight>=0)
|
||||
{
|
||||
struct b3JointSensorState info;
|
||||
|
||||
b3GetJointInfo(sm,bodyIndex,sensorJointIndexRight,&info);
|
||||
b3Printf("Sensor for joint [%d] = %f,%f,%f\n", sensorJointIndexRight,
|
||||
info.m_jointForceTorque[0],
|
||||
info.m_jointForceTorque[1],
|
||||
info.m_jointForceTorque[2]);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
b3SubmitClientCommandAndWaitStatus(sm, b3InitResetSimulationCommand(sm));
|
||||
|
||||
Reference in New Issue
Block a user