Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bullet constructor not updating world objects #2830

Merged
merged 14 commits into from Sep 1, 2021
Merged

Fix bullet constructor not updating world objects #2830

merged 14 commits into from Sep 1, 2021

Conversation

yurirocha15
Copy link
Contributor

@yurirocha15 yurirocha15 commented Aug 20, 2021

Description

Bullet Collision Env's "copy constructor" does not update the manager with the copied world objects (by calling the notify function). This leads to an empty collision environment when planning a trajectory.

This is the constructor called in https://github.com/ros-planning/moveit/blob/master/moveit_core/planning_scene/src/planning_scene.cpp#L393-L397

which is used by the planning_scene_monitor to keep the move_group scene updated.

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #2830 (d45a675) into master (e1f6c6a) will increase coverage by 0.07%.
The diff coverage is 100.00%.

❗ Current head d45a675 differs from pull request most recent head 40adcf5. Consider uploading reports for the commit 40adcf5 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2830      +/-   ##
==========================================
+ Coverage   60.88%   60.94%   +0.07%     
==========================================
  Files         368      373       +5     
  Lines       31715    31725      +10     
==========================================
+ Hits        19306    19332      +26     
+ Misses      12409    12393      -16     
Impacted Files Coverage Δ
...sion_detection_bullet/src/collision_env_bullet.cpp 85.12% <100.00%> (+5.48%) ⬆️
.../ompl_interface/src/detail/constrained_sampler.cpp 43.25% <0.00%> (-16.21%) ⬇️
...meterization/work_space/pose_model_state_space.cpp 80.51% <0.00%> (-2.51%) ⬇️
...ipulation/pick_place/src/manipulation_pipeline.cpp 69.45% <0.00%> (-1.85%) ⬇️
...raint_samplers/src/default_constraint_samplers.cpp 80.42% <0.00%> (-0.29%) ⬇️
...lude/moveit/collision_detection/collision_plugin.h 100.00% <0.00%> (ø)
...et/src/collision_detector_bullet_plugin_loader.cpp 100.00% <0.00%> (ø)
...tection_fcl/collision_detector_fcl_plugin_loader.h 100.00% <0.00%> (ø)
...n_bullet/collision_detector_bullet_plugin_loader.h 100.00% <0.00%> (ø)
...n_fcl/src/collision_detector_fcl_plugin_loader.cpp 100.00% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1f6c6a...40adcf5. Read the comment docs.

@yurirocha15
Copy link
Contributor Author

yurirocha15 commented Aug 21, 2021

@v4hn I added the tests in the planning_scene folder as I believe they are related to the child scene collision environment not being correctly updated (when using Bullet). I created the same test for FCL as well. I verified that the test fails before this fix and passes after it.

As I had to add the bullet dependency to the tests, I also replicated the FCL multithreaded test (as #2598 made Bullet thread-safe).

@yurirocha15
Copy link
Contributor Author

yurirocha15 commented Aug 22, 2021

RoboStack's Windows build cannot find bullet:

-- Checking for module 'bullet'
--   No package 'bullet' found
-- Could NOT find Bullet: Found unsuitable version "", but required is at least "2.87" (found )
-- Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.

Because of this BULLET_INC is not being set which leads to a build error:

fatal error C1083: Cannot open include file: 'moveit/collision_detection_bullet/collision_detector_allocator_bullet.h': No such file or directory

Any suggestions on how to proceed from here?

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Bullet code should be disregarded if Bullet was not found.

@@ -14,6 +14,7 @@ target_link_libraries(${MOVEIT_LIB_NAME}
moveit_exceptions
moveit_transforms
moveit_collision_detection_fcl
moveit_collision_detection_bullet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lib shouldn't be added explicitly here as it is a plugin!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove it, the tests fail to compile as they cannot find the collision_detection::CollisionDetectorAllocatorBullet definition. I thought it was ok to link bullet here as there is a link for fcl already, but I guess that this plugin wouldn't exist if Bullet was not available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it (c7df778) to a conditional based on whether -DBULLET_ENABLE was defined or not.

if(BULLET_ENABLE)
    set(BULLET_LIB moveit_collision_detection_bullet)
endif()

target_link_libraries(${MOVEIT_LIB_NAME}
  moveit_robot_model
  moveit_robot_state
  moveit_exceptions
  moveit_transforms
  moveit_collision_detection_fcl
  ${BULLET_LIB}
  moveit_kinematic_constraints
...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, you would load the plugin via the plugin mechanism instead of instantiating it directly ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

Comment on lines 47 to 48
#include <moveit/collision_detection_bullet/collision_detector_allocator_bullet.h>
#include <moveit/collision_detection_bullet/collision_env_bullet.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These includes are not available when Bullet is not available. You need to conditionally include them!
My suggestion is to add add_definitions(-DBULLET_ENABLE) here and in c++ code use:

#ifdef BULLET_ENABLE
...
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion! Added in 2433753

@rhaschke
Copy link
Contributor

I will have a look into the remaining CI failure. Seems to be related to clang being used as the compiler...

@yurirocha15
Copy link
Contributor Author

yurirocha15 commented Aug 23, 2021

I will have a look into the remaining CI failure. Seems to be related to clang being used as the compiler...

I ran industrial_ci locally and was able to fix it. I believe it was related to the compiler resetting the class_loader ptr first and then resetting the planning_scene ptrs (maybe trying to access the deleted BulletPlugin at destruction?). After explicitly setting the destruction order the segmentation fault disappeared (at least when running locally), Hopefully, it will pass now.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid code duplication in tests, I provided https://github.com/makinarocks/moveit/pull/2 with more simplifications. However, this relies on #2834.
Otherwise, I approve.

@yurirocha15
Copy link
Contributor Author

@rhaschke as #2834 was merged, I cherry-picked the commits from https://github.com/makinarocks/moveit/pull/2 and rebased the branch on top of master.

@rhaschke
Copy link
Contributor

rhaschke commented Sep 1, 2021

I pushed another commit to https://github.com/makinarocks/moveit/pull/2 to fix the gtest compatibility issues: https://github.com/makinarocks/moveit/pull/2/commits/893e63f2a1b1769343532d353f5c5b84c1de742a

@rhaschke rhaschke merged commit e808fb0 into moveit:master Sep 1, 2021
@yurirocha15 yurirocha15 deleted the bugfix/fix-bullet-constructor branch September 1, 2021 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants