Create a PhysicsLoopBack that includes both PhysicsClient and PhysicsServer over shared memory.
Add a test for PhysicsLoopBack.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
project ("Test_SharedMemoryPhysicsClient")
|
||||
project ("Test_SharedMemoryPhysicsClient")
|
||||
|
||||
language "C++"
|
||||
kind "ConsoleApp"
|
||||
@@ -25,4 +25,57 @@
|
||||
"../../examples/Utils/b3ResourcePath.cpp",
|
||||
"../../examples/Utils/b3ResourcePath.h",
|
||||
}
|
||||
|
||||
project ("Test_PhysicsLoopBack")
|
||||
|
||||
language "C++"
|
||||
kind "ConsoleApp"
|
||||
|
||||
includedirs {"../../src", "../../examples/SharedMemory",
|
||||
"../../examples/ThirdPartyLibs"}
|
||||
defines {"PHYSICS_LOOP_BACK"}
|
||||
links {
|
||||
"BulletFileLoader",
|
||||
"BulletWorldImporter",
|
||||
"Bullet3Common",
|
||||
"BulletDynamics",
|
||||
"BulletCollision",
|
||||
"LinearMath"
|
||||
}
|
||||
|
||||
files {
|
||||
"test.c",
|
||||
"../../examples/SharedMemory/PhysicsClient.cpp",
|
||||
"../../examples/SharedMemory/PhysicsClient.h",
|
||||
"../../examples/SharedMemory/PhysicsServer.cpp",
|
||||
"../../examples/SharedMemory/PhysicsServer.h",
|
||||
"../../examples/SharedMemory/PhysicsLoopback.cpp",
|
||||
"../../examples/SharedMemory/PhysicsLoopback.h",
|
||||
"../../examples/SharedMemory/PhysicsLoopbackC_Api.cpp",
|
||||
"../../examples/SharedMemory/PhysicsLoopbackC_Api.h",
|
||||
"../../examples/SharedMemory/PhysicsClientSharedMemory.cpp",
|
||||
"../../examples/SharedMemory/PhysicsClientSharedMemory.h",
|
||||
"../../examples/SharedMemory/PhysicsClientC_API.cpp",
|
||||
"../../examples/SharedMemory/PhysicsClientC_API.h",
|
||||
"../../examples/SharedMemory/Win32SharedMemory.cpp",
|
||||
"../../examples/SharedMemory/Win32SharedMemory.h",
|
||||
"../../examples/SharedMemory/PosixSharedMemory.cpp",
|
||||
"../../examples/SharedMemory/PosixSharedMemory.h",
|
||||
"../../examples/Utils/b3ResourcePath.cpp",
|
||||
"../../examples/Utils/b3ResourcePath.h",
|
||||
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
|
||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
||||
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
|
||||
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
|
||||
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||
"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||
"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||
"../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp",
|
||||
"../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
|
||||
"../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp",
|
||||
"../../examples/Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||
"../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||
}
|
||||
|
||||
@@ -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