Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

Since you already include ROS, one way is to create a ROS node within the plugin instead of the transport::NodePtr, and create a ROS subscriber. Put both of the following into private:

ros::NodeHandle node;
private: ros::Subscriber sub1;

Then define the subscriber within "public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /_sdf/){...}"

sub1 = node.subscribe("/Topic_of_interest", 1, &ModelPush::callback_function,this);

and finally create the callback function to handle the incoming messages

      void callback_function(<whatever your message type is>) {<your code here>}