1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
use super::*;
#[derive(Clone, Debug, Default, PartialEq)]
pub struct RotatingTelemetry {
pub b_field_igrf: [f32; 3],
pub sun_vec_eph: [f32; 3],
pub sc_pos_eci: [f32; 3],
pub sc_vel_eci: [f32; 3],
pub kepler_elem: KeplerElem,
pub k_bdot: [f32; 3],
pub kp: [f32; 3],
pub kd: [f32; 3],
pub k_unload: [f32; 3],
pub css_bias: [i16; 6],
pub mag_bias: [i16; 3],
pub rws_volt: i16,
pub rws_press: i16,
pub att_det_mode: u8,
pub rws_reset_cntr: [u8; 3],
pub sun_mag_aligned: u8,
pub minor_version: u8,
pub mai_sn: u8,
pub orbit_prop_mode: u8,
pub acs_op_mode: u8,
pub proc_reset_cntr: u8,
pub major_version: u8,
pub ads_op_mode: u8,
pub css_gain: [f32; 6],
pub mag_gain: [f32; 3],
pub orbit_epoch: u32,
pub true_anomoly_epoch: f32,
pub orbit_epoch_next: u32,
pub sc_pos_eci_epoch: [f32; 3],
pub sc_vel_eci_epoch: [f32; 3],
pub qb_x_wheel_speed: i16,
pub qb_x_filter_gain: f32,
pub qb_x_dipole_gain: f32,
pub dipole_gain: [f32; 3],
pub wheel_speed_bias: [i16; 3],
pub cos_sun_mag_align_thresh: f32,
pub unload_ang_thresh: f32,
pub q_sat: f32,
pub rwa_trq_max: f32,
pub rws_motor_current: [u16; 3],
pub rws_motor_temp: i16,
}
impl RotatingTelemetry {
pub fn update(&mut self, msg: &StandardTelemetry) {
match msg.tlm_counter & 0x1F {
0 => {
self.b_field_igrf[0] = f32::from_bits(msg.rotating_variable_a);
self.b_field_igrf[1] = f32::from_bits(msg.rotating_variable_b);
self.b_field_igrf[2] = f32::from_bits(msg.rotating_variable_c);
}
1 => {
self.sun_vec_eph[0] = f32::from_bits(msg.rotating_variable_a);
self.sun_vec_eph[1] = f32::from_bits(msg.rotating_variable_b);
self.sun_vec_eph[2] = f32::from_bits(msg.rotating_variable_c);
}
2 => {
self.sc_pos_eci[0] = f32::from_bits(msg.rotating_variable_a);
self.sc_pos_eci[1] = f32::from_bits(msg.rotating_variable_b);
self.sc_pos_eci[2] = f32::from_bits(msg.rotating_variable_c);
}
3 => {
self.sc_vel_eci[0] = f32::from_bits(msg.rotating_variable_a);
self.sc_vel_eci[1] = f32::from_bits(msg.rotating_variable_b);
self.sc_vel_eci[2] = f32::from_bits(msg.rotating_variable_c);
}
4 => {
self.kepler_elem.semi_major_axis = f32::from_bits(msg.rotating_variable_a);
self.kepler_elem.eccentricity = f32::from_bits(msg.rotating_variable_b);
self.kepler_elem.inclination = f32::from_bits(msg.rotating_variable_c);
}
5 => {
self.kepler_elem.raan = f32::from_bits(msg.rotating_variable_a);
self.kepler_elem.arg_parigee = f32::from_bits(msg.rotating_variable_b);
self.kepler_elem.true_anomoly = f32::from_bits(msg.rotating_variable_c);
}
6 => {
self.k_bdot[0] = f32::from_bits(msg.rotating_variable_a);
self.k_bdot[1] = f32::from_bits(msg.rotating_variable_b);
self.k_bdot[2] = f32::from_bits(msg.rotating_variable_c);
}
7 => {
self.kp[0] = f32::from_bits(msg.rotating_variable_a);
self.kp[1] = f32::from_bits(msg.rotating_variable_b);
self.kp[2] = f32::from_bits(msg.rotating_variable_c);
}
8 => {
self.kd[0] = f32::from_bits(msg.rotating_variable_a);
self.kd[1] = f32::from_bits(msg.rotating_variable_b);
self.kd[2] = f32::from_bits(msg.rotating_variable_c);
}
9 => {
self.k_unload[0] = f32::from_bits(msg.rotating_variable_a);
self.k_unload[1] = f32::from_bits(msg.rotating_variable_b);
self.k_unload[2] = f32::from_bits(msg.rotating_variable_c);
}
10 => {
self.css_bias[0] = msg.rotating_variable_a as i16;
self.css_bias[1] = msg.rotating_variable_b as i16;
self.css_bias[2] = msg.rotating_variable_c as i16;
self.css_bias[3] = msg.rotating_variable_a.wrapping_shr(16) as i16;
self.css_bias[4] = msg.rotating_variable_b.wrapping_shr(16) as i16;
self.css_bias[5] = msg.rotating_variable_c.wrapping_shr(16) as i16;
}
11 => {
self.mag_bias[0] = msg.rotating_variable_a as i16;
self.mag_bias[1] = msg.rotating_variable_b as i16;
self.mag_bias[2] = msg.rotating_variable_c as i16;
self.rws_volt = msg.rotating_variable_a.wrapping_shr(16) as i16;
self.rws_press = msg.rotating_variable_b.wrapping_shr(16) as i16;
}
12 => {
self.att_det_mode = msg.rotating_variable_a as u8;
self.rws_reset_cntr[0] = msg.rotating_variable_a.wrapping_shr(8) as u8;
self.sun_mag_aligned = msg.rotating_variable_a.wrapping_shr(16) as u8;
self.minor_version = msg.rotating_variable_a.wrapping_shr(24) as u8;
self.mai_sn = msg.rotating_variable_b as u8;
self.rws_reset_cntr[1] = msg.rotating_variable_b.wrapping_shr(8) as u8;
self.orbit_prop_mode = msg.rotating_variable_b.wrapping_shr(16) as u8;
self.acs_op_mode = msg.rotating_variable_b.wrapping_shr(24) as u8;
self.proc_reset_cntr = msg.rotating_variable_c as u8;
self.rws_reset_cntr[2] = msg.rotating_variable_c.wrapping_shr(8) as u8;
self.major_version = msg.rotating_variable_c.wrapping_shr(16) as u8;
self.ads_op_mode = msg.rotating_variable_c.wrapping_shr(24) as u8;
}
13 => {
self.css_gain[0] = f32::from_bits(msg.rotating_variable_a);
self.css_gain[1] = f32::from_bits(msg.rotating_variable_b);
self.css_gain[2] = f32::from_bits(msg.rotating_variable_c);
}
14 => {
self.css_gain[3] = f32::from_bits(msg.rotating_variable_a);
self.css_gain[4] = f32::from_bits(msg.rotating_variable_b);
self.css_gain[5] = f32::from_bits(msg.rotating_variable_c);
}
15 => {
self.mag_gain[0] = f32::from_bits(msg.rotating_variable_a);
self.mag_gain[1] = f32::from_bits(msg.rotating_variable_b);
self.mag_gain[2] = f32::from_bits(msg.rotating_variable_c);
}
16 => {
self.orbit_epoch = msg.rotating_variable_a as u32;
self.true_anomoly_epoch = f32::from_bits(msg.rotating_variable_b);
self.orbit_epoch_next = msg.rotating_variable_c as u32;
}
17 => {
self.sc_pos_eci_epoch[0] = f32::from_bits(msg.rotating_variable_a);
self.sc_pos_eci_epoch[1] = f32::from_bits(msg.rotating_variable_b);
self.sc_pos_eci_epoch[2] = f32::from_bits(msg.rotating_variable_c);
}
18 => {
self.sc_vel_eci_epoch[0] = f32::from_bits(msg.rotating_variable_a);
self.sc_vel_eci_epoch[1] = f32::from_bits(msg.rotating_variable_b);
self.sc_vel_eci_epoch[2] = f32::from_bits(msg.rotating_variable_c);
}
19 => {
self.qb_x_wheel_speed = msg.rotating_variable_a.wrapping_shr(16) as i16;
self.qb_x_filter_gain = f32::from_bits(msg.rotating_variable_b);
self.qb_x_dipole_gain = f32::from_bits(msg.rotating_variable_c);
}
20 => {
self.dipole_gain[0] = f32::from_bits(msg.rotating_variable_a);
self.dipole_gain[1] = f32::from_bits(msg.rotating_variable_b);
self.dipole_gain[2] = f32::from_bits(msg.rotating_variable_c);
}
21 => {
self.wheel_speed_bias[0] = msg.rotating_variable_a as i16;
self.wheel_speed_bias[1] = msg.rotating_variable_b as i16;
self.wheel_speed_bias[2] = msg.rotating_variable_c as i16;
}
22 => {
self.cos_sun_mag_align_thresh = f32::from_bits(msg.rotating_variable_a);
self.unload_ang_thresh = f32::from_bits(msg.rotating_variable_b);
self.q_sat = f32::from_bits(msg.rotating_variable_c);
}
23 => {
self.rwa_trq_max = f32::from_bits(msg.rotating_variable_a);
self.rws_motor_current[0] = msg.rotating_variable_b as u16;
self.rws_motor_current[1] = msg.rotating_variable_b.wrapping_shr(16) as u16;
self.rws_motor_current[2] = msg.rotating_variable_c as u16;
self.rws_motor_temp = msg.rotating_variable_c.wrapping_shr(16) as i16;
}
_ => {}
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct KeplerElem {
pub semi_major_axis: f32,
pub eccentricity: f32,
pub inclination: f32,
pub raan: f32,
pub arg_parigee: f32,
pub true_anomoly: f32,
}