MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / measure_streaming_frequency

Function measure_streaming_frequency

avp_stream/sim_latency_test.py:314–366  ·  view source on GitHub ↗

Measure the actual streaming frequency achieved. Args: streamer: VisionProStreamer instance model: MuJoCo model data: MuJoCo data duration: Test duration in seconds target_hz: Target update rate in Hz Returns: Dictionary with

(streamer: VisionProStreamer, 
                                 model, data,
                                 duration: float = 5.0,
                                 target_hz: float = 120.0)

Source from the content-addressed store, hash-verified

312
313
314def measure_streaming_frequency(streamer: VisionProStreamer,
315 model, data,
316 duration: float = 5.0,
317 target_hz: float = 120.0) -> dict:
318 """
319 Measure the actual streaming frequency achieved.
320
321 Args:
322 streamer: VisionProStreamer instance
323 model: MuJoCo model
324 data: MuJoCo data
325 duration: Test duration in seconds
326 target_hz: Target update rate in Hz
327
328 Returns:
329 Dictionary with frequency statistics
330 """
331 update_count = 0
332 update_times = []
333 last_time = None
334
335 target_dt = 1.0 / target_hz
336 start_time = time.perf_counter()
337
338 while time.perf_counter() - start_time < duration:
339 mujoco.mj_step(model, data)
340 streamer.update_sim()
341 update_count += 1
342
343 now = time.perf_counter()
344 if last_time is not None:
345 update_times.append(now - last_time)
346 last_time = now
347
348 # Sleep to maintain target rate
349 elapsed = time.perf_counter() - start_time
350 expected_updates = int(elapsed * target_hz)
351 if update_count > expected_updates:
352 sleep_time = (update_count / target_hz) - elapsed
353 if sleep_time > 0:
354 time.sleep(sleep_time)
355
356 total_time = time.perf_counter() - start_time
357 actual_hz = update_count / total_time
358
359 return {
360 "target_hz": target_hz,
361 "actual_hz": actual_hz,
362 "update_count": update_count,
363 "duration_s": total_time,
364 "mean_dt_ms": float(np.mean(update_times)) * 1000 if update_times else 0,
365 "std_dt_ms": float(np.std(update_times)) * 1000 if update_times else 0,
366 }
367
368
369def run_frequency_sweep(args):

Callers 2

run_frequency_sweepFunction · 0.85
run_body_count_sweepFunction · 0.85

Calls 3

update_simMethod · 0.80
intFunction · 0.50
floatFunction · 0.50

Tested by

no test coverage detected