0
$\begingroup$

Using something like

from moveit.planning import MoveItPy
robot = MoveItPy(node_name="moveit_py")
psm = robot.get_planning_scene_monitor()
psm.start_scene_monitor("/planning_scene")
psm.start_state_monitor("/joint_states", "/attached_collision_object")
with psm.read_write() as planning_scene:
   planning_scene.apply_collision_object(collision_object, color)

I do not see any changes to what is shown in RViz.

Is the issue that I also need to call startPublishingPlanningScene so that my collision objects are actually published? Do I understand correctly that there is no Python API for that? Anything else I should or could do? Perhaps manually publish to /attached_collision_object or some other relevant topic?

For moveit 1, there seems to be https://github.com/moveit/moveit/blob/master/moveit_commander/src/moveit_commander/planning_scene_interface.py, but nothing similar for MoveIt2?

$\endgroup$

1 Answer 1

0
$\begingroup$

You should add planning_scene.current_state.update() after apply_collision_object call.

EDIT: The attached collision objects are stored inside the robot state of the planning scene. If an object is attached to the scene, the robot state needs to be explicitly updated with the call above so that link and collision body transforms take effect. See PlanningScene::processAttachedCollisionObjectMsg and RobotState::update methods.

$\endgroup$
2
  • $\begingroup$ Welcome to Robotics tahsin kose. Thanks for your answer but we are looking for comprehensive answers that provide some explanation and context. Very short answers cannot do this, so please edit your answer to explain why it is right, ideally with citations. Answers that don't include explanations may be removed. See How to Answer for more info. $\endgroup$ Commented Jun 13 at 13:07
  • $\begingroup$ Can you explain why, what does planning_scene.current_state.update() do? $\endgroup$ Commented Jun 16 at 8:19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.