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_rear_controller_test_data
 
 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_state
 
 system_can_message_telemetry_telemetry
 
 system_can_message_front_controller_front_controller_pedal_data
 

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_test_data

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

◆ system_can_message_steering_steering_state

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

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