March 2018
Intermediate to advanced
1396 pages
42h 14m
English
It is also possible to control how many times a given message is shown. We can print it only once with ROS_<LEVEL>[_STREAM]_ONCE[_NAMED]:
for(int i = 0; i< 10; ++i ) {
ROS_INFO_STREAM_ONCE("My once INFO stream message; i = " <<i);
}
This code from the example2 node will show the message only once.
However, it is usually better to show the message with a certain frequency. For that, we have throttle messages. They have the same format as the once message, but here ONCE is replaced with THROTTLE. They also include a first argument, which is period in seconds, that is, it is printed only every period seconds:
for(int i = 0; i< 10; ++i ) { ROS_INFO_STREAM_THROTTLE(2, "My throttle INFO ...