Welcome to Jetson Orin NX Developer Kit repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
16.ROS2 common command tools
16. ROS2 Common Command Tools
1. Package Management Tool ros2 pkg
1.1. ros2 pkg create
Function: create a function package. When creating one, you need to specify the package name, the build type, the dependencies, etc.
Format:
ros2 pkg create <package_name> --build-type <build-type> --dependencies <dependencies>In the ros2 command:
pkg: indicates the functions related to function packages;
create: indicates the creation of a function package;
package_name: required: the name of the new function package;
build-type: required: indicates whether the newly created function package is C++ or Python. If C++ or C is used, follow ament_cmake; if Python is used, follow ament_python;
dependencies: optional: indicates the dependencies of the function package. A C++ function package needs to include rclcpp, and a Python function package needs to include rclpy, as well as any other required dependencies;
1.2. ros2 pkg list
Function: view the list of function packages in the system
Format:
xxxxxxxxxxros2 pkg list
1.3. ros2 pkg executables
Function: view all executable files within a certain package
Format:
xxxxxxxxxxros2 pkg executables pkg_name
2. Node Run ros2 run
Function: run the node program of a function package
Format:
xxxxxxxxxxros2 run pkg_name node_namepkg_name: the name of the function package
node_name: the name of the executable program

3. Node-Related Tools ros2 node
3.1. ros2 node list
Function: list the names of all nodes in the current domain
Format:
xxxxxxxxxxros2 node list
3.2. ros2 node info
Function: view detailed node information, including subscribed and published messages, started services and actions, etc.
Format:
xxxxxxxxxxros2 node info node_name
node_name: the name of the node to be viewed
4. Topic-Related Tools ros2 topic
4.1. ros2 topic list
Function: list all the topics in the current domain
Format:
xxxxxxxxxxros2 topic list
4.2. ros2 topic info
Function: display the message type of a topic and the number of subscribers/publishers
Format:
xxxxxxxxxxros2 topic info topic_nametopic_name: the name of the topic to be queried
4.3. ros2 topic type
Function: view the message type of a topic
Format:
xxxxxxxxxxros2 topic type topic_nametopic_name: the name of the topic whose type needs to be queried
4.4. ros2 topic hz
Function: display the average publishing frequency of a topic
Format:
xxxxxxxxxxros2 topic hz topic_name
topic_name: the name of the topic whose frequency needs to be queried

4.5. ros2 topic echo
Function: print topic messages in the terminal, similar to a subscriber
Format: ros2 topic echo topic_name
topic_name: the name of the topic whose messages need to be printed
4.6. ros2 topic pub
Function: publish messages on a specified topic in the terminal
Format:
xxxxxxxxxxros2 topic pub topic_name message_type message_content
topic_name: the name of the topic on which to publish the message
message_type: the data type of the topic
message_content: the message content
By default it publishes in a loop at 1Hz. The following parameters can be set:
Parameter -1 publishes only once, ros2 topic pub -1 topic_name message_type message_content
Parameter -t count publishes in a loop count times and then ends, ros2 topic pub -t count topic_name message_type message_content
Parameter -r count publishes in a loop at a frequency of count Hz, ros2 topic pub -r count topic_name message_type message_content
Example:
Publish a speed command through the command line
Note that there should be a space after each colon, otherwise a format error will be reported
xxxxxxxxxxros2 topic pub turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.2}}"
5. Interface-Related Tools ros2 interface
5.1. ros2 interface list
Function: list all the interfaces in the current system, including topics, services, and actions.
Format:
xxxxxxxxxxros2 interface list
5.2. ros2 interface show
Function: display the detailed content of a specified interface
Format:
xxxxxxxxxxros2 interface show interface_nameinterface_name: the name of the interface whose content needs to be displayed
6. Service-Related Tools ros2 service
6.1. ros2 service list
Function: list all the services in the current domain
Format:
xxxxxxxxxxros2 interface show interface_name
6.2. ros2 service call
Function: call a specified service
Format:
xxxxxxxxxxros2 interface call service_name service_Type arguments
service_name: the service to be called
service_Type: the service data type
arguments: the parameters needed to provide the service
For example, call the turtle spawn service
xxxxxxxxxxros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: 'turtle10'}"