2. ROS2 command and tool

1. Package management tool ros2 pkg

1.1 ros2 pkg create

Function: Create a functional package, you need to specify the package name, compilation method, dependencies and so on.

Command Format: ros2 pkg create --build-type ament_python pkg_name rclpy std_msgs sensor_msgs

ros2 pkg create: the command to create the package

--build-type: the newly created package should be ament_cmake if it uses C++ or C, or ament_python if it uses Python.

pkg_name: the name of the package to create.

rclpy std_msgs sensor_msgs: these are some compilation dependencies.

1.2 ros2 pkg list

Function: View the list of packages in the system

Command Format: ros2 pkg list

image-20230427154146879

1.3 ros2 pkg executables

Command Format: ros2 pkg executables pkg_name

Command Format: ros2 pkg executables pkg_name

image-20230427154419005

2. Node run ros2 run

Command Function: Run the function package node program.

Command Format: ros2 run pkg_name node_name

image-20230427155359745

3. Node-related tools ros2 node

3.1 ros2 node list

Command Function: List all the nodes in the current domain.

Command Format: ros2 node list

image-20230427155655753

3.2 ros2 node info

Command Function: View node details, including subscriptions, published messages, opened services and actions, etc.

Command Format: ros2 node info node_name

image-20230427160001101

4. Topic-related tools ros2 topic

4.1 ros2 topic list

Command Function: List all topics in the current domain.

Command Format: ros2 topic list

image-20230427160351051

4.2 ros2 topic info

Command Function: Display topic message type and number of subscribers/publishers.

Command Format: ros2 topic info topic_name

image-20230427160625594

4.3 ros2 topic type

Command Function: Check the message type of a topic.

Command Format: ros2 topic type topic_name

image-20230427161056536

4.4 ros2 topic hz

Command Function: Display the average posting frequency of topics.

Command Format: ros2 topic hz topic_name

image-20230427161721650

4.5 ros2 topic echo

Command Function: Print the topic message in the terminal, similar to a subscriber.

Command Format: ros2 topic echo topic_name

image-20230427162312888

4.5 ros2 topic pub

Command Function: Publish the specified topic message in the terminal.

Command Format: ros2 topic pub topic_name message_type message_content

By default, the topic is published cyclically at a frequency of 1Hz, and the following parameters can be set.

The important thing to note here is that there is a space after the colon.

image-20230427163737824

5. Interface-related tools ros2 interface

5.1. ros2 interface list

Command Function: lists all the interfaces of the current system, including topics, services and actions.

Command Format: ros2 interface list

image-20230427164755075

5.2 ros2 interface show

Command Function: Display the details of the specified interface.

Command Format: ros2 interface show interface_name

image-20230427165057647

6. Service-related tools ros2 service

6.1 ros2 service list

Command Format: ros2 interface show interface_name

Command Format: ros2 interface show interface_name

image-20230427172236875

6.2 ros2 service call

Command Function: Call the specified service.

Command Format: ros2 interface call service_name service_Type arguments

For example, to call the turtle generation service

image-20230427173625631

7. rqt_image_view

rosrun rqt_image_view rqt_image_view

rqt_image_view can be used to view an image, if there is a published image topic data in the current domain, you can use this tool to view the image.

image-20230427192305253

Displays image data via the image topic selected in the upper left corner.

8. rqt_graph

rqt_graph can be used to view which nodes are running in the current domain and the topic communication between nodes, use the following command to turn it on.

image-20230427192536559

9. rviz2

The core framework of Rviz is an open platform built on Qt visualisation tools. Follow the messages in ROS to publish the corresponding topics and you can see the graphical results. In ROS2, use rviz2 to launch the rviz tool.

image-20230427191933170

Through the above steps you can add visualisation data through plugins or through topics, the general choice is to add through topics.

10. tf2_tools

tf2_tools can view the current TF tree, will enter the command under the terminal to generate frame.pdf file.