Skip to content

Commit

Permalink
add ability to play back mcap at different rate
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw committed Aug 27, 2024
1 parent c63d2b9 commit 652abe4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions one2z/scripts/ros1_play_mcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def main():
msg_classes = {}
count = 0
while not rospy.is_shutdown():
rate = rospy.get_param("~rate", 1.0)
play_mcap(sys.argv[1], msg_classes)
rospy.loginfo(f"looping {count}")
count += 1
time.sleep(1.0)


def play_mcap(name: str, msg_classes):
def play_mcap(name: str, msg_classes, rate=1.0):
# TODO(lucasw) make optional
clock_pub = rospy.Publisher("/clock", Clock, queue_size=3)
last_clock_msg = None
Expand Down Expand Up @@ -180,7 +181,7 @@ def __init__(self):
last_tf_static_stamp = clock_msg.clock

dt = t_cur - t_old
time.sleep(dt)
time.sleep(dt / rate)
t_old = t_cur

# TODO(lucasw) keep advancing /clock for a few seconds before looping
Expand Down

0 comments on commit 652abe4

Please sign in to comment.