lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

logplayer: Show indictor of time till next message (when large) #438

Open judfs opened 1 year ago

judfs commented 1 year ago

When lcm-logplayer-gui is waiting is waiting for another message, the gui appears as though it is stalled. The internal timer continues to tick, but there is no user feedback that things are still working.

I was trying to play a log I collected. I hit this behavior and my first thought was my log somehow got corrupted and it somehow ended up breaking the player. But actually when recording the log, my data source was just down for several minutes. However there is no indication in the log player that the next message actually will come.

Kind of surprising, but I guess useful, hitting pause+play will skip waiting and will jump to the next message instead of pausing a playback timer.

I actually have now clue how I would like this displayed. Would be simple to add print statements to command line player if desired. Might at the minimum also be useful for the gui version.


A script to create a log with a large content break. Using examples/python dir/types:

import lcm
import time
import datetime

from exlcm import example_t

lc = lcm.LCM()

msg = example_t()
msg.timestamp = int(time.time() * 1000000)
msg.position = (1, 2, 3)
msg.orientation = (1, 0, 0, 0)
msg.ranges = range(15)
msg.num_ranges = len(msg.ranges)
msg.name = "example string"
msg.enabled = True

logname = "stalled.lcmlog"
log = lcm.EventLog(logname, "w", overwrite=True)

unit_to_micro = lambda x: int(x * 1e6)

channel = "EXAMPLE"

t0 = datetime.datetime.fromisoformat("2021-02-03").timestamp()  # Arbitrary fixed point
t0 = unit_to_micro(t0)

clock_s = 0

# 30s of 1hz data
duration = 30
for i in range(clock_s, clock_s + duration):
    msg.name = f"e{i}"
    mu_i = unit_to_micro(i)
    log.write_event(t0 + mu_i, channel, msg.encode())
clock_s += duration

# Wait 2 min
clock_s += 2 * 60

# After waiting data continues to flow in.
duration = 5 * 60
for i in range(clock_s, clock_s + duration):
    msg.name = f"e{i}"
    mu_i = unit_to_micro(i)
    log.write_event(t0 + mu_i, channel, msg.encode())
clock_s += duration

#
log.close()