ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

launch other launch files and ROS nodes

asked 2016-07-07 22:21:48 -0500

Morefoam gravatar image

updated 2018-01-28 08:45:24 -0500

130s gravatar image

Hello, I am new to ROS and the launch file syntax is scary. I want to launch all of these together:

-roslaunch turtlebot_gazebo turtlebot_world.launch

-roslaunch turtlebot_gazebo gmapping_demo.launch

-roslaunch turtlebot_rviz_launchers view_robot.launch

-roslaunch turtlebot_teleop keyboard_t...

-rosbag record -a

My question is: Can a launch file do this? or how would i go about making this executable by typing in "roslaunch <filename>.launch" into a terminal?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2016-07-08 04:25:04 -0500

Caba gravatar image

To launch all together you have simply to include all the launch files into a single launch file. (Take a look to this ).

Regarding the rosbag check this answer, the xml syntax for rosbag record -ais: <node pkg="rosbag" type="record" name="recorder" output="screen" args="-a"/> (in "args" you can put all the arguments for that command)

So the whole launch file to launch all you need is:

<launch>

   <include file="$(find turtlebot_gazebo)/launch/turtlebot_world.launch"/>
   <include file="$(find turtlebot_gazebo)/launch/gmapping_demo.launch"/>
   <include file="$(find turtlebot_rviz_launchers)/launch/view_robot.launch"/>
   <include file="$(find turtlebot_teleop)/launch/keyboard_t.launch"/>

   <!-- 
     The rosbag will be saved in the ~./ros folder
   -->
   <node pkg="rosbag" type="record" name="recorder" output="screen" args="-a"/>    
</launch>

Now you can launch it from the terminal as a normal launch file.

edit flag offensive delete link more

Comments

This was a more helpful answer than I expected! Thanks for the links as well as the xml example! :)

Morefoam gravatar image Morefoam  ( 2016-07-08 16:10:00 -0500 )edit

One more question: I need to somehow link my launch file to somewhere so that I don't have to be in the launch directory to launch it. I believe I learned how to do this in the tutorials, but as I'm searching through them again I don't see it. I'm gonna keep looking, but help would be appreciated.

Morefoam gravatar image Morefoam  ( 2016-07-08 16:15:06 -0500 )edit

You can launch it from whatever folder you are in, just type:

roslaunch <name_package> file.launch

If you use roslaunch file.launch you have to be in the launch folder of the package.

I am not completely understing your question, is this what you mean?

Caba gravatar image Caba  ( 2016-07-08 16:29:36 -0500 )edit

I figured it out. Thanks for the help. I have another question, though. Is there a way to make the bag file save to a specified folder? How do I change "<node pkg="rosbag" type="record" name="recorder" output="screen" args="-a"/>" to make it save to a specified location?

Morefoam gravatar image Morefoam  ( 2016-07-08 18:44:04 -0500 )edit

<arg name="FOLDER" default="/home/nicola/test/"/> <node pkg="rosbag" type="record" name="recorder" output="screen" args="-a -o $(arg FOLDER)"/>

Caba gravatar image Caba  ( 2016-07-09 01:56:55 -0500 )edit

The "arg" stuff is like creating a variable. When you launch the file you can pass the name of the folder as parameter (roslaunch name_package launnch_file FOLDER:=new_folder) otherwise it will use the one specified in the default tag. See here for more opts

Caba gravatar image Caba  ( 2016-07-09 01:59:37 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-07-07 22:21:48 -0500

Seen: 2,822 times

Last updated: Jan 28 '18