moveit
moveit copied to clipboard
PlanningSceneInterface::clearScene()
The best reliable way I know for user nodes to remove all objects from the planning scene is this:
moveit::planning_interface::PlanningSceneInterface psi;
moveit_msgs::PlanningScene rm;
rm.is_diff = true;
rm.robot_state.is_diff = true;
rm.robot_state.attached_collision_objects.resize(1);
rm.robot_state.attached_collision_objects[0].object.operation = moveit_msgs::CollisionObject::REMOVE;
rm.world.collision_objects.resize(1);
rm.world.collision_objects[0].operation = moveit_msgs::CollisionObject::REMOVE;
psi.applyPlanningScene(rm);
I would propose to simplify this to
moveit::planning_interface::PlanningSceneInterface psi;
psi.clearScene();
Opinions? Additions? Alternatives?
I am all for this - in fact, it already exists in Python and the function should be linked if a C++ implementation is added.
PlanningScene has a removeAllCollisionObjects()
method. Doesn't that work in this case? The planning_interface does not work with MoveItCpp I believe, but then the PlanningScene can be accessed through the PlanninSceneMonitor. So removeAllCollisionObjects()
works for both MoveGroupInterface and MoveItCpp.
PlanningScene has a
removeAllCollisionObjects()
method. Doesn't that work in this case?
Using the MGI/PSI you usually interact with the PlanningScene of a move_group
ROS node.
You don't have access to this method of the C++ PlanningScene class from outside the node and the PSM does not help with that.
For MoveItCpp I agree though.
Hi, I am new to open source contributing if this issue still exists, I would like to work on it.
If yes, then can the simple steps stated below be included in the PSI to create a function in PSI and then just psi.clearScene()
Would that be a viable solution?
The best reliable way I know for user nodes to remove all objects from the planning scene is this:
moveit::planning_interface::PlanningSceneInterface psi; moveit_msgs::PlanningScene rm; rm.is_diff = true; rm.robot_state.is_diff = true; rm.robot_state.attached_collision_objects.resize(1); rm.robot_state.attached_collision_objects[0].object.operation = moveit_msgs::CollisionObject::REMOVE; rm.world.collision_objects.resize(1); rm.world.collision_objects[0].operation = moveit_msgs::CollisionObject::REMOVE; psi.applyPlanningScene(rm);
@aaryanmurgunde, you are very welcome to work on this. Concrete TODOs:
- [ ] Wrap the listed code snippet into a new function in
PlanningSceneInterface::clear()
. - [ ] Optionally use that function also in python code as suggested here
- [ ] Test everything. Ideally, provide a new unit test for it.
@aaryanmurgunde, you are very welcome to work on this. Concrete TODOs:
- [x] Wrap the listed code snippet into a new function in
PlanningSceneInterface::clear()
.- [ ] Optionally use that function also in python code as suggested here
- [x] Test everything. Ideally, provide a new unit test for it.
@rhaschke I'm not sure about the wrapper for python if you could help me understand that then I can build for the same as well.
Thank You : )
Just use the newly implemented function in python, i.e. call self._psi.clear()
. This requires clear
to be exposed by the python wrapper of PlanningSceneInterface
.
@rhaschke For the python wrapper file wrapper_python_planning_scene_interface.cpp on line L112 adding
+ bool clearPython()
+ {
+ return clear();
+ }
and on line L126
+ planning_scene_class.def("clear", &PlanningSceneInterfaceWrapper::clearPython);
and in the planning_scene_interface.py on line L171
# replace
- self.remove_attached_object()
- self.remove_world_object()
# with
+ self._psi.clear()
Any other changes that need to made ?
I suffices to define the wrapper like this (no need to define clearPython()
):
- planning_scene_class.def("clear", &PlanningSceneInterfaceWrapper::clearPython);
+ planning_scene_class.def("clear", &PlanningSceneInterfaceWrapper::clear);
- [x] Wrap the listed code snippet into a new function in
PlanningSceneInterface::clear()
.- [x] Optionally use that function also in python code as suggested here
- [x] Test everything. Ideally, provide a new unit test for it.
Done! pushed a commit for that as well.
Thank you so much for helping me out @rhaschke. It has been a big learning curve, I'm now much more prepared to work more on fixing issues and contributing to Open Source.
Let's Close this issue then @rhaschke ?
This issue will be closed via #2764.