Midnight Sun Firmware
Loading...
Searching...
No Matches
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_front_controller_front_controller_pedal_data
 
 system_can_message_rear_controller_rear_controller_status
 
 system_can_message_rear_controller_battery_stats_a
 
 system_can_message_rear_controller_battery_stats_b
 
 system_can_message_rear_controller_power_input_stats
 
 system_can_message_rear_controller_afe1_status_a
 
 system_can_message_rear_controller_afe1_status_b
 
 system_can_message_rear_controller_afe2_status_a
 
 system_can_message_rear_controller_afe2_status_b
 
 system_can_message_rear_controller_afe_temperature
 
 system_can_message_imu_gyro_data
 
 system_can_message_imu_accel_data
 
 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_steering_steering_buttons
 
 system_can_message_steering_steering_target_velocity
 

Detailed Description

Main simulation script.

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

Variable Documentation

◆ 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_front_controller_front_controller_pedal_data

system_can_message_front_controller_front_controller_pedal_data
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_FRONT_CONTROLLER_FRONT_CONTROLLER_PEDAL_DATA_ID,
3data = bytearray(pack(can_data_cache.get("front_controller_front_controller_pedal_data", "percentage"), 32) + pack(can_data_cache.get("front_controller_front_controller_pedal_data", "brake_enabled"), 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_rear_controller_afe1_status_a

system_can_message_rear_controller_afe1_status_a
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_AFE1_STATUS_A_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_afe1_status_a", "id"), 8) + pack(can_data_cache.get("rear_controller_afe1_status_a", "voltage_0"), 16) + pack(can_data_cache.get("rear_controller_afe1_status_a", "voltage_1"), 16) + pack(can_data_cache.get("rear_controller_afe1_status_a", "voltage_2"), 16)))

◆ system_can_message_rear_controller_afe1_status_b

system_can_message_rear_controller_afe1_status_b
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_AFE1_STATUS_B_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_afe1_status_b", "id"), 8) + pack(can_data_cache.get("rear_controller_afe1_status_b", "voltage_0"), 16) + pack(can_data_cache.get("rear_controller_afe1_status_b", "voltage_1"), 16) + pack(can_data_cache.get("rear_controller_afe1_status_b", "voltage_2"), 16)))

◆ system_can_message_rear_controller_afe2_status_a

system_can_message_rear_controller_afe2_status_a
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_AFE2_STATUS_A_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_afe2_status_a", "id"), 8) + pack(can_data_cache.get("rear_controller_afe2_status_a", "voltage_0"), 16) + pack(can_data_cache.get("rear_controller_afe2_status_a", "voltage_1"), 16) + pack(can_data_cache.get("rear_controller_afe2_status_a", "voltage_2"), 16)))

◆ system_can_message_rear_controller_afe2_status_b

system_can_message_rear_controller_afe2_status_b
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_AFE2_STATUS_B_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_afe2_status_b", "id"), 8) + pack(can_data_cache.get("rear_controller_afe2_status_b", "voltage_0"), 16) + pack(can_data_cache.get("rear_controller_afe2_status_b", "voltage_1"), 16) + pack(can_data_cache.get("rear_controller_afe2_status_b", "voltage_2"), 16)))

◆ system_can_message_rear_controller_afe_temperature

system_can_message_rear_controller_afe_temperature
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_AFE_TEMPERATURE_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_afe_temperature", "id"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_0"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_1"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_2"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_3"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_4"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_5"), 8) + pack(can_data_cache.get("rear_controller_afe_temperature", "temperature_6"), 8)))

◆ system_can_message_rear_controller_battery_stats_a

system_can_message_rear_controller_battery_stats_a
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_BATTERY_STATS_A_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_battery_stats_a", "pack_voltage"), 16) + pack(can_data_cache.get("rear_controller_battery_stats_a", "pack_current"), 16) + pack(can_data_cache.get("rear_controller_battery_stats_a", "pack_soc"), 16)))

◆ system_can_message_rear_controller_battery_stats_b

system_can_message_rear_controller_battery_stats_b
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_BATTERY_STATS_B_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_battery_stats_b", "max_cell_voltage"), 16) + pack(can_data_cache.get("rear_controller_battery_stats_b", "min_cell_voltage"), 16) + pack(can_data_cache.get("rear_controller_battery_stats_b", "max_temperature"), 16) + pack(can_data_cache.get("rear_controller_battery_stats_b", "motor_precharge_complete"), 8)))

◆ system_can_message_rear_controller_power_input_stats

system_can_message_rear_controller_power_input_stats
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_POWER_INPUT_STATS_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_power_input_stats", "input_dcdc_voltage"), 16) + pack(can_data_cache.get("rear_controller_power_input_stats", "input_dcdc_current"), 16) + pack(can_data_cache.get("rear_controller_power_input_stats", "input_aux_voltage"), 16) + pack(can_data_cache.get("rear_controller_power_input_stats", "input_aux_current"), 16)))

◆ system_can_message_rear_controller_rear_controller_status

system_can_message_rear_controller_rear_controller_status
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_REAR_CONTROLLER_REAR_CONTROLLER_STATUS_ID,
3data = bytearray(pack(can_data_cache.get("rear_controller_rear_controller_status", "bps_fault"), 16) + pack(can_data_cache.get("rear_controller_rear_controller_status", "relay_state"), 8) + pack(can_data_cache.get("rear_controller_rear_controller_status", "power_state"), 8) + pack(can_data_cache.get("rear_controller_rear_controller_status", "afe_status"), 8)))

◆ system_can_message_steering_steering_buttons

system_can_message_steering_steering_buttons
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_STEERING_STEERING_BUTTONS_ID,
3data = bytearray(pack(can_data_cache.get("steering_steering_buttons", "drive_state"), 8) + pack(can_data_cache.get("steering_steering_buttons", "cruise_control"), 8) + pack(can_data_cache.get("steering_steering_buttons", "regen_braking"), 8) + pack(can_data_cache.get("steering_steering_buttons", "hazard_enabled"), 8) + pack(can_data_cache.get("steering_steering_buttons", "horn_enabled"), 8)))

◆ system_can_message_steering_steering_target_velocity

system_can_message_steering_steering_target_velocity
Initial value:
1= Message(
2arbitration_id = SystemCanMessageId.SYSTEM_CAN_MESSAGE_STEERING_STEERING_TARGET_VELOCITY_ID,
3data = bytearray(pack(can_data_cache.get("steering_steering_target_velocity", "target_velocity"), 32)))

◆ 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", "telemetry_data"), 64)))