Difference between revisions of "Getting Started with ROS on Embedded Systems/User Guide/C++/Launch files"

From RidgeRun Developer Connection
Jump to: navigation, search
(Created page with "{{Getting Started with ROS on Embedded Systems/Head|previous=User Guide/C++/Publishers_and_subscribers|next=User Guide/C++/Parameters|keywords=ROS}} == Introduction == This w...")
 
m (Examples)
Line 10: Line 10:
  
 
== Examples ==
 
== Examples ==
 +
 +
Simple launch file with parameter loading
 +
 +
<syntaxhighlight lang="xml">
 +
 +
<launch>
 +
  <group ns="group_namespace">
 +
    <rosparam command="load" file="$(find node_package)/configuration/node_parameters.yaml" ns="node_parameters_namespace"/>
 +
    <node name="$(arg node_name)" pkg="node_package" type="listener" required="true" output="screen"/>
 +
  </group>
 +
</launch>
 +
 +
</syntaxhighlight>
 +
 +
# This launch file receives one parameter, the node name as an argument.
 +
# This will create a node under group_namespace/node_name, and all the logs will be output into the caller terminal.
 +
# This should also load the parameters yaml file inside the node_parameters_namespace/ namespace.
 +
# You can add more nodes in this launch file too, the only requirement is that these have different name.
 +
 +
The launch files should be located inside a launch subfolder inside each package.
 +
 +
The to launch it, you can use
 +
 +
<syntaxhighlight lang="bash">
 +
roslaunch <package name> <launch file> node_name:=my_node
 +
</syntaxhighlight>

Revision as of 14:34, 10 November 2021




Previous: User Guide/C++/Publishers_and_subscribers Index Next: User Guide/C++/Parameters




Introduction

This wiki is based on the following pages:

  1. http://wiki.ros.org/roslaunch
  2. http://wiki.ros.org/roslaunch/XML

ROS launch files are XML files that used with the roslaunch tools, eases the launching of multiple nodes, with multiple configurations. This makes it easier to have for example more than one node running, you don't need to have the roscore running, and you can ease node grouping, topic renaming, node naming, parameter loading, and many other things by using this tool.

Examples

Simple launch file with parameter loading

<launch>
  <group ns="group_namespace">
    <rosparam command="load" file="$(find node_package)/configuration/node_parameters.yaml" ns="node_parameters_namespace"/>
    <node name="$(arg node_name)" pkg="node_package" type="listener" required="true" output="screen"/>
  </group>
</launch>
  1. This launch file receives one parameter, the node name as an argument.
  2. This will create a node under group_namespace/node_name, and all the logs will be output into the caller terminal.
  3. This should also load the parameters yaml file inside the node_parameters_namespace/ namespace.
  4. You can add more nodes in this launch file too, the only requirement is that these have different name.

The launch files should be located inside a launch subfolder inside each package.

The to launch it, you can use

roslaunch <package name> <launch file> node_name:=my_node