Robotics StackExchange | Archived questions

How to create custom topic?

I want to create custom topic to visualize data from sensors.

Asked by roman7426 on 2018-07-11 08:34:03 UTC

Comments

Answers

Create a gazebo node:

   gznode_ = gazebo::transport::NodePtr(new gazebo::transport::Node());

and advertise a new publisher:

   pub = gznode_->Advertise<gazebo::msgs::"message_type">("custom_topic_name");

change "message_type" and custom_topic_name to your own needs. Now you can publish a message by:

  pub->Publish(msg);

The types depend on the Gazebo Version you are using. For all versions < 9 you need to include:

  #include "gazebo/transport/transport.hh"

and the variable declaration look like this:

 gazebo::transport::NodePtr gznode_;
 gazebo::transport::PublisherPtr pub;

Asked by wentz on 2018-07-23 07:37:21 UTC

Comments

Can you provide a bit more info? What type should gznode and pub be?

Asked by jc on 2018-08-14 12:49:01 UTC

I updated the Answer, hope that helps.

Asked by wentz on 2018-08-15 04:04:09 UTC