| 38 | #endif |
| 39 | |
| 40 | void testSharedMemory(b3PhysicsClientHandle sm) |
| 41 | { |
| 42 | int i, dofCount, posVarCount, ret, numJoints; |
| 43 | int sensorJointIndexLeft = -1; |
| 44 | int sensorJointIndexRight = -1; |
| 45 | const char* urdfFileName = "r2d2.urdf"; |
| 46 | const char* sdfFileName = "kuka_iiwa/model.sdf"; |
| 47 | double gravx = 0, gravy = 0, gravz = -9.8; |
| 48 | double timeStep = 1. / 60.; |
| 49 | double startPosX, startPosY, startPosZ; |
| 50 | int imuLinkIndex = -1; |
| 51 | int bodyIndex = -1; |
| 52 | |
| 53 | if (b3CanSubmitCommand(sm)) |
| 54 | { |
| 55 | { |
| 56 | b3SharedMemoryCommandHandle command = b3InitPhysicsParamCommand(sm); |
| 57 | b3SharedMemoryStatusHandle statusHandle; |
| 58 | ret = b3PhysicsParamSetGravity(command, gravx, gravy, gravz); |
| 59 | ret = b3PhysicsParamSetTimeStep(command, timeStep); |
| 60 | statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command); |
| 61 | ASSERT_EQ(b3GetStatusType(statusHandle), CMD_CLIENT_COMMAND_COMPLETED); |
| 62 | } |
| 63 | |
| 64 | { |
| 65 | b3SharedMemoryStatusHandle statusHandle; |
| 66 | int statusType; |
| 67 | int bodyIndicesOut[10]; //MAX_SDF_BODIES = 10 |
| 68 | int numJoints, numBodies; |
| 69 | int bodyUniqueId; |
| 70 | b3SharedMemoryCommandHandle command = b3LoadSdfCommandInit(sm, sdfFileName); |
| 71 | statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command); |
| 72 | statusType = b3GetStatusType(statusHandle); |
| 73 | ASSERT_EQ(statusType, CMD_SDF_LOADING_COMPLETED); |
| 74 | |
| 75 | numBodies = b3GetStatusBodyIndices(statusHandle, bodyIndicesOut, 10); |
| 76 | ASSERT_EQ(numBodies, 1); |
| 77 | bodyUniqueId = bodyIndicesOut[0]; |
| 78 | { |
| 79 | { |
| 80 | b3SharedMemoryStatusHandle statusHandle; |
| 81 | int statusType; |
| 82 | b3SharedMemoryCommandHandle command = b3InitRequestVisualShapeInformation(sm, bodyUniqueId); |
| 83 | statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command); |
| 84 | statusType = b3GetStatusType(statusHandle); |
| 85 | if (statusType == CMD_VISUAL_SHAPE_INFO_COMPLETED) |
| 86 | { |
| 87 | struct b3VisualShapeInformation vi; |
| 88 | b3GetVisualShapeInformation(sm, &vi); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | numJoints = b3GetNumJoints(sm, bodyUniqueId); |
| 94 | ASSERT_EQ(numJoints, 7); |
| 95 | |
| 96 | #if 0 |
| 97 | b3Printf("numJoints: %d\n", numJoints); |
no test coverage detected