8
8
*/
9
9
public class Attitude implements DroneAttribute {
10
10
11
- private double roll ;
11
+ /**
12
+ * Roll angle (deg, -180..+180)
13
+ */
14
+ private double roll ;
15
+
16
+ /**
17
+ * Roll angular speed (deg/s)
18
+ */
19
+ private float rollSpeed ;
20
+
21
+ /**
22
+ * Pitch angle (deg, -180 to 180)
23
+ */
12
24
private double pitch ;
25
+
26
+ /**
27
+ * Pitch angular speed (deg / s)
28
+ */
29
+ private float pitchSpeed ;
30
+
31
+ /**
32
+ * Yaw angle (deg, -180 to 180)
33
+ */
13
34
private double yaw ;
14
35
36
+ /**
37
+ * Yaw angular speed (deg/ s)
38
+ */
39
+ private float yawSpeed ;
40
+
15
41
public Attitude (){}
16
42
17
- public Attitude (double roll , double pitch , double yaw ) {
43
+ public Attitude (double roll , double pitch , double yaw , float rollSpeed , float pitchSpeed , float yawSpeed ) {
18
44
this .roll = roll ;
19
45
this .pitch = pitch ;
20
46
this .yaw = yaw ;
47
+ this .rollSpeed = rollSpeed ;
48
+ this .pitchSpeed = pitchSpeed ;
49
+ this .yawSpeed = yawSpeed ;
21
50
}
22
51
23
52
public void setRoll (double roll ) {
@@ -44,18 +73,56 @@ public double getYaw() {
44
73
return yaw ;
45
74
}
46
75
76
+ public float getPitchSpeed () {
77
+ return pitchSpeed ;
78
+ }
79
+
80
+ public void setPitchSpeed (float pitchSpeed ) {
81
+ this .pitchSpeed = pitchSpeed ;
82
+ }
83
+
84
+ public float getRollSpeed () {
85
+ return rollSpeed ;
86
+ }
87
+
88
+ public void setRollSpeed (float rollSpeed ) {
89
+ this .rollSpeed = rollSpeed ;
90
+ }
91
+
92
+ public float getYawSpeed () {
93
+ return yawSpeed ;
94
+ }
95
+
96
+ public void setYawSpeed (float yawSpeed ) {
97
+ this .yawSpeed = yawSpeed ;
98
+ }
99
+
100
+ @ Override
101
+ public String toString () {
102
+ return "Attitude{" +
103
+ "pitch=" + pitch +
104
+ ", roll=" + roll +
105
+ ", rollSpeed=" + rollSpeed +
106
+ ", pitchSpeed=" + pitchSpeed +
107
+ ", yaw=" + yaw +
108
+ ", yawSpeed=" + yawSpeed +
109
+ '}' ;
110
+ }
111
+
47
112
@ Override
48
113
public boolean equals (Object o ) {
49
114
if (this == o ) return true ;
50
115
if (!(o instanceof Attitude )) return false ;
51
116
52
117
Attitude attitude = (Attitude ) o ;
53
118
54
- if (Double .compare (attitude .pitch , pitch ) != 0 ) return false ;
55
119
if (Double .compare (attitude .roll , roll ) != 0 ) return false ;
120
+ if (Float .compare (attitude .rollSpeed , rollSpeed ) != 0 ) return false ;
121
+ if (Double .compare (attitude .pitch , pitch ) != 0 ) return false ;
122
+ if (Float .compare (attitude .pitchSpeed , pitchSpeed ) != 0 ) return false ;
56
123
if (Double .compare (attitude .yaw , yaw ) != 0 ) return false ;
124
+ return Float .compare (attitude .yawSpeed , yawSpeed ) == 0 ;
57
125
58
- return true ;
59
126
}
60
127
61
128
@ Override
@@ -64,22 +131,16 @@ public int hashCode() {
64
131
long temp ;
65
132
temp = Double .doubleToLongBits (roll );
66
133
result = (int ) (temp ^ (temp >>> 32 ));
134
+ result = 31 * result + (rollSpeed != +0.0f ? Float .floatToIntBits (rollSpeed ) : 0 );
67
135
temp = Double .doubleToLongBits (pitch );
68
136
result = 31 * result + (int ) (temp ^ (temp >>> 32 ));
137
+ result = 31 * result + (pitchSpeed != +0.0f ? Float .floatToIntBits (pitchSpeed ) : 0 );
69
138
temp = Double .doubleToLongBits (yaw );
70
139
result = 31 * result + (int ) (temp ^ (temp >>> 32 ));
140
+ result = 31 * result + (yawSpeed != +0.0f ? Float .floatToIntBits (yawSpeed ) : 0 );
71
141
return result ;
72
142
}
73
143
74
- @ Override
75
- public String toString () {
76
- return "Attitude{" +
77
- "roll=" + roll +
78
- ", pitch=" + pitch +
79
- ", yaw=" + yaw +
80
- '}' ;
81
- }
82
-
83
144
84
145
@ Override
85
146
public int describeContents () {
@@ -91,12 +152,18 @@ public void writeToParcel(Parcel dest, int flags) {
91
152
dest .writeDouble (this .roll );
92
153
dest .writeDouble (this .pitch );
93
154
dest .writeDouble (this .yaw );
155
+ dest .writeFloat (this .rollSpeed );
156
+ dest .writeFloat (this .pitchSpeed );
157
+ dest .writeFloat (this .yawSpeed );
94
158
}
95
159
96
160
private Attitude (Parcel in ) {
97
161
this .roll = in .readDouble ();
98
162
this .pitch = in .readDouble ();
99
163
this .yaw = in .readDouble ();
164
+ this .rollSpeed = in .readFloat ();
165
+ this .pitchSpeed = in .readFloat ();
166
+ this .yawSpeed = in .readFloat ();
100
167
}
101
168
102
169
public static final Parcelable .Creator <Attitude > CREATOR = new Parcelable .Creator <Attitude >() {
0 commit comments