Rosanswers logo


I am trying to create a planner plugin within MoveIt, based on the CHOMP Planner already implemented. For this I need a distance function which returns the minimum distance between robot and environment, which DistanceToCollision provides. In order for the obstacles to be recognized and to avoid:


I use planning_scene_interface_.getObjects(). All of this works when the c++ code is run with moveit running, however when added to the planner this line causes an infinite loop, perhaps because the PlanningSceneInterface requires move_group, and the planner is run from it.

What could be done to solve this? Or alternatively is there another function that calculates distance to environment which does not require the PlanningSceneInterface and would work in the planner?

Thank you in advance.

Originally posted by Guenther on ROS Answers with karma: 3 on 2017-01-16

Post score: 0

Original comments

Comment by gvdhoorn on 2017-01-31:
This is actually a cross-post of ros-planning/moveit#430.

Comment by zubair on 2019-01-07:
hi, which sensor did you use !! @Guenther


1 Answer 1


Rosanswers logo

Assuming that the "planning_scene" object has been updated to reflect the current state of the environment then you can use the checkCollision method, by setting the CollisionRequest.distance = true. The returned CollisionResult struct contains a map with the objects that collided and the shortest distance. Alternatively, you can use the distanceToCollision method.

Originally posted by jrgnicho with karma: 486 on 2017-01-31

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by Guenther on 2017-02-01:
Yes, you are correct. The problem was a planning scene that had not been updated. The planning_scene_interface is not intended to be used within a planner that is running as part of the move_group node, hence the errors. As gvdhoorn mentioned more details can be found at the moveit issue.

Comment by alavin89 on 2018-01-24:
This correctly gives you the single closest distance to collision. I'm curious though, @jrgnicho is there a way to get a distance value for each robot link? https://answers.ros.org/question/280521/moveit-planning-how-can-i-get-a-collision-distance-field-from-a-planningscene/

Comment by jrgnicho on 2018-02-12:
@alavin89 I believe this feature is a work in progress at the moment, see here

Comment by alavin89 on 2018-04-19:
looks like it was just merged!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.