Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make constants explicit in synchronization database #218

Merged
merged 8 commits into from
May 13, 2021

Conversation

johnwlambert
Copy link
Contributor

Make the frame rate constants more readable/ clear.

LIDAR_FRAME_RATE_HZ = 10

# in milliseconds
RING_CAMERA_SHUTTER_INTERVAL_MS = (1 / RING_CAMERA_FPS) * 1000 # evaluates to 33.3 ms
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that 1000 might be more readable as 1e3.

Copy link
Contributor

Choose a reason for hiding this comment

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

(in terms of quickly determining the units conversion)

@@ -14,6 +14,17 @@

logger = logging.getLogger(__name__)

RING_CAMERA_FPS = 30
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add typing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typing_extensions.Final?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah

# Stereo Camera is 5 Hz (once per 200 milliseconds)
# LiDAR is 10 Hz
# Since Stereo is more sparse, we look for 200 millisecond on either side
MAX_LIDAR_RING_CAM_TIMESTAMP_DIFF = RING_CAMERA_SHUTTER_INTERVAL_MS * (1.0 / 2) * (1.0 / 1000) * 1e9
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider making this more readable. One idea:

MAX_LIDAR_RING_CAM_TIMESTAMP_DIFF = 0.5 * (1e9 / 1e3) * RING_CAMERA_SHUTTER_INTERVAL_MS

I think ideally we would have a function to change units:

to_metric_time(ts: int, src: TimeUnit, dst: TimeUnit)

or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MAX_LIDAR_RING_CAM_TIMESTAMP_DIFF = to_metric_time(RING_CAMERA_SHUTTER_INTERVAL_MS / 2), src=Millisecond, dst=Nanosecond)

@@ -14,6 +14,17 @@

logger = logging.getLogger(__name__)

RING_CAMERA_FPS = 30
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah


logger = logging.getLogger(__name__)

Millisecond = TimeUnit.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the convention for renaming enums? Does PEP 8 say anything about this?

@johnwlambert johnwlambert merged commit de2872c into master May 13, 2021
@johnwlambert johnwlambert deleted the clean-up-constants branch May 13, 2021 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants