| 2 | #include "b3RobotSimulatorClientAPI_NoGUI.h" |
| 3 | |
| 4 | int main(int argc, char* argv[]) |
| 5 | { |
| 6 | b3RobotSimulatorClientAPI_NoGUI* sim = new b3RobotSimulatorClientAPI_NoGUI(); |
| 7 | |
| 8 | bool isConnected = sim->connect(eCONNECT_SHARED_MEMORY); |
| 9 | |
| 10 | if (!isConnected) |
| 11 | { |
| 12 | printf("Using Direct mode\n"); |
| 13 | isConnected = sim->connect(eCONNECT_DIRECT); |
| 14 | } |
| 15 | else |
| 16 | { |
| 17 | printf("Using shared memory\n"); |
| 18 | } |
| 19 | |
| 20 | //remove all existing objects (if any) |
| 21 | sim->resetSimulation(); |
| 22 | sim->setGravity(btVector3(0, 0, -9.8)); |
| 23 | sim->setNumSolverIterations(100); |
| 24 | b3RobotSimulatorSetPhysicsEngineParameters args; |
| 25 | sim->getPhysicsEngineParameters(args); |
| 26 | |
| 27 | int planeUid = sim->loadURDF("plane.urdf"); |
| 28 | printf("planeUid = %d\n", planeUid); |
| 29 | |
| 30 | int r2d2Uid = sim->loadURDF("r2d2.urdf"); |
| 31 | printf("r2d2 #joints = %d\n", sim->getNumJoints(r2d2Uid)); |
| 32 | |
| 33 | btVector3 basePosition = btVector3(0, 0, 0.5); |
| 34 | btQuaternion baseOrientation = btQuaternion(0, 0, 0, 1); |
| 35 | |
| 36 | sim->resetBasePositionAndOrientation(r2d2Uid, basePosition, baseOrientation); |
| 37 | |
| 38 | while (sim->isConnected()) |
| 39 | { |
| 40 | btVector3 basePos; |
| 41 | btQuaternion baseOrn; |
| 42 | sim->getBasePositionAndOrientation(r2d2Uid, basePos, baseOrn); |
| 43 | printf("r2d2 basePosition = [%f,%f,%f]\n", basePos[0], basePos[1], basePos[2]); |
| 44 | |
| 45 | sim->stepSimulation(); |
| 46 | } |
| 47 | delete sim; |
| 48 | } |
nothing calls this directly
no test coverage detected