当前位置:网站首页>ROS2——常用命令行(四)
ROS2——常用命令行(四)
2022-07-05 06:35:00 【我与nano】
ROS2机器人操作系统
前言
下面介绍ROS2中常用的操作指令
一、常用命令行
cd
语法:cd <目录路径>
功能:改变工作目录。若没有指定“目录路径”,则回到用户的主目录
pwd
语法:pwd
功能:此命令显示出当前工作目录的绝对路径
mkdir
语法:mkdir [选项] <目录名称>
功能:创建一个目录/文件夹
ls
语法:ls [选项] [目录名称…]
功能:列出目录/文件夹中的文件列表
gedit
语法:gedit <文件名称>
功能:打开gedit编辑器编辑文件,若没有此文件则会新建
mv
语法:mv [选项] <源文件或目录> <目地文件或目录>
功能:为文件或目录改名或将文件由一个目录移入另一个目录中
cp
语法:cp [选项] <源文件名称或目录名称> <目的文件名称或目录名称>
功能:把一个文件或目录拷贝到另一文件或目录中,或者把多个源文件复制到目标目录中
rm
语法:rm [选项] <文件名称或目录名称…>
功能:该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除。对于链接文件,只是删除了链接,原有文件均保持不变
sudo
语法:sudo [选项] [指令]
功能:以系统管理员权限来执行指令
二、ROS2中的命令行
ROS2命令行的操作机制与Linux相同,不过所有操作都集成在一个ros2的总命令中,后边第一个参数表示不同的操作目的,比如node表示对节点的操作,topic表示对话题的操作,具体操作干什么,还可以在后边继续跟一系列参数内容。
1.运行节点程序
想要运行ROS2中某个节点,我们可以使用ros2 run命令进行操作,例如我们要运行海龟仿真节点和键盘控制节点:
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key

2.查看节点信息
当前运行的ROS系统中都有哪些节点呢?可以这样来查看:
ros2 node list

如果对某一个节点感兴趣,加上一个info子命令,就可以知道它的详细信息啦:
ros2 node info /turtlesim

三、查看话题信息
当前系统中都有话题呢,使用如下命令即可查看:
ros2 topic list

还想看到某一个话题中的消息数据,加上echo子命令试一试:
ros2 topic echo /turtle1/pose

四、发布话题消息
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}}"

五、发送服务请求
一只海龟太孤单,仿真器还提供改了一个服务——产生海龟,我们试一试服务调用,再来一只海龟:
ros2 service call /spawn turtlesim/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"

六、录制控制命令
系统运行中的数据有很多,如果想要把某段数据录制下来,回到实验室再复现这段数据如何?ROS2中的rosbag功能还是很好用的,轻松实现数据的录制与播放:
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
总结
这些指令经常使用就会用了
边栏推荐
- Markdown syntax
- LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
- UIO driven framework
- Redis-01.初识Redis
- 3. Oracle control file management
- Utf8 encoding
- 将webApp或者H5页面打包成App
- Dataframe (1): introduction and creation of dataframe
- mysql设置触发器问题
- [algorithm post interview] interview questions of a small factory
猜你喜欢
随机推荐
Orin 两种刷机方式
Design specification for mobile folding screen
All English in the code
摄像头的MIPI接口、DVP接口和CSI接口
Interval problem acwing 906 Interval grouping
Genesis builds a new generation of credit system
Dataframe (1): introduction and creation of dataframe
Integer to 8-bit binary explanation (including positive and negative numbers) scope of application -127~+127
Record of problems in ollvm compilation
【MySQL8.0不支持表名大写-对应方案】
2048 project realization
MySQL (UDF authorization)
The route of wechat applet jumps again without triggering onload
Preemption of CFS scheduling
达梦数据库全部
Sre core system understanding
Ret2xx---- common CTF template proposition in PWN
Rehabilitation type force deduction brush question notes D3
In C language, int a= 'R'
A brief introduction to heading/pitch/roll and omega/phi/kappa








![[moviepy] unable to find a solution for exe](/img/0a/4841f53cedc1333654b9443e406f4c.jpg)
