Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions components/CAN/CAN_Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#define VCU_FRONT_WHEEL_LEFT 2028
#define VCU_FRONT_WHEEL_RIGHT 2029
#define PACKINFO 1057
#define VCU_PITOT_TUBE 2030

inline CAN_Signal HSD1_ID2012{true, 0, 8};
inline CAN_Signal HSD2_ID2012{true, 8, 8};
Expand Down Expand Up @@ -291,6 +292,9 @@ inline CAN_Signal MinTemp_ID1057{true, 0, 16, 0.1f};
inline CAN_Signal MaxTemp_ID1057{true, 16, 16, 0.1f};
inline CAN_Signal MinCellVoltage_ID1057{true, 32, 16, 0.001f};
inline CAN_Signal MaxCellVoltage_ID1057{true, 48, 16, 0.001f};
inline CAN_Signal Pitot_Voltage_ID2030{true, 0, 16, 0.01f};
inline CAN_Signal Pitot_Pressure_ID2030{true, 16, 16, 0.01f};
inline CAN_Signal Pitot_Speed_ID2030{true, 32, 16, 0.01f};

// Define the CAN Map
inline etl::map CAN_Map
Expand Down Expand Up @@ -622,17 +626,22 @@ inline etl::map CAN_Map
etl::pair{VCU_FRONT_WHEEL_RIGHT, etl::vector<CAN_Signal*, 16>{
&Front_Right_Ticker_ID2029
} },
etl::pair{PACKINFO, etl::vector<CAN_Signal*, 16>{
etl::pair{PACKINFO, etl::vector<CAN_Signal*, 16>{
&MinTemp_ID1057,
&MaxTemp_ID1057,
&MinCellVoltage_ID1057,
&MaxCellVoltage_ID1057
&MaxCellVoltage_ID1057
} },
etl::pair{VCU_PITOT_TUBE, etl::vector<CAN_Signal*, 16>{
&Pitot_Voltage_ID2030,
&Pitot_Pressure_ID2030,
&Pitot_Speed_ID2030
} }
};
inline etl::set CAN_Rx_IDs = {PACKINFO, 2023, 2022, 173, 172, 194, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 174, 175, 514, 176, 1712, 1713, 1714, 406451072, 406451073, 406451074, 406451075, 406451076, 177, 1000, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 403105268, 419385573, 1001, 1002, 1003, 1004, 1005, 2012};

inline etl::set CAN_Tx_10ms_IDs = {M192_COMMAND_MESSAGE};
inline etl::set CAN_Tx_100ms_IDs = {VCU_WHEELSPEED_INFO, VCU_FRONT_IMU_1, VCU_FRONT_IMU_2, BMS_CURRENT_LIMIT, VCU_STATE_INFO, VCU_FRONT_SENSORS_1, VCU_FRONT_SENSORS_2, VCU_FRONT_SENSORS_3, VCU_FRONT_SENSORS_4, VCU_PDM_REAR_CMD, VCU_FRONT_WHEEL_LEFT, VCU_FRONT_WHEEL_RIGHT};
inline etl::set CAN_Tx_100ms_IDs = {VCU_WHEELSPEED_INFO, VCU_FRONT_IMU_1, VCU_FRONT_IMU_2, BMS_CURRENT_LIMIT, VCU_STATE_INFO, VCU_FRONT_SENSORS_1, VCU_FRONT_SENSORS_2, VCU_FRONT_SENSORS_3, VCU_FRONT_SENSORS_4, VCU_PDM_REAR_CMD, VCU_FRONT_WHEEL_LEFT, VCU_FRONT_WHEEL_RIGHT, VCU_PITOT_TUBE};
inline etl::set CAN_Tx_1000ms_IDs = {192};
;
// they don't like to be empty
Expand Down
10 changes: 10 additions & 0 deletions components/Sensors/Sensors.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Sensors.h"
#include "esp_log.h"
#include <cmath>
static const char *TAG = "Sensors"; // Used for ESP_LOGx commands. See ESP-IDF Documentation

Sensors *Sensors::instancePtr = nullptr;
Expand Down Expand Up @@ -47,6 +48,15 @@ void Sensors::poll_sensors()
A12_ID2016.set(Sensors::Get()->get_sensor_voltage(static_cast<Sensors::SENSOR_INDEX>(11)));
A13_ID2017.set(Sensors::Get()->get_sensor_voltage(static_cast<Sensors::SENSOR_INDEX>(12)));
A14_ID2017.set(Sensors::Get()->get_sensor_voltage(static_cast<Sensors::SENSOR_INDEX>(13)));
float pitot_voltage = Sensors::Get()->get_sensor_voltage(Sensors::PITOT);
float pitot_pressure_mbar = (pitot_voltage - 0.5f) * 6.25f + 50.0f;
float pitot_dynamic_mbar = pitot_pressure_mbar - 50.0f;
float pitot_speed_kph = (pitot_dynamic_mbar > 0.0f) ? sqrtf(2.0f * pitot_dynamic_mbar * 100.0f / 1.225f) * 3.6f : 0.0f;
printf(">Pitot_Pressure:%.2f\n", pitot_pressure_mbar);
printf(">Pitot_Speed:%.2f\n", pitot_speed_kph);
Pitot_Voltage_ID2030.set(pitot_voltage);
Pitot_Pressure_ID2030.set(pitot_pressure_mbar);
Pitot_Speed_ID2030.set(pitot_speed_kph);
}

etl::array<float,14> Sensors::get_sensor_voltages(){
Expand Down
1 change: 1 addition & 0 deletions components/Sensors/Sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Sensors{
APPS2 = ECU_17_A14,
BPS1 = ECU_3_A3,
BPS2 = ECU_4_A4,
PITOT = ECU_5_A5,
}SENSOR_INDEX;
//Deleting the copy constructor and copy reference constructor to prevent copies
Sensors(const Sensors &) = delete;
Expand Down
Loading