output format fixes

This commit is contained in:
Robin Müller 2023-02-08 22:55:22 +01:00
parent aadd6f59b5
commit 1d73bcce00
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -528,44 +528,45 @@ def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes):
return
current_idx = 0
fmt_str = "!fff"
vec_fmt = "[{:8.3f}, {:8.3f}, {:8.3f}]"
inc_len = struct.calcsize(fmt_str)
mgm_0 = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_0_str = [f"{val:8.3f}" for val in mgm_0]
pw.dlog(f"MGM 0 Vec: {mgm_0_str}")
mgm_0_str = vec_fmt.format(*mgm_0)
pw.dlog(f"{'MGM 0 Vec'.ljust(25)}: {mgm_0_str}")
current_idx += inc_len
mgm_1 = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_1_str = [f"{val:8.3f}" for val in mgm_1]
pw.dlog(f"MGM 1 Vec: {mgm_1_str}")
mgm_1_str = vec_fmt.format(*mgm_1)
pw.dlog(f"{'MGM 1 Vec'.ljust(25)}: {mgm_1_str}")
current_idx += inc_len
mgm_2 = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_2_str = [f"{val:8.3f}" for val in mgm_2]
pw.dlog(f"MGM 2 Vec: {mgm_2_str}")
mgm_2_str = vec_fmt.format(*mgm_2)
pw.dlog(f"{'MGM 2 Vec'.ljust(25)}: {mgm_2_str}")
current_idx += inc_len
mgm_3 = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_3_str = [f"{val:8.3f}" for val in mgm_3]
pw.dlog(f"MGM 3 Vec: {mgm_3_str}")
mgm_3_str = vec_fmt.format(*mgm_3)
pw.dlog(f"{'MGM 3 Vec'.ljust(25)}: {mgm_3_str}")
current_idx += inc_len
mgm_4 = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_4_str = [f"{val:8.3f}" for val in mgm_4]
pw.dlog(f"MGM 4 Vec: {mgm_4_str}")
mgm_4_str = vec_fmt.format(*mgm_4)
pw.dlog(f"{'MGM 4 Vec'.ljust(25)}: {mgm_4_str}")
current_idx += inc_len
fmt_str = "!ddd"
inc_len = struct.calcsize(fmt_str)
mgm_vec_tot = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
mgm_vec_tot = [f"{val:8.3f}" for val in mgm_vec_tot]
mgm_vec_tot = vec_fmt.format(*mgm_vec_tot)
current_idx += inc_len
pw.dlog(f"MGM Total Vec: {mgm_vec_tot}")
pw.dlog(f"{'MGM Total Vec'.ljust(25)}: {mgm_vec_tot}")
mgm_vec_tot_deriv = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
mgm_vec_tot_deriv = [f"{val:8.3f}" for val in mgm_vec_tot_deriv]
pw.dlog(f"MGM Total Vec Deriv: {mgm_vec_tot_deriv}")
mgm_vec_tot_deriv = vec_fmt.format(*mgm_vec_tot_deriv)
pw.dlog(f"{'MGM Total Vec Deriv'.ljust(25)}: {mgm_vec_tot_deriv}")
current_idx += inc_len
mag_igrf_model = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
mag_igrf_model = [f"{val:8.3f}" for val in mag_igrf_model]
pw.dlog(f"MAG IGRF Model: {mag_igrf_model}")
mag_igrf_model = vec_fmt.format(*mag_igrf_model)
pw.dlog(f"{'MAG IGRF Model'.ljust(25)}: {mag_igrf_model}")
current_idx += inc_len
if PERFORM_MGM_CALIBRATION:
perform_mgm_calibration(pw, mgm_3)
@ -679,6 +680,8 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes):
def handle_mekf_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog("Received MEKF Set")
fmt_quat = "!dddd"
fmt_str_4 = "[{:8.3f}, {:8.3f}, {:8.3f}, {:8.3f}]"
fmt_str_3 = "[{:8.3f}, {:8.3f}, {:8.3f}]"
fmt_vec = "!ddd"
inc_len_quat = struct.calcsize(fmt_quat)
inc_len_vec = struct.calcsize(fmt_vec)
@ -686,22 +689,12 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog("Received HK set too small")
return
current_idx = 0
quat = [
f"{val:8.3f}"
for val in struct.unpack(
fmt_quat, hk_data[current_idx : current_idx + inc_len_quat]
)
]
quat = struct.unpack(fmt_quat, hk_data[current_idx : current_idx + inc_len_quat])
current_idx += inc_len_quat
rate = [
f"{val:8.3f}"
for val in struct.unpack(
fmt_vec, hk_data[current_idx : current_idx + inc_len_vec]
)
]
rate = struct.unpack(fmt_vec, hk_data[current_idx : current_idx + inc_len_vec])
current_idx += inc_len_vec
pw.dlog(f"MEKF Quaternion: {quat}")
pw.dlog(f"MEKF Rotational Rate: {rate}")
pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}")
pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rate)}")
pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=2)