Midnight Sun Firmware
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
can_simulator.py File Reference

Main simulation script. More...

Functions

def pack (num, size)
 
def periodic_sender (bus, messages, period, stop_event)
 
def main ()
 

Variables

float RETRY_TRANSMIT_S = 0.05
 
float FAST_CYCLE_PERIOD = 0.5
 
int MEDIUM_CYCLE_PERIOD = 5
 
int SLOW_CYCLE_PERIOD = 10
 
list messages_fast = []
 
list messages_medium = []
 
list messages_slow = []
 
 can_data_cache = CanSimulatorDataCache()
 
 system_can_message_telemetry_telemetry
 
 system_can_message_can_communication_fast_one_shot_msg
 
 system_can_message_can_communication_medium_one_shot_msg
 
 system_can_message_can_communication_slow_one_shot_msg
 
 system_can_message_imu_gyro_data
 
 system_can_message_imu_accel_data
 
 system_can_message_bms_carrier_battery_status
 
 system_can_message_bms_carrier_battery_vt
 
 system_can_message_bms_carrier_battery_info
 
 system_can_message_bms_carrier_mc_status
 
 system_can_message_bms_carrier_motor_controller_vc
 
 system_can_message_bms_carrier_motor_velocity
 
 system_can_message_bms_carrier_motor_sink_temps
 
 system_can_message_bms_carrier_dsp_board_temps
 
 system_can_message_bms_carrier_battery_relay_info
 
 system_can_message_bms_carrier_afe1_status
 
 system_can_message_bms_carrier_afe2_status
 
 system_can_message_bms_carrier_afe3_status
 
 system_can_message_centre_console_cc_pedal
 
 system_can_message_centre_console_cc_info
 
 system_can_message_centre_console_cc_steering
 
 system_can_message_centre_console_cc_regen_percentage
 

Detailed Description

Main simulation script.

Date
2025-03-09
Author
Midnight Sun Team #24 - MSXVI

Variable Documentation

◆ system_can_message_bms_carrier_afe1_status

system_can_message_bms_carrier_afe1_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_AFE1_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_afe1_status", "id"), 8) + pack(can_data_cache.get("bms_carrier_afe1_status", "temp"), 8) + pack(can_data_cache.get("bms_carrier_afe1_status", "v1"), 16) + pack(can_data_cache.get("bms_carrier_afe1_status", "v2"), 16) + pack(can_data_cache.get("bms_carrier_afe1_status", "v3"), 16)))

◆ system_can_message_bms_carrier_afe2_status

system_can_message_bms_carrier_afe2_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_AFE2_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_afe2_status", "id"), 8) + pack(can_data_cache.get("bms_carrier_afe2_status", "temp"), 8) + pack(can_data_cache.get("bms_carrier_afe2_status", "v1"), 16) + pack(can_data_cache.get("bms_carrier_afe2_status", "v2"), 16) + pack(can_data_cache.get("bms_carrier_afe2_status", "v3"), 16)))

◆ system_can_message_bms_carrier_afe3_status

system_can_message_bms_carrier_afe3_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_AFE3_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_afe3_status", "id"), 8) + pack(can_data_cache.get("bms_carrier_afe3_status", "temp"), 8) + pack(can_data_cache.get("bms_carrier_afe3_status", "v1"), 16) + pack(can_data_cache.get("bms_carrier_afe3_status", "v2"), 16) + pack(can_data_cache.get("bms_carrier_afe3_status", "v3"), 16)))

◆ system_can_message_bms_carrier_battery_info

system_can_message_bms_carrier_battery_info
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_BATTERY_INFO_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_battery_info", "fan1"), 8) + pack(can_data_cache.get("bms_carrier_battery_info", "fan2"), 8) + pack(can_data_cache.get("bms_carrier_battery_info", "max_cell_v"), 16) + pack(can_data_cache.get("bms_carrier_battery_info", "min_cell_v"), 16)))

◆ system_can_message_bms_carrier_battery_relay_info

system_can_message_bms_carrier_battery_relay_info
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_BATTERY_RELAY_INFO_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_battery_relay_info", "state"), 8)))

◆ system_can_message_bms_carrier_battery_status

system_can_message_bms_carrier_battery_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_BATTERY_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_battery_status", "fault"), 16) + pack(can_data_cache.get("bms_carrier_battery_status", "fault_val"), 16) + pack(can_data_cache.get("bms_carrier_battery_status", "aux_batt_v"), 16) + pack(can_data_cache.get("bms_carrier_battery_status", "afe_status"), 8)))

◆ system_can_message_bms_carrier_battery_vt

system_can_message_bms_carrier_battery_vt
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_BATTERY_VT_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_battery_vt", "voltage"), 16) + pack(can_data_cache.get("bms_carrier_battery_vt", "current"), 16) + pack(can_data_cache.get("bms_carrier_battery_vt", "temperature"), 16) + pack(can_data_cache.get("bms_carrier_battery_vt", "batt_perc"), 16)))

◆ system_can_message_bms_carrier_dsp_board_temps

system_can_message_bms_carrier_dsp_board_temps
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_DSP_BOARD_TEMPS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_dsp_board_temps", "dsp_temp_l"), 16) + pack(can_data_cache.get("bms_carrier_dsp_board_temps", "dsp_temp_r"), 16)))

◆ system_can_message_bms_carrier_mc_status

system_can_message_bms_carrier_mc_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_MC_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_mc_status", "limit_bitset_l"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "error_bitset_l"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "limit_bitset_r"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "error_bitset_r"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "board_fault_bitset"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "overtemp_bitset"), 8) + pack(can_data_cache.get("bms_carrier_mc_status", "precharge_status"), 8)))

◆ system_can_message_bms_carrier_motor_controller_vc

system_can_message_bms_carrier_motor_controller_vc
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_MOTOR_CONTROLLER_VC_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_motor_controller_vc", "mc_voltage_l"), 16) + pack(can_data_cache.get("bms_carrier_motor_controller_vc", "mc_current_l"), 16) + pack(can_data_cache.get("bms_carrier_motor_controller_vc", "mc_voltage_r"), 16) + pack(can_data_cache.get("bms_carrier_motor_controller_vc", "mc_current_r"), 16)))

◆ system_can_message_bms_carrier_motor_sink_temps

system_can_message_bms_carrier_motor_sink_temps
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_MOTOR_SINK_TEMPS_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_motor_sink_temps", "motor_temp_l"), 16) + pack(can_data_cache.get("bms_carrier_motor_sink_temps", "heatsink_temp_l"), 16) + pack(can_data_cache.get("bms_carrier_motor_sink_temps", "motor_temp_r"), 16) + pack(can_data_cache.get("bms_carrier_motor_sink_temps", "heatsink_temp_r"), 16)))

◆ system_can_message_bms_carrier_motor_velocity

system_can_message_bms_carrier_motor_velocity
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_BMS_CARRIER_MOTOR_VELOCITY_ID,
3data = bytearray(pack(can_data_cache.get("bms_carrier_motor_velocity", "velocity_l"), 16) + pack(can_data_cache.get("bms_carrier_motor_velocity", "velocity_r"), 16) + pack(can_data_cache.get("bms_carrier_motor_velocity", "brakes_enabled"), 8)))

◆ system_can_message_can_communication_fast_one_shot_msg

system_can_message_can_communication_fast_one_shot_msg
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CAN_COMMUNICATION_FAST_ONE_SHOT_MSG_ID,
3data = bytearray(pack(can_data_cache.get("can_communication_fast_one_shot_msg", "sig1"), 16) + pack(can_data_cache.get("can_communication_fast_one_shot_msg", "sig2"), 16)))

◆ system_can_message_can_communication_medium_one_shot_msg

system_can_message_can_communication_medium_one_shot_msg
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CAN_COMMUNICATION_MEDIUM_ONE_SHOT_MSG_ID,
3data = bytearray(pack(can_data_cache.get("can_communication_medium_one_shot_msg", "sig1"), 16) + pack(can_data_cache.get("can_communication_medium_one_shot_msg", "sig2"), 16)))

◆ system_can_message_can_communication_slow_one_shot_msg

system_can_message_can_communication_slow_one_shot_msg
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CAN_COMMUNICATION_SLOW_ONE_SHOT_MSG_ID,
3data = bytearray(pack(can_data_cache.get("can_communication_slow_one_shot_msg", "sig1"), 16) + pack(can_data_cache.get("can_communication_slow_one_shot_msg", "sig2"), 16)))

◆ system_can_message_centre_console_cc_info

system_can_message_centre_console_cc_info
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CENTRE_CONSOLE_CC_INFO_ID,
3data = bytearray(pack(can_data_cache.get("centre_console_cc_info", "target_velocity"), 32) + pack(can_data_cache.get("centre_console_cc_info", "drive_state"), 8) + pack(can_data_cache.get("centre_console_cc_info", "cruise_control"), 8) + pack(can_data_cache.get("centre_console_cc_info", "regen_braking"), 8) + pack(can_data_cache.get("centre_console_cc_info", "hazard_enabled"), 8)))

◆ system_can_message_centre_console_cc_pedal

system_can_message_centre_console_cc_pedal
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CENTRE_CONSOLE_CC_PEDAL_ID,
3data = bytearray(pack(can_data_cache.get("centre_console_cc_pedal", "throttle_output"), 32) + pack(can_data_cache.get("centre_console_cc_pedal", "brake_output"), 8)))

◆ system_can_message_centre_console_cc_regen_percentage

system_can_message_centre_console_cc_regen_percentage
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CENTRE_CONSOLE_CC_REGEN_PERCENTAGE_ID,
3data = bytearray(pack(can_data_cache.get("centre_console_cc_regen_percentage", "percent"), 32)))

◆ system_can_message_centre_console_cc_steering

system_can_message_centre_console_cc_steering
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_CENTRE_CONSOLE_CC_STEERING_ID,
3data = bytearray(pack(can_data_cache.get("centre_console_cc_steering", "input_cc"), 8) + pack(can_data_cache.get("centre_console_cc_steering", "input_lights"), 8)))

◆ system_can_message_imu_accel_data

system_can_message_imu_accel_data
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_IMU_ACCEL_DATA_ID,
3data = bytearray(pack(can_data_cache.get("imu_accel_data", "x_axis"), 16) + pack(can_data_cache.get("imu_accel_data", "y_axis"), 16) + pack(can_data_cache.get("imu_accel_data", "z_axis"), 16)))

◆ system_can_message_imu_gyro_data

system_can_message_imu_gyro_data
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_IMU_GYRO_DATA_ID,
3data = bytearray(pack(can_data_cache.get("imu_gyro_data", "x_axis"), 16) + pack(can_data_cache.get("imu_gyro_data", "y_axis"), 16) + pack(can_data_cache.get("imu_gyro_data", "z_axis"), 16)))

◆ system_can_message_telemetry_telemetry

system_can_message_telemetry_telemetry
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_TELEMETRY_TELEMETRY_ID,
3data = bytearray(pack(can_data_cache.get("telemetry_telemetry", "data"), 64)))