Gazebo | Ignition | Community
Ask Your Question
0

How to create custom topic?

asked 2018-07-11 08:34:03 -0500

roman7426 gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-07-23 07:37:21 -0500

wentz gravatar image

updated 2018-08-15 04:03:48 -0500

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;
edit flag offensive delete link more

Comments

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

jc gravatar imagejc ( 2018-08-14 12:49:01 -0500 )edit

I updated the Answer, hope that helps.

wentz gravatar imagewentz ( 2018-08-15 04:04:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-11 08:34:03 -0500

Seen: 450 times

Last updated: Aug 15 '18