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

As suggested by Weasfas in the comment above, you can use a ros::Timer. The following snippet should do the work:

ros::Publisher my_pub = nh.advertise<Message>("my_topic", queue);
ros::Timer timer = nh.createTimer(ros::Duration(1/100), timerCallback);
Message modified_message;

...

// timer callback. Pub lishes modified message on a specified frequency
void timerCallback(const ros::TimerEvent &) {
  my_pub.publish(modified_message);
}

...

void subCallback(Message message_in){
// do some processing of the message_in and update modified_message
...
//
}

You can also check this question regarding using throttle to republish data to another topic, either at a maximum bandwidth or maximum message rate.

As suggested by Weasfas in the comment above, you can use a ros::Timer. The following snippet should do the work:

ros::Publisher my_pub = nh.advertise<Message>("my_topic", queue);
ros::Timer timer = nh.createTimer(ros::Duration(1/100), timerCallback);
Message modified_message;

...

// timer callback. Pub lishes modified message on a specified frequency
void timerCallback(const ros::TimerEvent &) {
  my_pub.publish(modified_message);
}

...

void subCallback(Message message_in){
// do some processing of the message_in and update modified_message
...
//
}

You can also check this question regarding using throttle throttle to republish data to another topic, either at a maximum bandwidth or maximum message rate.