1. 概述
阅读Xsens在ROS下MTi系列节点源代码,将有用的部分总结一下,主要是时间戳以及topic的处理。
2. 目录结构
上一节对MTI系列的驱动和节点进行了处理,MTI_ROS_Driver。
节点目录结构如下
.
├── CMakeLists.txt
├── launch
│ ├── display.launch
│ └── xsens_mti_node.launch
├── lib
│ └── xspublic
│ ├── Makefile
│ ├── xscommon
│ │ ├── abstractadditionallogger.h
│ │ ├── 、、、、
│ ├── xscontroller
│ │ ├── broadcastdevice.cpp
│ │ └── 、、、、
│ └── xstypes
│ ├── datapacket_p.cpp
│ └── 、、、、
├── LICENSE.txt
├── package.xml
├── param
│ └── xsens_mti_node.yaml
├── README.txt
├── rviz
│ ├── display.rviz
│ └── example.rviz
├── src
│ ├── main.cpp
│ ├── messagepublishers
│ │ ├── accelerationpublisher.h
│ │ ├── angularvelocitypublisher.h
│ │ ├── freeaccelerationpublisher.h
│ │ ├── gnsspublisher.h
│ │ ├── imupublisher.h
│ │ ├── magneticfieldpublisher.h
│ │ ├── orientationincrementspublisher.h
│ │ ├── orientationpublisher.h
│ │ ├── packetcallback.h
│ │ ├── pressurepublisher.h
│ │ ├── temperaturepublisher.h
│ │ ├── timereferencepublisher.h
│ │ ├── transformpublisher.h
│ │ ├── twistpublisher.h
│ │ └── velocityincrementpublisher.h
│ ├── xdacallback.cpp
│ ├── xdacallback.h
│ ├── xdainterface.cpp
│ └── xdainterface.h
└── urdf
├── MTi_10.stl
├── MTi_10.urdf
├── MTi_1.stl
├── MTi_1.urdf
├── MTi_6xx.stl
└── MTi_6xx.urdf
可以很清楚的看到launch文件所在的位置。
├── launch
│ ├── display.launch
│ └── xsens_mti_node.launch
3. 时间戳的处理
每一种传感器信息定义了一个结构体,具体的结构体信息可以查看每个文件。
│ ├── messagepublishers
│ │ ├── accelerationpublisher.h
│ │ ├── angularvelocitypublisher.h
│ │ ├── freeaccelerationpublisher.h
│ │ ├── gnsspublisher.h
│ │ ├── imupublisher.h
│ │ ├── magneticfieldpublisher.h
│ │ ├── orientationincrementspublisher.h
│ │ ├── orientationpublisher.h
│ │ ├── packetcallback.h
│ │ ├── pressurepublisher.h
│ │ ├── temperaturepublisher.h
│ │ ├── timereferencepublisher.h
│ │ ├── transformpublisher.h
│ │ ├── twistpublisher.h
│ │ └── velocityincrementpublisher.h
在构造函数中完成topic的初始化。
例如对IMU信息topic的处理如下,首先从参数服务器中获取发布消息队列大小,设置发布topic为imu/data,消息类型为sensor_msgs::Imu,这是标准的ROS消息类型,具体消息内容可以查看msg/Imu,进一步对方差进行了初始化。
ImuPublisher(ros::NodeHandle &node)
{
int pub_queue_size = 5;
ros::param::get("~publisher_queue_size", pub_queue_size);
pub = node