ROS中message的相关知识点

这里从官方文档做一些整理,以备后续查看。

msg的定义不用说了,这里说说msg在ros相关项目中实现的东西。

1. msg overview

ROS uses a simplified messages description language for describing the data values (aka messages) that ROS nodes publish. This description makes it easy for ROS tools to automatically generate source code for the message type in several target languages. Message descriptions are stored in .msg files in the msg/ subdirectory of a ROS package.

(这一段告诉我们msg文件的路径)

There are two parts to a .msg file: fields and constants. Fields are the data that is sent inside of the message. Constants define useful values that can be used to interpret those fields (e.g. enum-like constants for an integer value).(msg文件的格式)

Message types are referred to using package resource names. For example, the file geometry_msgs/msg/Twist.msgis commonly referred to as geometry_msgs/Twist.(注:这里很重要,大部分头文件都会以后者作为名称,而非前者)

详见:http://www.ros.org/wiki/msg

2. msg generation

Like all ROS Client Libraries, roscpp takes msg files and generates C++ source code for them. The pattern for this is:

  • package_name/msg/Foo.msg → package_name::Foo

Similarly, srv files have C++ source code generated. The pattern for this is:

  • package_name/srv/Foo.srv → package_name::Foo

Note that a limitation of roscpp is that the message and service namespaces overlap.(roscpp中的msg和srv的名字空间是重合的)

The source for the generated files are put in the msg_gen/cpp/include/package_name/  and srv_gen/cpp/include/package_name/ directories, for messages and services respectively. The header files are generated with the same name as the filename of the msg/srv.

(实际上,msg文件会最终被转为一系列的头文件,而且保持文件名称不变)

Thus, including the std_msgs/String message in your code involves:

#include <std_msgs/String.h>

and instantiating the message:

std_msgs :: String str ;
 
(以上是一些实际的例子,以str为例,可以看见其用法)
 
 
未完待续。。。。。

 

转载于:https://www.cnblogs.com/ShaneZhang/archive/2013/05/22/3093328.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值