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

Lidar processing #49

Merged
merged 6 commits into from
Oct 23, 2024
Merged

Lidar processing #49

merged 6 commits into from
Oct 23, 2024

Conversation

Mmoyv27
Copy link
Contributor

@Mmoyv27 Mmoyv27 commented Oct 20, 2024

made review changes, adjusted for linting

Representing a LiDAR Oscillation
"""

from lidar_detection import LidarDetection
Copy link
Contributor

Choose a reason for hiding this comment

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

import the module instead of the class - so instead use from . import lidar_detection

Copy link
Contributor

Choose a reason for hiding this comment

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

this is just to maintain consistency as well as to avoid confusion because some data structure files contain multiple classes so it is easier to trace back where each object is from this way.

__create_key = object()

@classmethod
def create(cls, readings: list[LidarDetection]) -> "tuple[bool, LidarOscillation | None]":
Copy link
Contributor

Choose a reason for hiding this comment

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

since we changed the import this would now be lidar_detection.LidarDetection

Create a new LidarOscillation object from a list of LidarReading objects.
"""
# Ensuring the list does not contain None values
if any(reading is None for reading in readings):
Copy link
Contributor

Choose a reason for hiding this comment

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

we can assume that every reading inside readings is valid so no need to check here. validation will be done in the lidar parser, not here in the data structure creation itself

assert class_private_create_key is LidarOscillation.__create_key, "Use the create() method"

self.readings = readings
valid_angles = [reading.angle for reading in readings if reading is not None]
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed for reason above

"""
Create a new LidarOscillation object from a list of LidarReading objects.
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

Check if list is empty

self.readings = readings
angles = [reading.angle for reading in readings]

if angles:
Copy link
Contributor

Choose a reason for hiding this comment

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

since we checked list is empty, we can assume there are valid angle readings so we can remove this check

Copy link
Contributor

@ashum68 ashum68 left a comment

Choose a reason for hiding this comment

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

LGTM

@Mmoyv27 Mmoyv27 merged commit 52f39eb into main Oct 23, 2024
1 check passed
@Mmoyv27 Mmoyv27 deleted the lidar-processing branch October 23, 2024 02:30
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.

2 participants