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

Suppress TF_REPEATED_DATA warnings?

asked 2021-07-01 03:20:40 -0500

raabuchanan gravatar image

updated 2022-06-05 11:15:27 -0500

lucasw gravatar image

I've read the discussions on why this warning is being printed but that's not really relevant to me. I'm trying to play back an old rosbag which published a TF repeatedly with the same timestamp. I only need the TF once so I don't care that the rest of the messages are ignored but I keep getting the message

Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame...

spamming my terminal making debugging other parts of my code impossible. So my question is how can I stop this message? I've tried changing the logging levels but loading a custom rosconsole file but there was no change. Here is the file I make:

#
#   rosconsole will find this file by default at $ROS_ROOT/config/rosconsole.config
#
#   You can define your own by e.g. copying this file and setting
#   ROSCONSOLE_CONFIG_FILE (in your environment) to point to the new file
# log4j.logger.ros=ERROR log4j.logger.ros.roscpp.superdebug=ERROR
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2021-09-26 09:25:25 -0500

lucasw gravatar image

updated 2021-09-26 09:27:43 -0500

You can run a version of geometry2 that reduces the warning by cloning this repo and branch in your catkin_ws/src:

git clone --branch throttle-tf-repeated-data-error git@github.com:BadgerTechnologies/geometry2.git

Then rebuild, source setup.bash, run and then it should be reduced down to once every 10 seconds. If 10 seconds is still too much log output then change the ros::Duration(10.0) to 10000 seconds or whatever you like.

https://github.com/ros/geometry2/pull...

I haven't actually run that branch but it looks reasonable that it will work as claimed.

edit flag offensive delete link more

Comments

2

I can confirm that this works.

labude gravatar image labude  ( 2022-05-31 12:21:48 -0500 )edit

Thank you! This worked like a charm. Ideally there would be a way to set the time delay without having to re-compile but for now this is great.

raabuchanan gravatar image raabuchanan  ( 2023-02-08 08:57:54 -0500 )edit

this works

Muhammad_Usman gravatar image Muhammad_Usman  ( 2023-07-17 05:13:57 -0500 )edit
1

answered 2022-08-10 14:09:44 -0500

xperroni gravatar image

For anyone interested in a horribly over-engineered solution for suppressing TF_REPEATED_DATA warnings on the receiving end, I wrote the below Python code:

import multiprocessing
import os
import pipes
import threading
import sys

import rospy

class suppress_TF_REPEATED_DATA(object):
    r'''Standard error filter used to suppress TF_REPEATED_DATA warning messages.
    '''
    def __init__(self):
        r'''Create a new warning suppressor object.
        '''
        self.__registered = False

    def __call__(self):
        r'''Replace the normal STDERR with a filter that suppresses
            `Warning: TF_REPEATED_DATA` messages.
        '''
        if self.__registered:
            return

        # Because the filter works by redirecting STDERR to a pipe, it's not possible to
        # then print error messages that are not meant to be suppressed. The solution is
        # to create a child process to print those messages in place of this process.
        queue = multiprocessing.Queue()
        def printer(queue):
            while True:
                line = queue.get()
                if line is None:
                    return

                sys.stderr.write(line)

        # Start the output process.
        self.__printer = multiprocessing.Process(target=printer, args=(queue,))
        self.__printer.start()

        # Preserve the normal STDERR.
        stderr_fileno = os.dup(2)
        stderr = sys.stderr

        # Create a pipe object and replace STDERR with it.
        piper = pipes.Template()
        pipe_name = rospy.get_name().replace('/', '_')
        pipe_out = piper.open(pipe_name, 'w')
        os.dup2(pipe_out.fileno(), 2)
        sys.stderr = pipe_out

        def read_pipe():
            skip = False

            # Open the pipe in read mode and read messages from it.
            with open(pipe_name) as pipe_in:
                while not rospy.is_shutdown():
                    line = pipe_in.readline()
                    if line.strip() == '':
                        continue

                    # The warning message is two lines long, so we need to also skip the line
                    # following the one starting with "Warning: TF_REPEATED_DATA".
                    if skip:
                        skip = False
                        continue

                    if line.startswith('Warning: TF_REPEATED_DATA'):
                        skip = True
                        continue

                    # If the line is not to be suppressed,
                    # send it to the child process for printing.
                    queue.put(line)

            # Stop the output process.
            queue.put(None)
            self.__printer.join()

            # Restore the normal STDERR.
            pipe_out.close()
            os.dup2(stderr_fileno, 2)
            sys.stderr = stderr

            self.__registered = False

        self.__reader = threading.Thread(target=read_pipe)
        self.__reader.start()

        self.__registered = True


# Turn the class into a singleton.
suppress_TF_REPEATED_DATA = suppress_TF_REPEATED_DATA()

Add this code to a module in your system, then import and call suppress_TF_REPEATED_DATA() right after the call to rospy.init_node().

The implementation of a C++ solution is left as an exercise to the reader. ;)

edit flag offensive delete link more
0

answered 2023-07-28 23:29:52 -0500

thesane gravatar image

setting logger level works. you just need to set it on the right node. or if you don't know the node you can set it for all nodes using

for n in `rosnode list`; do rosservice call $n/set_logger_level ros "error"; done
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-07-01 03:20:40 -0500

Seen: 6,754 times

Last updated: Aug 10 '22