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

Removing part of a published topics path

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

TheMilkman gravatar image

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

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
1

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

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;

/diagnostics

While

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

publishes to the

node_name/diagnostics
edit flag offensive delete link more

Comments

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

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

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

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

Question Tools

1 follower

Stats

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

Seen: 382 times

Last updated: Sep 19 '18