Ask Your Question
3

Custom state sampler in MoveIt!

asked 2018-07-04 09:01:18 -0600

mxch_18 gravatar image

Hello everyone,

I'm using MoveIt! with ROS Kinetic on Ubuntu 16.04 Xenial to plan the motion of a climbing legged robot. I want to try using sample-based planners to produce a feasible complete joint path/trajectory. To do that I need to create a custom state sampler, because in my application I can't rely on rejection-sampling to find suitable new states.

I have read the MoveIt! custom constraint sampler tutorial page, but I guess it is still incomplete, because I can't find the

ROBOT_moveit_plugins/ROBOT_moveit_constraint_sampler_plugin

template that they talk about.

I have also taken a look at the MoveIt! planning with approximated constraint manifolds but, from what I understand, that is not what I want.

I wish to program in C++. I am not unfamiliar with the OMPL library (so such a thing doesn't scare me), but I'm very far from being an expert. My guess is that I need to repeat the procedure provided in the last link, and somehow make it so MoveIt! knows to use this sampler instead of the default one.

So my question is: how can I implement a custom sampler to use in the MoveIt! framework? I say "custom" in the sense that my sampler will use a specific method to produce valid new states without having to rely extensively on rejection-sampling.

Any input is appreciated.

Best, Maxens

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
5

answered 2018-07-19 04:22:14 -0600

mxch_18 gravatar image

Hello again,

I figured it out, so I thought I would come back to share my solution. I hope it can help other people.

As of today (July 2018), the solution to implementing a new sampler (or a planner for that matter) in MoveIt works as follow:

  1. Build MoveIt from source. Just follow the instructions on MoveIt website. I tested with ROS Kinetic. (As long as you later use an OMPL version that is compatible with your ROS distro, everything should work fine)
  2. Delete the OMPL binaries that should have been installed by the procedure in the previous link. To do that I used sudo apt-get remove and sudo apt-get purge on the libompl-dev package.
  3. Download/Checkout OMPL source code. You can use their BitBucket repository, in the "Download" section, in the "Branches" tab, you can find archives containing source code compatible with your ROS distro. Put the source code in the same catkin workspace as your MoveIt source.
  4. Modify OMPL source code as you need. You can find tutorials about adding planners/samplers on their website.
  5. Modify MoveIt source code. If you added a planner, you need to do that. It shouldn't be needed if you just added a new sampling strategy. Modify planning_context_manager.h and planning_context_manager.cpp to add your planner just like the original ones. This comes from this webarchive.
  6. Change install target folder in the CMakeLists.txt that can be found in ../ompl/src/ompl/CMakeList.txt. On line 83, you should change ${CMAKE_INSTALL_LIBDIR} to the path where the OMPL binaries are usually installed (their names are libompl.so or libompl.so.version_number). For example, on my system, it was /opt/ros/kinetic/lib/x86_64_linux_gnu. This step can be avoided if you understand CMake and source building better than me. You can probably tell catkin to link to the right place (some build or include folder in the workspace) while building MoveIt, but I don't know how to do that.
  7. sudo catkin build. You need sudo because it will install the libs in /opt. I know this is unsafe, and I guess it shows that I don't really know what I'm doing. But it worked for me.
  8. Modify ompl_planning.yaml. This is quite trivial. Please follow the last step from the webarchive linked above.

That's it. I'm pretty sure most steps are useless to someone who understands build systems but that's what solved my problem.

edit flag offensive delete link more

Comments

I think the whole "put OMPL source in the same workspace" is actually not needed. You could just put it somewhere else and set some CMake variable to point to the right place at compile time, but I don't know how to do that.

mxch_18 gravatar imagemxch_18 ( 2018-07-19 04:24:24 -0600 )edit
0

answered 2019-05-14 03:54:45 -0600

How do you implement the fourth and fifth steps?

edit flag offensive delete link more

Comments

Please ask your questions in the comment of the other answer, you can click the "add a comment" button to do that.

BryceWilley gravatar imageBryceWilley ( 2019-05-14 08:23:16 -0600 )edit
-1

answered 2018-09-07 22:12:18 -0600

Rob.Chen gravatar image

updated 2018-09-07 22:58:38 -0600

Hello! Thanks for your solution first, and i have done much jobs after following your solution , but i have one problem at step 7, after i type "sudo catkin build", and the error is show as follow:

Errors << moveit_planners_ompl:make         
/home/logan/ws_moveit/logs/moveit_planners_ompl/build.make.012.log
/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/libmoveit_ompl_interface.so.0.9.12: undefined reference to `ompl::geometric::myPlanner::myPlanner(std::shared_ptr<ompl::base::SpaceInformation> const&, bool)'
/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/libmoveit_ompl_interface.so.0.9.12: undefined reference to `ompl::geometric::myPlanner::~myPlanner()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/moveit_planners_ompl/moveit_ompl_planner] Error 1
make[1]: *** [ompl_interface/CMakeFiles/moveit_ompl_planner.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/libmoveit_ompl_interface.so.0.9.12: undefined reference to `ompl::geometric::myPlanner::myPlanner(std::shared_ptr<ompl::base::SpaceInformation> const&, bool)'
/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/libmoveit_ompl_interface.so.0.9.12: undefined reference to `ompl::geometric::myPlanner::~myPlanner()'
collect2: error: ld returned 1 exit status    
make[2]: ***     [/home/logan/ws_moveit/devel/.private/moveit_planners_ompl/lib/moveit_planners_ompl/moveit_demo_construct_constraints_database] Error 1
make[1]: *** [ompl_interface/CMakeFiles/moveit_demo_construct_constraints_database.dir/all] Error 2
make: *** [all] Error 2
cd /home/logan/ws_moveit/build/moveit_planners_ompl; catkin build --get-env moveit_planners_ompl | catkin env -si /usr/bin/make --jobserver-fds=6,7 -j; cd -

the new planner "myPlanner" is just copied from "ompl/src/ompl/geometric/planners/prm", and i have changed all the file's name by "myPlanner" , i want to know how to add a planner by myself. And i know the problem is appeared after i add the header file that defines the new planner and register the new planner in the registerDefaultPlanners() function in "src/moveit_planners/ompl/ompl_interface/src/planning_context_manager.cpp" file. the ompl can cmake and make install success, and i if i remove the content what i add in "planning_context_manager.cpp" file, the ws_moveit workspace can be build success.

If you know some solution about this problem, please help me, thank you very much!

edit flag offensive delete link more

Comments

I figure it out, copy the three "libompl" file from /opt/ros/kinetic/lib/x86_64_linux_gnu to /opt/ros/kinetic/lib/, but i am confused about it, because we have at step 6, we change the install directory, so the three "libompl" file can be installed in /opt/ros/kinetic/lib/x86_64_linux_gnu,

Rob.Chen gravatar imageRob.Chen ( 2018-09-08 05:53:03 -0600 )edit

but it is still not enough, or maybe we should try change the CMAKE_INSTALL_LIBDIR to /opt/ros/kinetic/lib/ directly.

Rob.Chen gravatar imageRob.Chen ( 2018-09-08 05:54:25 -0600 )edit

i just verified my idea, i changed the CMAKE_INSTALL_LIBDIR to /opt/ros/kinetic/lib/, and these three "libompl*" file just appeared in /opt/ros/kinetic/lib/ file, and then:

cd ~/ws_moveit
sudo catkin build

and every thing is going fine!

Rob.Chen gravatar imageRob.Chen ( 2018-09-08 06:53:20 -0600 )edit

Glad that you found a solution!

mxch_18 gravatar imagemxch_18 ( 2018-09-09 05:37:36 -0600 )edit
1

Please don't ask new questions in an answer, it's not how this site works. For posterity, the question you (correctly) posted: https://answers.ros.org/question/3027...

fvd gravatar imagefvd ( 2018-09-09 19:39:37 -0600 )edit

I am sorry, i am just too eager to know the answer, and i will remember your suggestion, thanks.

Rob.Chen gravatar imageRob.Chen ( 2018-09-09 20:09:42 -0600 )edit

Your Answer

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

Add Answer

Question Tools

3 followers

Stats

Asked: 2018-07-04 08:54:18 -0600

Seen: 732 times

Last updated: Sep 07 '18