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

port of bullet collision to ros2 #322

Merged
merged 10 commits into from
Mar 10, 2021

Conversation

jrgnicho
Copy link
Contributor

Description

Port of bullet collision module to ROS2

@henningkayser please review

@AndyZe
Copy link
Member

AndyZe commented Jan 12, 2021

I'll take a quick look at this since I've been poking around Bullet lately

Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

I don't see anything wrong 👍 but haven't tested it

# endif()
find_package(Bullet 2.87)

# TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life
Copy link
Member

Choose a reason for hiding this comment

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

we're so close to the 16.04 EOL that you could probably drop this (April 2021)

@@ -28,7 +28,7 @@
<depend>assimp</depend>
<depend>boost</depend>
<depend>eigen</depend>
<depend>bullet</depend>
<depend>libbullet-dev</depend>
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be available with rosdep, bullet however is. Were there any issues with the bullet dependency?

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 think at some point I had an issue when I was building in eloquent but I no longer do in foxy

# endif()
find_package(Bullet 2.87)

# TODO(j-petit): Version check can be dropped when Xenial reaches end-of-life
Copy link
Member

Choose a reason for hiding this comment

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

I think we can safely remove this check since bullet is available from Foxy/Focal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean this entire section

   set(BULLET_ENABLE "Bullet")
   set(BULLET_LIB "moveit_collision_detection_bullet")
   set(BULLET_INC "collision_detection_bullet/include")
   message(STATUS "Compiling with Bullet")
 else()
   message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.")
 endif()

?

# else()
# message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.")
# endif()
find_package(Bullet 2.87)
Copy link
Member

Choose a reason for hiding this comment

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

The current version in focal is 2.88 so this should be updated. We could probably also disable the check altogether.

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 think in our meeting we agreed to leave it in this version (2.87). However let me know if you'd prefer I change this.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think we can ignore the case that bullet is not available because MoveIt 2 doesn't support systems older than 20.04 and even with 18.04 bullet is available with the right version. Also, rosdep already installs bullet on the system since it's listed in the package.xml. I would simply add a REQUIRED to the find_package() and remove the BULLET_FOUND check altogether.

@@ -33,6 +33,9 @@

namespace collision_detection_bullet
{

static const rclcpp::Logger BULLET_LOGGER = rclcpp::get_logger("collision_detection.bullet");
Copy link
Member

Choose a reason for hiding this comment

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

It's not ideal to put static const instances in header files like this as it will produce logger instances for all compilation units. Better declare the logger and define a single global instance in a cpp file. We are still at C++14 so using extern would be the best solution for now. With C++17 we should switch to inline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been addressed. I couldn't use extern as I had to declare this global variable in each cpp file that needed it and so having extern would cause a multiple definition build error.

@henningkayser henningkayser added this to In progress in Sprint 00 via automation Jan 19, 2021
@jrgnicho
Copy link
Contributor Author

@henningkayser I've made the requested change, please review

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me code-wise. Were you already able to test this somehow?

# else()
# message(STATUS "Version of Bullet too old or not available: disabling Bullet collision detection plugin. Try using Ubuntu 18.04 or later.")
# endif()
find_package(Bullet 2.87)
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think we can ignore the case that bullet is not available because MoveIt 2 doesn't support systems older than 20.04 and even with 18.04 bullet is available with the right version. Also, rosdep already installs bullet on the system since it's listed in the package.xml. I would simply add a REQUIRED to the find_package() and remove the BULLET_FOUND check altogether.

target_link_libraries(collision_detector_bullet_plugin
${MOVEIT_LIB_NAME}
moveit_planning_scene
)

install(TARGETS ${MOVEIT_LIB_NAME} collision_detector_bullet_plugin
Copy link
Member

Choose a reason for hiding this comment

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

return false;
}
}
bool acmCheck(const std::string& body_1, const std::string& body_2,
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this should be moved to the cpp files. @j-petit could you comment on any potential drawbacks with this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine to move. I simply used the structure which was given in the old tesseract / bullet code.

* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

/* Author: Jorge Nicho*/
Copy link
Member

Choose a reason for hiding this comment

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

Could you also list the original authors of these functions?

@jrgnicho
Copy link
Contributor Author

jrgnicho commented Jan 26, 2021

Looks pretty good to me code-wise. Were you already able to test this somehow?

I haven't, Is there a unit test or demo program I can run?

@jrgnicho
Copy link
Contributor Author

jrgnicho commented Feb 3, 2021

@henningkayser I've made the requested changes
Would you have any recommendations on how to test this change?

@codecov
Copy link

codecov bot commented Feb 3, 2021

Codecov Report

Merging #322 (45b539c) into main (0eb366f) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
+ Coverage   53.23%   53.23%   +0.01%     
==========================================
  Files         209      209              
  Lines       18849    18849              
==========================================
+ Hits        10032    10033       +1     
+ Misses       8817     8816       -1     
Impacted Files Coverage Δ
moveit_ros/moveit_servo/src/servo_calcs.cpp 78.84% <0.00%> (+0.21%) ⬆️

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 0eb366f...16f5666. Read the comment docs.

@AndyZe
Copy link
Member

AndyZe commented Feb 3, 2021

Sorry if this is too obvious but take a look at the Bullet tutorial from MoveIt1.

Bullet tutorial

Source code here:

source code

You should be able to take any MoveIt2 application and switch to Bullet like this, I believe:

planning_scene->setActiveCollisionDetector(collision_detection::CollisionDetectorAllocatorBullet::create());

@jrgnicho
Copy link
Contributor Author

jrgnicho commented Feb 3, 2021

Sorry if this is too obvious but take a look at the Bullet tutorial from MoveIt1.

Bullet tutorial

Source code here:

source code

You should be able to take any MoveIt2 application and switch to Bullet like this, I believe:

planning_scene->setActiveCollisionDetector(collision_detection::CollisionDetectorAllocatorBullet::create());

OK, thanks for providing that link. Looks like I may have to port that example just to test it

@jrgnicho
Copy link
Contributor Author

jrgnicho commented Feb 3, 2021

It looks like ament lint is coming back with an error. How do I run this locally? I tried the directions here with the .clang-tidy file in the moveit2 repo but it didn't find any changes to make.

@AndyZe
Copy link
Member

AndyZe commented Feb 3, 2021

OK, thanks for providing that link. Looks like I may have to port that example just to test it

I don't think you need to do that. Just find an existing example and set it to use Bullet. There must be some unit tests for FCL collisions you could modify?

@henningkayser henningkayser moved this from In progress to Review in progress in Sprint 00 Feb 23, 2021
@jrgnicho
Copy link
Contributor Author

jrgnicho commented Mar 2, 2021

This just passed the CI checks

@jrgnicho
Copy link
Contributor Author

jrgnicho commented Mar 9, 2021

@henningkayser looks like merging caused a build error, I just rebased and resolved the conflicts

Sprint 00 automation moved this from Review in progress to Reviewer approved Mar 10, 2021
@henningkayser henningkayser merged commit c47020c into moveit:main Mar 10, 2021
Sprint 00 automation moved this from Reviewer approved to Done Mar 10, 2021
@jrgnicho
Copy link
Contributor Author

Did anyone get to test this?

@jrgnicho
Copy link
Contributor Author

@henningkayser I'm trying to test using the bullet collision detector in the run_moveit_cpp demo program but I haven't been able to get it to find Bullet from the exports coming from the moveit_core package. I'm far from being a Cmake wizard so I could use some guidance on this, my branch with the demo can be found here
https://github.com/jrgnicho/moveit2/tree/test_bullet_collision_detector

MikeWrock pushed a commit to MikeWrock/moveit2 that referenced this pull request Aug 15, 2022
* Fix to move_group list and change formatting of references to move_group to be consistent

* Run pre-commit

Co-authored-by: JafarAbdi <cafer.abdi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants