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.
Function: View the list of packages in the system
Command Format: ros2 pkg list
Command Format: ros2 pkg executables pkg_name
Command Format: ros2 pkg executables pkg_name
Command Function: Run the function package node program.
Command Format: ros2 run pkg_name node_name
Command Function: List all the nodes in the current domain.
Command Format: ros2 node list
Command Function: View node details, including subscriptions, published messages, opened services and actions, etc.
Command Format: ros2 node info node_name
Command Function: List all topics in the current domain.
Command Format: ros2 topic list
Command Function: Display topic message type and number of subscribers/publishers.
Command Format: ros2 topic info topic_name
Command Function: Check the message type of a topic.
Command Format: ros2 topic type topic_name
Command Function: Display the average posting frequency of topics.
Command Format: ros2 topic hz topic_name
Command Function: Print the topic message in the terminal, similar to a subscriber.
Command Format: ros2 topic echo topic_name
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.
xxxxxxxxxx
ros2 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}}"
The important thing to note here is that there is a space after the colon.
Command Function: lists all the interfaces of the current system, including topics, services and actions.
Command Format: ros2 interface list
Command Function: Display the details of the specified interface.
Command Format: ros2 interface show interface_name
Command Format: ros2 interface show interface_name
Command Format: ros2 interface show interface_name
Command Function: Call the specified service.
Command Format: ros2 interface call service_name service_Type arguments
For example, to call the turtle generation service
xxxxxxxxxx
ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"
requester: making request: turtlesim.srv.Spawn_Request(x=2.0, y=2.0, theta=0.2, name='turtle2')
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.
xxxxxxxxxx
ros2 run rqt_image_view rqt_image_view
Displays image data via the image topic selected in the upper left corner.
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.
xxxxxxxxxx
ros2 run run rqt_graph rqt_graph
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.
xxxxxxxxxx
rviz2
Through the above steps you can add visualisation data through plugins or through topics, the general choice is to add through topics.
tf2_tools can view the current TF tree, will enter the command under the terminal to generate frame.pdf file.
xxxxxxxxxx
ros2 run tf2_tools view_frames.py