Skip to content

Python example for mcap using RangedPlayback#862

Open
ericmlujan wants to merge 5 commits intoeric/new-mcap-examplefrom
eric/mcap-python-example
Open

Python example for mcap using RangedPlayback#862
ericmlujan wants to merge 5 commits intoeric/new-mcap-examplefrom
eric/mcap-python-example

Conversation

@ericmlujan
Copy link
Contributor

Changelog

  • Add Python example for using the RangedPlayback capability

Docs

  • This is an example.

Description

Add a Python example using the RangedPlayback websocket capability to load and play back an mcap file. This example introduces an annotated PlaybackSource ABC, which others can pattern match to when implementing their own loaders for custom data formats.

This PR ports #859.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

def _clamp_speed(speed: float) -> float:
if not (speed >= _MIN_PLAYBACK_SPEED): # handles NaN/inf
return _MIN_PLAYBACK_SPEED
return speed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Positive infinity speed causes crash in time calculations

Low Severity

The _clamp_speed function handles NaN and negative infinity by clamping to _MIN_PLAYBACK_SPEED, but positive infinity passes through unchanged since float('inf') >= 0.01 evaluates to True. When positive infinity is used as the speed, calculations like int(elapsed_wall_ns * self._speed) in TimeTracker._current_log_time() will raise an OverflowError because int(float('inf')) is not allowed in Python.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants