moveit: Bullet collision: memory leak

Is the Bullet collision library compatible with MTC?

From my understanding by following the moveit tutorials, only this line of code is needed to choose Bullet over FCL in MTC. With this line, is FCL replaced completly with Bullet?

# current_state.cpp
include <moveit/collision_detection_bullet/collision_detector_allocator_bullet.h>

void CurrentState::compute() {
    scene_ = std::make_shared<planning_scene::PlanningScene>(robot_model_);
    scene_->setActiveCollisionDetector(collision_detection::CollisionDetectorAllocatorBullet::create());

When planning with MTC, it plans for a certain amount of time before running in a segfault:

Thread 239 "bob_planner_pp" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd188e700 (LWP 943260)]
0x00007ffff2129c46 in ?? () from /lib/x86_64-linux-gnu/libBulletCollision.so.2.88
(gdb) backtrace
#0  0x00007ffff2129c46 in ?? () from /lib/x86_64-linux-gnu/libBulletCollision.so.2.88
moveit/moveit_task_constructor#1  0x00007ffff212aac6 in btDbvt::update(btDbvtNode*, btDbvtAabbMm&) () from /lib/x86_64-linux-gnu/libBulletCollision.so.2.88
moveit/moveit_task_constructor#2  0x00007ffff212ac3e in btDbvt::update(btDbvtNode*, btDbvtAabbMm&, btVector3 const&, float) () from /lib/x86_64-linux-gnu/libBulletCollision.so.2.88
moveit/moveit_task_constructor#3  0x00007ffff212c8b1 in btDbvtBroadphase::setAabb(btBroadphaseProxy*, btVector3 const&, btVector3 const&, btDispatcher*) () from /lib/x86_64-linux-gnu/libBulletCollision.so.2.88
moveit/moveit_task_constructor#4  0x00007ffff4f78ed0 in collision_detection_bullet::BulletBVHManager::setCollisionObjectsTransform(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::Transform<double, 3, 1, 0> const&) () from /home/captain-yoshi/ws/ros/catkin_ws/devel/lib/libmoveit_collision_detection_bullet.so.1.1.1
moveit/moveit_task_constructor#5  0x00007ffff4f740b3 in collision_detection::CollisionEnvBullet::checkSelfCollisionHelper(collision_detection::CollisionRequest const&, collision_detection::CollisionResult&, moveit::core::RobotState const&, collision_detection::AllowedCollisionMatrix const*) const () from /home/captain-yoshi/ws/ros/catkin_ws/devel/lib/libmoveit_collision_detection_bullet.so.1.1.1
moveit/moveit_task_constructor#6  0x00007fffe83e6ba0 in ompl_interface::StateValidityChecker::isValid(ompl::base::State const*, bool) const () from /home/captain-yoshi/ws/ros/catkin_ws/devel/lib/libmoveit_ompl_interface.so.1.1.1
moveit/moveit_task_constructor#7  0x00007fffe8403ea5 in ompl_interface::ConstrainedGoalSampler::sampleUsingConstraintSampler(ompl::base::GoalLazySamples const*, ompl::base::State*) ()
   from /home/captain-yoshi/ws/ros/catkin_ws/devel/lib/libmoveit_ompl_interface.so.1.1.1
moveit/moveit_task_constructor#8  0x00007fffd22e2824 in ompl::base::GoalLazySamples::goalSamplingThread() () from /home/captain-yoshi/ws/ros/catkin_ws/devel/lib/libompl.so.16
moveit/moveit_task_constructor#9  0x00007ffff69b3d84 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
moveit/moveit_task_constructor#10 0x00007ffff7f6c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
moveit/moveit_task_constructor#11 0x00007ffff67f2293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Also tried patching MoveIt with this PR but still got a segfault. Running on Noetic.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 21 (19 by maintainers)

Most upvoted comments

Good point, I could reduce some of my mesh. Its strange that FCL has no problem with my mesh quality. Thx for your help! Just ping me if you want me to test some PR related to Bullet.

For me, Bullet took ~2X as long as FCL in the worst case.

As my understanding, you could relax the longuest_valid_segment_fraction to say 0.05 with bullet, and compare with FCL againt the same parameter with 0.01 or 0.005. You should see an improvement on time, not sure on the quality of the returning path.

Wow that was a fast reply! With the suggested PR there are no more segfaults. It seems the planning time is much slower then with FCL, even though it should be quicker (~10 times).

This comment has the following table.

image

What does MTC or MoveIt use as the Collision Environment?

The speed could also be explained by this PR: ros-planning/moveit/pull/1584. One the Con’s of a Unified collision environment:

For multi-threaded collision checks, it is not directly clear for me how we can avoid copying the whole collision_env. But as maybe memory got cheaper than it was some years ago, these advantages can be forsaken in turn for the above mentioned advantages. Or, other smart copying techniques could be applied (I am no expert here).

It seems that this could be what is currently happening to me. @AndyZe Are you seeing drop in speed when using Bullet with MTC? I will report back with timing information to compare FCL and bullet.

Yep, that line should be all that’s required. Can you please try it with this PR instead: https://github.com/ros-planning/moveit/pull/2481

It’s great to have somebody else try this stuff. Thank you!