@@ -92,6 +92,20 @@ class MoveItPlanner(PlannerBackend):
9292 GetPlanningSceneRequest ,
9393 GetPlanningSceneResponse )
9494
95+ def init_planner (self ):
96+ self .collision_object_topic = Topic (self , '/collision_object' ,
97+ 'moveit_msgs/CollisionObject' , queue_size = None )
98+ self .collision_object_topic .advertise ()
99+
100+ self .attached_collision_object_topic = Topic (
101+ self , '/attached_collision_object' ,
102+ 'moveit_msgs/AttachedCollisionObject' , queue_size = None )
103+ self .attached_collision_object_topic .advertise ()
104+
105+ def dispose_planner (self ):
106+ self .collision_object_topic .unadvertise ()
107+ self .attached_collision_object_topic .unadvertise ()
108+
95109 # ==========================================================================
96110 # planning services
97111 # ==========================================================================
@@ -286,8 +300,7 @@ def append_collision_mesh(self, collision_mesh):
286300
287301 def _collision_object (self , collision_object , operation = CollisionObject .ADD ):
288302 collision_object .operation = operation
289- topic = Topic (self , '/collision_object' , 'moveit_msgs/CollisionObject' )
290- topic .publish (collision_object .msg )
303+ self .collision_object_topic .publish (collision_object .msg )
291304
292305 def add_attached_collision_mesh (self , attached_collision_mesh ):
293306 """Add a collision mesh attached to the robot."""
@@ -303,6 +316,4 @@ def remove_attached_collision_mesh(self, id):
303316
304317 def _attached_collision_object (self , attached_collision_object , operation = CollisionObject .ADD ):
305318 attached_collision_object .object .operation = operation
306- topic = Topic (self , '/attached_collision_object' ,
307- 'moveit_msgs/AttachedCollisionObject' )
308- topic .publish (attached_collision_object .msg )
319+ self .attached_collision_object_topic .publish (attached_collision_object .msg )
0 commit comments