-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new cluster data struct and converted lidar detection to have x, y co… (
#35) * new cluster data struct and converted lidar detection to have x, y coords instead of dist, angle * formatting * added dist and angle back to struct and added better desc * removed coordinates from lidar_detection * edited docstring * added better comments
- Loading branch information
Showing
2 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
LiDAR detection cluster data structure. | ||
""" | ||
|
||
from . import lidar_detection | ||
|
||
|
||
class DetectionCluster: | ||
""" | ||
Cluster of LiDAR detections. | ||
""" | ||
|
||
__create_key = object() | ||
|
||
@classmethod | ||
def create( | ||
cls, detections: "list[lidar_detection.LidarDetection]" | ||
) -> "tuple[bool, DetectionCluster]": | ||
""" | ||
Combines lidar readings in close proximity. | ||
""" | ||
return True, DetectionCluster(cls.__create_key, detections) | ||
|
||
def __init__( | ||
self, create_key: object, detections: "list[lidar_detection.LidarDetection]" | ||
) -> None: | ||
""" | ||
Private constructor, use create() method. | ||
""" | ||
assert create_key is DetectionCluster.__create_key, "Use create() method" | ||
|
||
self.detections = detections | ||
|
||
def __str__(self) -> str: | ||
""" | ||
String representation. | ||
""" | ||
detections_str = ", ".join(str(detection) for detection in self.detections) | ||
return f"{self.__class__.__name__} (Count: {len(self.detections)}): {detections_str}. " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters