Skip to content

Commit

Permalink
add HelloBulletRobotics C++ example with similar API to PyBullet
Browse files Browse the repository at this point in the history
Add ANYmal quadruped robot URDF to pybullet_data
  • Loading branch information
Erwin Coumans committed May 24, 2018
1 parent 8ace925 commit ff4d0b1
Show file tree
Hide file tree
Showing 26 changed files with 162,202 additions and 11 deletions.
11 changes: 5 additions & 6 deletions Extras/BulletRobotics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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
Expand Down Expand Up @@ -90,18 +91,15 @@ SET(BulletRobotics_SRCS
../../examples/MultiThreading/b3PosixThreadSupport.cpp
../../examples/MultiThreading/b3Win32ThreadSupport.cpp
../../examples/MultiThreading/b3ThreadSupportInterface.cpp


../../examples/RobotSimulator/b3RobotSimulatorClientAPI_NoGUI.cpp
../../examples/RobotSimulator/b3RobotSimulatorClientAPI_NoGUI.h
)

IF(BUILD_CLSOCKET)
ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET)
ENDIF(BUILD_CLSOCKET)

IF(WIN32)
LINK_LIBRARIES(
${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF(BUILD_ENET)
ADD_DEFINITIONS(-DWIN32 -DBT_ENABLE_ENET)
ENDIF(BUILD_ENET)
Expand All @@ -120,7 +118,7 @@ ELSE(WIN32)

IF(NOT APPLE)
LINK_LIBRARIES( pthread ${DL} )
ENDIF(APPLE)
ENDIF(NOT APPLE)
ENDIF(WIN32)

IF(BUILD_ENET)
Expand Down Expand Up @@ -176,6 +174,7 @@ IF (INSTALL_EXTRA_LIBS)
../../examples/SharedMemory/PhysicsClientTCP_C_API.h
../../examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h
../../examples/SharedMemory/SharedMemoryPublic.h
../../examples/RobotSimulator/b3RobotSimulatorClientAPI_NoGUI.h
DESTINATION include/bullet
)
INSTALL(TARGETS
Expand Down
1 change: 1 addition & 0 deletions examples/ExampleBrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ ENDIF(BUILD_SHARED_LIBS)
INCLUDE_DIRECTORIES(
.
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
)

Expand Down
1 change: 1 addition & 0 deletions examples/ExampleBrowser/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ project "App_BulletExampleBrowser"
includedirs {
".",
"../../src",
"../../examples/SharedMemory",
"../ThirdPartyLibs",
}

Expand Down
39 changes: 35 additions & 4 deletions examples/RobotSimulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -86,15 +85,14 @@ 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
)

SET(RobotSimulator_NoGUI_SRCS
RobotSimulatorMain.cpp
b3RobotSimulatorClientAPI_NoGUI.cpp
b3RobotSimulatorClientAPI_NoGUI.h
MinitaurSetup.cpp
MinitaurSetup.h
)
Expand Down Expand Up @@ -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)



Expand Down
37 changes: 37 additions & 0 deletions examples/RobotSimulator/HelloBulletRobotics.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion examples/RobotSimulator/b3RobotSimulatorClientAPI_NoGUI.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions examples/RobotSimulator/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ project ("App_RobotSimulator")
includedirs {
".",
"../../src",
"../../examples/SharedMemory",
"../ThirdPartyLibs",
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1

newmtl None.001
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.800000 0.800000 0.800000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
Loading

0 comments on commit ff4d0b1

Please sign in to comment.