ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Removing part of a published topics path

asked 2018-09-19 21:45:09 -0600

TheMilkman gravatar image

updated 2018-09-19 22:46:30 -0600

Say if im publishing diagnostic messages from a node using this;

nh.advertise<diagnostic_msgs::DiagnosticArray>("diagnostics", 10);

In the case its from our IMU node, making the topic its publishing called /imu/diagnostics. Is there a way to remove the /imu prefix so that the aggregator doesn't get confused? Or should I be running diagnostics from a separate node or something?

Thanks for any help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-19 22:44:23 -0600

TheMilkman gravatar image

I found my own solution.

When defining a publisher, if you're trying to publish to the top level you must add a '/' to the front of the path. For example;

nh.advertise<diagnostic_msgs::DiagnosticArray>("/diagnostics", 10);

publishes to the topic;



nh.advertise<diagnostic_msgs::DiagnosticArray>("diagnostics", 10);

publishes to the

edit flag offensive delete link more


You're right, the wiki Names explains it with more details if you want.

Delb gravatar image Delb  ( 2018-09-20 01:39:30 -0600 )edit

I guess I wasn't googling the right words, thanks for the link!

TheMilkman gravatar image TheMilkman  ( 2018-10-04 23:55:00 -0600 )edit

Question Tools

1 follower


Asked: 2018-09-19 21:45:09 -0600

Seen: 379 times

Last updated: Sep 19 '18