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

ROSCONSOLE_FORMAT not working in ROSPY on Hydro

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

Andrzej Pronobis gravatar image

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

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)
        r.sleep()

if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass

I get unformatted outputs like:

mjyc@ubuntu:~$ python test.py
[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

Comments

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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

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

demmeln gravatar image

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

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 https://github.com/ros/ros_comm 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: https://docs.python.org/2/library/log...

edit flag offensive delete link more

Comments

Thanks a lot Niko for a very informative answer!

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

Thank you!

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

Question Tools

1 follower

Stats

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

Seen: 517 times

Last updated: Jul 24 '14