1
1
"""
2
2
Position and orientation of drone.
3
3
"""
4
+
4
5
import math
5
6
6
7
7
- # Basically a struct
8
- # pylint: disable=too-few-public-methods
9
8
class DronePosition :
10
9
"""
11
10
WGS 84 following ISO 6709 (latitude before longitude).
12
11
"""
12
+
13
13
__create_key = object ()
14
14
15
15
@classmethod
16
- def create (cls ,
17
- latitude : "float | None" ,
18
- longitude : "float | None" ,
19
- altitude : "float | None" ) -> "tuple[bool, DronePosition | None]" :
16
+ def create (
17
+ cls , latitude : "float | None" , longitude : "float | None" , altitude : "float | None"
18
+ ) -> "tuple[bool, DronePosition | None]" :
20
19
"""
21
20
latitude, longitude in decimal degrees.
22
21
altitude in metres.
@@ -35,11 +34,9 @@ def create(cls,
35
34
36
35
return True , DronePosition (cls .__create_key , latitude , longitude , altitude )
37
36
38
- def __init__ (self ,
39
- class_private_create_key ,
40
- latitude : float ,
41
- longitude : float ,
42
- altitude : float ):
37
+ def __init__ (
38
+ self , class_private_create_key : object , latitude : float , longitude : float , altitude : float
39
+ ) -> None :
43
40
"""
44
41
Private constructor, use create() method.
45
42
"""
@@ -49,25 +46,21 @@ def __init__(self,
49
46
self .longitude = longitude
50
47
self .altitude = altitude
51
48
52
- # pylint: enable=too-few-public-methods
53
-
54
49
55
- # Basically a struct
56
- # pylint: disable=too-few-public-methods
57
50
class DroneOrientation :
58
51
"""
59
52
Yaw, pitch, roll following NED system (x forward, y right, z down).
60
53
Specifically, intrinsic (Tait-Bryan) rotations in the zyx/3-2-1 order.
61
54
"""
55
+
62
56
__create_key = object ()
63
57
64
58
@classmethod
65
59
# Required for checks
66
60
# pylint: disable-next=too-many-return-statements
67
- def create (cls ,
68
- yaw : "float | None" ,
69
- pitch : "float | None" ,
70
- roll : "float | None" ) -> "tuple[bool, DroneOrientation | None]" :
61
+ def create (
62
+ cls , yaw : "float | None" , pitch : "float | None" , roll : "float | None"
63
+ ) -> "tuple[bool, DroneOrientation | None]" :
71
64
"""
72
65
yaw, pitch, roll in radians.
73
66
"""
@@ -91,7 +84,9 @@ def create(cls,
91
84
92
85
return True , DroneOrientation (cls .__create_key , yaw , pitch , roll )
93
86
94
- def __init__ (self , class_private_create_key , yaw : float , pitch : float , roll : float ):
87
+ def __init__ (
88
+ self , class_private_create_key : object , yaw : float , pitch : float , roll : float
89
+ ) -> None :
95
90
"""
96
91
Private constructor, use create() method.
97
92
"""
@@ -101,21 +96,18 @@ def __init__(self, class_private_create_key, yaw: float, pitch: float, roll: flo
101
96
self .pitch = pitch
102
97
self .roll = roll
103
98
104
- # pylint: enable=too-few-public-methods
105
-
106
99
107
- # Basically a struct
108
- # pylint: disable=too-few-public-methods
109
100
class DroneOdometry :
110
101
"""
111
102
Wrapper for DronePosition and DroneOrientation.
112
103
"""
104
+
113
105
__create_key = object ()
114
106
115
107
@classmethod
116
- def create (cls ,
117
- position : DronePosition ,
118
- orientation : DroneOrientation ) -> "tuple[bool, DroneOdometry | None]" :
108
+ def create (
109
+ cls , position : DronePosition , orientation : DroneOrientation
110
+ ) -> "tuple[bool, DroneOdometry | None]" :
119
111
"""
120
112
Position and orientation in one class.
121
113
"""
@@ -127,10 +119,12 @@ def create(cls,
127
119
128
120
return True , DroneOdometry (cls .__create_key , position , orientation )
129
121
130
- def __init__ (self ,
131
- class_private_create_key ,
132
- position : DronePosition ,
133
- orientation : DroneOrientation ):
122
+ def __init__ (
123
+ self ,
124
+ class_private_create_key : object ,
125
+ position : DronePosition ,
126
+ orientation : DroneOrientation ,
127
+ ) -> None :
134
128
"""
135
129
Private constructor, use create() method.
136
130
"""
0 commit comments