2018-05-24 05:48:45 +00:00
|
|
|
|
|
|
|
#include "b3RobotSimulatorClientAPI_NoGUI.h"
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
b3RobotSimulatorClientAPI_NoGUI* sim = new b3RobotSimulatorClientAPI_NoGUI();
|
|
|
|
|
|
|
|
bool isConnected = sim->connect(eCONNECT_SHARED_MEMORY);
|
|
|
|
if (!isConnected)
|
|
|
|
{
|
|
|
|
printf("Using Direct mode\n");
|
|
|
|
isConnected = sim->connect(eCONNECT_DIRECT);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
printf("Using shared memory\n");
|
|
|
|
}
|
|
|
|
//remove all existing objects (if any)
|
|
|
|
sim->resetSimulation();
|
|
|
|
|
|
|
|
int planeUid = sim->loadURDF("plane.urdf");
|
|
|
|
printf("planeUid = %d\n", planeUid);
|
|
|
|
|
|
|
|
int r2d2Uid = sim->loadURDF("r2d2.urdf");
|
|
|
|
printf("r2d2 #joints = %d\n", sim->getNumJoints(r2d2Uid));
|
|
|
|
|
2018-05-27 00:55:53 +00:00
|
|
|
btVector3 basePosition = btVector3(0,0,1);
|
|
|
|
btQuaternion baseOrientation = btQuaternion(0,0,0,1);
|
2018-05-24 05:48:45 +00:00
|
|
|
|
|
|
|
sim->resetBasePositionAndOrientation(r2d2Uid, basePosition, baseOrientation);
|
2018-05-27 00:55:53 +00:00
|
|
|
sim->setGravity(btVector3(0,0,-10));
|
2018-05-24 05:48:45 +00:00
|
|
|
|
|
|
|
while (sim->isConnected())
|
|
|
|
{
|
|
|
|
sim->stepSimulation();
|
|
|
|
}
|
|
|
|
delete sim;
|
|
|
|
}
|