+rad2deg -opIds +setInterval

This commit is contained in:
Marius Eggert 2023-03-07 11:07:01 +01:00
parent 94ae2d16e2
commit 2e21087c6d

View File

@ -2,6 +2,7 @@ import enum
import logging
import socket
import struct
import math
from socket import AF_INET
from typing import Tuple
@ -85,36 +86,36 @@ class OpCodes:
SET_PARAMETER_SCALAR = ["set_scalar_param"]
SET_PARAMETER_VECTOR = ["set_vector_param"]
SET_PARAMETER_MATRIX = ["set_matrix_param"]
REQUEST_RAW_MGM_HK = ["0", "mgm_raw_hk"]
ENABLE_RAW_MGM_HK = ["1", "mgm_raw_enable_hk"]
DISABLE_RAW_MGM_HK = ["2", "mgm_raw_disable_hk"]
REQUEST_PROC_MGM_HK = ["3", "mgm_proc_hk"]
ENABLE_PROC_MGM_HK = ["4", "mgm_proc_enable_hk"]
DISABLE_PROC_MGM_HK = ["5", "mgm_proc_disable_hk"]
REQUEST_RAW_SUS_HK = ["6", "sus_raw_hk"]
ENABLE_RAW_SUS_HK = ["7", "sus_raw_enable_hk"]
DISABLE_RAW_SUS_HK = ["8", "sus_raw_disable_hk"]
REQUEST_PROC_SUS_HK = ["9", "sus_proc_hk"]
ENABLE_PROC_SUS_HK = ["10", "sus_proc_enable_hk"]
DISABLE_PROC_SUS_HK = ["11", "sus_proc_disable_hk"]
REQUEST_RAW_GYR_HK = ["12", "gyr_raw_hk"]
ENABLE_RAW_GYR_HK = ["13", "gyr_raw_enable_hk"]
DISABLE_RAW_GYR_HK = ["14", "gyr_raw_disable_hk"]
REQUEST_PROC_GYR_HK = ["15", "gyr_proc_hk"]
ENABLE_PROC_GYR_HK = ["16", "gyr_proc_enable_hk"]
DISABLE_PROC_GYR_HK = ["17", "gyr_proc_disable_hk"]
REQUEST_PROC_GPS_HK = ["18", "gps_proc_hk"]
ENABLE_PROC_GPS_HK = ["19", "gps_proc_enable_hk"]
DISABLE_PROC_GPS_HK = ["20", "gps_proc_disable_hk"]
REQUEST_MEKF_HK = ["21", "mekf_hk"]
ENABLE_MEKF_HK = ["22", "mekf_enable_hk"]
DISABLE_MEKF_HK = ["23", "mekf_disable_hk"]
REQUEST_CTRL_VAL_HK = ["24", "ctrl_val_hk"]
ENABLE_CTRL_VAL_HK = ["25", "ctrl_val_enable_hk"]
DISABLE_CTRL_VAL_HK = ["26", "ctrl_val_disable_hk"]
REQUEST_ACT_CMD_HK = ["27", "act_cmd_hk"]
ENABLE_ACT_CMD_HK = ["28", "act_cmd_enable_hk"]
DISABLE_ACT_CMD_HK = ["29", "act_cmd_disable_hk"]
REQUEST_RAW_MGM_HK = ["mgm_raw_hk"]
ENABLE_RAW_MGM_HK = ["mgm_raw_enable_hk"]
DISABLE_RAW_MGM_HK = ["mgm_raw_disable_hk"]
REQUEST_PROC_MGM_HK = ["mgm_proc_hk"]
ENABLE_PROC_MGM_HK = ["mgm_proc_enable_hk"]
DISABLE_PROC_MGM_HK = ["mgm_proc_disable_hk"]
REQUEST_RAW_SUS_HK = ["sus_raw_hk"]
ENABLE_RAW_SUS_HK = ["sus_raw_enable_hk"]
DISABLE_RAW_SUS_HK = ["sus_raw_disable_hk"]
REQUEST_PROC_SUS_HK = ["sus_proc_hk"]
ENABLE_PROC_SUS_HK = ["sus_proc_enable_hk"]
DISABLE_PROC_SUS_HK = ["sus_proc_disable_hk"]
REQUEST_RAW_GYR_HK = ["gyr_raw_hk"]
ENABLE_RAW_GYR_HK = ["gyr_raw_enable_hk"]
DISABLE_RAW_GYR_HK = ["gyr_raw_disable_hk"]
REQUEST_PROC_GYR_HK = ["gyr_proc_hk"]
ENABLE_PROC_GYR_HK = ["gyr_proc_enable_hk"]
DISABLE_PROC_GYR_HK = ["gyr_proc_disable_hk"]
REQUEST_PROC_GPS_HK = ["gps_proc_hk"]
ENABLE_PROC_GPS_HK = ["gps_proc_enable_hk"]
DISABLE_PROC_GPS_HK = ["gps_proc_disable_hk"]
REQUEST_MEKF_HK = ["mekf_hk"]
ENABLE_MEKF_HK = ["mekf_enable_hk"]
DISABLE_MEKF_HK = ["mekf_disable_hk"]
REQUEST_CTRL_VAL_HK = ["ctrl_val_hk"]
ENABLE_CTRL_VAL_HK = ["ctrl_val_enable_hk"]
DISABLE_CTRL_VAL_HK = ["ctrl_val_disable_hk"]
REQUEST_ACT_CMD_HK = ["act_cmd_hk"]
ENABLE_ACT_CMD_HK = ["act_cmd_enable_hk"]
DISABLE_ACT_CMD_HK = ["act_cmd_disable_hk"]
class Info:
@ -283,9 +284,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET))
)
elif op_code in OpCodes.ENABLE_RAW_MGM_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_RAW_MGM_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET), 2.0
False, make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -302,9 +304,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET))
)
elif op_code in OpCodes.ENABLE_PROC_MGM_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_PROC_MGM_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET), 2.0
False, make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -321,9 +324,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET))
)
elif op_code in OpCodes.ENABLE_RAW_SUS_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_RAW_SUS_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET), 2.0
False, make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -340,9 +344,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET))
)
elif op_code in OpCodes.ENABLE_PROC_SUS_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_PROC_SUS_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET), 2.0
False, make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -359,9 +364,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET))
)
elif op_code in OpCodes.ENABLE_RAW_GYR_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_RAW_GYR_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
True, make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET), 2.0
True, make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -380,9 +386,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
)
)
elif op_code in OpCodes.ENABLE_PROC_GYR_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_PROC_GYR_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET), 2.0
True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -399,9 +406,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET))
)
elif op_code in OpCodes.ENABLE_PROC_GPS_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_PROC_GPS_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET), 2.0
False, make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -418,9 +426,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.MEKF_DATA))
)
elif op_code in OpCodes.ENABLE_MEKF_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_MEKF_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
True, make_sid(ACS_CONTROLLER, SetId.MEKF_DATA), 2.0
True, make_sid(ACS_CONTROLLER, SetId.MEKF_DATA), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -435,9 +444,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA))
)
elif op_code in OpCodes.ENABLE_CTRL_VAL_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_CTRL_VAL_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA), 2.0
False, make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -454,9 +464,10 @@ def pack_acs_ctrl_command(p: ServiceProviderParams):
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA))
)
elif op_code in OpCodes.ENABLE_ACT_CMD_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_ACT_CMD_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA), 2.0
False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
@ -890,7 +901,7 @@ def handle_gyr_data_processed(pw: PrintWrapper, hk_data: bytes):
current_idx = 0
for i in range(4):
gyr_vec = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
@ -898,7 +909,7 @@ def handle_gyr_data_processed(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"{GYR_NAMES[i]}: {gyr_vec}")
current_idx += inc_len
gyr_vec_tot = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
]
pw.dlog(f"GYR Vec Total: {gyr_vec_tot}")
@ -917,19 +928,26 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes):
return
current_idx = 0
lat = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_scalar, hk_data[current_idx : current_idx + inc_len_scalar]
)
]
current_idx += inc_len_scalar
long = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_scalar, hk_data[current_idx : current_idx + inc_len_scalar]
)
]
current_idx += inc_len_scalar
alt = [
f"{val:8.3f}"
for val in struct.unpack(
fmt_scalar, hk_data[current_idx: current_idx + inc_len_scalar]
)
]
current_idx += inc_len_scalar
pos = [
f"{val:8.3f}"
for val in struct.unpack(
@ -944,8 +962,9 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes):
)
]
current_idx += inc_len_vec
pw.dlog(f"GPS Latitude: {lat} [rad]")
pw.dlog(f"GPS Longitude: {long} [rad]")
pw.dlog(f"GPS Latitude: {lat} [deg]")
pw.dlog(f"GPS Longitude: {long} [deg]")
pw.dlog(f"GPS Altitude: {alt} [m]")
pw.dlog(f"GPS Position: {pos} [m]")
pw.dlog(f"GPS Velocity: {velo} [m/s]")
pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=4)
@ -976,7 +995,7 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes):
current_idx = 0
quat = struct.unpack(fmt_quat, hk_data[current_idx : current_idx + inc_len_quat])
current_idx += inc_len_quat
rate = 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])*180/math.pi
current_idx += inc_len_vec
status = struct.unpack(fmt_sts, hk_data[current_idx : current_idx + inc_len_sts])[0]
current_idx += inc_len_sts
@ -1013,14 +1032,14 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes):
]
current_idx += inc_len_quat
err_ang = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_scalar, hk_data[current_idx : current_idx + inc_len_scalar]
)
]
current_idx += inc_len_scalar
tgt_rot = [
f"{val:8.3f}"
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_vec, hk_data[current_idx : current_idx + inc_len_vec]
)
@ -1028,8 +1047,8 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes):
current_idx += inc_len_vec
pw.dlog(f"Control Values Target Quaternion: {tgt_quat}")
pw.dlog(f"Control Values Error Quaternion: {err_quat}")
pw.dlog(f"Control Values Error Angle: {err_ang} [rad]")
pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [rad/s]")
pw.dlog(f"Control Values Error Angle: {err_ang} [deg]")
pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [deg/s]")
pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=4)