Angelo D'Amante
Angelo D'Amante

Reputation: 13

What are the differences between exec and name in ros2 launch file?

I'am a ros2 noob and I would like to understand differences between exec and name in launch file.

I'll give an example to be precise:

<launch>
    <node pkg="camera" exec="" name="">
</launch>

Thanks!

Upvotes: 0

Views: 505

Answers (1)

Ryan Friedman
Ryan Friedman

Reputation: 366

  • exec: The filename of the executable
  • name: The name that ros2 node list shows

For example, from the tutorial comparison in launch files:

There is a line that sets both name and exec

<node pkg="turtlesim" exec="turtlesim_node" name="sim" namespace="turtlesim2">

When I created a package to run that, here's what happens.

$ ros2 node list
/listener
/mimic
/my/chatter/ns/listener
/my/chatter/ns/talker
/talker
/turtlesim1/sim
/turtlesim2/sim

You can see how the node name shows up, with an extra caveat - because namespace was also added, it appears as <namespace>/<name>.

Now, for the executable, you can just go see that in your ROS installation directory. For example, on my Linux computer running humble, there's the executable. I added -l to show it's executable.

$ ls -l /opt/ros/humble/lib/turtlesim/turtlesim_node 
-rwxr-xr-x 1 root root 798384 Jan 17 18:00 /opt/ros/humble/lib/turtlesim/turtlesim_node

An easy way to find out the executables in your package is through tab complete with ros2 pkg executables <package_name>

$ ros2 pkg executables turtlesim
turtlesim draw_square
turtlesim mimic
turtlesim turtle_teleop_key
turtlesim turtlesim_node

The reason you have both is because you may re-use the same executable multiple times in a DDS domain, so the name , or namespace, can be used to differentiate them.

Upvotes: 0

Related Questions