Working with ROS2¶
CLI¶
Node¶
Passing arguments¶
ros2 run <ROS_PACKAGE_NAME> <ROS_NODE_NAME> --ros-args -r <ARG>:=<VALUE> -r <ARG>:=<VALUE>
for example:
ros2 run demo_nodes_cpp talker --ros-args -r __ns:=/demo -r __node:=my_talker -r chatter:=my_topic
will start talker node with name my_talker publishing on the topic named my_topic instead of the default of chatter. The namespace, which must start with a forward slash, is set to /demo, which means that topics are created in that namespace (/demo/my_topic), as opposed to globally (/my_topic).
Launch¶
Get available launch arguments¶
ros2 launch <ROS_PACKAGE_NAME> <LAUNCH_FILE> --show-args
Passing launch arguments¶
ros2 launch <ROS_PACKAGE_NAME> <LAUNCH_FILE> <LAUNCH_ARGUMENT>:=<VALUE>
for example:
ros2 launch turtlebot4_navigation slam.launch.py namespace:="/turtleX"