官网教程:http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i6
《一》ros通信的意义
在利用gazebo仿真时。我们可以利用gazebo的通信机制进行创建节点和发布消息。但是这只是在仿真平台实现。如果想要实际使用,就需要利用ros系统的通信机制对模型进行控制。这一节内容就是如果在plugin中加入ros系统的节点,利用ros系统的通信命令进行参数的修改。
《二》实现过程
(1)在velodyne_plugin.cc中添加与ros通信相关的头文件
#include <thread>
#include "ros/ros.h"
#include "ros/callback_queue.h"
#include "ros/subscribe_options.h"
#include "std_msgs/Float32.h"
(2)定义ros通信的成员变量
/// \brief A node use for ROS transport
private: std::unique_ptr<ros::NodeHandle> rosNode;
/// \brief A ROS subscriber
private: ros::Subscriber rosSub;
/// \brief A ROS callbackqueue that helps process messages
private: ros::CallbackQueue rosQueue;
/// \brief A thread the keeps running the rosQueue
priva