Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
if __name__ == '__main__':
      while not rospy.is_shutdown():
           listener()
           rospy.Publisher('talk', Float64, queue_size=5).publish(ranges)
           rospy.sleep(0.01)

You are re-creating your subscriber every 0.01 seconds, which is probably not what you want.

However when I move the data from the callback functions to my processing algorithm the using global variables, the variables are updated very slowly.

I can imagine that the chances of ROS succesfully registering your subscriber, receiving a message and delivering it to your callback in 0.01 sec are rather slim, and only succeeds every now and then. If that leads to most messages being missed, it would appear as if updates to ranges are very slow. In reality, they are actually very infrequent.

if __name__ == '__main__':
      while not rospy.is_shutdown():
           listener()
           rospy.Publisher('talk', Float64, queue_size=5).publish(ranges)
           rospy.sleep(0.01)

You are re-creating your subscriber every 0.01 seconds, which is probably not what you want.

However when I move the data from the callback functions to my processing algorithm the using global variables, the variables are updated very slowly.

I can imagine that the chances of ROS succesfully registering your subscriber, receiving a message and delivering it to your callback in 0.01 sec are rather slim, and only succeeds every now and then. If that leads to most messages being missed, it would appear as if updates to ranges are very slow. In reality, they are actually probably very infrequent.

if __name__ == '__main__':
      while not rospy.is_shutdown():
           listener()
           rospy.Publisher('talk', Float64, queue_size=5).publish(ranges)
           rospy.sleep(0.01)

You are re-creating your subscriber every 0.01 seconds, which is probably not what you want.

However when I move the data from the callback functions to my processing algorithm the using global variables, the variables are updated very slowly.

I can imagine that the chances of ROS succesfully successfully registering your subscriber, receiving a message and delivering it to your callback in 0.01 sec are rather slim, and only succeeds every now and then. If that leads to most messages being missed, it would appear as if updates to ranges are very slow. In reality, they are probably very infrequent.