Publishing and reciving at different rate (rospy)

asked 2022-07-21 15:30:03 -0600

tsoetosaa gravatar image


Running a python based simulation for multiple robots (Ubuntu 20.04, rosdistro: noetic, rosversion: 1.15.14). The structure of the simulation and publication scheme is shown below.

class sim():
  def __init__(self):
    rate = rospy.Rate(sim_rate_value)
    self.odom_publisher = []
    self.odom_publisher.append(rospy.Publisher("odom1", Odometry, queue_size=1, tcp_nodelay=True))
    self.odom_publisher.append(rospy.Publisher("odom2", Odometry, queue_size=1, tcp_nodelay=True))
    self.odom_publisher.append(rospy.Publisher("odom3", Odometry, queue_size=1, tcp_nodelay=True))
    while not rospy.is_shutdown():
      # numerical integration [this section is quite heavy and slow]
      for index in range(3):
        odom_pub = Odometry()
        current_time = rospy.get_rostime()
        odom_pub.header.stamp = current_time
        # fill up odom_pub with computed odom from robot index

Recorded all odom msgs using

rosbag record -a

Issue: Published odom/header/stamp gives me consistent delta t between msgs, but bagfile time index does not give me consistent delta t between msgs.

Published odom/header/stamp shows consistent delta t between msgs, whereas in bagfile delta t varies (delta t is ~0.0 between the first two received msgs and twice the normal delta t between the second and thrid msgs). I do not experience this in other cpp or python publishers. Why is this happening? Is this a publisher issue or a subscriber issue?

edit retag flag offensive close merge delete