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

ROSCONSOLE_FORMAT not working in ROSPY on Hydro

asked 2014-07-20 00:21:53 -0600

Andrzej Pronobis gravatar image

updated 2014-07-24 11:35:56 -0600

I tried to use ROSCONSOLE_FORMAT as shown in Console Output Formatting on rosconsole wiki.

I configured my .bashrc as shown below:

source /opt/ros/hydro/setup.bash 
source ~/myproject/devel/setup.bash
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=<removed_link>
export ROBOT=sim
export ROSCONSOLE_FORMAT='[${severity}] [${node}@${function}:${line}]: ${message}'

For C++ I get expected outputs. However for any python program, for example

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String

def talker():
    # pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    r = rospy.Rate(1)  # 10hz
    while not rospy.is_shutdown():
        # str = "hello world %s" % rospy.get_time()
        rospy.loginfo("Hello World!")
        # pub.publish(str)

if __name__ == '__main__':
    except rospy.ROSInterruptException:

I get unformatted outputs like:

mjyc@ubuntu:~$ python
[INFO] [WallTime: 1405812621.854884] Hello World!
[INFO] [WallTime: 1405812622.856649] Hello World!
[INFO] [WallTime: 1405812623.856340] Hello World!
[INFO] [WallTime: 1405812624.856789] Hello World!
[INFO] [WallTime: 1405812625.855262] Hello World!

Anybody has any clue?

I'm on Ubuntu 12.04 and using hydro.

edit retag flag offensive close merge delete


FYI: ros_comm/pull/519 adds support for ROSCONSOLE_FORMAT to rospy. It's currently only merged into indigo-devel though.

gvdhoorn gravatar image gvdhoorn  ( 2015-04-07 05:35:12 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-21 15:15:17 -0600

demmeln gravatar image

updated 2014-07-22 19:10:35 -0600

Hi Andrzej,

so rosconsole is purley a C++ logging related package. rospy's logging seems to be somewhat unrelated. In particular the logging with rospy tutorial makes no mention of such a configuration of the output.

The only mention of ROSCONSOLE_FORMAT in is in C++ code and the code that seems to implent the output formatting in rospy is also pretty clearly not configurable in such a way.

It's probably pretty straight forward to implement support for that environment variable also for rospy. The existence of this file suggests to me that you can configure rospy to use your custom stream handler without touching rospy code itself, but I'm sure PR's to improve rospy are welcome.

Cheers, Niko

Edit: Check out the python logging module extesive configuration capabilities here:

edit flag offensive delete link more


Thanks a lot Niko for a very informative answer!

Andrzej Pronobis gravatar image Andrzej Pronobis  ( 2014-07-22 20:54:40 -0600 )edit

Thank you!

m_jaeyoon_c gravatar image m_jaeyoon_c  ( 2014-07-23 14:26:25 -0600 )edit

Question Tools

1 follower


Asked: 2014-07-20 00:21:53 -0600

Seen: 507 times

Last updated: Jul 24 '14