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

rosconsole command line utility not honoring ROSCONSOLE_FORMAT

asked 2022-02-21 10:35:32 -0500

thebyohazard gravatar image

I have set up my shells to have a custom ROSCONSOLE_FORMAT

export ROSCONSOLE_FORMAT='${time:%T.%f}[${severity}] ${node}/${logger}: ${message}'

When I run or launch nodes, they have the desired format:

22:45:20.180207[ INFO] /test_node/ros.test: Test node message

However, if I use the rosconsole command line utility,

rosconsole echo -l info

I get the default format that does not have the time in it:

[ INFO  ] [/test_node]: Test node message

How do I make the output of the rosconsole command line utility show in the desired format?

I know I can pass option -v to show verbose messages, but I don't want all of that. Honestly, I am having trouble finding documentation for the command line utility. Everything I search for brings me to the library and it's not on the wiki's utility page.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-02-21 14:37:27 -0500

gvdhoorn gravatar image

updated 2022-02-21 14:48:58 -0500

How do I make the output of the rosconsole command line utility show in the desired format?

Looking at the source, I don't believe you can.

That script uses a rospy.Subscriber to subscribe to the /rosout topic topic (here), and uses a relatively simple callback to print incoming messages in a fixed format (here):

def _print(self, msg):
    print('[ {} ] [\033[1m{}\033[21m]: {}'.format(
        self._level_string_map[msg.level], msg.name, msg.msg))

    if self._verbose:
        stamp_sec = msg.header.stamp.to_sec()
        stamp_tz = datetime.fromtimestamp(stamp_sec, tzlocal())

        print('          [{} ({:.6f})] [{}]: {}:{}'.format(
            stamp_tz, stamp_sec, msg.function, msg.file, msg.line))

You would have to change the script to get it to print in any other way.

If you do, and there isn't already a PR open, it would be nice to add this feature to the script and submit it for inclusion in rospy.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-02-21 10:35:32 -0500

Seen: 174 times

Last updated: Feb 21 '22