******************** The ros2 command ******************** The following list shows the most commonly used ros2 commands. ros2 run ======== Runs executables provided by a package. .. code-block:: bash # ros2 run This command starts a node. E.g., .. code-block:: bash $ ros2 run turtlesim ros2 node ========= Shows information about currently running ROS2 nodes. .. code-block:: bash $ ros2 node list Use this command to see a list of running nodes. .. code-block:: bash # ros2 node info / Run this command to see the topics and services the node is using. E.g., .. code-block:: bash $ ros2 node /turtlesim. ros2 pkg ============ Shows information about ROS2 packages visible in the current environment. .. code-block:: bash $ ros2 pkg list This command lists all ROS2 packages of your system. .. code-block:: bash # ros2 pkg executables Use this command to see a list of executables made available by a package. E.g., .. code-block:: bash $ ros2 pkg executables turtlesim .. code-block:: bash # ros2 pkg prefix This command is used to get the installation location of a package. E.g., .. code-block:: bash $ ros2 pkg prefix turtlesim .. code-block:: bash # ros2 pkg create Use this command to create a ROS2 package including a CMakeLists.txt and a package.xml file. E.g., .. code-block:: bash $ ros2 pkg create turtlesim Use the optinal ``--build-type`` argument to specificially create a ROS2 Python or ROS2 C++ package. By default you will create a C++ (cmake based) package. E.g., .. code-block:: bash $ ros2 pkg create turtlesim --build-type ament_python #Python $ ros2 pkg create turtlesim --build-type ament_cmake #C++ Use the optional ``--node-name`` argument to create a simple Hello World type executable in the package. .. code-block:: bash $ ros2 pkg create --build-type --node-name E.g., .. code-block:: bash $ ros2 pkg create turtlesim --build-type ament_python --node-name turtlesim_node ros2 topic ============== Shows information about topics currently used by one or more nodes. .. code-block:: bash $ ros2 topic list -t Use this command to see currently published topics and what type they are. .. code-block:: bash # ros2 topic info / This command is used to see information about a topic that the node is publishing. E.g., .. code-block:: bash $ ros2 topic info /turtle1/pose .. code-block:: bash # ros2 topic echo / Run this command to subscribe to the topic and print it on the terminal. E.g., .. code-block:: bash $ ros2 topic echo /turtle1/pose .. code-block:: bash $ ros2 topic -h This command shows a list of more available subcommands. ros2 service/srv/interface ========================================= Shows information about ROS2 services. .. code-block:: bash $ ros2 service list This command lists currently available services. .. code-block:: bash $ ros2 srv list This command lists all available services on your ROS2 systems. .. code-block:: bash # ros2 interface show This command can be used to see the service definition of the service. E.g., .. code-block:: bash $ ros2 interface show turtlesim/srv/Spawn .. code-block:: bash # ros2 service call / '{}' This command is used to manually call a service. The fields of the service request must be set using a YAML dictionary that specifies the field names and values. E.g., .. code-block:: bash $ ros2 service call /spawn turtlesim/srv/Spawn '{x: 5.0, y: 2.5, theta: 0.6, name: eloquent}' ros2 launch =============== Start an installed launch file. .. code-block:: bash # ros2 launch E.g., .. code-block:: bash $ ros2 launch turtlesim multisim.launch.py Notice the ``.py`` suffix on the launch file, it’s a python script. ros2 param =============== Access parameters from command line. .. code-block:: bash $ ros2 param lists Use this command to get a list of all available paramaters. .. code-block:: bash # ros2 param get This command is used to get the current value of a parameter. E.g., $ ros2 param get /turtlesim background_r .. code-block:: bash $ ros2 param set This command is used to set a new value to a parameter. E.g., .. code-block:: bash $ ros2 param set /turtlesim background_r 150