Why the output of some topic delays with IDEs?

asked 2020-09-02 03:59:28 -0600

Redhwan gravatar image

updated 2020-09-06 00:22:30 -0600

I wrote small code to see the time of the output for "/move_base/status" topic.

This is my code:

#!/usr/bin/env python
import rospy
from actionlib_msgs.msg import GoalStatusArray

def callback(data):
    print(data.status_list[0].status)
def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("/move_base/status", GoalStatusArray, callback)

    rate = rospy.Rate(50)
    while not rospy.is_shutdown():

        rate.sleep()

if __name__ == '__main__':
    listener()

At the same time, I run the topic in the terminal $ rostopic echo /move_base/status here it was fast

I observed around 6 sec delay with pycharm compared to the terminal.

Is there a scientific explanation for this?

edit retag flag offensive close merge delete

Comments

Hey Redhwan, maybe it's a configuration problem?

For example I'm using the ros environment with visual studio code combined with a ssh connection and my rostopic data needs 10 - 20ms.

WhilteShad0w gravatar image WhilteShad0w  ( 2020-09-06 02:11:48 -0600 )edit

First of all, thank you for your comment. This topic is depending on actionlib_msgs, which is installed without configuration. I really confused. I used both pycharm and visual studio. The same results.

Redhwan gravatar image Redhwan  ( 2020-09-07 01:58:40 -0600 )edit

This topic only late, rest of topics are fine.

Redhwan gravatar image Redhwan  ( 2020-09-07 02:01:00 -0600 )edit