技术领域technical field
本发明涉及机器人分布计算技术领域,具体涉及一种在云机器人架构中,将机器人软件包部署为云计算服务,通过云服务协议访问机器人软件包,使得机器人软件包能够通过互联网远程为机器人提供后台云计算支持的方法。The invention relates to the technical field of distributed computing of robots, in particular to a cloud robot architecture, deploying a robot software package as a cloud computing service, and accessing the robot software package through a cloud service protocol, so that the robot software package can remotely provide a background for the robot through the Internet Methods supported by cloud computing.
背景技术Background technique
机器人中间件是支撑机器人架构的软件基础设施,它封装了机器人服务共性问题(如数据通信、事务)的解决方案,从而可以大幅简化此类应用的开发过程。ROS(RobotOperating System)是目前主流的机器人中间件,它包含了一个开源的中间件框架和一个用于机器人开发和管理的综合工具链。这个中间件框架实现了能够与各个软件模块进行交互的通讯基础设施,综合的工具链包括一系列机器系统开发、调试、检查、状态可视化的工具,包括基本的命令行工具、传感器数据可视化工具、图形化界面开发工具等。Robot middleware is the software infrastructure that supports the robot architecture. It encapsulates the solutions to the common problems of robot services (such as data communication and transactions), which can greatly simplify the development process of such applications. ROS (RobotOperating System) is the current mainstream robot middleware, which includes an open source middleware framework and a comprehensive tool chain for robot development and management. This middleware framework implements a communication infrastructure that can interact with various software modules. The comprehensive tool chain includes a series of tools for machine system development, debugging, inspection, and status visualization, including basic command-line tools, sensor data visualization tools, Graphical interface development tools, etc.
从分布式的观点出发,ROS可以看做一个面向消息的中间件。一个ROS应用由一组ROS自描述软件实体组成,这种软件实体称为软件包。这些软件包能够在不同的位置运行,它们通过ROS消息传输通道交互ROS消息从而实现共同的任务目标。From a distributed point of view, ROS can be seen as a message-oriented middleware. A ROS application consists of a set of ROS self-describing software entities called software packages. These packages can run in different locations, and they exchange ROS messages through the ROS message transport channel to achieve a common mission goal.
ROS消息传输有两种传输通道,一种是主题(Topic)消息通道,该消息通道基于发布/订阅机制广播消息。主题消息通道上传输的消息叫主题消息,主题消息按照主题名进行分类。主题消息通道分成两种消息模式:1)消息发布(Publish)模式,ROS机器人软件包基于主题名发布ROS消息用于广播数据;2)消息订阅(Subscribe)模式,ROS机器人软件包订阅其他软件包发布的主题消息,订阅完成之后,其他软件包一旦发布该消息,就能接收到该消息内容。另一种是服务(Service)消息通道。服务消息通道上传输的消息叫服务消息。通过这种消息通道,ROS机器人软件包能够远程调用其他ROS机器人软件包中定义的服务,并获取所需的结果。There are two transmission channels for ROS message transmission, one is the topic (Topic) message channel, which broadcasts messages based on the publish/subscribe mechanism. The messages transmitted on the topic message channel are called topic messages, and topic messages are classified according to topic names. The topic message channel is divided into two message modes: 1) message publishing (Publish) mode, ROS robot software package publishes ROS messages based on topic names for broadcasting data; 2) message subscription (Subscribe) mode, ROS robot software package subscribes to other software packages The published topic message, after the subscription is completed, once the message is published by other software packages, the content of the message can be received. The other is the service (Service) message channel. The messages transmitted on the service message channel are called service messages. Through this message channel, the ROS robotics package can remotely call services defined in other ROS robotics packages and get the desired results.
ROS中主题消息由主题名和主题消息内容构成。ROS的主题名由字母、数字和“/”符号组成,一个ROS主题名唯一标识一类主题消息。主题消息内容由符合主题消息类型的值组成,主题消息类型规定了一个主题名对应的主题消息内容所包含数据的数据类型(例如int、string等)以及这些数据类型数据的组合方式。ROS中服务消息由服务名和服务消息内容构成。ROS的服务名由字母、数字和“/”符号组成,一个ROS服务名唯一标识一类服务消息。服务消息内容由符合服务消息类型的值组成,服务消息类型规定了一个服务名对应的服务消息内容所包含数据的数据类型(例如int、string等)以及这些数据类型数据的组合方式。Topic messages in ROS consist of topic names and topic message content. The topic name of ROS consists of letters, numbers and "/" symbols. A ROS topic name uniquely identifies a type of topic message. The topic message content consists of values that conform to the topic message type. The topic message type specifies the data type (such as int, string, etc.) of the data contained in the topic message content corresponding to a topic name and the combination of these data types. The service message in ROS consists of the service name and the content of the service message. The service name of ROS consists of letters, numbers and "/" symbols. A ROS service name uniquely identifies a type of service message. The service message content consists of values that conform to the service message type. The service message type specifies the data type (such as int, string, etc.) of the data contained in the service message content corresponding to a service name and the combination of these data types.
ROS Master软件包是提供目录服务的一种ROS机器人软件包,是ROS消息功能实现的核心。ROS Master软件包可以记录每个软件包发布的主题名和对应的主题消息类型,同时也记录了每个软件包所提供服务名以及对应的服务消息类型。任何想要发布主题消息或者提供服务的软件包都要在ROS Master上注册。一个ROS机器人软件包通过ROS Master软件包知道其他ROS机器人软件包发布了什么主题消息以及对应的主题消息类型,也通过ROSMaster软件包告诉其它ROS机器人软件包自己发布了什么主题消息以及对应的主题消息类型,同时通过ROS Master软件包知道其他ROS机器人软件包能够提供什么服务以及对应的服务消息类型,也告诉其它ROS机器人软件包自己能够提供什么服务以及对应的服务消息类型。因此每一个使用ROS消息机制的机器人软件包都必须与ROS Master进行交互。为了保证ROS消息功能的正确实现,防止出现在ROS Master软件包上注册信息不一致的情况,ROS运行机制限定了同一个ROS系统上只能运行一个ROS Master软件包,并且要求不同ROS机器人软件包在同一个ROS Master上注册的同名消息(包括主题消息和服务消息)必须保证消息类型一致。The ROS Master software package is a ROS robot software package that provides directory services, and is the core of the ROS message function implementation. The ROS Master software package can record the topic name and the corresponding topic message type published by each software package, as well as the service name provided by each software package and the corresponding service message type. Any package that wants to publish topic messages or provide services must be registered with the ROS Master. A ROS robot software package knows what topic messages and corresponding topic message types are published by other ROS robot software packages through the ROS Master software package, and also tells other ROS robot software packages what topic messages and corresponding topic messages have been published by the ROSMaster software package. At the same time, the ROS Master software package knows what services other ROS robot software packages can provide and the corresponding service message types, and also tells other ROS robot software packages what services they can provide and the corresponding service message types. Therefore every robotics package that uses the ROS messaging mechanism must interact with the ROS Master. In order to ensure the correct implementation of the ROS message function and prevent inconsistent registration information on the ROS Master software package, the ROS operating mechanism limits that only one ROS Master software package can run on the same ROS system, and requires different ROS robot software packages to run on the same ROS system. Messages of the same name (including topic messages and service messages) registered on the same ROS Master must ensure the same message type.
由于ROS为机器人应用提供了良好消息通讯机制以及开发和管理的综合工具链,使得机器人应用的开发过程得到大幅简化。基于ROS的机器人应用得到快速的发展。目前ROS软件生态系统中已经积累了上千个可以重用的机器人软件包,这些机器人软件包包含了许多独立的包装好的自动化机器人算法,大大减少了机器人开发的重复性工作,使得ROS机器人中间件在机器人社区被广泛地接受。Because ROS provides a good message communication mechanism and a comprehensive tool chain for development and management for robot applications, the development process of robot applications is greatly simplified. Robotic applications based on ROS have been rapidly developed. At present, thousands of reusable robot software packages have been accumulated in the ROS software ecosystem. These robot software packages contain many independently packaged automated robot algorithms, which greatly reduces the repetitive work of robot development and makes ROS robot middleware. Widely accepted in the robotics community.
云机器人指云计算服务和机器人的组合,它利用云计算和大数据等后台基础设施,提升机器人在复杂环境下遂行任务的能力。云机器人架构是指通过云计算服务来增强机器人个体能力,协助机器人完成任务的系统架构。在云机器人架构中,机器人所需的部份功能(如计算密集型的算法)由云计算服务实现,实现本地计算卸载。机器人本地只运行必要的环境信息获取、行动机构控制等软件,这些本地软件与云计算服务紧密交互,相互配合完成指定的任务。引入云机器人架构,带来简化机器人本地软件开发、降低机器人本地计算资源占用等优点。Cloud robot refers to the combination of cloud computing services and robots. It uses back-end infrastructure such as cloud computing and big data to improve the ability of robots to perform tasks in complex environments. Cloud robot architecture refers to a system architecture that enhances the individual capabilities of robots and assists robots to complete tasks through cloud computing services. In the cloud robot architecture, part of the functions required by the robot (such as computationally intensive algorithms) are implemented by cloud computing services to realize local computing offload. The robot only runs the necessary software such as environmental information acquisition and action mechanism control locally. These local software closely interact with cloud computing services and cooperate with each other to complete the specified tasks. The introduction of the cloud robot architecture brings the advantages of simplifying the development of local software of robots and reducing the occupation of local computing resources of robots.
鉴于ROS软件生态系统提供了大量的现成的可以重用的机器人软件包,以及云机器人的优势和特点,如何在云机器人架构中不需要修改ROS软件包直接为机器人提供云服务成为核心目标。实现这个目标的关键是实现云端与机器人计算节点之间的通讯。ROS本身提供消息机制,但是ROS消息机制基于ROS Master软件包的中心化架构以及ROS软件包之间的消息交互通讯机制,这使得ROS消息机制只能为运行在本地局域网上的小规模系统服务。为了不需要修改ROS机器人软件包就将其部署在云端为机器人提供服务,必须克服ROS只能为本地局域网的小规模机器人系统服务这个缺陷,需要提供一种通过云服务协议访问ROS机器人软件包的方法。Given that the ROS software ecosystem provides a large number of ready-made reusable robot software packages and the advantages and characteristics of cloud robots, how to directly provide cloud services for robots without modifying the ROS software package in the cloud robot architecture has become the core goal. The key to achieving this goal is to realize the communication between the cloud and the robot computing nodes. ROS itself provides a message mechanism, but the ROS message mechanism is based on the centralized architecture of the ROS Master package and the message interaction and communication mechanism between ROS packages, which makes the ROS message mechanism only serve small-scale systems running on the local LAN. In order to deploy the ROS robot software package in the cloud to provide services for robots without modifying the ROS robot software package, it is necessary to overcome the defect that ROS can only serve small-scale robot systems on a local area network. It is necessary to provide a way to access the ROS robot software package through the cloud service protocol method.
目前主流的云服务访问协议包括HTML协议、WebSocket协议等。其中,基于TCP连接的全双工通信协议WebSocket协议提供了能够在单个TCP连接上进行全双工交互通信的能力。通过WebSocket API,客户端和服务端只需进行一个“握手”动作,就可以建立一条“快速通道”,两者之间可以随时直接进行数据传送。目前,WebSocket已经在互联网和云计算领域上得到了较为广泛的应用。The current mainstream cloud service access protocols include HTML protocol, WebSocket protocol, etc. Among them, the WebSocket protocol, a full-duplex communication protocol based on a TCP connection, provides the ability to perform full-duplex interactive communication on a single TCP connection. Through the WebSocket API, the client and the server only need to perform a "handshake" action to establish a "fast channel", and data can be directly transmitted between the two at any time. At present, WebSocket has been widely used in the field of Internet and cloud computing.
如何将云服务访问协议WebSocket用于机器人ROS消息的传输,使得部署在云端的ROS机器人软件包能够无需修改地转换成云计算服务,并且与部署在机器人上的ROS机器人软件包进行即时的通信,减少将机器人应用“云”化的成本,使得机器人能够更加便利地利用云端资源为自己服务,提高机器人应用的效率,是本领域急于解决的技术问题。How to use the cloud service access protocol WebSocket for the transmission of robot ROS messages, so that the ROS robot software package deployed in the cloud can be converted into cloud computing services without modification, and communicate with the ROS robot software package deployed on the robot instantly, Reducing the cost of "cloud"izing robot applications, enabling robots to more conveniently use cloud resources to serve themselves, and improving the efficiency of robot applications are technical problems that the field is eager to solve.
发明内容SUMMARY OF THE INVENTION
本发明要解决的技术问题是提供一种通过云服务协议访问ROS机器人软件包的方法,使得无需修改ROS机器人软件包,就可以将ROS机器人软件包部署在云计算中心,并且机器人使用的ROS机器人软件包能够使用主流的云服务访问协议与云端运行的ROS机器人软件包进行交互。The technical problem to be solved by the present invention is to provide a method for accessing the ROS robot software package through a cloud service protocol, so that the ROS robot software package can be deployed in the cloud computing center without modifying the ROS robot software package, and the ROS robot software used by the robot Packages are able to interact with ROS robotics packages running in the cloud using mainstream cloud service access protocols.
本发明的技术方案是直接将ROS机器人软件包部署在云计算中心,使用WebSocket协议实现机器人计算节点的ROS机器人软件包与云计算中心的ROS机器人软件包之间ROS消息的交互。本发明能使得ROS消息机制中基于单ROS Master的本地机器人通讯系统扩展成支持在多个ROS系统之间也就是基于多个ROS Master的实时通讯系统。机器人计算节点的ROS机器人软件包与云计算中心的ROS机器人软件包之间的消息通讯实际上是基于机器人ROS Master软件包和云计算中心ROS Master软件包的通讯。由于不同的ROS Master运行在不同的系统之上,所以ROS机器人软件包在不同的ROS Master软件包上注册的ROS消息相互之间没有关联,因此存在同一个主题名在不同的ROS Master上对应着不同的主题消息类型的情况,即在两个ROS Master上注册的信息不一致。为了避免这种情况,需要在消息传递之前对消息的类型进行比对,主题消息类型一致才能相互传输消息。在云计算中心和机器人计算节点分别引入ROS消息和数据传输格式JSON(JavaScript Object Notation)消息的双向转换机制,使用WebSocket协议建立连接和进行数据传输。使得机器人计算节点的ROS消息可以封装成JSON格式,并通过WebSocket协议经互联网传递到云计算中心,与云计算中心部署的ROS机器人软件包进行消息交互,同时机器人计算节点可以使用同样的方法在从云计算中心订阅ROS消息。The technical solution of the present invention is to directly deploy the ROS robot software package in the cloud computing center, and use the WebSocket protocol to realize the interaction of ROS messages between the ROS robot software package of the robot computing node and the ROS robot software package of the cloud computing center. The present invention enables the local robot communication system based on a single ROS Master in the ROS message mechanism to be extended to support a real-time communication system between multiple ROS systems, that is, a real-time communication system based on multiple ROS Masters. The message communication between the ROS robot software package of the robot computing node and the ROS robot software package of the cloud computing center is actually based on the communication between the robot ROS Master software package and the ROS Master software package of the cloud computing center. Since different ROS Masters run on different systems, the ROS messages registered by the ROS robot software package on different ROS Master software packages are not related to each other, so there is a same topic name corresponding to different ROS Masters In the case of different topic message types, that is, the information registered on the two ROS Masters is inconsistent. In order to avoid this situation, it is necessary to compare the types of the messages before the message is delivered, so that the message types of the topics are consistent to transmit messages to each other. The two-way conversion mechanism of ROS message and data transmission format JSON (JavaScript Object Notation) message is introduced in the cloud computing center and robot computing node respectively, and the WebSocket protocol is used to establish connection and perform data transmission. The ROS message of the robot computing node can be encapsulated in JSON format, and transmitted to the cloud computing center through the WebSocket protocol through the Internet, and the message interaction with the ROS robot software package deployed in the cloud computing center can be carried out. The cloud computing center subscribes to ROS messages.
本发明包括以下步骤:The present invention includes the following steps:
第一步,搭建云机器人计算节点环境,它由m个机器人计算节点与1个云计算中心组成(m≥1,m是整数)。机器人计算节点是可以运行软件程序的机器人硬件设备(如无人机、无人车、人形机器人等);云计算中心是运行计算密集型或者数据密集型机器人应用并对外提供服务的计算设备。机器人计算节点间以及云计算中心通过网络设备互联。The first step is to build a cloud robot computing node environment, which consists of m robot computing nodes and a cloud computing center (m≥1, m is an integer). Robot computing nodes are robot hardware devices (such as drones, unmanned vehicles, humanoid robots, etc.) that can run software programs; cloud computing centers are computing devices that run computing-intensive or data-intensive robot applications and provide external services. The robot computing nodes and the cloud computing center are interconnected through network equipment.
每个机器人计算节点上除了安装有操作系统Ubuntu(例如14.04版本)、机器人中间件ROS(例如Indigo版本)、WebSocket协议外,还安装有第一ROS消息执行模块、第一消息转换模块和WebSocket连接模块。In addition to the operating system Ubuntu (such as version 14.04), robot middleware ROS (such as Indigo version), and WebSocket protocol installed on each robot computing node, the first ROS message execution module, the first message conversion module and the WebSocket connection are also installed module.
本发明定义“消息操作类型”变量用于描述ROS消息传输的操作方式,它可能的值为:发布主题操作(publish)、订阅主题操作(subscribe)和调用服务操作(call_service)。The present invention defines a variable "message operation type" to describe the operation mode of ROS message transmission, and its possible values are: publish topic operation (publish), subscribe topic operation (subscribe) and call service operation (call_service).
ROS提供的/rosapi/topic_type服务的功能是获取主题名对应的主题消息类型,也就是说通过使用主题名作为参数调用/rosapi/topic_type服务就能得到该主题名对应的主题消息类型,从而获得对应的主题消息内容的格式。The function of the /rosapi/topic_type service provided by ROS is to obtain the topic message type corresponding to the topic name, that is to say, by calling the /rosapi/topic_type service using the topic name as a parameter, the topic message type corresponding to the topic name can be obtained, so as to obtain the corresponding topic message type. The format of the subject message content.
第一ROS消息执行模块由第一服务验证组件、第一消息订阅组件和第一消息发布组件组成。The first ROS message execution module is composed of a first service verification component, a first message subscription component and a first message publishing component.
第一服务验证组件的功能是比较机器人计算节点和云计算中心发布与订阅具有相同主题名的主题消息类型是否一致。第一服务验证组件与第一消息转换模块、第一消息发布组件、第一消息订阅组件和用户相连。第一服务验证组件从用户接收发布与订阅主题名,设置消息操作类型、调用服务名称,将消息操作类型、调用服务名称和主题名发送给第一消息转换模块;第一服务验证组件从第一消息转换模块接收云计算中心返回的发布与订阅主题名对应的主题消息类型和应答结果标记,使用发布与订阅的主题名作为参数调用所属机器人计算节点的/rosapi/topic_type服务获取所属机器人计算节点这些主题名对应的主题消息类型,并与从云计算中心获取的主题名对应的主题消息类型进行比较,若机器人计算节点和云计算中心相同的主题名对应的主题消息类型相同,则机器人计算节点和云计算中心的ROS机器人软件包可以通过云服务协议进行交互,将订阅主题名和主题消息类型发送给第一消息订阅组件,将发布主题名和主题消息类型发送给第一消息发布组件;若主题消息类型不同,则不能访问。The function of the first service verification component is to compare whether the robot computing node and the cloud computing center publish and subscribe to the same topic message type with the same topic name. The first service verification component is connected with the first message conversion module, the first message publishing component, the first message subscribing component and the user. The first service verification component receives the publish and subscribe topic name from the user, sets the message operation type, the calling service name, and sends the message operation type, calling service name and topic name to the first message conversion module; The message conversion module receives the topic message type and response result tag corresponding to the publish and subscribe topic names returned by the cloud computing center, and uses the publish and subscribe topic names as parameters to call the /rosapi/topic_type service of the robot computing node to which the robot computing node belongs to get these The topic message type corresponding to the topic name is compared with the topic message type corresponding to the topic name obtained from the cloud computing center. If the robot computing node and the cloud computing center have the same topic message type corresponding to the same topic name, the robot computing node and The ROS robot software package in the cloud computing center can interact through the cloud service protocol, send the subscription topic name and topic message type to the first message subscription component, and send the publishing topic name and topic message type to the first message publishing component; if the topic message type different, it cannot be accessed.
第一消息订阅组件使用已经通过验证的订阅主题名订阅云计算中心的ROS消息,并接收云计算中心返回的主题名和主题消息内容,在所属机器人计算节点构造和发布ROS消息。第一消息订阅组件与第一服务验证组件、第一消息转换模块、ROS机器人软件包中ROS消息订阅者相连。第一订阅消息组件从第一服务验证组件接收订阅主题名和主题消息类型,设置消息操作类型,将主题名、主题消息类型和消息操作类型发送给第一消息转换模块。第一消息订阅组件从第一消息转换模块获取主题消息内容和主题名,通过ROS消息机制构造和发布ROS消息,ROS机器人软件包中ROS消息订阅者通过ROS消息机制接收到ROS消息。The first message subscription component subscribes to the ROS message of the cloud computing center using the verified subscription topic name, receives the topic name and topic message content returned by the cloud computing center, and constructs and publishes the ROS message on the robot computing node to which it belongs. The first message subscription component is connected with the first service verification component, the first message conversion module, and the ROS message subscriber in the ROS robot software package. The first subscription message component receives the subscription topic name and topic message type from the first service verification component, sets the message operation type, and sends the topic name, topic message type and message operation type to the first message conversion module. The first message subscription component obtains the topic message content and topic name from the first message conversion module, constructs and publishes the ROS message through the ROS message mechanism, and the ROS message subscriber in the ROS robot software package receives the ROS message through the ROS message mechanism.
第一消息发布组件的功能是将已经通过验证的发布主题名上的ROS消息发布到云计算中心。它与第一服务验证组件、第一消息转模块、ROS机器人软件包中ROS消息发布者相连。第一消息发布组件从第一服务验证组件接收发布主题名和主题消息类型,使用ROS消息机制订阅该主题上的ROS消息。第一消息发布组件使用ROS机制接收到ROS消息发布者在该主题上发布的ROS消息,将ROS消息和消息操作类型发送给第一消息转换模块。The function of the first message publishing component is to publish the ROS message on the verified publishing topic name to the cloud computing center. It is connected with the first service verification component, the first message transfer module, and the ROS message publisher in the ROS robot software package. The first message publishing component receives the publishing topic name and the topic message type from the first service verification component, and uses the ROS message mechanism to subscribe to ROS messages on the topic. The first message publishing component uses the ROS mechanism to receive the ROS message published by the ROS message publisher on the topic, and sends the ROS message and the message operation type to the first message conversion module.
第一消息转换模块与第一消息订阅组件、第一消息发布组件、第一服务验证组件、WebSocket连接模块相连,具有构造和解析JSON消息的功能。The first message conversion module is connected with the first message subscription component, the first message publishing component, the first service verification component, and the WebSocket connection module, and has the function of constructing and parsing JSON messages.
第一消息转换模块构造JSON消息的方法是:The method that the first message conversion module constructs the JSON message is:
如果是发布主题操作,第一消息转换模块从第一消息发布组件接收ROS消息和消息操作类型,获取ROS消息的主题消息内容和主题名,将原ROS主题消息内容转化成JSON字段,构造发布主题格式的JSON消息,并将发布主题格式的JSON消息发送给WebSocket连接模块。如果是订阅主题操作,第一消息转换模块从第一消息订阅组件接收订阅主题名、主题消息类型和消息操作类型,构造订阅主题格式的JSON消息,并将订阅主题格式的JSON消息发送给WebSocket连接模块。如果是调用服务操作,第一消息转换模块从第一服务验证组件接收消息操作类型、调用服务名称和主题名,构造调用服务请求格式的JSON消息,并将调用服务请求格式的JSON消息发送给WebSocket连接模块。If it is a publishing topic operation, the first message conversion module receives the ROS message and the message operation type from the first message publishing component, obtains the topic message content and topic name of the ROS message, converts the original ROS topic message content into JSON fields, and constructs a publishing topic Format JSON message, and send the JSON message in publish topic format to the WebSocket connection module. If it is a subscription topic operation, the first message conversion module receives the subscription topic name, topic message type and message operation type from the first message subscription component, constructs a JSON message in the subscription topic format, and sends the JSON message in the subscription topic format to the WebSocket connection. module. If it is an invocation service operation, the first message conversion module receives the message operation type, invocation service name and topic name from the first service verification component, constructs a JSON message in the format of the invocation service request, and sends the JSON message in the format of the invocation service request to WebSocket Connect the module.
第一消息转换模块解析JSON消息的方法是:The method that the first message conversion module parses the JSON message is:
第一消息转换模块从WebSocket连接模块接收JSON消息,解析JSON消息中的消息操作类型,如果是发布主题操作,第一消息转换模块获取主题名和主题消息内容,将主题名和主题消息内容发送给第一消息订阅组件。如果是调用服务操作,第一消息转换模块获取应答结果标记和服务返回结果(即主题消息类型),将应答结果标记和服务返回结果发送给第一服务验证组件。(第一消息转换模块从WebSocket连接模块接收的JSON消息中的消息操作类型不会是订阅主题操作,因为第一消息转换模块收到的JSON消息都是第二消息转换模块构造的JSON消息,第二消息转换模块不会构造订阅主题格式的JSON消息,因为云计算中心被动提供服务,不会主动订阅机器人计算节点上的信息,因此不涉及构造订阅主题格式的JSON消息)。The first message conversion module receives the JSON message from the WebSocket connection module, and parses the message operation type in the JSON message. If it is a publishing topic operation, the first message conversion module obtains the topic name and topic message content, and sends the topic name and topic message content to the first message. message subscription component. If it is to invoke the service operation, the first message conversion module obtains the response result mark and the service return result (ie, the topic message type), and sends the response result mark and the service return result to the first service verification component. (The message operation type in the JSON message received by the first message conversion module from the WebSocket connection module will not be a subscription topic operation, because the JSON messages received by the first message conversion module are all JSON messages constructed by the second message conversion module. The second message conversion module will not construct JSON messages in subscription topic format, because the cloud computing center passively provides services and will not actively subscribe to information on robot computing nodes, so it does not involve constructing JSON messages in subscription topic format).
WebSocket连接模块与第一消息转换模块、云计算中心相连。WebSocket连接模块通过URL(UniformResourceLocator,统一资源定位符)和端口与云计算中心建立WebSocket链接。WebSocket连接模块的功能是发送和接收JSON消息。WebSocket连接模块从第一消息转换模块接收JSON消息,使用WebSocket链接将JSON消息发送给云计算中心。WebSocket连接模块通过WebSocket链接从云计算中心接收JSON消息,将JSON消息发送给第一消息转换模块。The WebSocket connection module is connected with the first message conversion module and the cloud computing center. The WebSocket connection module establishes a WebSocket link with the cloud computing center through a URL (UniformResourceLocator, Uniform Resource Locator) and a port. The function of the WebSocket connection module is to send and receive JSON messages. The WebSocket connection module receives the JSON message from the first message conversion module, and uses the WebSocket connection to send the JSON message to the cloud computing center. The WebSocket connection module receives the JSON message from the cloud computing center through the WebSocket link, and sends the JSON message to the first message conversion module.
云计算中心上除了装有操作系统Ubuntu(例如14.04版本)、机器人中间件ROS(例如Indigo版本,由ROS消息发布者、ROS消息订阅者以及ROS原有通信协议等组成)、WebSocket协议外,还有第二ROS消息执行模块、第二消息转换模块和WebSocket服务模块。In addition to the operating system Ubuntu (such as version 14.04), the robot middleware ROS (such as Indigo version, which consists of ROS message publishers, ROS message subscribers, and ROS original communication protocols, etc.), and the WebSocket protocol, the cloud computing center is also installed. There are a second ROS message execution module, a second message conversion module and a WebSocket service module.
WebSocket服务模块与第二消息转换模块、机器人计算节点的WebSocket连接模块相连。WebSocket服务模块的功能是使得机器人计算节点能够通过URL和端口与云计算中心建立WebSocket链接。WebSocket服务模块通过监听WebSocket连接从WebSocket连接模块接收JSON消息,将JSON消息发送给第二消息转换模块。WebSocket服务模块从第二消息转换模块接收JSON消息,使用WebSocket连接将JSON消息发送给机器人计算节点的WebSocket连接模块。The WebSocket service module is connected with the second message conversion module and the WebSocket connection module of the robot computing node. The function of the WebSocket service module is to enable the robot computing node to establish a WebSocket link with the cloud computing center through URL and port. The WebSocket service module receives the JSON message from the WebSocket connection module by monitoring the WebSocket connection, and sends the JSON message to the second message conversion module. The WebSocket service module receives the JSON message from the second message conversion module, and uses the WebSocket connection to send the JSON message to the WebSocket connection module of the robot computing node.
第二消息转换模块与WebSocket服务模块相连,其功能与机器人计算节点的第一消息转换模块的功能基本相同,具有构造和解析JSON消息的功能。The second message conversion module is connected to the WebSocket service module, and its function is basically the same as that of the first message conversion module of the robot computing node, and has the function of constructing and parsing JSON messages.
第二消息转换模块构造JSON消息的方法是:The method for constructing the JSON message by the second message conversion module is:
如果是发布主题操作,表明云计算中心发布了机器人订阅的主题,需要将该主题上ROS消息返回给机器人。第二消息转换模块从第二消息订阅组件接收ROS消息和消息操作类型,获取ROS消息的主题消息内容和主题名,将ROS消息的主题消息内容转化成JSON字段,构造发布主题格式的JSON消息,并将发布主题格式的JSON消息发送给WebSocket服务模块。如果是调用服务操作,表示机器人调用服务有返回结果。第二消息转换模块从第二服务验证组件获取消息操作类型、调用服务名称、主题消息类型和应答结果标记,构造调用服务应答格式的JSON消息,并将调用服务应答格式的JSON消息发送给WebSocket服务模块。If the operation is to publish a topic, it indicates that the cloud computing center has published the topic subscribed by the robot, and the ROS message on the topic needs to be returned to the robot. The second message conversion module receives the ROS message and the message operation type from the second message subscription component, obtains the topic message content and topic name of the ROS message, converts the topic message content of the ROS message into a JSON field, and constructs a JSON message in a published topic format, And send the JSON message in the format of the publish topic to the WebSocket service module. If it is to call a service operation, it means that the robot calls the service and returns a result. The second message conversion module obtains the message operation type, calling service name, topic message type and response result mark from the second service verification component, constructs a JSON message in the format of the response to the called service, and sends the JSON message in the format of the response to the called service to the WebSocket service module.
第二消息转换模块解析JSON消息的方法是:The method for the second message conversion module to parse the JSON message is:
第二消息转换模块从WebSocket服务模块接收JSON消息,解析JSON消息中的消息操作类型,如果是发布主题操作,获取主题名和主题消息内容,将主题名和主题消息内容发送给第二消息发布组件。如果是订阅主题操作,获取订阅的主题名和主题消息类型,将订阅的主题名和主题消息类型发送给第二消息订阅组件。如果是调用服务操作,获取调用服务名称和参数,将调用服务名称和参数发送给第二服务验证组件。The second message conversion module receives the JSON message from the WebSocket service module, parses the message operation type in the JSON message, and if it is a publishing topic operation, obtains the topic name and topic message content, and sends the topic name and topic message content to the second message publishing component. If the operation is to subscribe to a topic, obtain the subscribed topic name and topic message type, and send the subscribed topic name and topic message type to the second message subscription component. If it is an operation of calling a service, obtain the name and parameters of the calling service, and send the name and parameters of the calling service to the second service verification component.
第二ROS消息执行模块由第二服务验证组件、第二消息订阅组件和第二消息发布组件组成。The second ROS message execution module is composed of a second service verification component, a second message subscription component and a second message publishing component.
第二服务验证组件的功能是获得发布与订阅主题名对应的主题消息类型。第二服务验证组件与第二消息转换模块相连,第二服务验证组件从第二消息转换模块接收调用服务名称和主题名,使用主题名作为参数调用服务,获得主题名对应的主题消息类型,并将消息操作类型和主题消息类型发送给第二消息转换模块。The function of the second service verification component is to obtain the topic message type corresponding to the publish and subscribe topic names. The second service verification component is connected to the second message conversion module, the second service verification component receives the calling service name and the topic name from the second message conversion module, uses the topic name as a parameter to call the service, obtains the topic message type corresponding to the topic name, and Send the message operation type and topic message type to the second message conversion module.
第二消息订阅组件使用订阅消息主题名订阅ROS消息,接收ROS消息并向机器人计算节点发布ROS消息。它与第二消息转换模块、ROS机器人软件包中ROS消息发布者相连。第二消息订阅组件从第二消息转换模块接收订阅消息主题名和主题消息类型,使用ROS消息机制进行ROS消息订阅。第二消息订阅组件使用ROS消息机制接收ROS消息发布者在某一主题上发布的ROS消息,将ROS主题消息内容和消息操作类型发送给第二消息转换模块。The second message subscription component subscribes to the ROS message using the subscription message topic name, receives the ROS message, and publishes the ROS message to the robot computing node. It is connected with the second message conversion module, the ROS message publisher in the ROS robot software package. The second message subscription component receives the subscription message topic name and topic message type from the second message conversion module, and uses the ROS message mechanism to subscribe to the ROS message. The second message subscription component uses the ROS message mechanism to receive the ROS message published by the ROS message publisher on a certain topic, and sends the ROS topic message content and message operation type to the second message conversion module.
第二消息发布组件使用ROS消息机制发布ROS消息。它与第二消息转换模块、ROS机器人软件包中ROS消息订阅者相连。第二消息发布组件从第二消息转换模块接收消息主题名和主题消息内容,使用ROS消息机制构造和发布ROS消息,机器人软件包中ROS消息订阅者通过ROS消息机制接收到ROS消息。The second message publishing component uses the ROS message mechanism to publish ROS messages. It is connected with the second message conversion module, the ROS message subscriber in the ROS robot software package. The second message publishing component receives the message topic name and topic message content from the second message conversion module, uses the ROS message mechanism to construct and publish the ROS message, and the ROS message subscriber in the robot software package receives the ROS message through the ROS message mechanism.
第二步,机器人计算节点和云计算中心相互配合,比较机器人计算节点的发布主题名对应的主题消息类型与云计算中心上的同名订阅主题名的主题消息类型是否相同,同时比较机器人计算节点的订阅主题名的主题消息类型与云计算中心的发布主题名的主题消息类型是否相同。具体步骤如下:In the second step, the robot computing node and the cloud computing center cooperate with each other to compare whether the topic message type corresponding to the publishing topic name of the robot computing node is the same as the topic message type of the subscription topic name of the same name on the cloud computing center. Whether the topic message type of the subscription topic name is the same as the topic message type of the publishing topic name of the cloud computing center. Specific steps are as follows:
2.1机器人计算节点的WebSocket连接模块通过使用URL和端口(例如“ws://<B_IP_Address>:Port”)与云计算中心的WebSocket服务模块建立WebSocket连接。如果无法连接则显示报错信息,执行第四步,正确连接则执行步骤2.2。2.1 The WebSocket connection module of the robot computing node establishes a WebSocket connection with the WebSocket service module of the cloud computing center by using the URL and port (for example, "ws://<B_IP_Address>:Port"). If it cannot be connected, an error message will be displayed and go to step 4. If the connection is correct, go to step 2.2.
2.2机器人计算节点的第一服务验证组件接收用户指定的发布和订阅主题名(例如/TopicSubscribe和/TopicPublish),使用主题名作为参数,通过WebSocket连接模块获得云计算中心同样主题名对应的主题消息类型。具体步骤如下:2.2 The first service verification component of the robot computing node receives the user-specified publish and subscribe topic names (such as /TopicSubscribe and /TopicPublish), uses the topic name as a parameter, and obtains the topic message type corresponding to the same topic name in the cloud computing center through the WebSocket connection module . Specific steps are as follows:
2.2.1机器人计算节点的第一服务验证组件接收用户指定的发布和订阅主题名,设置调用服务名称为“/rosapi/topic_type”和消息操作类型为"call_service",将该用户指定的发布和订阅主题名、调用服务名称和消息操作类型发送给第一消息转换模块。2.2.1 The first service verification component of the robot computing node receives the user-specified publish and subscribe topic name, sets the call service name to "/rosapi/topic_type" and the message operation type to "call_service", and the user-specified publish and subscribe The topic name, the calling service name and the message operation type are sent to the first message conversion module.
2.2.2机器人计算节点的第一消息转换模块接收到发布和订阅主题名、调用服务名称和消息操作类型,对消息操作类型进行判断。消息操作类型是"call_service",依据下述格式构造调用服务请求格式的JSON消息,并将调用服务请求格式的JSON消息发送给WebSocket连接模块。2.2.2 The first message conversion module of the robot computing node receives the publish and subscribe topic name, the calling service name and the message operation type, and judges the message operation type. The message operation type is "call_service", construct the JSON message in the calling service request format according to the following format, and send the JSON message in the calling service request format to the WebSocket connection module.
调用服务请求格式的JSON消息的格式为:The format of the JSON message in the call service request format is:
“op”字段是string类型,表示对ROS消息的操作类型;The "op" field is of type string, indicating the type of operation on the ROS message;
“service”字段是string类型,表示调用服务的名称;The "service" field is of type string, indicating the name of the calling service;
“args”字段由JSON数据列表组成,表示调用服务的参数,参数内容用JSON格式数据来表示,本字段是可供选择的字段,即有的服务不需要参数。The "args" field consists of a list of JSON data, representing the parameters for calling the service. The parameter content is represented by JSON format data. This field is an optional field, that is, some services do not require parameters.
构造调用服务请求格式的JSON消息方法是:将“op”字段设置为"call_service",将“service”字段设置为调用服务名称"/rosapi/topic_type",将“arg”字段设置为发布与订阅主题名即"/TopicSubscribe/TopicPublish"。The method of constructing the JSON message in the call service request format is: set the "op" field to "call_service", set the "service" field to the call service name "/rosapi/topic_type", and set the "arg" field to the publish and subscribe topic The name is "/TopicSubscribe/TopicPublish".
2.2.3机器人计算节点的WebSocket连接模块接收到调用服务请求格式的JSON消息后,使用步骤2.1建立的WebSocket连接向云计算中心的WebSocket服务模块发送调用服务请求格式的JSON消息。如果发送失败则打印错误信息并执行第四步,发送成功则执行步骤2.2.4。2.2.3 After receiving the JSON message in the calling service request format, the WebSocket connection module of the robot computing node uses the WebSocket connection established in step 2.1 to send the JSON message in the calling service request format to the WebSocket service module of the cloud computing center. If the sending fails, print the error message and go to step 4; if the sending is successful, go to step 2.2.4.
2.2.4云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接获得机器人计算节点发送的调用服务请求格式的JSON消息,将调用服务请求格式的JSON消息发送给云计算中心的第二消息转换模块。2.2.4 The WebSocket service module of the cloud computing center obtains the JSON message in the calling service request format sent by the robot computing node by monitoring the WebSocket connection established in step 2.1, and sends the JSON message in the calling service request format to the second message conversion of the cloud computing center. module.
2.2.5云计算中心的第二消息转换模块接收到调用服务请求格式的JSON消息后,解析调用服务请求格式的JSON消息的内容,获取消息操作类型。消息操作类型是call_service,第二消息转换模块解析调用服务名称和参数,并将调用服务名称和参数发送给云计算中心的第二服务验证组件。2.2.5 After receiving the JSON message in the calling service request format, the second message conversion module of the cloud computing center parses the content of the JSON message in the calling service request format to obtain the message operation type. The message operation type is call_service, and the second message conversion module parses the calling service name and parameters, and sends the calling service name and parameters to the second service verification component of the cloud computing center.
2.2.6云计算中心的第二服务验证组件接收到调用服务名称和参数,使用发布与订阅主题名作为参数运行服务/rosapi/topic_type,获取主题消息类型。如果成功获取主题消息类型,设置应答结果标记为“1”,表示成功获取结果;否则设置应答结果标记为“0”,主题消息类型置为空。第二服务验证组件将发布与订阅主题的主题消息类型、应答结果标记、调用服务名称和消息操作类型发送给云计算中心的第二消息转换模块。2.2.6 The second service verification component of the cloud computing center receives the calling service name and parameters, and uses the publish and subscribe topic name as a parameter to run the service /rosapi/topic_type to obtain the topic message type. If the topic message type is successfully obtained, set the response result flag to "1", indicating that the result is successfully obtained; otherwise, set the response result flag to "0", and set the topic message type to null. The second service verification component sends the topic message type of the publish and subscribe topic, the response result mark, the calling service name and the message operation type to the second message conversion module of the cloud computing center.
2.2.7云计算中心的第二消息转换模块接收到消息操作类型、调用服务名称、发布与订阅主题的主题消息类型和应答结果标记之后,构造调用服务应答格式的JSON消息。依据下述格式构造调用服务操作应答格式的JSON消息,并将调用服务应答格式的JSON消息发送给WebSocket服务模块。2.2.7 After the second message conversion module of the cloud computing center receives the message operation type, the calling service name, the topic message type of the publishing and subscribing topics, and the response result mark, it constructs a JSON message in the calling service response format. Construct the JSON message in the response format of calling service operation according to the following format, and send the JSON message in response format of calling service to the WebSocket service module.
调用服务应答格式的JSON消息的格式为:The format of the JSON message in the call service response format is:
“op”字段是string类型,表示对ROS消息的操作类型;The "op" field is of type string, indicating the type of operation on the ROS message;
“service”字段是string类型,表示调用服务的名称;The "service" field is of type string, indicating the name of the calling service;
“result”字段是bool类型,表示调用服务有返回值,0表示调用服务没有成功获取,1表示调用服务成功获取;The "result" field is of bool type, indicating that the calling service has a return value, 0 indicates that the calling service was not successfully obtained, and 1 indicates that the calling service was successfully obtained;
“value”字段由JSON格式的数据列表组成,表示调用服务的返回值。The "value" field consists of a JSON-formatted list of data representing the return value of calling the service.
构造调用服务应答格式JSON消息的方法是:将“op”字段设置为"call_service",将“service”字段设置为调用服务名称"/rosapi/topic_type",将“result”字段设置为应答结果标记,将“value”字段设置为获取的发布与订阅主题的主题消息类型。The method of constructing a JSON message in call service response format is: set the "op" field to "call_service", set the "service" field to the call service name "/rosapi/topic_type", and set the "result" field to the response result tag, Set the "value" field to the topic message type of the fetched pub and subscribe topic.
2.2.8云计算中心的WebSocket服务模块接收到调用服务应答格式的JSON消息后,使用步骤2.1建立的WebSocket连接将调用服务应答格式的JSON消息发送给机器人计算节点的WebSocket连接模块。2.2.8 After the WebSocket service module of the cloud computing center receives the JSON message in the response format for calling the service, it uses the WebSocket connection established in step 2.1 to send the JSON message in the response format for calling the service to the WebSocket connection module of the robot computing node.
2.2.9机器人计算节点的WebSocket连接模块接收到调用服务应答格式的JSON消息后,将其发送给第一消息转换模块。2.2.9 After the WebSocket connection module of the robot computing node receives the JSON message in the call service response format, it sends it to the first message conversion module.
2.2.10机器人计算节点的第一消息转换模块接收到调用服务应答格式的JSON消息后,解析调用服务应答格式的JSON消息的内容,获取消息操作类型。消息操作类型是call_service,获取云计算中心发布与订阅主题的主题消息类型和应答结果标记,并将主题名的主题消息类型和应答结果标记发送给第一服务验证组件。2.2.10 After receiving the JSON message in the service call response format, the first message conversion module of the robot computing node parses the content of the JSON message in the service call response format to obtain the message operation type. The message operation type is call_service, obtains the topic message type and response result tag of the topic published and subscribed by the cloud computing center, and sends the topic message type and response result tag of the topic name to the first service verification component.
2.3机器人计算节点的第一服务验证组件接收到云计算中心发布与订阅主题的主题消息类型和应答结果标记,对应答结果标记进行判断。如果应答结果标记是0,说明没有成功获得云计算中心发布与订阅主题名对应的主题消息类型,打印错误信息并执行第四步;如果应答结果标记是1,使用云计算中心发布与订阅的主题名作为参数调用所属机器人计算节点的/rosapi/topic_type服务,获取所属机器人计算节点发布与订阅主题名对应的主题消息类型,将所属机器人计算节点发布与订阅的主题名对应的主题消息类型与云计算中心的同名主题名对应的主题消息类型进行比较。如果机器人计算节点的发布主题名对应的主题消息类型和云计算中心同名的订阅主题名对应的主题消息类型相同并且机器人节点订阅主题名对应的主题消息类型和云计算中心同名的发布主题名对应的主题消息类型相同,则将发布主题名和主题消息类型发送给第一消息发布组件,将订阅主题名和主题消息类型发送给第一消息订阅组件,执行第三步;否则显示错误信息并执行第四步。2.3 The first service verification component of the robot computing node receives the topic message type and response result mark of the topic published and subscribed by the cloud computing center, and judges the response result mark. If the response result flag is 0, it means that the topic message type corresponding to the topic name published and subscribed by the cloud computing center has not been successfully obtained, print an error message and perform step 4; if the response result flag is 1, use the topic published and subscribed by the cloud computing center Name as a parameter to call the /rosapi/topic_type service of the robot computing node to which the robot computing node belongs, obtain the topic message type corresponding to the topic name published and subscribed by the robot computing node, and match the topic message type corresponding to the topic name published and subscribed by the robot computing node to the cloud computing node. Compare the topic message type corresponding to the topic name of the center with the same name. If the topic message type corresponding to the publishing topic name of the robot computing node is the same as the topic message type corresponding to the subscription topic name of the same name in the cloud computing center, and the topic message type corresponding to the subscription topic name of the robot node is the same as that of the cloud computing center. If the topic message types are the same, send the publishing topic name and topic message type to the first message publishing component, send the subscription topic name and topic message type to the first message subscribing component, and perform step 3; otherwise, display an error message and perform step 4 .
第三步,机器人计算节点按3.1的步骤使用订阅主题名订阅云计算中心同名主题的ROS消息;同时,机器人计算节点按3.2的步骤向云计算中心按发布主题名发布ROS消息。具体步骤如下:In the third step, the robot computing node uses the subscription topic name to subscribe to the ROS message of the same name in the cloud computing center according to the steps of 3.1; at the same time, the robot computing node publishes the ROS message to the cloud computing center according to the publishing topic name according to the steps of 3.2. Specific steps are as follows:
3.1机器人计算节点使用订阅主题名订阅云计算中心同名主题的ROS消息。具体步骤如下:3.1 The robot computing node uses the subscription topic name to subscribe to the ROS message of the topic of the same name in the cloud computing center. Specific steps are as follows:
3.1.1机器人计算节点的第一消息订阅组件从第一服务验证组件接收订阅主题名和主题消息类型,将消息操作类型设置为"subscribe",将消息操作类型、订阅主题名和主题消息类型发送给第一消息转换模块。3.1.1 The first message subscription component of the robot computing node receives the subscription topic name and topic message type from the first service verification component, sets the message operation type to "subscribe", and sends the message operation type, subscription topic name and topic message type to the first A message conversion module.
3.1.2机器人计算节点的第一消息转换模块接收到订阅主题名、主题消息类型和消息操作类型,判断消息操作类型为"subscribe",依据下述格式构造订阅主题格式的JSON消息,并将订阅主题格式的JSON消息发送给WebSocket连接模块。3.1.2 The first message conversion module of the robot computing node receives the subscription topic name, topic message type and message operation type, judges that the message operation type is "subscribe", constructs a JSON message in the subscription topic format according to the following format, and subscribes Topic-formatted JSON messages are sent to the WebSocket connection module.
订阅主题格式的JSON消息的格式为:The format of the JSON message in the subscription topic format is:
“op”字段是string类型,表示对ROS消息的操作类型;The "op" field is of type string, indicating the type of operation on the ROS message;
“topic”字段是string类型,表示订阅消息的消息名称;The "topic" field is of type string, indicating the message name of the subscription message;
“type”表示是string类型,是一个可供选择的字段,表示订阅ROS消息的主题消息类型。"type" indicates a string type, which is an optional field, indicating the type of topic message that subscribes to ROS messages.
构造订阅主题格式的JSON消息的方法是:将“op”字段设置为"subscribe",将“topic”字段设置为订阅主题名,将“type”字段设置为主题消息类型。The way to construct a JSON message in subscription topic format is to set the "op" field to "subscribe", the "topic" field to the subscription topic name, and the "type" field to the topic message type.
3.1.3机器人计算节点的WebSocket连接模块接收到订阅主题格式的JSON消息,使用步骤2.1建立的WebSocket连接发送给云计算中心的WebSocket服务模块。如果发送失败则打印错误信息并执行第四步,发送成功则执行步骤3.1.4。3.1.3 The WebSocket connection module of the robot computing node receives the JSON message in the subscription topic format, and sends it to the WebSocket service module of the cloud computing center using the WebSocket connection established in step 2.1. If the sending fails, print the error message and go to step 4; if the sending is successful, go to step 3.1.4.
3.1.4云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接获取到机器人计算节点发送的订阅主题格式的JSON消息,将该订阅主题格式的JSON消息发送给云计算中心的第二消息转换模块。3.1.4 The WebSocket service module of the cloud computing center obtains the JSON message in the subscription topic format sent by the robot computing node by monitoring the WebSocket connection established in step 2.1, and sends the JSON message in the subscription topic format to the second message conversion of the cloud computing center. module.
3.1.5云计算中心的第二消息转换模块接收到订阅主题格式的JSON消息后,解析订阅主题格式的JSON消息的内容,获取消息操作类型,对消息操作类型进行判断。消息操作类型是subscribe,获得订阅主题名和主题消息类型,并将订阅主题名和主题消息类型发送给第二消息订阅组件。3.1.5 After receiving the JSON message in the subscription topic format, the second message conversion module of the cloud computing center parses the content of the JSON message in the subscription topic format, obtains the message operation type, and judges the message operation type. The message operation type is subscribe, obtain the subscription topic name and topic message type, and send the subscription topic name and topic message type to the second message subscription component.
3.1.6云计算中心的第二消息订阅组件接收到订阅主题名和主题消息类型,以消息的主题名和主题消息类型作为参数,使用ROS消息机制订阅该主题名上的消息。3.1.6 The second message subscription component of the cloud computing center receives the subscription topic name and topic message type, and uses the ROS message mechanism to subscribe to the message on the topic name with the topic name and topic message type of the message as parameters.
3.1.7第二消息订阅组件通过ROS消息机制接收云计算中心的ROS机器人软件包中ROS消息发布者基于该主题名发布的ROS消息,设置消息操作类型为"publish",并将ROS消息和消息操作类型发送给云计算中心的第二消息转换模块。3.1.7 The second message subscription component receives the ROS message published by the ROS message publisher based on the topic name in the ROS robot software package of the cloud computing center through the ROS message mechanism, sets the message operation type to "publish", and sends the ROS message to the message. The operation type is sent to the second message conversion module of the cloud computing center.
3.1.8云计算中心的第二消息转换模块接收到ROS消息和消息操作类型,判断消息操作类型为"publish",第二消息转换模块解析ROS消息,获取主题名和主题消息内容,将主题消息内容转化成JSON字段。按照下述格式构造发布主题格式的JSON消息,并将发布主题格式的JSON消息发送给WebSocket服务模块。3.1.8 The second message conversion module of the cloud computing center receives the ROS message and the message operation type, and judges that the message operation type is "publish". The second message conversion module parses the ROS message, obtains the topic name and topic message content, and converts the topic message content. Converted to JSON fields. Construct the JSON message in the publish topic format according to the following format, and send the JSON message in the publish topic format to the WebSocket service module.
发布主题格式的JSON消息格式为:The format of the JSON message in the publish topic format is:
{"op":<string>,{"op":<string>,
"topic":<string>,"topic":<string>,
"msg":<json>"msg":<json>
}}
“op”字段是string类型,表示对ROS消息的操作类型;The "op" field is of type string, indicating the type of operation on the ROS message;
“topic”字段是string类型,表示发布消息的主题名;The "topic" field is of type string, indicating the topic name of the published message;
“msg”字段是JSON格式的数据,表示发布主题消息的内容。The "msg" field is JSON-formatted data representing the content of the published topic message.
构造发布主题的JSON消息的方法是:将“op”字段设置为"publish",将“topic”字段设置为ROS消息的主题名,将“msg”字段设置为转换成JSON格式的主题消息内容。The method of constructing a JSON message for publishing a topic is to set the "op" field to "publish", set the "topic" field to the topic name of the ROS message, and set the "msg" field to the content of the topic message converted into JSON format.
3.1.9云计算中心的WebSocket服务模块接收到发布主题格式的JSON消息,使用步骤2.1建立的WebSocket连接将发布主题格式的JSON消息发送给机器人计算节点的WebSocket连接模块。3.1.9 The WebSocket service module of the cloud computing center receives the JSON message in the published topic format, and uses the WebSocket connection established in step 2.1 to send the JSON message in the published topic format to the WebSocket connection module of the robot computing node.
3.1.10机器人计算节点的WebSocket连接模块通过监听步骤2.1建立的WebSocket连接接收到发布主题格式的JSON消息,将发布主题格式的JSON消息发送给第一消息转换模块。3.1.10 The WebSocket connection module of the robot computing node receives the JSON message in the published topic format by monitoring the WebSocket connection established in step 2.1, and sends the JSON message in the published topic format to the first message conversion module.
3.1.11机器人计算节点的第一消息转换模块接收到发布主题格式的JSON消息,获取消息操作类型。判断消息操作类型为"publish",获取主题名和主题消息内容,并将主题名和主题消息内容发送给第一消息订阅组件。3.1.11 The first message conversion module of the robot computing node receives the JSON message in the published topic format, and obtains the message operation type. It is judged that the message operation type is "publish", the topic name and topic message content are obtained, and the topic name and topic message content are sent to the first message subscription component.
3.1.12机器人计算节点的第一订阅消息组件接收主题名和主题消息内容,通过ROS消息机制构造和发布ROS消息,机器人软件包的ROS消息订阅者通过ROS机制接收到ROS消息。转步骤3.1.7继续接收订阅的云计算中心ROS消息。3.1.12 The first subscription message component of the robot computing node receives the topic name and topic message content, constructs and publishes the ROS message through the ROS message mechanism, and the ROS message subscriber of the robot software package receives the ROS message through the ROS mechanism. Go to step 3.1.7 to continue to receive subscribed cloud computing center ROS messages.
3.2机器人计算节点向云计算中心按发布主题名发布ROS消息。具体步骤如下:3.2 The robot computing node releases ROS messages to the cloud computing center according to the release topic name. Specific steps are as follows:
3.2.1机器人计算节点的第一消息发布组件从第一服务验证组件接收发布主题名和主题消息类型,使用ROS消息机制订阅该主题名。3.2.1 The first message publishing component of the robot computing node receives the publishing topic name and topic message type from the first service verification component, and uses the ROS message mechanism to subscribe to the topic name.
3.2.2机器人计算节点的第一消息发布组件通过ROS消息机制接收机器人计算节点的机器人软件包中ROS消息发布者基于该主题名发布的ROS消息,将消息操作类型设置为“publish”,并将ROS消息和消息操作类型发送给第一消息转换模块。3.2.2 The first message publishing component of the robot computing node receives the ROS message published by the ROS message publisher based on the topic name in the robot software package of the robot computing node through the ROS message mechanism, sets the message operation type to "publish", and sets the message operation type to "publish". The ROS message and the message operation type are sent to the first message conversion module.
3.2.3机器人计算节点的第一消息转换模块接收到ROS消息和消息操作类型后,判断消息操作类型为“publish”,第一消息转换模块解析ROS消息,获取主题名和主题消息内容,按照3.1.8的方法构造发布主题格式的JSON消息,即将“op”字段设置为"publish",将“topic”字段设置为ROS消息的主题名,将“msg”字段设置为主题消息内容转化的JSON字段,并将发布主题格式的JSON消息发送给WebSocket连接模块。3.2.3 After the first message conversion module of the robot computing node receives the ROS message and the message operation type, it determines that the message operation type is "publish", and the first message conversion module parses the ROS message to obtain the topic name and topic message content, according to 3.1. The method of 8 constructs a JSON message in the published topic format, that is, set the "op" field to "publish", set the "topic" field to the topic name of the ROS message, and set the "msg" field to the JSON field of the topic message content conversion, And send a JSON message in publish topic format to the WebSocket connection module.
3.2.4机器人计算节点的WebSocket连接模块接收到发布主题格式的JSON消息后,使用步骤2.1建立的WebSocket连接将发布主题格式的JSON消息发送给云计算中心的WebSocket服务模块。如果WebSocket连接模块发送失败则打印错误信息并执行第四步。如果WebSocket连接模块发送成功,则执行步骤3.2.5。3.2.4 After receiving the JSON message in the published topic format, the WebSocket connection module of the robot computing node uses the WebSocket connection established in step 2.1 to send the JSON message in the published topic format to the WebSocket service module of the cloud computing center. If the WebSocket connection module fails to send, print an error message and perform the fourth step. If the WebSocket connection module sends successfully, go to step 3.2.5.
3.2.5云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接接收机器人计算节点发送的发布主题格式的JSON格式的消息,将该消息发送给云计算中心的第二消息转换模块。3.2.5 The WebSocket service module of the cloud computing center receives the message in JSON format sent by the robot computing node by monitoring the WebSocket connection established in step 2.1, and sends the message to the second message conversion module of the cloud computing center.
3.2.6云计算中心的第二消息转换模块接收到发布主题格式的JSON消息后,获取消息操作类型。判断消息操作类型为"publish",获取主题名和主题消息内容,并将主题名和主题消息内容发送给第二消息发布组件。3.2.6 After receiving the JSON message in the published topic format, the second message conversion module of the cloud computing center obtains the message operation type. It is judged that the message operation type is "publish", the topic name and topic message content are obtained, and the topic name and topic message content are sent to the second message publishing component.
3.2.7云计算中心的第二消息发布组件接收到主题名和主题消息内容后,通过ROS消息机制构造和发布ROS消息。3.2.7 After receiving the topic name and topic message content, the second message publishing component of the cloud computing center constructs and publishes the ROS message through the ROS message mechanism.
3.2.8云计算中心ROS机器人软件包中ROS消息订阅者使用发布主题名订阅ROS消息,通过ROS消息机制接收到ROS消息。转步骤3.2.2向云计算中心发布ROS消息。3.2.8 The ROS message subscriber in the ROS robot software package of the cloud computing center subscribes to the ROS message using the publication topic name, and receives the ROS message through the ROS message mechanism. Go to step 3.2.2 to publish ROS messages to the cloud computing center.
ROS软件包发布与订阅的主题消息是按照主题名进行分类的。步骤3.1.1-步骤3.1.6完成了机器人计算节点订阅云计算中心同名主题的ROS消息功能,步骤3.1.7-步骤3.1.12完成了机器人软件包中ROS消息订阅者接收云计算中心同名主题的ROS消息功能。机器人计算节点只需订阅一次某个主题消息,就能接收该类主题上发布的所有消息,所以会循环步骤3.1.7到3.1.12。同理,步骤3.2.1是机器人计算节点的第一消息发布组件接收发布主题名并订阅ROS消息,只需订阅1次即可。步骤3.2.2-步骤3.2.8完成了第一消息发布组件接收ROS消息,向云计算中心按发布主题名发布ROS消息的功能。机器人计算节点发布某个主题消息意味着需要发布该该类主题所有的消息,也就是说机器人计算节点要将某个主题上发布的所有消息都发送给云计算中心,所以会循环步骤3.2.2到3.2.8。Topic messages published and subscribed to by ROS packages are categorized by topic name. Step 3.1.1-Step 3.1.6 completes the ROS message function of the robot computing node subscribing to the topic of the same name in the cloud computing center, and steps 3.1.7-step 3.1.12 completes the ROS message subscriber in the robot software package to receive the topic of the same name in the cloud computing center. ROS message function. The robot computing node only needs to subscribe to a certain topic message once to receive all the messages published on the topic, so steps 3.1.7 to 3.1.12 will be repeated. Similarly, step 3.2.1 is that the first message publishing component of the robot computing node receives the publishing topic name and subscribes to ROS messages, and only needs to subscribe once. Steps 3.2.2 to 3.2.8 complete the function of the first message publishing component receiving the ROS message and publishing the ROS message to the cloud computing center according to the publishing topic name. When the robot computing node publishes a certain topic message, it means that all the messages of this type of topic need to be published, that is to say, the robot computing node needs to send all the messages published on a certain topic to the cloud computing center, so step 3.2.2 will be repeated. to 3.2.8.
第四步,结束。Fourth step, end.
采用本发明可以达到如下的有益效果:The following beneficial effects can be achieved by adopting the present invention:
(1)实现了机器人与云服务之间基于互联网的通信。通过引入ROS消息执行模块、WebSocket连接模块、WebSocket服务模块等功能模块,机器人计算节点ROS机器人软件包可以通过主流的WebSocket云服务访问协议,访问部署在云计算中心的ROS机器人软件包。(1) Internet-based communication between robots and cloud services is realized. By introducing functional modules such as ROS message execution module, WebSocket connection module, and WebSocket service module, the ROS robot software package of the robot computing node can access the ROS robot software package deployed in the cloud computing center through the mainstream WebSocket cloud service access protocol.
(2)现有的基于机器人中间件ROS的机器人软件可以不需要修改就直接部署在云计算中心上成为云服务,机器人计算节点也不需要经过大量修改就可以实现像使用本地ROS应用一样使用云服务。由于本发明引入了消息转换模块、WebSocket连接模块、WebSocket服务模块等,从而屏蔽了ROS消息到JSON消息转换与WebSocket通信的细节,因此现有的ROS软件以及机器人计算节点使用ROS软件的方式并不需要修改。(2) The existing robot software based on the robot middleware ROS can be directly deployed on the cloud computing center to become a cloud service without modification, and the robot computing node can use the cloud like a local ROS application without a lot of modifications. Serve. Since the present invention introduces a message conversion module, a WebSocket connection module, a WebSocket service module, etc., so as to shield the details of ROS message to JSON message conversion and WebSocket communication, the existing ROS software and the way that robot computing nodes use ROS software does not Modification is required.
附图说明Description of drawings
图1是本发明第一步构建多机器人计算节点环境物理结构图。FIG. 1 is a physical structure diagram of the environment for building a multi-robot computing node in the first step of the present invention.
图2是本发明机器人计算节点和云计算机中心上的软件部署图。FIG. 2 is a software deployment diagram on the robot computing node and cloud computing center of the present invention.
图3是本发明整体流程图。Figure 3 is an overall flow chart of the present invention.
图4是本发明第三步3.1步中机器人计算节点订阅云计算中心的ROS消息的流程图。FIG. 4 is a flowchart of the robot computing node subscribing to the ROS message of the cloud computing center in the third step 3.1 of the present invention.
图5是本发明第三步3.2步中机器人计算节点向云计算中心发布ROS消息的流程图。FIG. 5 is a flow chart of the robot computing node publishing ROS messages to the cloud computing center in the third step 3.2 of the present invention.
具体实施方式Detailed ways
图1是本发明第一步构建的多机器人计算节点环境物理结构图,它由m个机器人计算节点与1个云计算中心组成(m≥1,m是整数)。机器人计算节点是可以运行软件程序的机器人硬件设备(如无人机、无人车、人形机器人等);云计算中心是计算与存储资源丰富,可以运行计算密集型或者数据密集型机器人应用并对外提供服务的计算设备。机器人计算节点间以及云计算中心通过网络路由设备互联。1 is a physical structure diagram of the multi-robot computing node environment constructed in the first step of the present invention, which consists of m robot computing nodes and a cloud computing center (m≥1, m is an integer). Robot computing nodes are robot hardware devices that can run software programs (such as drones, unmanned vehicles, humanoid robots, etc.); cloud computing centers are rich in computing and storage resources, and can run computing-intensive or data-intensive robot applications and externally Computing devices that provide services. Robot computing nodes and cloud computing centers are interconnected through network routing devices.
图2是本发明机器人计算节点上的软件部署图。每个机器人计算节点上除了安装有操作系统Ubuntu(例如14.04版本)、机器人中间件ROS(例如Indigo版本)、WebSocket协议外,还安装有第一ROS消息执行模块、第一消息转换模块和WebSocket连接模块。云计算中心上除了装有操作系统Ubuntu(例如14.04版本)、机器人中间件ROS(例如Indigo版本,由ROS消息发布者、ROS消息订阅者以及ROS原有通信协议等组成)、WebSocket协议外,还有第二ROS消息执行模块、第二消息转换模块和WebSocket服务模块。FIG. 2 is a software deployment diagram on the robot computing node of the present invention. In addition to the operating system Ubuntu (such as version 14.04), robot middleware ROS (such as Indigo version), and WebSocket protocol installed on each robot computing node, the first ROS message execution module, the first message conversion module and the WebSocket connection are also installed module. In addition to the operating system Ubuntu (such as version 14.04), the robot middleware ROS (such as Indigo version, which consists of ROS message publishers, ROS message subscribers, and ROS original communication protocols, etc.), and the WebSocket protocol, the cloud computing center is also installed. There are a second ROS message execution module, a second message conversion module and a WebSocket service module.
以下以turtlebot机器人跟随人进行移动为例说明本发明的具体实施方式。该实例由一台turtlebot机器人与一个云计算中心组成。云计算中心上除了运行第二ROS消息执行模块、第二消息转换模块和WebSocket服务模块外,还运行turtlebot_fllower机器人软件包(常用ROS机器人软件包,可从http://wiki.ros.org/turtlebot_follower下载),其功能是计算环境点云数据中包含的跟随物的中心、距离和速度,然后计算出机器人为了与跟随物保持一定的跟随距离所需要的线速度和角速度。turtlebot机器人除了运行第一ROS消息执行模块、第一消息转换模块和WebSocket连接模块外,还运行freenect_launch软件包(常用ROS机器人软件包,可从http://wiki.ros.org/freenect_launch下载)和turtlebot_bringup软件包(常用ROS机器人软件包,可从http://wiki.ros.org/turtlebot_bringup/Tutorials/indigo/TurtleBot%20Bringup下载)。freenect_launch软件包用于获取深度摄像头的点云数据,freenect_launch软件包通过“/depth/image_rect”主题向云计算中心的turtlebot_fllower机器人软件包发布环境的点云数据。turtlebot_bringup软件包订阅云计算中心的turtlebot_fllower机器人软件包发布“/cmd_vel”主题的消息,获得线速度和角速度,然后控制机器人行走对人进行跟随。The specific embodiment of the present invention is described below by taking the turtlebot robot moving with a person as an example. The instance consists of a turtlebot robot and a cloud computing center. In addition to running the second ROS message execution module, the second message conversion module and the WebSocket service module, the cloud computing center also runs the turtlebot_fllower robot software package (the commonly used ROS robot software package, available from http://wiki.ros.org/turtlebot_follower Download), its function is to calculate the center, distance and velocity of the follower contained in the environmental point cloud data, and then calculate the linear and angular velocity required by the robot to maintain a certain following distance with the follower. In addition to running the first ROS message execution module, the first message conversion module and the WebSocket connection module, the turtlebot robot also runs the freenect_launch software package (a commonly used ROS robot software package, which can be downloaded fromhttp://wiki.ros.org/freenect_launch ) andturtlebot_bringup package (commonly used ROS robot package, available fromhttp://wiki.ros.org/turtlebot_bringup/Tutorials/indigo/TurtleBot%20Bringup ). The freenect_launch package is used to obtain the point cloud data of the depth camera. The freenect_launch package publishes the point cloud data of the environment to the turtlebot_fllower robot package in the cloud computing center through the topic "/depth/image_rect". The turtlebot_bringup package subscribes to the turtlebot_fllower robot package in the cloud computing center to publish messages on the topic "/cmd_vel", obtains the linear velocity and angular velocity, and then controls the robot to walk and follow the person.
采用本发明的具体实施方式如下:The specific embodiments of the present invention are as follows:
第一步,搭建云机器人计算节点环境,它由m个turtlebot机器人与1个云计算中心组成。为简单起见,令m=1,turtlebot机器人与1个云计算中心通过网络设备互联。turtlebot机器人硬件设备包括机器人底座,控制机器人的笔记本电脑以及点云数据采集设备Kinect摄像头。Turtlebot笔记本上装有操作系统Ubuntu 14.04版本、机器人中间件ROS Indigo版本、机器人控制软件包turtlebot_bringup,Kinect传感器数据采集与计算软件包freenect_launch、第一ROS消息执行模块、第一消息转换模块和WebSocket连接模块。云计算中心上运行有操作系统Ubuntu 14.04版本、ROS Indigo版本、第二ROS消息执行模块、第二消息转换模块和WebSocket服务模块,以及turtlebot_fllower软件包。The first step is to build a cloud robot computing node environment, which consists of m turtlebot robots and a cloud computing center. For the sake of simplicity, let m=1, and the turtlebot robot is interconnected with a cloud computing center through network equipment. The turtlebot robot hardware equipment includes a robot base, a laptop to control the robot, and a Kinect camera, a point cloud data acquisition device. The Turtlebot notebook is equipped with the operating system Ubuntu 14.04 version, the robot middleware ROS Indigo version, the robot control software package turtlebot_bringup, the Kinect sensor data acquisition and calculation software package freenect_launch, the first ROS message execution module, the first message conversion module and the WebSocket connection module. The cloud computing center runs the operating system Ubuntu 14.04 version, the ROS Indigo version, the second ROS message execution module, the second message conversion module, the WebSocket service module, and the turtlebot_fllower software package.
第二步,turtlebot机器人比较该机器人的发布主题名“/depth/image_rect”与订阅的主题名“/cmd_vel”对应的主题消息类型与云计算中心上的订阅主题名“/depth/image_rect”与发布的主题名“/cmd_vel”的主题消息类型是否相同。In the second step, the turtlebot robot compares the topic message type corresponding to the robot's publishing topic name "/depth/image_rect" and the subscribed topic name "/cmd_vel" with the subscription topic name "/depth/image_rect" on the cloud computing center and publishing Is the topic message type of the topic name "/cmd_vel" the same.
2.1 turtlebot机器人的WebSocket连接模块通过使用URL和端口(例如“ws://<202.197.251.250>:9090”)与云计算中心的WebSocket服务模块建立WebSocket连接。如果无法连接则显示报错信息,执行第四步,正确连接则执行步骤2.2。2.1 The WebSocket connection module of the turtlebot robot establishes a WebSocket connection with the WebSocket service module of the cloud computing center by using the URL and port (for example, "ws://<202.197.251.250>:9090"). If it cannot be connected, an error message will be displayed and go to step 4. If the connection is correct, go to step 2.2.
2.2 turtlebot机器人的第一服务验证组件使用主题名“/depth/image_rect”和“/cmd_vel”作为参数,通过WebSocket连接模块获得云计算中心这两个主题名对应的主题消息类型。具体步骤如下:2.2 The first service verification component of the turtlebot robot uses the topic names "/depth/image_rect" and "/cmd_vel" as parameters, and obtains the topic message types corresponding to these two topic names in the cloud computing center through the WebSocket connection module. Specific steps are as follows:
2.2.1 turtlebot机器人的第一服务验证组件接收用户指定的发布的主题名“/depth/image_rect”和订阅主题名“/cmd_vel”,设置调用服务名称名称为“/rosapi/topic_type”和消息操作类型为"call_service",将该用户指定的发布和订阅主题名、调用服务名称和消息操作类型发送给第一消息转换模块。2.2.1 The first service verification component of the turtlebot robot receives the published topic name "/depth/image_rect" and the subscription topic name "/cmd_vel" specified by the user, and sets the calling service name to "/rosapi/topic_type" and the message operation type For "call_service", the user-specified publish and subscribe topic name, call service name and message operation type are sent to the first message conversion module.
2.2.2 turtlebot机器人的第一消息转换模块接收到发布与订阅主题名“/depth/image_rect”和“/cmd_vel”、调用服务名称(“/rosapi/topic_type”)和消息操作类型("call_service")。消息操作类型是"call_service",构造调用服务请求格式的JSON消息,并将调用服务请求格式的JSON消息发送给WebSocket连接模块。2.2.2 The first message conversion module of the turtlebot robot receives the publish and subscribe topic names "/depth/image_rect" and "/cmd_vel", the call service name ("/rosapi/topic_type") and the message operation type ("call_service") . The message operation type is "call_service", constructs a JSON message in the format of the call service request, and sends the JSON message in the format of the call service request to the WebSocket connection module.
调用服务请求格式的JSON消息的格式是:The format of the JSON message in the call service request format is:
2.2.3 turtlebot机器人的WebSocket连接模块接收到调用服务请求格式的JSON消息后,使用步骤2.1建立的WebSocket连接向云计算中心的WebSocket服务模块发送调用服务请求格式的JSON消息。如果发送失败则打印错误信息并执行第四步,发送成功则执行步骤2.2.4。2.2.3 After receiving the JSON message in the calling service request format, the WebSocket connection module of the turtlebot robot uses the WebSocket connection established in step 2.1 to send the JSON message in the calling service request format to the WebSocket service module of the cloud computing center. If the sending fails, print the error message and go to step 4; if the sending is successful, go to step 2.2.4.
2.2.4云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接获得turtlebot机器人发送的调用服务请求格式的JSON消息,将JSON消息发送给云计算中心的第二消息转换模块。2.2.4 The WebSocket service module of the cloud computing center obtains the JSON message in the format of the calling service request sent by the turtlebot robot by monitoring the WebSocket connection established in step 2.1, and sends the JSON message to the second message conversion module of the cloud computing center.
2.2.5云计算中心的第二消息转换模块接收到调用服务请求格式的JSON消息后,解析调用服务请求格式的JSON消息的内容,获取消息操作类型是"call_service",第二消息转换模块解析出调用服务名称是“/rosapi/topic_type”,参数是{"topicname":"/depth/image_rect"}和{"topicname":"/cmd_vel"}。并将调用服务名称和参数发送给云计算中心的第二服务验证组件。2.2.5 After receiving the JSON message in the calling service request format, the second message conversion module of the cloud computing center parses the content of the JSON message in the calling service request format, and obtains that the operation type of the message is "call_service", and the second message conversion module parses out The calling service name is "/rosapi/topic_type", and the parameters are {"topicname":"/depth/image_rect"} and {"topicname":"/cmd_vel"}. and send the calling service name and parameters to the second service verification component of the cloud computing center.
2.2.6云计算中心的第二服务验证组件接收到调用服务名称和参数后,使用主题名“/depth/image_rect”和“/cmd_vel”作为参数运行服务“/rosapi/topic_type”,获取主题消息类型。成功获取主题消息类型,“/depth/image_rect”对应的主题消息类型是“sensor_msgs/Image”,“/cmd_vel”对应的主题消息类型是“/geometry_msgs/Twist”。设置应答结果标记为“1”。第二服务验证组件将发布与订阅主题的主题消息类型、应答结果标记、调用服务名称和消息操作类型发送给云计算中心的第二消息转换模块。2.2.6 After receiving the calling service name and parameters, the second service verification component of the cloud computing center uses the topic name "/depth/image_rect" and "/cmd_vel" as parameters to run the service "/rosapi/topic_type" to obtain the topic message type . The topic message type is successfully obtained. The topic message type corresponding to "/depth/image_rect" is "sensor_msgs/Image", and the topic message type corresponding to "/cmd_vel" is "/geometry_msgs/Twist". Set the response result flag to "1". The second service verification component sends the topic message type of the publish and subscribe topic, the response result mark, the calling service name and the message operation type to the second message conversion module of the cloud computing center.
2.2.7云计算中心的第二消息转换模块接收到消息操作类型、调用服务名称、发布与订阅主题的主题消息类型和应答结果标记之后,构造调用服务应答格式JSON消息。构造的调用服务操作应答格式JSON消息如下,并将调用服务应答格式的JSON消息发送给WebSocket服务模块。2.2.7 After receiving the message operation type, calling service name, topic message type of publishing and subscribing topics, and response result mark, the second message conversion module of the cloud computing center constructs the calling service response format JSON message. The constructed JSON message in the response format for calling the service operation is as follows, and the JSON message in the response format for calling the service is sent to the WebSocket service module.
调用服务应答格式的JSON消息的格式是:The format of the JSON message in the call service response format is:
2.2.8云计算中心的WebSocket服务模块接收到调用服务应答格式JSON消息后,使用步骤2.1建立的WebSocket连接将调用服务应答格式JSON消息发送给turtlebot机器人的WebSocket连接模块。2.2.8 After the WebSocket service module of the cloud computing center receives the JSON message in the response format for calling the service, it uses the WebSocket connection established in step 2.1 to send the JSON message in the response format for calling the service to the WebSocket connection module of the turtlebot robot.
2.2.9 turtlebot机器人的WebSocket连接模块接收到调用服务应答格式JSON消息后,将其发送给第一消息转换模块。2.2.9 After the WebSocket connection module of the turtlebot robot receives the JSON message in the calling service response format, it sends it to the first message conversion module.
2.2.10 turtlebot机器人的第一消息转换模块接收到调用服务应答格式JSON消息后,解析调用服务应答格式JSON消息的内容,发现消息操作类型是“call_service”,获取云计算中心的主题名的主题消息类型和应答结果标记,并将主题名的主题消息类型和应答结果标记发送给第一服务验证组件。2.2.10 After the first message conversion module of the turtlebot robot receives the JSON message in the call service response format, it parses the content of the JSON message in the call service response format, finds that the message operation type is "call_service", and obtains the topic message of the topic name of the cloud computing center type and response result tag, and send the topic message type of the topic name and the response result tag to the first service verification component.
2.3 turtlebot机器人的第一服务验证组件接收到云计算中心发布与订阅主题名对应的主题消息类型和应答结果标记,对应答结果标记进行判断。应答结果标记是1,使用主题名“/depth/image_rect”和“/cmd_vel”作为参数调用turtlebot机器人的“/rosapi/topic_type”服务,获取“/depth/image_rect”和“/cmd_vel”主题对应的主题消息类型"/sensor_msgs/Image"和"/cmd_vel"。与云计算中心返回的“/depth/image_rect”和“/cmd_vel”的主题消息类型进行比较。主题消息类型相同,则将主题名“/depth/image_rect”和主题消息类型"/sensor_msgs/Image"发送给第一消息发布组件,将主题名“/cmd_vel”和主题消息类型"/cmd_vel"发送给第一消息订阅组件,执行第三步。2.3 The first service verification component of the turtlebot robot receives the topic message type and response result mark corresponding to the subscription topic name published by the cloud computing center, and judges the response result mark. The response result flag is 1, use the topic name "/depth/image_rect" and "/cmd_vel" as parameters to call the "/rosapi/topic_type" service of the turtlebot robot, and get the topics corresponding to the "/depth/image_rect" and "/cmd_vel" topics Message types "/sensor_msgs/Image" and "/cmd_vel". Compare with the topic message types of "/depth/image_rect" and "/cmd_vel" returned by the cloud computing center. If the topic message types are the same, the topic name "/depth/image_rect" and topic message type "/sensor_msgs/Image" are sent to the first message publishing component, and the topic name "/cmd_vel" and topic message type "/cmd_vel" are sent to The first message subscription component performs the third step.
第三步,turtlebot机器人按3.2的步骤基于“/depth/image_rect”主题向云计算中心发布ROS消息;与此同时,turtlebot机器人按3.1的步骤使用主题名“/cmd_vel”主题订阅云计算中心的ROS消息。具体步骤如下:In the third step, the turtlebot robot publishes ROS messages to the cloud computing center based on the topic "/depth/image_rect" according to the steps of 3.2; at the same time, the turtlebot robot uses the topic name "/cmd_vel" to subscribe to the ROS of the cloud computing center according to the steps of 3.1. information. Specific steps are as follows:
3.1 turtlebot机器人订阅云计算中心发布的“/cmd_vel”主题,具体步骤如下:3.1 The turtlebot robot subscribes to the "/cmd_vel" topic published by the cloud computing center. The specific steps are as follows:
3.1.1 turtlebot机器人的第一消息订阅组件从第一服务验证组件接收到订阅的主题名“/cmd_vel”,对应的主题消息类型为“/sensor_msgs/Image”,将消息操作类型设置为"subscribe",将消息操作类型、订阅主题名和主题消息类型发送给第一消息转换模块。3.1.1 The first message subscription component of the turtlebot robot receives the subscribed topic name "/cmd_vel" from the first service verification component, the corresponding topic message type is "/sensor_msgs/Image", and the message operation type is set to "subscribe" , and send the message operation type, subscription topic name and topic message type to the first message conversion module.
3.1.2 turtlebot机器人的第一消息转换模块接收到订阅主题名、主题消息类型和消息操作类型,判断消息操作类型为"subscribe",构造订阅主题格式的JSON消息如下,并将订阅主题格式的JSON消息发送给WebSocket连接模块。3.1.2 The first message conversion module of the turtlebot robot receives the subscription topic name, topic message type and message operation type, judges that the message operation type is "subscribe", constructs the JSON message in the subscription topic format as follows, and subscribes the JSON message in the topic format The message is sent to the WebSocket connection module.
订阅主题格式的JSON消息的格式是:The format of a JSON message in a subscription topic format is:
3.1.3 turtlebot机器人的WebSocket连接模块接收到订阅主题格式的JSON消息,使用步骤2.1建立的WebSocket连接发送给云计算中心的WebSocket服务模块。如果发送失败则打印错误信息并执行第四步,发送成功则执行步骤3.1.4。3.1.3 The WebSocket connection module of the turtlebot robot receives the JSON message in the subscription topic format, and sends it to the WebSocket service module of the cloud computing center using the WebSocket connection established in step 2.1. If the sending fails, print the error message and go to step 4; if the sending is successful, go to step 3.1.4.
3.1.4云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接获取到turtlebot机器人发送的订阅主题格式的JSON消息,将该消息发送给云计算中心的第二消息转换模块。3.1.4 The WebSocket service module of the cloud computing center obtains the JSON message in the subscription topic format sent by the turtlebot robot by monitoring the WebSocket connection established in step 2.1, and sends the message to the second message conversion module of the cloud computing center.
3.1.5云计算中心的第二消息转换模块接收到订阅主题格式的JSON消息后,解析订阅主题格式的JSON消息的内容,获取消息操作类型,对消息操作类型进行判断。消息操作类型是"subscribe",获得订阅主题名和主题消息类型,并将订阅主题名和主题消息类型发送给第二消息订阅组件。3.1.5 After receiving the JSON message in the subscription topic format, the second message conversion module of the cloud computing center parses the content of the JSON message in the subscription topic format, obtains the message operation type, and judges the message operation type. The message operation type is "subscribe", obtain the subscription topic name and topic message type, and send the subscription topic name and topic message type to the second message subscription component.
3.1.6云计算中心的第二消息订阅组件接收到订阅主题名和主题消息类型后,使用ROS消息机制订阅“/cmd_vel”主题消息。3.1.6 After receiving the subscription topic name and topic message type, the second message subscription component of the cloud computing center uses the ROS message mechanism to subscribe to the "/cmd_vel" topic message.
3.1.7,第二消息订阅组件接收到turtlebot_fllower软件包发布的“/cmd_vel”主题消息之后,设置消息操作类型为"publish",并将“/cmd_vel”主题消息和消息操作类型发送给云计算中心的第二消息转换模块。3.1.7. After receiving the "/cmd_vel" topic message published by the turtlebot_fllower software package, the second message subscription component sets the message operation type to "publish", and sends the "/cmd_vel" topic message and message operation type to the cloud computing center The second message conversion module.
3.1.8云计算中心的第二消息转换模块接收到“/cmd_vel”主题消息和消息操作类型,判断消息操作类型为"publish",第二消息转换模块解析“/cmd_vel”主题消息,获取主题名为“/cmd_vel”和主题消息内容,将主题消息内容转化成JSON字段。构造的发布主题格式的JSON消息如下,并将发布主题格式的JSON消息发送给WebSocket服务模块。3.1.8 The second message conversion module of the cloud computing center receives the "/cmd_vel" topic message and the message operation type, judges that the message operation type is "publish", and the second message conversion module parses the "/cmd_vel" topic message and obtains the topic name For "/cmd_vel" and subject message content, convert the subject message content into JSON fields. The constructed JSON message in the format of the publish topic is as follows, and the JSON message in the format of the publish topic is sent to the WebSocket service module.
发布主题格式的JSON消息的格式是:The format of the JSON message in the publish topic format is:
{"op":"publish",{"op":"publish",
"topic":"/cmd_vel","topic":"/cmd_vel",
"msg":<json>"msg":<json>
}}
“msg”字段是JSON格式的数据,表示发布主题消息的内容。The "msg" field is JSON-formatted data representing the content of the published topic message.
3.1.9云计算中心的WebSocket服务模块接收到发布主题格式的JSON消息,使用步骤2.1建立的WebSocket连接将发布主题格式的JSON消息发送给turtlebot机器人的WebSocket连接模块。3.1.9 The WebSocket service module of the cloud computing center receives the JSON message in the format of the published topic, and uses the WebSocket connection established in step 2.1 to send the JSON message in the format of the published topic to the WebSocket connection module of the turtlebot robot.
3.1.10 turtlebot机器人的WebSocket连接模块通过监听步骤2.1建立的WebSocket连接接收到JSON消息,将该JSON消息发送给第一消息转换模块。3.1.10 The WebSocket connection module of the turtlebot robot receives the JSON message by monitoring the WebSocket connection established in step 2.1, and sends the JSON message to the first message conversion module.
3.1.11 turtlebot机器人的第一消息转换模块接收到JSON消息后,获取消息操作类型为"publish",然后获取主题名“/cmd_vel”和主题消息内容,并将主题名“/cmd_vel”和主题消息内容发送给第一消息订阅组件。3.1.11 After the first message conversion module of the turtlebot robot receives the JSON message, it obtains the message operation type as "publish", then obtains the topic name "/cmd_vel" and the content of the topic message, and converts the topic name "/cmd_vel" and the topic message The content is sent to the first message subscription component.
3.1.12 turtlebot机器人的第一订阅消息组件接收主题名“/cmd_vel”和主题消息内容后发布“/cmd_vel”主题,机器人软件包turtlebot_bringup就可以接收到到“/cmd_vel”主题上ROS消息。执行步骤3.1.7。3.1.12 The first subscription message component of the turtlebot robot receives the topic name "/cmd_vel" and the topic message content and publishes the "/cmd_vel" topic, and the robot package turtlebot_bringup can receive ROS messages on the "/cmd_vel" topic. Perform step 3.1.7.
3.2 turtlebot机器人向云计算中心基于“/depth/image_rect”主题发布ROS消息,云计算中心的turtlebot_fllower软件包中ROS消息订阅者接收该主题上的ROS消息。具体步骤如下:3.2 The turtlebot robot publishes ROS messages to the cloud computing center based on the topic "/depth/image_rect", and the ROS message subscribers in the turtlebot_fllower package of the cloud computing center receive ROS messages on the topic. Specific steps are as follows:
3.2.1 turtlebot机器人的第一消息发布组件从第一服务验证组件接收主题名“/depth/image_rect”以及对应的主题消息类型“/sensor_msgs/Image”,使用ROS消息机制订阅“/depth/image_rect”主题上的ROS消息。3.2.1 The first message publishing component of the turtlebot robot receives the topic name "/depth/image_rect" and the corresponding topic message type "/sensor_msgs/Image" from the first service verification component, and uses the ROS message mechanism to subscribe to "/depth/image_rect" ROS messages on the topic.
3.2.2 turtlebot机器人运行freenect_launch软件包,获取深度摄像头Kinect采集的点云数据,并发布“/depth/image_rect”主题消息,第一消息发布组件接收到freenect_launch软件包发布的“/depth/image_rect”主题消息,将消息操作类型设置为“publish”,并将“/depth/image_rect”主题消息和消息操作类型发送给第一消息转换模块。3.2.2 The turtlebot robot runs the freenect_launch package, obtains the point cloud data collected by the depth camera Kinect, and publishes the "/depth/image_rect" topic message. The first message publishing component receives the "/depth/image_rect" topic released by the freenect_launch package. message, set the message operation type to "publish", and send the "/depth/image_rect" topic message and message operation type to the first message conversion module.
3.2.3 turtlebot机器人的第一消息转换模块接收到“/depth/image_rect”主题消息和消息操作类型后,判断消息操作类型为“publish”,第一消息转换模块通过解析ROS消息,获取主题名“/depth/image_rect”和主题消息内容,将主题消息内容转化成JSON字段。按照3.1.8的方法构造发布主题格式的JSON消息,即将“op”字段设置为"publish",将“topic”字段设置为ROS消息的主题名,将“msg”字段设置为JSON字段,并将发布主题格式的JSON消息发送给WebSocket连接模块。3.2.3 After receiving the "/depth/image_rect" topic message and message operation type, the first message conversion module of the turtlebot robot judges that the message operation type is "publish", and the first message conversion module obtains the topic name by parsing the ROS message" /depth/image_rect" and the topic message content, convert the topic message content into a JSON field. Construct a JSON message in publish topic format according to the method in 3.1.8, that is, set the "op" field to "publish", set the "topic" field to the topic name of the ROS message, set the "msg" field to the JSON field, and set the "msg" field to the JSON field. Publishes a JSON message in topic format to the WebSocket connection module.
3.2.4 turtlebot机器人的WebSocket连接模块接收到发布主题格式的JSON消息后,使用步骤2.1建立的WebSocket连接将发布主题格式的JSON消息发送给云计算中心的WebSocket服务模块。如果WebSocket连接模块发送失败则打印错误信息并执行第四步。如果WebSocket连接模块发送成功,则执行步骤3.2.5。3.2.4 After the WebSocket connection module of the turtlebot robot receives the JSON message in the published topic format, it uses the WebSocket connection established in step 2.1 to send the JSON message in the published topic format to the WebSocket service module in the cloud computing center. If the WebSocket connection module fails to send, print an error message and perform the fourth step. If the WebSocket connection module sends successfully, go to step 3.2.5.
3.2.5云计算中心的WebSocket服务模块通过监听步骤2.1建立的WebSocket连接接收turtlebot机器人发送的JSON格式的消息,将该消息发送给云计算中心的第二消息转换模块。3.2.5 The WebSocket service module of the cloud computing center receives the message in JSON format sent by the turtlebot robot by monitoring the WebSocket connection established in step 2.1, and sends the message to the second message conversion module of the cloud computing center.
3.2.6云计算中心的第二消息转换模块接收到发布主题格式的JSON消息后,获取消息操作类型。判断消息操作类型为"publish"后,获取主题名“/depth/image_rect”和主题消息内容,并将主题名“/depth/image_rect”和主题消息内容发送给第二消息发布组件。3.2.6 After receiving the JSON message in the published topic format, the second message conversion module of the cloud computing center obtains the message operation type. After judging that the message operation type is "publish", obtain the topic name "/depth/image_rect" and the topic message content, and send the topic name "/depth/image_rect" and the topic message content to the second message publishing component.
3.2.7云计算中心的第二消息发布组件接收到主题名和主题消息内容后,基于“/depth/image_rect”主题发布ROS消息。3.2.7 After receiving the topic name and topic message content, the second message publishing component of the cloud computing center publishes the ROS message based on the "/depth/image_rect" topic.
3.2.8云计算中心turtlebot_fllower软件包订阅“/depth/image_rect”主题,接收“/depth/image_rect”主题上的ROS消息。turtlebot_fllower软件包通过接收到的环境点云数据,计算出线速度和角速度,并基于“/cmd_vel”主题发布ROS消息。执行步骤3.2.2。3.2.8 The turtlebot_fllower package of the cloud computing center subscribes to the "/depth/image_rect" topic and receives ROS messages on the "/depth/image_rect" topic. The turtlebot_fllower package calculates the linear velocity and angular velocity through the received environmental point cloud data, and publishes ROS messages based on the "/cmd_vel" topic. Perform step 3.2.2.
第四步,结束。Fourth step, end.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710284862.5ACN106936932B (en) | 2017-04-26 | 2017-04-26 | A way to access robot software packages via cloud service protocol |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710284862.5ACN106936932B (en) | 2017-04-26 | 2017-04-26 | A way to access robot software packages via cloud service protocol |
| Publication Number | Publication Date |
|---|---|
| CN106936932A CN106936932A (en) | 2017-07-07 |
| CN106936932Btrue CN106936932B (en) | 2019-07-26 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201710284862.5AActiveCN106936932B (en) | 2017-04-26 | 2017-04-26 | A way to access robot software packages via cloud service protocol |
| Country | Link |
|---|---|
| CN (1) | CN106936932B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107943458B (en)* | 2017-11-20 | 2020-07-24 | 上海木木聚枞机器人科技有限公司 | Robot development system |
| CN108594670A (en)* | 2018-01-10 | 2018-09-28 | 河海大学常州校区 | A kind of robot Overpassing Platform by Using agreement and control method |
| CN108594810B (en)* | 2018-04-08 | 2019-07-02 | 百度在线网络技术(北京)有限公司 | Method, apparatus, storage medium, terminal device and the automatic driving vehicle of data processing |
| CN108406781B (en)* | 2018-05-18 | 2021-12-28 | 顺丰科技有限公司 | Remote robot control system and control method |
| CN109159125B (en)* | 2018-09-28 | 2021-02-12 | 华东计算技术研究所(中国电子科技集团公司第三十二研究所) | Cloud service system based on ROS system robot |
| CN111124700B (en)* | 2018-10-31 | 2023-07-18 | 百度在线网络技术(北京)有限公司 | Method and device for accessing simulation software model |
| CN109737975B (en)* | 2018-12-21 | 2021-07-20 | 北京四维图新科技股份有限公司 | Map data collection and monitoring method, device and system |
| CN112039882B (en)* | 2020-08-31 | 2023-04-07 | 广州鲁邦通物联网科技股份有限公司 | Message transmission processing method, system, device and storage medium |
| US12081513B2 (en) | 2020-12-14 | 2024-09-03 | UiPath, Inc. | Organizational modelling for routing RPA related services of an RPA cloud suite |
| CN113218383A (en)* | 2021-05-10 | 2021-08-06 | 山东新一代信息产业技术研究院有限公司 | Cloud robot map construction method and system |
| CN115048098A (en)* | 2022-01-27 | 2022-09-13 | 远光软件股份有限公司 | Process automation method, device, system and storage medium |
| CN117336365A (en)* | 2023-09-12 | 2024-01-02 | 霞智科技有限公司 | Data interaction middleware applied to robot |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105429858A (en)* | 2015-12-11 | 2016-03-23 | 中国人民解放军国防科学技术大学 | A method of real-time message transmission among multi-robots |
| CN105897509A (en)* | 2016-04-08 | 2016-08-24 | 上海工程技术大学 | Cloud computing-based robot software operation and simulation system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105429858A (en)* | 2015-12-11 | 2016-03-23 | 中国人民解放军国防科学技术大学 | A method of real-time message transmission among multi-robots |
| CN105897509A (en)* | 2016-04-08 | 2016-08-24 | 上海工程技术大学 | Cloud computing-based robot software operation and simulation system |
| Title |
|---|
| 基于ROS的云机器人服务框架;陈贤等;《计算机系统应用》;20161231;第25卷(第10期);第73-79页 |
| 机器人中间件消息实时性保证机制的研究与实现;樊泽栋等;《国际IT传媒品牌》;20151231;第36卷(第10期);第21-25页 |
| Publication number | Publication date |
|---|---|
| CN106936932A (en) | 2017-07-07 |
| Publication | Publication Date | Title |
|---|---|---|
| CN106936932B (en) | A way to access robot software packages via cloud service protocol | |
| CN107018147B (en) | Internet of things communication method and system and gateway module | |
| US8209213B2 (en) | Method for the construction and execution of a distributed workflow in a communication system | |
| CN109815025B (en) | Service model calling method, device and storage medium | |
| CN112838940B (en) | Network controller frame and data processing method | |
| CN110769009B (en) | User identity authentication method and system | |
| EP2429150A1 (en) | Apparatus, web service component and method based on web service | |
| CN107809332A (en) | Compound interface configures and compound interface call method, device | |
| KR20160000542A (en) | Method and apparatus for gernerating data distribution service application | |
| US10536560B2 (en) | System and method for implementing augmented object members for remote procedure call | |
| CN110381058B (en) | Request transmission method and device based on full-duplex communication protocol WebSocket | |
| CN118055172A (en) | Visual docking configuration method for communication protocol of Internet of things equipment | |
| CN107295003B (en) | Data transmission method, device and system | |
| US20070130312A1 (en) | Web service provision apparatus and method and web service request apparatus and method | |
| US10938960B2 (en) | System and method for implementing augmented object members for remote procedure call | |
| CN111953640B (en) | Communication method, communication system, cloud node and readable storage medium | |
| CN114500674B (en) | Distributed system data transparent transmission method, device, storage medium and system | |
| Bagci et al. | A lightweight and high performance remote procedure call framework for cross platform communication | |
| CN114244698A (en) | CPE management configuration method based on MQTT | |
| CN111200533A (en) | OpenDDS-based distributed network configuration deployment method | |
| Ivan | A web based Publish-Subscribe framework for mobile computing | |
| Arnholm et al. | Combining industry 4.0 and 5g connectivity with robots in digital production factories | |
| Nguyen et al. | A unified method to design bridges for OPC UA PubSub networks in the industrial IoT | |
| JP5548433B2 (en) | Web service platform system | |
| US20230412466A1 (en) | Managing cloud-native virtual network functions |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |