add HelloBulletRobotics C++ example with similar API to PyBullet

Add ANYmal quadruped robot URDF to pybullet_data
This commit is contained in:
Erwin Coumans
2018-05-24 15:48:45 +10:00
parent 8ace9251aa
commit ff4d0b1777
26 changed files with 162202 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
@@ -11,8 +12,6 @@ SET(RobotSimulator_SRCS
RobotSimulatorMain.cpp
b3RobotSimulatorClientAPI.cpp
b3RobotSimulatorClientAPI.h
b3RobotSimulatorClientAPI_NoGUI.cpp
b3RobotSimulatorClientAPI_NoGUI.h
MinitaurSetup.cpp
MinitaurSetup.h
../../examples/ExampleBrowser/InProcessExampleBrowser.cpp
@@ -86,6 +85,7 @@ TARGET_LINK_LIBRARIES(App_RobotSimulator BulletRobotics BulletExampleBrowserLib
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
@@ -93,8 +93,6 @@ INCLUDE_DIRECTORIES(
SET(RobotSimulator_NoGUI_SRCS
RobotSimulatorMain.cpp
b3RobotSimulatorClientAPI_NoGUI.cpp
b3RobotSimulatorClientAPI_NoGUI.h
MinitaurSetup.cpp
MinitaurSetup.h
)
@@ -123,6 +121,39 @@ TARGET_LINK_LIBRARIES(App_RobotSimulator_NoGUI BulletRobotics BulletFileLoader B
########
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
)
SET(App_HelloBulletRobotics_SRCS
HelloBulletRobotics.cpp
)
ADD_EXECUTABLE(App_HelloBulletRobotics ${App_HelloBulletRobotics_SRCS})
SET_TARGET_PROPERTIES(App_HelloBulletRobotics PROPERTIES VERSION ${BULLET_VERSION})
SET_TARGET_PROPERTIES(App_HelloBulletRobotics PROPERTIES DEBUG_POSTFIX "_d")
IF(WIN32)
IF(BUILD_ENET OR BUILD_CLSOCKET)
TARGET_LINK_LIBRARIES(App_HelloBulletRobotics ws2_32 )
ENDIF(BUILD_ENET OR BUILD_CLSOCKET)
ELSE()
IF(APPLE)
ELSE(APPLE)
TARGET_LINK_LIBRARIES( App_HelloBulletRobotics pthread ${DL} )
ENDIF(APPLE)
ENDIF(WIN32)
TARGET_LINK_LIBRARIES(App_HelloBulletRobotics BulletRobotics BulletFileLoader BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath Bullet3Common)

View File

@@ -0,0 +1,37 @@
#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));
b3Vector3 basePosition = b3MakeVector3(0,0,1);
b3Quaternion baseOrientation = b3Quaternion(0,0,0,1);
sim->resetBasePositionAndOrientation(r2d2Uid, basePosition, baseOrientation);
sim->setGravity(b3MakeVector3(0,0,-10));
while (sim->isConnected())
{
sim->stepSimulation();
}
delete sim;
}

View File

@@ -1,7 +1,7 @@
#ifndef B3_ROBOT_SIMULATOR_CLIENT_API_H
#define B3_ROBOT_SIMULATOR_CLIENT_API_H
#include "../SharedMemory/SharedMemoryPublic.h"
#include "SharedMemoryPublic.h"
#include "Bullet3Common/b3Vector3.h"
#include "Bullet3Common/b3Quaternion.h"
#include "Bullet3Common/b3Transform.h"

View File

@@ -80,6 +80,7 @@ project ("App_RobotSimulator")
includedirs {
".",
"../../src",
"../../examples/SharedMemory",
"../ThirdPartyLibs",
}