1 std_msgs
该类型是ROS内置的标准消息类型,是最基础的消息类型
(1)对于单类型,下表是其与C++和python的对应关系:
Primitive Type | Serialization | C++ | Python2 / Python3 |
---|---|---|---|
bool | unsigned 8-bit int | uint8_t | bool |
int8 | signed 8-bit int | int8_t | int |
uint8 | unsigned 8-bit int | uint8_t | int |
int16 | signed 16-bit int | int16_t | int |
uint16 | unsigned 16-bit int | uint16_t | int |
int32 | signed 32-bit int | int32_t | int |
uint32 | unsigned 32-bit int | uint32_t | int |
int64 | signed 64-bit int | int64_t | long int |
uint64 | unsigned 64-bit int | uint64_t | long int |
float32 | 32-bit IEEE float | float | float |
float64 | 64-bit IEEE float | double | float |
string | ascii string | std::string | str bytes |
time | secs/nsecs unsigned 32-bit ints | ros::Time | rospy.Time |
duration | secs/nsecs signed 32-bit ints | ros::Duration | rospy.Duration |
(2)对于数组类型,其对应关系如下:
Primitive Type | Serialization | C++ | Python2 / Python3 |
---|---|---|---|
fixed-length | no extra serialization | boost::array<T, length>/std::vector | tuple |
variable-length | uint32 length prefix | std::vector | tuple |
uint8[] | see above | as above | str bytes |
bool[] | see above | std::vector<uint8_t> | list of bool |
(3)Head
std_msg中还包含一个特殊消息类型 :Head,表示包头,它是一个结构体,内置三个类型:
uint32 seq # 表示数据流的 sequenceID
time stamp # 表示时间戳
string frame_id # 表示当前帧数据的帧头(帧序号)
Head类型常用于记录每帧数据的时间和序列信息,用于记录历史数据的情形。
以上消息类型是其他各种类型的基础,其他各种消息类型的嵌套定义归根结底都依赖以上几种类型。
2 comm_msg
该类型是ros常用数据类型的集合,包括以下几种:actionlib_msgs、diagnostic_msgs、geometry_msgs、nav_msgs、sensor_msgs, 下面是几种最常用的类型的介绍:
2.1 geometry_msgs
是最常用的几何消息类型,定义了描述机器人状态的各种类型,比如点、速度、加速度、位姿等。
2.1.1 Vector3、Vector3Stamped
(1) geometry_msgs/Vector3.msg
表示自由空间的三维向量,是一个结构体,内置三个类型:
float64 x
float64 y
float64 z
注意:该类型仅用于表示方向,tf2中只能应用于(rotation)旋转,不能应用于变换(transtion),若想用于变换,需要用到geometry_msgs/Point类型。
(2) geometry_msgs/Vector3Stamped.msg
表示带有时间戳和参考坐标系的三维向量
std_msgs/Header header
geometry_msgs/Vector3 vector
2.1.2 Quaternion、QuaternionStamped
(1) geometry_msgs/Quaternion.msg
用四元数表示自由空间中的旋转:
float64 x
float64 y
float64 z
float64 w
(2) geometry_msgs/QuaternionStamped.msg
表示带有参考坐标系和时间戳的旋转:
std_msgs/Header header
geometry_msgs/Quaternion quaternion
2.1.3 Transform、TransformStamped
(1) geometry_msgs/Transform.msg
表示自由空间的两个坐标系之间的变换关系,包括旋转和平移。旋转用四元数表示,平移用平移向量表示:
geometry_msgs/Vector3 translation
geometry_msgs/Quaternion rotation
(2) geometry_msgs/TransformStamped.msg
表示从Head里面的坐标系到子坐标系的变换:
std_msgs/Header header
string child_frame_id #子坐标系
geometry_msgs/Transform transform
2.1.4 Point、Point32、PointStamped
(1) geometry_msgs/Point.msg
表示自由空间中的点:
float64 x
float64 y
float64 z
(2)geometry_msgs/Point32.msg
为了在发送点云时减少数据量,ros提供了压缩版的point32:
float32 x
float32 y
float32 z
(3)geometry_msgs/PointStamped.msg
带有参考坐标系和时间戳的point:
std_msgs/Header header
geometry_msgs/Point point
2.1.5 Pose、Pose2D、PoseArray、PoseStamped、PoseWithCovariance、PoseWithCovarianceStamp
(1) geometry_msgs/Pose.msg
位姿,即位置和姿态,用point表示位置,用四元数表示姿态:
geometry_msgs/Point position
geometry_msgs/Quaternion orientation
(2) geometry_msgs/Pose2D.msg
表示二维平面上面的一个点(表示2D流形上的位置和方向):
float64 x
float64 y
float64 theta
(3) geometry_msgs/PoseArray.msg
表示全局坐标系下的一组轨迹点:
std_msgs/Header header #head里面保存了参考系
geometry_msgs/Pose[] poses
(4) geometry_msgs/PoseStamped.msg
表示带有时间戳和参考系的位姿:
std_msgs/Header header
geometry_msgs/Pose pose
(5) geometry_msgs/PoseWithCovariance.msg
表示带有协方差矩阵的位姿估计,协方差矩阵表示其不确定度,用6*6的矩阵表示协方差,对应表示绕xyz三轴的不确定度
geometry_msgs/Pose pose
float64[36] covariance
(6) geometry_msgs/PoseWithCovariance.msg
表示带有时间戳和坐标系的位姿估计
geometry_msgs/Pose pose
float64[36] covariance
2.1.6 Twist、TwistStamped、TwistWithCovariance、TwistWithCovarianceStamped
(1) geometry_msgs/Twist.msg
表示自由空间的一组速度,包括线速度和角速度
geometry_msgs/Vector3 linear
geometry_msgs/Vector3 angular
(2) geometry_msgs/TwistStamped.msg
表示带有时间戳和参考坐标系的速度
std_msgs/Header header
geometry_msgs/Twist twist
(3) geometry_msgs/TwistWithCovariance.msg
表示带有协方差表示不确定度的速度估计
geometry_msgs/Twist twist
float64[36] covariance
(4) geometry_msgs/TwistWithCovarianceStamped.msg
表示带有时间戳和参考坐标系的速度估计
std_msgs/Header header
geometry_msgs/TwistWithCovariance twist
2.1.7 Accel、AccelStamped、AccelWithCovariance、AccelWithCovarianceStamped
(1) geometry_msgs/Accel.msg
表示自由空间的一组加速度,包括线加速度和角加速度
geometry_msgs/Vector3 linear
geometry_msgs/Vector3 angular
(2) geometry_msgs/AccelStamped.msg
表示带有时间戳和参考坐标系的加速度
std_msgs/Header header
geometry_msgs/Accel accel
(3) geometry_msgs/AccelWithCovariance.msg
表示带有协方差表示不确定度的加速度估计
geometry_msgs/Accel accel
float64[36] covariance
(4) geometry_msgs/AccelWithCovarianceStamped.msg
表示带有时间戳和参考坐标系的加速度估计
std_msgs/Header header
geometry_msgs/AccelWithCovariance accel
2.1.8 Polygon、PolygonStamped
(1) geometry_msgs/Accel.msg
表示自由空间的一块区域,用首位相连的一组点表示
geometry_msgs/Point32[] points
(2) geometry_msgs/AccelStamped.msg
表示带有参考坐标系和时间戳的自由空间的一块区域
std_msgs/Header header
geometry_msgs/Polygon polygon