Function: To create a function package, you need to specify the package name, compilation mode, dependencies, etc. when creating it.
Command format:ros2 pkg create --build-type ament_python pkg_name rclpy std_msgs sensor_msgs
ros2 pkg create:Instructions for creating packages
--build-type:If the newly created feature pack uses C++ or C, then write ament_cmake here, and if you use Python, write ament_python
pkg_name:Create a name for the feature pack
rclpy std_msgs sensor_msgs:These are some compilation dependencies
Features: View the list of feature packs in your system
Command format:ros2 pkg list
Command function: View the list of executable files in the package
Command format: ros2 pkg executables pkg_name
Command function: Run the feature pack node program
Command format:ros2 run pkg_name node_name
pkg_name:Feature pack name
node_name:The name of the executable program
Command function: Lists all node names in the current domain
Command format: ros2 node list
Command function: View node details, including subscriptions, published messages, enabled services, and actions
Command format: ros2 node info node_name
node_name:The name of the node that needs to be viewed
Command function: Lists all topics in the current domain
Command format: ros2 topic list
Command function: Displays the topic message type, number of subscribers/publishers
Command format: ros2 topic info topic_name
topic_name:The name of the topic that needs to be queried
Command function: View the message type of the thread
Command format: ros2 topic type topic_name
topic_name:You need to look up the name of the topic type
Command function: Displays the average publishing frequency of the topic
Command format: ros2 topic hz topic_name
topic_name:Need to query the name of the topic frequency
Command function: Print topic messages in the terminal, similar to a subscriber
Command format: ros2 topic echo topic_name
topic_name:The name of the topic on which the message needs to be printed
Command function: Publish a specified topic message in the terminal
Command format: ros2 topic pub topic_name message_type message_content
topic_name:The name of the topic that needs to post the thread message
message_type:The data type of the topic
message_content:Message content
The default is to cycle the release at a frequency of 1Hz, and the following parameters can be set:
Parameter -1 is published only once:
ros2 topic pub -1 topic_name message_type message_content
The parameter -t count loops the end of the release count:
ros2 topic pub -t count topic_name message_type message_content
The parameter -r count is cycled at the frequency of count Hz:
ros2 topic pub -r count topic_name message_type message_content
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}}"
It should be noted here that there is a space after the colon.
Command function: lists all interfaces of the current system, including topics, services, and actions.
Command format: ros2 interface list
Command function: Displays the details of the specified interface
Command format: ros2 interface show interface_name
interface_name:The name of the interface content to be displayed
Command function: lists all services in the current domain
Command format: ros2 interface show interface_name
Command function: Invoke the specified service
Command format: ros2 interface call service_name service_Type arguments
service_name:The service that needs to be called
service_Type:Service data type
arguments:Provide the parameters required for the service
For example: call the Build Turtle 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 images, if there is published image topic data in the current domain, you can use this tool to view images.
xxxxxxxxxx
ros2 run rqt_image_view rqt_image_view
Image data is displayed by 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 open:
xxxxxxxxxx
ros2 run run rqt_graph rqt_graph
The core framework of Rviz is an open platform based on Qt visualization tools, and you can see the graphical effect according to the corresponding topic of news release in ROS. In ROS2, launch the rviz tool using rviz2.
xxxxxxxxxx
rviz2
Through the above steps, you can add visual data through plugins or through topics, generally choosing to add through topics.
tf2_tools You can view the current TF tree, and a frame.pdf file will be generated under the terminal where the command is entered.
xxxxxxxxxx
ros2 run tf2_tools view_frames.py