ROS2学习笔记(五)

您所在的位置:网站首页 取消当前操作的命令是什么 ROS2学习笔记(五)

ROS2学习笔记(五)

2024-07-16 05:06:03| 来源: 网络整理| 查看: 265

        简介:在前面的章节中,我们先简单学习了ROS2的话题发布和订阅,两种操作都是通过python代码实现的,而在实际应用过程中,我们会经常用到命令行操作来辅助调试,更进一步的可以使用GUI工具辅助调试,比如前边用到的rqt中的Image View工具,这一节在现有功能基础上介绍一部分常用的命令行操作指令。

注:以下实际操作数据都是在duckiebot节点和control节点运行过程中的数据。

目录

1、包管理工具 ros2 pkg

1.1 ros2 pkg create

1.2 ros2 pkg list

1.3 ros2 pkg executables

2、节点运行工具 ros2 run

3、节点查看工具 ros2 node

3.1 ros2 node list

3.2 ros2 node info

4、主题操作工具 ros2 topic

4.1 ros2 topic list

4.2 ros2 topic info

4.3 ros2 topic type

4.4 ros2 topic find

4.5 ros2 topic hz

4.6 ros2 topic bw

4.7 ros2 topic delay

4.8 ros2 topic echo

4.9 ros2 topic pub

5、接口操作工具 ros2 interface

5.1 ros2 interface list

5.2 ros2 interface package

5.3 ros2 interface packages

5.4 ros2 interface show

5.5 ros2 interface proto

1、包管理工具 ros2 pkg

ros2 pkg有create、executables、list、prefix、xml共5个命令,我们常用的是前3个。

1.1 ros2 pkg create

命令功能:创建功能包,指定包名、编译方式、依赖项、节点名等

命令格式:ros2 pkg create duckiebot --build-type ament_python --node-name duckiebot_node --dependencies rclpy std_msgs sensor_msgs

命令

说明

ros2 pkg create

ROS2功能包创建命令

duckiebot

所建功能包名称,可以放在最后

--build-type ament_python

指定编程语言,我们这里使用python

--node-name duckiebot_node

指定要生成的源码文件,可以后期创建,但是手动创建需要手动配置

--dependencies rclpy std_msgs sensor_msgs

指定依赖模块,rclpy是python编程必选的, std_msgs和sensor_msgs是我们要用的消息模块,也可以不指定手动配置

1.2 ros2 pkg list

命令功能:查看系统中功能包列表

命令格式:ros2 pkg list

如果要查看自己写的节点包,需要用source设置环境变量

1.3 ros2 pkg executables

命令功能:查看包内可执行文件列表

命令格式: ros2 pkg executables

2、节点运行工具 ros2 run

命令功能:运行包内节点功能

命令格式:ros2 run

3、节点查看工具 ros2 node 3.1 ros2 node list

命令功能: 查看当前域内(ROS_DOMAIN_ID相同的节点组)活动的节点列表

命令格式: ros2 node list

3.2 ros2 node info

命令功能: 查看节点详细信息,包括订阅、发布的消息,开启的服务和动作等

命令格式:ros2 node info

4、主题操作工具 ros2 topic 4.1 ros2 topic list

命令功能:列出域内可使用的主题列表

命令格式:ros2 topic list

4.2 ros2 topic info

命令功能:显示主题消息类型,订阅者数量,发布者数量等

命令格式:ros2 topic info

4.3 ros2 topic type

命令功能:查看主题消息类型

命令格式:$ ros2 topic type

4.4 ros2 topic find

命令功能:按消息类型查找相关主题

命令格式:$ ros2 topic find

$ ros2 topic find

命令加-c参数,只统计并显示数量

4.5 ros2 topic hz

命令功能:显示主题平均发布频率

命令格式:ros2 topic hz

4.6 ros2 topic bw

命令功能:显示所查阅主题的带宽

命令格式:ros2 topic bw

4.7 ros2 topic delay

命令功能:通过header中的时间戳计算消息延迟

命令格式:ros2 topic delay

4.8 ros2 topic echo

命令功能:在控制台显示主题消息

命令格式:ros2 topic echo

运行主题查看命令后,按方向键,可以看到发布出来的控制消息:

4.9 ros2 topic pub

命令功能:通过命令行发布指定主题消息

命令格式:ros2 topic pub

ros2 topic pub -1

ros2 topic pub -t 5

ros2 topic pub -r 5

默认循环发布,频率为1Hz,参数-1只发布一次,参数-t 5循环发布5次结束,参数-r 5以5Hz的频率循环发布,详细命令如下:

$ ros2 topic pub control_node/action geometry_msgs/msg/TwistStamped "{header: {stamp:{sec: 0, nanosec: 0}, frame_id: control_node}, twist: {linear: {x: 0.3, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}}"

5、接口操作工具 ros2 interface 5.1 ros2 interface list

命令功能:f分类显示系统内所有的接口,包括消息(Messages)、服务(Services)、动作(Actions)

命令格式:ros2 interface list

5.2 ros2 interface package

命令功能:显示指定接口包内的子接口

命令格式:ros2 interface package

5.3 ros2 interface packages

命令功能:显示指定接口包

命令格式:ros2 interface packages

5.4 ros2 interface show

命令功能:显示指定接口的详细内容

命令格式:ros2 interface show

用于消息类型Messsage

用于服务Service

用于动作Action

5.5 ros2 interface proto

命令功能:显示消息模板

命令格式:ros2 interface proto

以上是目前内容可能会用到的命令行操作指令,后续功能再有相关命令时,将通过章节内穿插介绍或者单独章节介绍的方式给出。

若有收获,就点个赞吧



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭