Integrating bullet 2.81 into ROS project

Post Reply
Posts: 3
Joined: Sun Mar 03, 2013 5:52 am

Integrating bullet 2.81 into ROS project

Post by barragan »

Hello, I posted this question on and am posting it here to see if anyone involved in either project has some advice.

Apologies in advance for the long winded explanation. I want to make sure I explain clearly.

I have written some code that works with the Bullet Physics Engine to simulate some models for a bayesian filter. I can compile this code using g++ with this command line statement:

g++ main.cpp BasicDemo.cpp -lGL -lGLU -I ~/Documents/cppCode/bullet-2.81-rev2613/src/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletDynamics/libBulletDynamics.a ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletCollision/libBulletCollision.a ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/LinearMath/libLinearMath.a -o main

where those paths lead to the proper files on my particular system. I am using a PR2 to generate observations for my bayesian filter. Up to this point, I simply used another bullet simulation to do this but now want to use the PR2 instead. So I have written the necessary code on the PR2 side and the communication code to send a command to the PR2 to execute an action and return an observation. My plan was to add the other side of this communication code to my bullet and filter code and thus have the connection I'm looking for. As a first step, I placed the bullet and filter code into a ros package. I needed to modify my CMakelists to link to the compiled bullet code that exists on my machine. After much arguing and experimenting, I produced the CMakeLists.txt file that I have copied and pasted at the bottom of this post.

This compiled the code with no errors. The reason that the CMakeLists is written the way it is is because ROS Fuerte has a version of bullet physics in it. However, the version is older than the version that I need for parts of my code. I am using bullet 2.81. So I had to force cmake to find my libraries before it found the ones in my regular ROS search paths. This caused the manually adding flags section. Before I did this, it would tell me that certain classes did not have certain members which was true for the older bullet physics in ROS but is not true for the newer version I have been using. After these changes, the errors went away.

However, when I run the code, it throws a segmentation fault. This code is an exact copy (besides changing the header files to the regular way that a ros package would have them [for example instead of "BasicDemo.h" in my old files, it would be <basicbayesv2wrobot basicdemo.h=""> where basicBayesV2wRobot is the name of the package]) of the code that compiles and runs properly when compiled with the g++ command above.

I have very little experience with cmake and especially with compiling external libraries in a ROS package and making sure ROS finds my libraries which are a newer version of libraries it has. Does anyone have any experience with this. The line that seg faults (according to gdb) is a line that gives no errors with my original compilation using g++.



cmake_minimum_required(VERSION 2.4.6)

# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

#set the default path for built executables to the "bin" directory
#set the default path for built libraries to the "lib" directory

#o my goodness
SET(GCC_COVERAGE_LINK_FLAGS "-lGL -lGLU -I /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/src/ /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletDynamics/libBulletDynamics.a /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletCollision/libBulletCollision.a /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/LinearMath/libLinearMath.a")

#SET(GCC_COVERAGE_LINK_FLAGS "-lGL -lGLU -I/mit/barragan/Documents/cppCode/bullet-2.81-rev2613/src/")


#uncomment if you have defined messages
#uncomment if you have defined services

#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})

#include_directories(~/Documents/cppCode/bullet-2.81-rev2613/src/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletDynamics/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletCollision/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/LinearMath/)
#link_directories(~/Documents/cppCode/bullet-2.81-rev2613/src/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletDynamics/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletCollision/ ~/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/LinearMath/)
rosbuild_add_executable(basicBayesV2wRobot src/basicBayesV2wRobot.cpp src/BasicDemo.cpp)
target_link_libraries(basicBayesV2wRobot /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/src/ /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletDynamics/libBulletDynamics.a /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/BulletCollision/libBulletCollision.a /mit/barragan/Documents/cppCode/bullet-2.81-rev2613/bullet-build/src/LinearMath/libLinearMath.a)
#target_link_libraries(basicBayesV2wRobot GL GLU BulletDynamics BulletCollision LinearMath)
Post Reply