Receive hydraulic pressure from ABX

This commit is contained in:
Jasper Blanckenburg 2023-08-02 00:11:17 +02:00
parent be193e804e
commit 4ba8236c0e
4 changed files with 19 additions and 6 deletions

View File

@ -156,6 +156,8 @@ typedef struct {
float brake_press_f;
float brake_press_r;
float hyd_press_a;
float hyd_press_b;
float distance_total;

View File

@ -21,6 +21,7 @@
#define CAN_ID_ABX_BRAKE_T 0x105
#define CAN_ID_CS_INTERNAL 0x108
#define CAN_ID_ABX_MISC 0x109
#define CAN_ID_ABX_HYDRAULICS 0x110
#define CAN_ID_EPSC_OUT 0x321
#define CAN_ID_MISSION_SELECTED 0x400
#define CAN_ID_STW_BUTTONS 0x401
@ -37,6 +38,7 @@
#define CAN_JETSON_TX_ANGLE_FACTOR 0.00784314f
#define CAN_JETSON_TX_SPEED_FACTOR (0.2 * 3.6)
#define CAN_ABX_DRIVER_SPEED_FACTOR (0.2 * 3.6)
#define CAN_ABX_DRIVER_PRESS_FACTOR 0.1f
#define CAN_CS_INTERNAL_TEMP_FACTOR 0.01
#define CAN_ABX_MISC_DISTANCE_TOTAL_FACTOR 0.01
#define CAN_ABX_MISC_LV_BAT_VOLTAGE_FACTOR (15.0f / 255)
@ -56,6 +58,7 @@ void vehicle_thread_entry(ULONG hfdcan_addr) {
ftcan_add_filter(CAN_ID_ABX_BRAKE_T, 0x7FF);
ftcan_add_filter(CAN_ID_CS_INTERNAL, 0x7FF);
ftcan_add_filter(CAN_ID_ABX_MISC, 0x7FF);
ftcan_add_filter(CAN_ID_ABX_HYDRAULICS, 0x7FF);
ftcan_add_filter(CAN_ID_EPSC_OUT, 0x7FF);
ftcan_add_filter(CAN_ID_AS_MISSION_FB, 0x7FF);
ftcan_add_filter(CAN_ID_STW_STATUS, 0x7FF);
@ -130,10 +133,18 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
((int8_t)data[2]) * CAN_JETSON_TX_ANGLE_FACTOR;
break;
case CAN_ID_ABX_DRIVER:
vehicle_state.brake_press_f = (data[1] | ((data[2] & 0x0F) << 8)) * 0.1;
vehicle_state.brake_press_r = ((data[2] >> 4) | (data[3] << 4)) * 0.1;
vehicle_state.brake_press_f =
(data[1] | ((data[2] & 0x0F) << 8)) * CAN_ABX_DRIVER_PRESS_FACTOR;
vehicle_state.brake_press_r =
((data[2] >> 4) | (data[3] << 4)) * CAN_ABX_DRIVER_PRESS_FACTOR;
vehicle_state.speed = data[5] * CAN_ABX_DRIVER_SPEED_FACTOR;
break;
case CAN_ID_ABX_HYDRAULICS:
vehicle_state.hyd_press_a =
(data[0] | ((data[1] & 0x0F) << 8)) * CAN_ABX_DRIVER_PRESS_FACTOR;
vehicle_state.hyd_press_b =
((data[1] >> 4) | (data[2] << 4)) * CAN_ABX_DRIVER_PRESS_FACTOR;
break;
case CAN_ID_ABX_TIMINGS:
vehicle_state.lap_best = (data[0] | (data[1] << 8)) * 0.01f;
vehicle_state.lap_last = (data[2] | (data[3] << 8)) * 0.01f;

View File

@ -16,6 +16,7 @@ void AMIPresenter::deactivate() {}
void AMIPresenter::vehicleStateUpdated() {
view.setMission(vehicle_state.active_mission);
view.setASState(vehicle_state.as_state);
view.setIniChkState(vehicle_state.ini_chk_state);
view.updateDataFields();
#ifndef SIMULATOR
view.setJetsonTimeout(HAL_GetTick() - vehicle_state.last_jetson_msg > 500);

View File

@ -88,7 +88,7 @@ void AMIView::setIniChkState(IniChkState state) {
}
progressBar.invalidate();
const char *label;
const char *label = "UNKNOWN";
switch (vehicle_state.ini_chk_state) {
case INICHK_START:
label = "START";
@ -128,9 +128,8 @@ void AMIView::setIniChkState(IniChkState state) {
}
void AMIView::updateDataFields() {
// TODO: Accumulator pressures aren't transmitted yet
paField.setValue(0);
pbField.setValue(0);
paField.setValue(vehicle_state.hyd_press_a);
pbField.setValue(vehicle_state.hyd_press_b);
pfField.setValue(vehicle_state.brake_press_f);
prField.setValue(vehicle_state.brake_press_r);