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

print works but rospy.loginfo doesn't

asked 2017-08-09 02:57:45 -0600

vKuehn gravatar image


I have this code and print would work but rospy.loginfo

 import rospy

from std_msgs.msg import String
messageToRos = Queue.Queue()

def writeMessageToRos(messageToRos):
    pub = rospy.Publisher('chatter', String, queue_size=10)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        msg = messageToRos.get()
        print 'new messageToRos: ', msg
        rospy.loginfo('new messageToRos: ', msg)

even the publisher works fine. How would I correctly do a loginfo or debuginfo for msg ?

edit retag flag offensive close merge delete


Are you running this from rosrun or roslaunch?

naveedhd gravatar image naveedhd  ( 2017-08-09 03:35:54 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-09 09:27:33 -0600

Hi @vKuehn,

I made a video ( ) that answers exactly this question.

In summary, in order to make rospy.loginfo print on the screen, if you are running the node with roslaunch, you must use the parameter --screen when calling roslaunch, or add the output="screen" on your launch file.

For example:

1 - roslaunch your_package your_launchfile.launch --screen


2 - <node pkg="your_package" type="" name="your_file" output="screen"/>

On the video I explain step by step.

edit flag offensive delete link more


that sounds promising thanks will look at the video. is there a way to do that setting right in the python file ?

vKuehn gravatar image vKuehn  ( 2017-08-09 10:11:21 -0600 )edit

You're Welcome.

Well, I've never done this using directly the pytyon file.

But with the steps mentioned on the answer (and explained on the video) works perfectly ;)

Ruben Alves gravatar image Ruben Alves  ( 2017-08-09 11:43:43 -0600 )edit

just saw the video. What a rooky problem. You answer is however excellent ! thanks for the video

vKuehn gravatar image vKuehn  ( 2017-08-09 12:06:09 -0600 )edit

You're Welcome.

Glad to help you.

Ruben Alves gravatar image Ruben Alves  ( 2017-08-09 12:17:12 -0600 )edit

Why not explain step-by-step here? The problem with linking to a video for more steps is that now part of the answer is external and this answer is not self-contained. What if the video gets taken down?

jayess gravatar image jayess  ( 2017-08-09 16:10:11 -0600 )edit

The "step-by-step" is already on the answer.

Ruben Alves gravatar image Ruben Alves  ( 2017-08-09 18:02:02 -0600 )edit

Question Tools



Asked: 2017-08-09 02:57:45 -0600

Seen: 7,272 times

Last updated: Aug 09 '17