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

print works but rospy.loginfo doesn't

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

vKuehn gravatar image

Hi,

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)
        pub.publish(msg)
        rate.sleep()

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

edit retag flag offensive close merge delete

Comments

Are you running this from rosrun or roslaunch?

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

1 Answer

Sort by ยป oldest newest most voted
4

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

Hi @vKuehn,

I made a video ( https://www.youtube.com/watch?v=UCLcf... ) 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

or

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

On the video I explain step by step.

edit flag offensive delete link more

Comments

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

You're Welcome.

Glad to help you.

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

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

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

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

Question Tools

2 followers

Stats

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

Seen: 7,479 times

Last updated: Aug 09 '17