Callback rate is faster than the received message
Hello people. I have a node which subscribes to two topics with different frequencies and using two different callback functions I publish data to two different topics. My code is structured like this:
rospy.init_node('face_finder', anonymous=True)
marker_publisher = rospy.Publisher('box_visual', Marker, queue_size=100)
rospy.sleep(1)
path_pub = rospy.Publisher('/path', Path, queue_size=100)
rospy.sleep(1)
def get_odom(msg):
...
path_pub.publish(path)
def callback(data):
...
marker_publisher.publish(faces)
marker_publisher.publish(faces_caption)
marker_publisher.publish(est_pose)
def face_finder():
rospy.Subscriber("/odom", Odometry, get_odom, queue_size = 1)
rospy.Subscriber("/line_segments", LineSegmentList, callback, queue_size = 1)
rospy.spin()
if __name__ == '__main__':
face_finder()
I receive data from /odom
topic with 20 Hz, the get_odom
is executed and I publish to /path
with 20 Hz (that makes sense). I receive data from /line_segments
with 40 Hz, callback is executed but then, I publish to /box_visual
with an unstable frequency (120 - 160 Hz). I'm not using any rospy.Rate()
command to set a fixed rate, so I expect that callback
function will be called every time I get a new message from /line_segments
, right? That means a publishing rate around 40 Hz. Why I don't see that here and what I'm I possibly missing?
The two callbacks use data from the same global variables, but they don't change the content of the same global variables (I don't know if this affects somehow my problem)
I use Ubuntu 16.04 LTS on dual boot, ROS kinetic and python.
Thank you in advance!