Remapping using roslaunch python API

asked 2019-04-10 11:48:47 -0500

john_goni gravatar image

updated 2019-04-11 05:39:32 -0500

I am using roslaunch API to call two SLAM launcher one after the other. This is my code

#!/usr/bin/env python
import roslaunch
import rospy



if __name__=='__main__':


     rospy.init_node('launch_manipulation', anonymous = True)
     uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
     roslaunch.configure_logging(uuid)
     launch1 = roslaunch.parent.ROSLaunchParent(uuid, ["/home/john/catkin_ws/src/crsm-slam-ros-pkg/crsm_slam/launch/crsm_slam_simulation.launch"])
     launch2 = roslaunch.parent.ROSLaunchParent(uuid, ["/home/john/catkin_ws/src/hector_slam/hector_mapping/launch/mapping_default.launch"])
     rospy.loginfo("~~~~~~~~~~~~********CRSM IS ON********~~~~~~~~~~~~")
     launch1.start()

     rospy.sleep(20)
     #3 seconds later
     launch1.shutdown()

         launch2.start()
     rospy.loginfo("~~~~~~~~~~~~********HECTOR IS ON*********~~~~~~~~~~~~")
     rospy.sleep(10)
     launch2.shutdown()

So when I see the maps that each SLAM produces on rviz I have to change manually the map topic in order to see second SLAM's output.I know that I can remap the topic from a string to another, but every slam has its own topic. Therefore, I would need to know the previous topic, in order to do the remap each time. Is there a way through which I can take the topic (whichever that is) and change it to the desired one?

edit retag flag offensive close merge delete