@@ -241,24 +241,36 @@ def main(self, node_name, node_topic_namespace, wait_for_first_pointcloud=True):
241241 rospy .signal_shutdown ('Unable to connect to arm action server. Timeout exceeded.' )
242242 sys .exit ()
243243
244- self ._joint_states_subscriber = rospy .Subscriber ('/stretch/joint_states' , JointState , self ._joint_states_callback )
245-
244+ if self .robot_name == None :
245+ self ._joint_states_subscriber = rospy .Subscriber ('/stretch/joint_states' , JointState , self ._joint_states_callback )
246+ else :
247+ self ._joint_states_subscriber = rospy .Subscriber ('/' + self .robot_name + '/joint_states' , JointState , self ._joint_states_callback )
248+
246249 self .tf2_buffer = tf2_ros .Buffer ()
247250 self .tf2_listener = tf2_ros .TransformListener (self .tf2_buffer )
251+ if self .robot_name == None :
252+ self ._tool_subscriber = rospy .Subscriber ('/tool' , String , self ._tool_callback )
253+ self ._mode_subscriber = rospy .Subscriber ('/mode' , String , self ._mode_callback )
254+ self .point_cloud_subscriber = rospy .Subscriber ('/camera/depth/color/points' , PointCloud2 , self ._point_cloud_callback )
255+ else :
256+ self ._tool_subscriber = rospy .Subscriber ('/' + self .robot_name + '/tool' , String , self ._tool_callback )
257+ self ._mode_subscriber = rospy .Subscriber ('/' + self .robot_name + '/mode' , String , self ._mode_callback )
258+ self .point_cloud_subscriber = rospy .Subscriber ('/' + self .robot_name + '/camera/depth/color/points' , PointCloud2 , self ._point_cloud_callback )
248259
249- self ._tool_subscriber = rospy .Subscriber ('/tool' , String , self ._tool_callback )
250- self ._mode_subscriber = rospy .Subscriber ('/mode' , String , self ._mode_callback )
251-
252- self .point_cloud_subscriber = rospy .Subscriber ('/camera/depth/color/points' , PointCloud2 , self ._point_cloud_callback )
253260 self .point_cloud_pub = rospy .Publisher ('/' + node_topic_namespace + '/point_cloud2' , PointCloud2 , queue_size = 1 )
254261
255262 rospy .wait_for_service ('/home_the_robot' )
256263 rospy .wait_for_service ('/stow_the_robot' )
257264 rospy .wait_for_service ('/stop_the_robot' )
258265 rospy .loginfo ('Node ' + self .node_name + ' connected to robot services.' )
259- self .home_the_robot_service = rospy .ServiceProxy ('/home_the_robot' , Trigger )
260- self .stow_the_robot_service = rospy .ServiceProxy ('/stow_the_robot' , Trigger )
261- self .stop_the_robot_service = rospy .ServiceProxy ('/stop_the_robot' , Trigger )
266+ if self .robot_name == None :
267+ self .home_the_robot_service = rospy .ServiceProxy ('/home_the_robot' , Trigger )
268+ self .stow_the_robot_service = rospy .ServiceProxy ('/stow_the_robot' , Trigger )
269+ self .stop_the_robot_service = rospy .ServiceProxy ('/stop_the_robot' , Trigger )
270+ else :
271+ self .home_the_robot_service = rospy .ServiceProxy ('/' + self .robot_name + '/home_the_robot' , Trigger )
272+ self .stow_the_robot_service = rospy .ServiceProxy ('/' + self .robot_name + '/stow_the_robot' , Trigger )
273+ self .stop_the_robot_service = rospy .ServiceProxy ('/' + self .robot_name + '/stop_the_robot' , Trigger )
262274
263275 if wait_for_first_pointcloud :
264276 # Do not start until a point cloud has been received
0 commit comments