Rosanswers logo

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.

Originally posted by TheMilkman on ROS Answers with karma: 17 on 2018-09-19

Post score: 0


1 Answer 1


Rosanswers logo

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


Originally posted by TheMilkman with karma: 17 on 2018-09-19

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Delb on 2018-09-20:
You're right, the wiki Names explains it with more details if you want.

Comment by TheMilkman on 2018-10-04:
I guess I wasn't googling the right words, thanks for the link!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.