Ask Your Question

using bullet physics 2.81 with my ros package (a new angle)

asked 2013-03-06 19:07:26 -0500

barragan gravatar image

updated 2014-04-20 14:09:47 -0500

ngrennan gravatar image

Hi everyone,

I posted something similar earlier but have been tracking down the weirdness and now have more insight. But I still have a question on what is going on and thus am reposting.

So the backstory:

I have been trying to get a ROS package to work with bullet 2.81. ROS has an older version of bullet in it which doesn't have everything I want. Thus the attempted upgrade. My code with bullet compiles fine and runs fine with static or shared libraries when I compile it on it's own with g++. However, when I put that same code in a ROS package and compile it with the same shared libraries from bullet, it throws a segfault every time. So I've made very very sure (ldd on the binary) that the executable is pointing to the right libraries. And in fact, I've gone in and moded the bullet source code with some print statements and when I run my code, it prints out. So I'm sure it's pointing to the right ones.

So in one sentence, my bullet code runs fine when compiled on it's own, but when compiled in a rospackage using make (instead of just using g++ at the command line) it throws a seg fault. Same code.

So the issue(s):

So after spending a bunch of time tracing down the segfault, I found that creating btRigidObject objects was sometimes returning null pointers to their motion state. Then in my code when I tried to access these null pointers, I would get a segfault. So I went and added print statements to give me the pointers in my code and in the btRigidBody.cpp file in the construtor and the function it calls (setupRigidBody). So when I create the deafultMotionState the pointer is good. When the constructor sees it, the pointer is good all the way through setupRigidBody and out again. m_optionalMotionState is also good at the end of the constructor. However, back in my code immediately after the rigid body is made, sometimes rigidBody->getMotionState() which only gives me back the private variable m_optionalMotionState is suddenly a null pointer. Even though my print statements just printed out that it wasn't right before it returned the rigidBody.

However, the behavior is also inconsistent. As in, it does not happen every time I create a rigid body with the same code (I am using a function called createRigidBody that takes some necessary arguments and does the repetitive steps and then passes me back the rigid body). For clarity, I am checking the pointer within that function immediately after the rigid body is returned by the bullet constructor so hopefully no funny business is happening in the white space.

So the times that the the motion state pointer happens to go null, a seg fault is thrown when I try to access it.

But the plot thickens. If I immediately after the rigid body is returned, I use setMotionState ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-07 16:44:20 -0500

Thomas gravatar image

Is your current package depending on other packages that also uses Bullet? If this is the case you will end up linking against two different versions of Bullet which is very likely to not work (you will obtain strange behaviors / segv at random places). You can check this by running ldd on your program and look for bullet libraries.

If this is the case, the only way to fix this problem is compiling ROS from source against this newer Bullet. It may represent a significant effort although.

edit flag offensive delete link more

answered 2013-03-09 03:17:57 -0500

barragan gravatar image


I have checked ldd against my executable and it is in fact pointing to my compiled shared libraries of Bullet which is version 2.81. This is an important check though. The only ros packages it depends on are:

<depend package="roscpp"/> <depend package="std_msgs"/> <depend package="bullet2_81"/>

where bullet2_81 is the package I created with my shared libraries. I don't think that those packages depend on bullet although I'm not sure how to check besides looking at the dependency tree by going to individual packages and checking. This is very confusing.


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-03-06 19:07:26 -0500

Seen: 535 times

Last updated: Mar 09 '13