@@ -103,8 +103,10 @@ def init_planner(self):
103103 self .attached_collision_object_topic .advertise ()
104104
105105 def dispose_planner (self ):
106- self .collision_object_topic .unadvertise ()
107- self .attached_collision_object_topic .unadvertise ()
106+ if hasattr (self , 'collision_object_topic' ) and self .collision_object_topic :
107+ self .collision_object_topic .unadvertise ()
108+ if hasattr (self , 'attached_collision_object_topic' ) and self .attached_collision_object_topic :
109+ self .attached_collision_object_topic .unadvertise ()
108110
109111 # ==========================================================================
110112 # planning services
@@ -151,7 +153,7 @@ def forward_kinematics_async(self, callback, errback, joint_positions, base_link
151153 def plan_cartesian_motion_async (self , callback , errback , frames , base_link ,
152154 ee_link , group , joint_names , joint_types ,
153155 start_configuration , max_step , jump_threshold ,
154- avoid_collisions , path_constraints ,
156+ avoid_collisions , path_constraints ,
155157 attached_collision_meshes ):
156158 """Asynchronous handler of MoveIt cartesian motion planner service."""
157159 header = Header (frame_id = base_link )
@@ -299,6 +301,9 @@ def append_collision_mesh(self, collision_mesh):
299301 self ._collision_object (co , CollisionObject .APPEND )
300302
301303 def _collision_object (self , collision_object , operation = CollisionObject .ADD ):
304+ if not hasattr (self , 'collision_object_topic' ) or not self .collision_object_topic :
305+ self .init_planner ()
306+
302307 collision_object .operation = operation
303308 self .collision_object_topic .publish (collision_object .msg )
304309
@@ -315,5 +320,8 @@ def remove_attached_collision_mesh(self, id):
315320 return self ._attached_collision_object (aco , operation = CollisionObject .REMOVE )
316321
317322 def _attached_collision_object (self , attached_collision_object , operation = CollisionObject .ADD ):
323+ if not hasattr (self , 'attached_collision_object_topic' ) or not self .attached_collision_object_topic :
324+ self .init_planner ()
325+
318326 attached_collision_object .object .operation = operation
319327 self .attached_collision_object_topic .publish (attached_collision_object .msg )
0 commit comments