当前位置:网站首页>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
总结
这些指令经常使用就会用了
边栏推荐
- Skywalking all
- Rehabilitation type force deduction brush question notes D1
- Vant weapp swippecell set multiple buttons
- vsCode创建自己的代码模板
- GDB code debugging
- 【高德地图POI踩坑】AMap.PlaceSearch无法使用
- Vscode creates its own code template
- Pycahrm reports an error: indentation error: unindent does not match any outer indentation
- Relevant information of National Natural Science Foundation of China
- 4. Oracle redo log file management
猜你喜欢
UTC, GPS time and Tai
MPLS experiment
Utf8 encoding
Find the combination number acwing 889 01 sequence meeting conditions
Find the combination number acwing 887 Find combination number III
7. Oracle table structure
Vant Weapp SwipeCell設置多個按鈕
Rehabilitation type force deduction brush question notes D1
Ret2xx---- common CTF template proposition in PWN
Design specification for mobile folding screen
随机推荐
[algorithm post interview] interview questions of a small factory
Paper reading report
Technology blog learning website
Design specification for mobile folding screen
Utf8 encoding
Skywalking全部
Redis-02.Redis命令
*P++, (*p) + +, * (p++) differences
RecyclerView的应用
VLAN experiment
Knapsack problem acwing 9 Group knapsack problem
Cookie、Session、JWT、token四者间的区别与联系
Financial risk control practice -- feature derivation based on time series
Genesis builds a new generation of credit system
2.Oracle-数据文件的添加及管理
[MySQL 8.0 does not support capitalization of table names - corresponding scheme]
testing framework
Mutual transformation between two-dimensional array and sparse array (sparse matrix)
Build a microservice cluster environment locally and learn to deploy automatically
微信小程序路由再次跳转不触发onload