当前位置:网站首页>Ros2 - common command line (IV)

Ros2 - common command line (IV)

2022-07-05 06:51:00 Me and nano

ROS2 Robot operating system


Preface

Let's introduce ROS2 Common operation instructions in

One 、 Common command line

cd

grammar :cd < Directory path >

function : Change the working directory . If not specified “ Directory path ”, Then return to the user's home directory

pwd

grammar :pwd
function : This command shows the absolute path of the current working directory

mkdir

grammar :mkdir [ Options ] < Directory name >

function : Create a directory / Folder

ls

grammar :ls [ Options ] [ Directory name …]

function : List the contents / List of files in the folder

gedit

grammar :gedit < File name >

function : open gedit Editor edit file , If there is no such file, it will be created

mv

grammar :mv [ Options ] < Source file or directory > < Destination file or directory >

function : Rename a file or directory or move a file from one directory to another

cp

grammar :cp [ Options ] < Source file name or directory name > < Destination file name or directory name >

function : Copy a file or directory to another file or directory , Or copy multiple source files to the target directory

rm

grammar :rm [ Options ] < File name or directory name …>

function : The function of this command is to delete one or more files or directories in a directory , It can also delete a directory and all its files and subdirectories . For linked files , Just deleted the link , The original files remain unchanged

sudo

grammar :sudo [ Options ] [ Instructions ]

function : Execute instructions with the privileges of the system administrator

Two 、ROS2 The command line in

ROS2 The operation mechanism of the command line is similar to Linux identical , But all operations are integrated in one ros2 In the general order of , The first parameter in the back indicates different operation purposes , such as node Indicates the operation on the node ,topic Indicates the operation of the topic , What is the specific operation , You can also continue to follow a series of parameters .
 Insert picture description here

1. Run the node program

Want to run ROS2 A node in , We can use ros2 run Command to operate , For example, we need to run turtle simulation node and keyboard control node :

ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key

 Insert picture description here

2. View node information

Currently running ROS Which nodes are there in the system ? You can view it like this :

ros2 node list

 Insert picture description here

If you are interested in a node , Add a info Sons command , You can know its details :

ros2 node info /turtlesim 

 Insert picture description here

3、 ... and 、 View topic information

There are topics in the current system , Use the following command to view :

ros2 topic list

 Insert picture description here
I also want to see the message data in a topic , add echo Try the sub command :

ros2 topic echo /turtle1/pose 

 Insert picture description here

Four 、 Post topic news

ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

 Insert picture description here

5、 ... and 、 Send service request

A turtle is too lonely , The simulator also provides a service —— Produce turtles , Let's try service invocation , Another turtle :

ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"

 Insert picture description here

6、 ... and 、 Recording control command

There are many data in the operation of the system , If you want to record some data , How about going back to the laboratory to reproduce this data ?ROS2 Medium rosbag The function is still very easy to use , Easily record and play data :

ros2 bag record /turtle1/cmd_vel
ros2 bag play rosbag2_2022_04_11-17_35_40/rosbag2_2022_04_11-17_35_40_0.db3

summary

These instructions will be used if they are often used

原网站

版权声明
本文为[Me and nano]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050635158279.html