2
2
Representing a LiDAR Oscillation
3
3
"""
4
4
5
- from lidar_detection import LidarDetection
5
+ from . import lidar_detection
6
6
7
7
8
8
class LidarOscillation :
@@ -13,28 +13,29 @@ class LidarOscillation:
13
13
__create_key = object ()
14
14
15
15
@classmethod
16
- def create (cls , readings : list [LidarDetection ]) -> "tuple[bool, LidarOscillation | None]" :
16
+ def create (
17
+ cls , readings : list [lidar_detection .LidarDetection ]
18
+ ) -> "tuple[bool, LidarOscillation | None]" :
17
19
"""
18
20
Create a new LidarOscillation object from a list of LidarReading objects.
19
21
"""
20
- # Ensuring the list does not contain None values
21
- if any (reading is None for reading in readings ):
22
- return False , None
23
22
24
23
return True , LidarOscillation (cls .__create_key , readings )
25
24
26
- def __init__ (self , class_private_create_key : object , readings : list [LidarDetection ]) -> None :
25
+ def __init__ (
26
+ self , class_private_create_key : object , readings : list [lidar_detection .LidarDetection ]
27
+ ) -> None :
27
28
"""
28
29
Private constructor, use create() method to instantiate.
29
30
"""
30
31
assert class_private_create_key is LidarOscillation .__create_key , "Use the create() method"
31
32
32
33
self .readings = readings
33
- valid_angles = [reading .angle for reading in readings if reading is not None ]
34
+ angles = [reading .angle for reading in readings ]
34
35
35
- if valid_angles :
36
- self .min_angle = min (valid_angles )
37
- self .max_angle = max (valid_angles )
36
+ if angles :
37
+ self .min_angle = min (angles )
38
+ self .max_angle = max (angles )
38
39
else :
39
40
self .min_angle = None
40
41
self .max_angle = None
0 commit comments