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

Revision history [back]

click to hide/show revision 1
initial version

I am not sure I exactly understood what you wanna do. But here is a suggestion:

First when you announce your publisher, specify 0 to avoid missing a msg (infinite queue: WATCH OUT! This can be dangerous..). Like this!

ros::Publisher msg_pub = nh.advertise("new_topic_name", 0);

Then just do this inside your callbacks:

msg_pub.publish(new_msg);

I am not sure I exactly understood what you wanna do. But here is a suggestion:

First when you announce your publisher, specify 0 to avoid missing a msg (infinite queue: WATCH OUT! This can be dangerous..). Like this!

ros::Publisher msg_pub = nh.advertise("new_topic_name", 0);

Then just do this inside your callbacks:

msg_pub.publish(new_msg);

Note that you do not need to create a node to change a topic name. This is easily done by just adding this line in the right place on your launch file:

<remap from="old_topic_name" to="new_topic_name"/>