前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ROS2编程基础课程--命令行工具

ROS2编程基础课程--命令行工具

作者头像
zhangrelay
发布2019-09-19 14:14:06
6800
发布2019-09-19 14:14:06
举报

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/ZhangRelay/article/details/100773460

Introspection with command line tools 使用命令行工具进行自检

ROS 2 includes a suite of command-line tools for introspecting a ROS 2 system.

ROS 2包括一套用于ROS 2系统自检的命令行工具。

Usage 用法

The main entry point for the tools is the command ros2, which itself has various sub-commands for introspecting and working with nodes, topics, services, and more.

这些工具的主要入口点是命令ros2,它本身具有各类子命令,用于自检和处理节点、主题、服务等。

To see all available sub-commands run: 要查看运行的所有可用子命令:

ros2 --help

每个子命令的细节,如节点:

ros2 node -h

Examples of sub-commands that are available include:

可用的子命令示例包括:

  • daemon: Introspect/configure the ROS 2 daemon 自检/配置ROS 2守护程序
  • launch: Run a launch file 运行启动文件
  • lifecycle: Introspect/manage nodes with managed lifecycles 使用托管生命周期自检/管理节点
  • msg: Introspect msg types 自检msg类型
  • node: Introspect ROS nodes 自检ROS节点
  • param: Introspect/configure parameters on a node 在节点上自检/配置参数
  • pkg: Introspect ROS packages 自检ROS包
  • run: Run ROS nodes 运行ROS节点
  • security: Configure security settings 配置安全性设置
  • service: Introspect/call ROS services 自检/调用ROS服务
  • srv: Introspect srv types 自检srv类型
  • topic: Introspect/publish ROS topics 自检/发布ROS主题

Example 示例

To produce the typical talker-listener example using command-line tools, the topic sub-command can be used to publish and echo messages on a topic.

要使用命令行工具生成典型的talker-listener示例,topic子命令可用于发布和回显主题上的消息。

Publish messages in one terminal with:

在一个终端中发布消息:

$ ros2 topic pub /chatter std_msgs/String "data: Hello world"

publisher: beginning loop

publishing std_msgs.msg.String(data='Hello world')

publishing std_msgs.msg.String(data='Hello world')

Echo messages received in another terminal with:

在另一个终端收到的回应消息:

$ ros2 topic echo /chatter

data: Hello world

data: Hello world

如果ok,可以看到如下:

Behind the scenes 背后机制

ROS 2 uses a distributed discovery process for nodes to connect to each other. As this process purposefully does not use a centralized discovery mechanism (like the ROS Master in ROS 1), it can take time for ROS nodes to discover all other participants in the ROS graph. Because of this, there is a long-running daemon in the background that stores information about the ROS graph to provide faster responses to queries, e.g. the list of node names.

ROS 2使用分布式发现过程来连接节点。由于此过程刻意不使用集中式发现机制(如ROS 1中的ROS Master),因此ROS节点可能需要一段时间才能发现ROS图中的所有其他参与者。因此,后台存在一个长时间运行的守护程序,它存储有关ROS图的信息,以便更快地响应查询,例如节点名称列表。

The daemon is automatically started when the relevant command-line tools are used for the first time. You can run ros2 daemon --help for more options for interacting with the daemon.

首次使用相关命令行工具时,守护程序将自动启动。可以运行ros2 daemon --help更多选项以与守护程序进行交互。

Implementation 实现

The source code for the ros2 command is available at https://github.com/ros2/ros2cli

关于ros2命令的源代码可在网页https://github.com/ros2/ros2cli上找到

The ros2 tool has been implemented as a framework that can be extended via plugins. For example, the sros2 package provides a security sub-command that is automatically detected by the ros2 tool if the sros2 package is installed.

ros2工具实现了可通过插件扩展的框架。例如,sros2包提供了一个security子命令,ros2如果安装了sros2包,工具会自动检测该子命令。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年09月12日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Introspection with command line tools 使用命令行工具进行自检
    • Usage 用法
      • Example 示例
        • Behind the scenes 背后机制
          • Implementation 实现
          相关产品与服务
          命令行工具
          腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档