前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ROS1云课→06节点消息流(计算图级)

ROS1云课→06节点消息流(计算图级)

作者头像
zhangrelay
发布2022-09-26 15:44:08
6640
发布2022-09-26 15:44:08
举报

ROS1云课→05消息类型


节点之间通过ROS1消息进行通信,当然这还需要网络层。

ROS1会创建一个连接到所有进程的网络。在系统中的任何节点都可以访问此网络,并通过该网络与其他节点交互,获取其他节点发布的信息,并将自身数据发布到网络上。

ROS2使用DDS。

在这一层级中最基本的概念包括节点、节点管理器、参数服务器、消息、服务、主题和消息记录包,这些概念都以不同的方式向计算图级提供数据:

  • 节点(Node) 节点是主要的计算执行进程。如果想要有一个可以与其他节点进行交互的进程,那么你需要创建一个节点,并将此节点连接到ROS网络。通常情况下,系统包含能够实现不同功能的多个节点。你最好让每一个节点都具有特定的单一的功能,而不是在系统中创建一个包罗万象的大节点。节点需要使用如roscpprospy的ROS客户端库进行编写。
代码语言:javascript
复制
rosnode is a command-line tool for printing information about ROS Nodes.

Commands:
	rosnode ping	test connectivity to node
	rosnode list	list active nodes
	rosnode info	print information about node
	rosnode machine	list nodes running on a particular machine or list machines
	rosnode kill	kill a running node
	rosnode cleanup	purge registration information of unreachable nodes

Type rosnode <command> -h for more detailed usage, e.g. 'rosnode ping -h'
  • 节点管理器(Master) 节点管理器用于节点的名称注册和查找等。它也设置节点间的通信。如果在你的整个ROS系统中没有节点管理器,就不会有节点、服务、消息之间的通信。需要注意的是,由于ROS本身就是一个分布式网络系统,你可以在某一台计算机上运行节点管理器,在该管理器或其他计算机上运行节点。

roscore

代码语言:javascript
复制
Usage: roscore [options]

roscore will start up a ROS Master, a ROS Parameter Server and a rosout
logging node

Options:
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  master port. Only valid if master is launched
  -v                    verbose printing
  -w NUM_WORKERS, --numworkers=NUM_WORKERS
                        override number of worker threads
  -t TIMEOUT, --timeout=TIMEOUT
                        override the socket connection timeout (in seconds).

See http://www.ros.org/wiki/roscore
  • 参数服务器(Parameter Server) 参数服务器能够使数据通过关键词存储在一个系统的核心位置。通过使用参数,就能够在运行时配置节点或改变节点的工作任务。

rospara

代码语言:javascript
复制
rosparam is a command-line tool for getting, setting, and deleting parameters from the ROS Parameter Server.

Commands:
	rosparam set	set parameter
	rosparam get	get parameter
	rosparam load	load parameters from file
	rosparam dump	dump parameters to file
	rosparam delete	delete parameter
	rosparam list	list parameter names
  • 消息(Message) 节点通过消息完成彼此的沟通。消息包含一个节点发送到其他节点的信息数据。ROS1中包含很多种标准类型的消息,同时你也可以基于标准消息开发自定义类型的消息。

rosmsg

代码语言:javascript
复制
rosparam is a command-line tool for getting, setting, and deleting parameters from the ROS Parameter Server.

Commands:
	rosparam set	set parameter
	rosparam get	get parameter
	rosparam load	load parameters from file
	rosparam dump	dump parameters to file
	rosparam delete	delete parameter
	rosparam list	list parameter names
  • 主题(Topic) 每个消息都必须有一个名称以便被ROS1网络分发。每一条消息都要发布到相应的主题。当一个节点发送数据时,我们就说该节点正在向主题发布消息。节点可以通过订阅某个主题,接收来自其他节点的消息。一个节点可以订阅一个主题,而不需要该节点同时发布该主题。这就保证了消息的发布者和订阅者之间相互解耦,完全无需知晓对方的存在。主题的名称必须是独一无二的,否则在同名主题之间的消息路由就会发生错误。

rostopic

代码语言:javascript
复制
rostopic is a command-line tool for printing information about ROS Topics.

Commands:
	rostopic bw	display bandwidth used by topic
	rostopic delay	display delay of topic from timestamp in header
	rostopic echo	print messages to screen
	rostopic find	find topics by type
	rostopic hz	display publishing rate of topic    
	rostopic info	print information about active topic
	rostopic list	list active topics
	rostopic pub	publish data to topic
	rostopic type	print topic or field type

Type rostopic <command> -h for more detailed usage, e.g. 'rostopic echo -h'
  • 服务(Service) 在发布主题时,正在发送的数据能够以多对多的方式交互。但当需要从某个节点获得一个请求或应答时,就不能通过主题来实现了。在这种情况下,服务能够允许我们直接与某个节点进行交互。此外,服务必须有唯一的名称。当一个节点提供某个服务时,所有的节点都可以通过使用ROS客户端库编写的代码与它通信。

rosservie

代码语言:javascript
复制
Commands:
	rosservice args	print service arguments
	rosservice call	call the service with the provided args
	rosservice find	find services by service type
	rosservice info	print information about service
	rosservice list	list active services
	rosservice type	print service type
	rosservice uri	print service ROSRPC uri

Type rosservice <command> -h for more detailed usage, e.g. 'rosservice call -h'
  • 消息记录包(Bag) 消息记录包是一种用于保存和回放ROS消息数据的文件格式。消息记录包是一种用于存储数据的重要机制。它能够获取并记录各种难以收集的传感器数据。我们可以通过消息记录包反复获取实验数据,进行必要的开发和算法测试。在使用复杂机器人进行实验工作时,需要经常使用消息记录包。

rosbag

代码语言:javascript
复制
Usage: rosbag <subcommand> [options] [args]

A bag is a file format in ROS for storing ROS message data. The rosbag command can record, replay and manipulate bags.

Available subcommands:
   check  	Determine whether a bag is playable in the current system, or if it can be migrated.
   compress  	Compress one or more bag files.
   decompress  	Decompress one or more bag files.
   filter  	Filter the contents of the bag.
   fix  	Repair the messages in a bag file so that it can be played in the current system.
   help  
   info  	Summarize the contents of one or more bag files.
   play  	Play back the contents of one or more bag files in a time-synchronized fashion.
   record  	Record a bag file with the contents of specified topics.
   reindex  	Reindexes one or more bag files.

For additional information, see http://wiki.ros.org/rosbag

在下图中可以看到计算图级的图形化表示(节点状态图)。它表示了真实机器人在真实条件下系统的工作状态。在图中,可以看到节点和主题,以及哪些节点订阅哪些主题等。此节点状态图中并没有消息、消息记录包、参数服务器和服务。这些内容需要使用其他工具进行图形化展示。用于创建该图表的工具是rqt_graph,在后续课程中学习到更多的相关知识。

这些概念在ros-comm库中实现。

导航案例:

图形化展示节点信息流工具:


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

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档