当前位置:网站首页>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
总结
这些指令经常使用就会用了
边栏推荐
- Ret2xx---- common CTF template proposition in PWN
- Bit of MySQL_ OR、BIT_ Count function
- MySQL (UDF authorization)
- 6-4 search by serial number of linked list
- NVM Downloading npm version 6.7.0... Error
- 扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
- Vscode editor
- Sum of two numbers, the numbers in the array are converted to decimal, added, and output inversely
- ethtool 原理介绍和解决网卡丢包排查思路(附ethtool源码下载)
- TypeScript入门
猜你喜欢
PHY驱动调试之 --- PHY控制器驱动(二)
SolidWorks template and design library are convenient for designers to call
3. Oracle control file management
[wustctf2020] plain_ WP
7. Oracle table structure
Some classic recursion problems
[MySQL 8.0 does not support capitalization of table names - corresponding scheme]
Orin installs CUDA environment
Skywalking all
Rehabilitation type force deduction brush question notes D2
随机推荐
Cloud native related technology learning
微信小程序路由再次跳轉不觸發onload
confidential! Netease employee data analysis internal training course, white whoring! (attach a data package worth 399 yuan)
[Gaode map POI stepping pit] amap Placesearch cannot be used
5. Oracle tablespace
【高德地图POI踩坑】AMap.PlaceSearch无法使用
Xavier CPU & GPU high load power consumption test
[algorithm post interview] interview questions of a small factory
Technical conference arrangement
Cookie、Session、JWT、token四者间的区别与联系
how to understand the “model independent.“
Volcano resource reservation feature
Vscode editor
时间很快,请多做有意义的事情
4. Oracle redo log file management
Using handler in a new thread
Redis-02. Redis command
kata container
[MySQL 8.0 does not support capitalization of table names - corresponding scheme]
在新线程中使用Handler