233 lines
4.7 KiB
C
233 lines
4.7 KiB
C
#ifndef __INC_VEHICLE_STATE_H
|
|
#define __INC_VEHICLE_STATE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "params.h"
|
|
#include "stw_defines.h"
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
TS_INACTIVE = 0,
|
|
TS_ACTIVE = 1,
|
|
TS_PRECHARGE = 2,
|
|
TS_DISCHARGE = 3,
|
|
TS_ERROR = 4,
|
|
TS_CHARGING_CHECK = 5,
|
|
TS_CHARGING = 6,
|
|
} TSState;
|
|
|
|
typedef enum {
|
|
AS_OFF = 0,
|
|
AS_MANUAL = 1,
|
|
AS_READY = 2,
|
|
AS_DRIVING = 3,
|
|
AS_FINISHED = 4,
|
|
AS_EMERGENCY = 5,
|
|
} ASState;
|
|
|
|
typedef enum {
|
|
R2D_NONE = 0,
|
|
R2D_SDC_CLOSED = 1,
|
|
R2D_TSACTIVE = 2,
|
|
R2D_RESETTING_NODES = 3,
|
|
R2D_RESETTING_COMMS = 4,
|
|
R2D_WAITING_INIT = 5,
|
|
R2D_INIT_STAGE1 = 6,
|
|
R2D_INIT_STAGE2 = 7,
|
|
R2D_INIT_SUCCESS = 0xF,
|
|
} R2DProgress;
|
|
|
|
typedef enum {
|
|
SDC_OFF = 0,
|
|
SDC_PDU_OK = 1, //
|
|
SDC_RES_OK = 2,
|
|
SDC_AMS_OK = 3,
|
|
SDC_IMD_OK = 4,
|
|
SDC_BOTS_OK = 5,
|
|
SDC_SDB_DB_OK = 6, // shut down button dashboard
|
|
SDC_IS_OK = 7,
|
|
SDC_BSPD_OK = 8,
|
|
SDC_SDB_L_OK = 9,
|
|
SDC_SDB_R_OK = 10,
|
|
SDC_TSMS_OK = 11,
|
|
SDC_HVD_OK = 12,
|
|
} SDCStatus;
|
|
|
|
typedef enum {
|
|
INICHK_START = 0,
|
|
INICHK_WD_CHECK = 1,
|
|
INICHK_WD_OK = 2,
|
|
INICHK_ASB_CHECK_1 = 3,
|
|
INICHK_ASB_CHECK_2 = 4,
|
|
INICHK_WAIT_TS = 5,
|
|
INICHK_EBS_CHECK_A = 6,
|
|
INICHK_EBS_CHECK_B = 7,
|
|
INICHK_DONE = 8,
|
|
INICHK_ERROR = 9,
|
|
} InitialCheckupState;
|
|
|
|
const char *inichkstate_str(InitialCheckupState state);
|
|
|
|
typedef enum {
|
|
AMS_ERROR_NONE = 0x00,
|
|
AMS_ERROR_SLAVE_TIMEOUT = 0x01,
|
|
AMS_ERROR_SLAVE_PANIC = 0x02,
|
|
AMS_ERROR_SHUNT_TIMEOUT = 0x03,
|
|
AMS_ERROR_SHUNT_OVERCURRENT = 0x04,
|
|
AMS_ERROR_SHUNT_OVERTEMP = 0x05,
|
|
} AMSErrorKind;
|
|
typedef enum {
|
|
AMS_SLAVEPANIC_OVERTEMP = 0x00,
|
|
AMS_SLAVEPANIC_UNDERTEMP = 0x01,
|
|
AMS_SLAVEPANIC_OVERVOLTAGE = 0x02,
|
|
AMS_SLAVEPANIC_UNDERVOLTAGE = 0x03,
|
|
AMS_SLAVEPANIC_TOO_FEW_TEMP = 0x04,
|
|
AMS_SLAVEPANIC_OPENWIRE = 0x05,
|
|
} AMSSlavePanicKind;
|
|
|
|
typedef struct {
|
|
AMSErrorKind kind;
|
|
uint8_t arg;
|
|
} AMSError;
|
|
|
|
typedef struct {
|
|
float wss_fl; // in km/h
|
|
float wss_fr; // in km/h
|
|
float wss_rl; // in km/h
|
|
float wss_rr; // in km/h
|
|
} WheelSpeeds;
|
|
|
|
typedef struct {
|
|
float tire_fl;
|
|
float tire_fr;
|
|
float tire_rl;
|
|
float tire_rr;
|
|
|
|
float brake_fl;
|
|
float brake_fr;
|
|
float brake_rl;
|
|
float brake_rr;
|
|
|
|
float inv_1;
|
|
float inv_2;
|
|
float mot_1;
|
|
float mot_2;
|
|
} Temperatures;
|
|
|
|
typedef struct {
|
|
uint16_t x;
|
|
uint16_t y;
|
|
} ConePosition;
|
|
|
|
typedef struct {
|
|
// AMS / TS system
|
|
struct {
|
|
uint8_t id;
|
|
AMSSlavePanicKind kind;
|
|
uint32_t arg;
|
|
} last_ams_slave_panic;
|
|
TSState ts_state;
|
|
bool sdc_closed;
|
|
uint8_t soc_ts;
|
|
float min_cell_volt; // in V
|
|
float max_cell_temp; // in °C
|
|
bool imd_ok; // latest IMD measurement
|
|
bool tsal_green;
|
|
bool imd_error; // latched imd error
|
|
bool ams_error; // latched ams error
|
|
|
|
AMSError last_ams_error;
|
|
|
|
// dcdc temp not in temps because temps only contains temperatures with multiple instances
|
|
float dcdc_temp; // in °C
|
|
float dcdc_current; // in A
|
|
|
|
float ts_current; // in A
|
|
float ts_voltage_bat; // in V
|
|
float ts_voltage_veh; // in V
|
|
float shunt_temperature; // in °C
|
|
|
|
Temperatures temps;
|
|
|
|
float lap_time_best; // in s
|
|
float lap_time_last; // in s
|
|
float sector_time_best; // in s
|
|
float sector_time_last; // in s
|
|
|
|
WheelSpeeds wheel_speeds; // all in km/h
|
|
uint16_t distance_session; // in m
|
|
|
|
float tank_pressure_1;
|
|
float tank_pressure_2;
|
|
|
|
float lv_voltage;
|
|
float lv_soc;
|
|
|
|
uint8_t apps_percent;
|
|
float brake_pressure_f;
|
|
float brake_pressure_r;
|
|
int8_t steering_angle;
|
|
float speed; // in m/s
|
|
uint8_t lap_count;
|
|
uint8_t sector_count;
|
|
|
|
R2DProgress r2d_progress;
|
|
struct {
|
|
bool err_pdu : 1;
|
|
bool err_res : 1;
|
|
bool err_as : 1;
|
|
bool err_apps_plausible : 1;
|
|
bool err_soft_bspd : 1;
|
|
bool err_scs : 1; // system critical signals
|
|
bool err_con_mon : 1; // continuous monitoring of autonomous system
|
|
bool err_initial_checkup : 1; // initial checkup
|
|
bool err_inv_1 : 1;
|
|
bool err_inv_2 : 1;
|
|
bool err_ams : 1;
|
|
bool err_sdc : 1; // sdc err = not closed
|
|
} errors;
|
|
SDCStatus sdc_status;
|
|
bool inv_1_ready;
|
|
bool inv_2_ready;
|
|
float energy_per_lap;
|
|
InitialCheckupState initial_checkup_state;
|
|
|
|
// autonomous system
|
|
Mission active_mission;
|
|
ASState as_state;
|
|
|
|
float inv_velocity_1;
|
|
float inv_velocity_2;
|
|
|
|
int16_t inv_torque_demanded_1;
|
|
int16_t inv_torque_demanded_2;
|
|
int16_t inv_torque_desired_1;
|
|
int16_t inv_torque_desired_2;
|
|
|
|
uint16_t inv_control_word_1;
|
|
uint16_t inv_control_word_2;
|
|
int16_t inv_torque_actual_1;
|
|
int16_t inv_torque_actual_2;
|
|
|
|
uint16_t inv_errors_1;
|
|
uint16_t inv_errors_2;
|
|
uint16_t inv_warnings_1;
|
|
uint16_t inv_warnings_2;
|
|
|
|
ParamType last_param_confirmed;
|
|
|
|
uint8_t drs_led_active;
|
|
} VehicleState;
|
|
|
|
extern VehicleState vehicle_state;
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // __INC_VEHICLE_STATE_H
|