Running a node (ros2 run)
The most basic way of running a Node is using the ROS2 tool ros2 run.
More information on it can be obtained through
ros2 run -h
which returns the most relevant arguments package_name
and executable_name
.
usage: ros2 run [-h] [--prefix PREFIX] package_name executable_name ...
Run a package specific executable
positional arguments:
package_name Name of the ROS package
executable_name Name of the executable
argv Pass arbitrary arguments to the executable
options:
-h, --help show this help message and exit
--prefix PREFIX Prefix command, which should go before the executable. Command must be wrapped
in quotes if it contains spaces (e.g. --prefix 'gdb -ex run --args').
Back to our example, with a properly sourced terminal, the example node can be executed with
ros2 run python_package_with_a_node sample_python_node
which will now correctly output
Hi from python_package_with_a_node.