Skip to content

Commit

Permalink
Feature/dgulewicz/throttle map squash (#114)
Browse files Browse the repository at this point in the history
* throttle map 2

* remove car.c faults
  • Loading branch information
LukeOxley authored Apr 5, 2024
1 parent 9af8219 commit fd3c7d5
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 155 deletions.
25 changes: 5 additions & 20 deletions common/daq/can_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
{"msg_name": "max_cell_temp"},
{"msg_name": "LWS_Standard"},
{"msg_name": "main_module_bl_cmd" , "callback": true},
{"msg_name": "throttle_remapped"},
{"msg_name": "orion_currents_volts"},
{"msg_name": "throttle_vcu"}
]
Expand Down Expand Up @@ -425,8 +424,7 @@
"signals":[
{"sig_name":"gps_vel_n","type":"int16_t","unit": "m/s", "scale": 0.01},
{"sig_name":"gps_vel_e", "type":"int16_t","unit": "m/s", "scale": 0.01},
{"sig_name":"gps_vel_d", "type":"int16_t","unit": "m/s", "scale": 0.01},
{"sig_name":"gps_vel_total", "type":"int16_t", "unit": "m/s","scale": 0.01}
{"sig_name":"gps_vel_d", "type":"int16_t","unit": "m/s", "scale": 0.01}
],
"msg_period":40,
"msg_hlp":3,
Expand All @@ -435,9 +433,6 @@
{ "msg_name":"gps_position",
"msg_desc":"gps position",
"signals":[
{"sig_name":"gps_pos_x","type":"int16_t","unit": "m", "scale": 0.01},
{"sig_name":"gps_pos_y", "type":"int16_t","unit": "m", "scale": 0.01},
{"sig_name":"gps_pos_z", "type":"int16_t","unit": "m", "scale": 0.01},
{"sig_name":"height", "type":"int16_t", "unit": "m", "scale": 0.01}
],
"msg_period":40,
Expand Down Expand Up @@ -546,23 +541,13 @@
{
"msg_name": "throttle_vcu",
"msg_desc": "throttle vcu",
"signals":[
{"sig_name": "vcu_r_rl", "type": "int16_t", "unit": "none", "scale": 1},
{"sig_name": "vcu_r_rr", "type": "int16_t", "unit": "none", "scale": 1}
],
"msg_period": 15,
"msg_hlp": 1,
"msg_pgn": 151
},
{
"msg_name": "throttle_remapped",
"msg_desc": "throttle remapped",
"signals":[
{"sig_name": "vcu_k_rl", "type": "int16_t", "unit": "none", "scale": 1},
{"sig_name": "vcu_k_rr", "type": "int16_t", "unit": "none", "scale": 1}
{"sig_name": "vcu_k_rr", "type": "int16_t", "unit": "none", "scale": 1},
{"sig_name": "vcu_r_max", "type": "int16_t", "unit": "none", "scale": 1}
],
"msg_period": 15,
"msg_hlp": 1,
"msg_hlp": 3,
"msg_pgn": 150
},
{
Expand All @@ -579,7 +564,7 @@
"msg_name": "vehHead",
"msg_desc": "Vehicle Heading",
"signals":[
{"sig_name": "vehHead", "type": "int16_t", "unit": "none", "scale": 1}
{"sig_name": "vehHead", "type": "int16_t", "unit": "none", "scale": 0.1}
],
"msg_period": 15,
"msg_hlp": 3,
Expand Down
33 changes: 10 additions & 23 deletions common/daq/per_dbc.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,13 @@ BO_ 2348812088 orion_errors: 4 OrionBMS
SG_ charger_safety_relay : 1|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ discharge_limit_enforce : 0|1@1+ (1,0) [0|0] "" Vector__XXX

BO_ 2348810935 gps_velocity: 8 torque_vector
SG_ gps_vel_total : 48|16@1- (0.01,0) [0|0] "m/s" Vector__XXX
BO_ 2348810935 gps_velocity: 6 torque_vector
SG_ gps_vel_d : 32|16@1- (0.01,0) [0|0] "m/s" Vector__XXX
SG_ gps_vel_e : 16|16@1- (0.01,0) [0|0] "m/s" Vector__XXX
SG_ gps_vel_n : 0|16@1- (0.01,0) [0|0] "m/s" Vector__XXX

BO_ 2348819255 gps_position: 8 torque_vector
SG_ height : 48|16@1- (0.01,0) [0|0] "m" Vector__XXX
SG_ gps_pos_z : 32|16@1- (0.01,0) [0|0] "m" Vector__XXX
SG_ gps_pos_y : 16|16@1- (0.01,0) [0|0] "m" Vector__XXX
SG_ gps_pos_x : 0|16@1- (0.01,0) [0|0] "m" Vector__XXX
BO_ 2348819255 gps_position: 2 torque_vector
SG_ height : 0|16@1- (0.01,0) [0|0] "m" Vector__XXX

BO_ 2348819319 gps_coordinates: 8 torque_vector
SG_ longitude : 32|32@1- (1,0) [0|0] "deg" Vector__XXX
Expand Down Expand Up @@ -299,19 +295,16 @@ BO_ 2348902967 sfs_ang_vel: 6 torque_vector
SG_ sfs_ang_vel_y : 16|16@1- (0.0001,0) [0|0] "" Vector__XXX
SG_ sfs_ang_vel_x : 0|16@1- (0.0001,0) [0|0] "" Vector__XXX

BO_ 2214602231 throttle_vcu: 4 torque_vector
SG_ vcu_r_rr : 16|16@1- (1,0) [0|0] "none" Vector__XXX
SG_ vcu_r_rl : 0|16@1- (1,0) [0|0] "none" Vector__XXX

BO_ 2214602167 throttle_remapped: 4 torque_vector
BO_ 2348819895 throttle_vcu: 6 torque_vector
SG_ vcu_r_max : 32|16@1- (1,0) [0|0] "none" Vector__XXX
SG_ vcu_k_rr : 16|16@1- (1,0) [0|0] "none" Vector__XXX
SG_ vcu_k_rl : 0|16@1- (1,0) [0|0] "none" Vector__XXX

BO_ 2348820023 maxR: 2 torque_vector
SG_ vcu_max_r : 0|16@1- (1,0) [0|0] "none" Vector__XXX

BO_ 2348820087 vehHead: 2 torque_vector
SG_ vehHead : 0|16@1- (1,0) [0|0] "none" Vector__XXX
SG_ vehHead : 0|16@1- (0.1,0) [0|0] "none" Vector__XXX

BO_ 2416010039 tv_can_stats: 4 torque_vector
SG_ can_rx_overrun : 24|8@1+ (1,0) [0|0] "" Vector__XXX
Expand Down Expand Up @@ -801,15 +794,11 @@ CM_ SG_ 2348812088 internal_hardware "";
CM_ SG_ 2348812088 charger_safety_relay "";
CM_ SG_ 2348812088 discharge_limit_enforce "";
CM_ BO_ 2348810935 "gps velocity";
CM_ SG_ 2348810935 gps_vel_total "";
CM_ SG_ 2348810935 gps_vel_d "";
CM_ SG_ 2348810935 gps_vel_e "";
CM_ SG_ 2348810935 gps_vel_n "";
CM_ BO_ 2348819255 "gps position";
CM_ SG_ 2348819255 height "";
CM_ SG_ 2348819255 gps_pos_z "";
CM_ SG_ 2348819255 gps_pos_y "";
CM_ SG_ 2348819255 gps_pos_x "";
CM_ BO_ 2348819319 "gps coordinates";
CM_ SG_ 2348819319 longitude "";
CM_ SG_ 2348819319 latitude "";
Expand Down Expand Up @@ -846,12 +835,10 @@ CM_ BO_ 2348902967 "orientation vel from sfs";
CM_ SG_ 2348902967 sfs_ang_vel_z "";
CM_ SG_ 2348902967 sfs_ang_vel_y "";
CM_ SG_ 2348902967 sfs_ang_vel_x "";
CM_ BO_ 2214602231 "throttle vcu";
CM_ SG_ 2214602231 vcu_r_rr "";
CM_ SG_ 2214602231 vcu_r_rl "";
CM_ BO_ 2214602167 "throttle remapped";
CM_ SG_ 2214602167 vcu_k_rr "";
CM_ SG_ 2214602167 vcu_k_rl "";
CM_ BO_ 2348819895 "throttle vcu";
CM_ SG_ 2348819895 vcu_r_max "";
CM_ SG_ 2348819895 vcu_k_rr "";
CM_ SG_ 2348819895 vcu_k_rl "";
CM_ BO_ 2348820023 "Maximum Allowed Throttle";
CM_ SG_ 2348820023 vcu_max_r "";
CM_ BO_ 2348820087 "Vehicle Heading";
Expand Down
36 changes: 13 additions & 23 deletions source/main_module/can/can_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,16 @@ void canRxUpdate(void)
can_data.main_module_bl_cmd.data = msg_data_a->main_module_bl_cmd.data;
main_module_bl_cmd_CALLBACK(msg_data_a);
break;
case ID_THROTTLE_REMAPPED:
can_data.throttle_remapped.vcu_k_rl = (int16_t) msg_data_a->throttle_remapped.vcu_k_rl;
can_data.throttle_remapped.vcu_k_rr = (int16_t) msg_data_a->throttle_remapped.vcu_k_rr;
can_data.throttle_remapped.stale = 0;
can_data.throttle_remapped.last_rx = sched.os_ticks;
break;
case ID_ORION_CURRENTS_VOLTS:
can_data.orion_currents_volts.pack_current = (int16_t) msg_data_a->orion_currents_volts.pack_current;
can_data.orion_currents_volts.pack_voltage = msg_data_a->orion_currents_volts.pack_voltage;
can_data.orion_currents_volts.stale = 0;
can_data.orion_currents_volts.last_rx = sched.os_ticks;
break;
case ID_THROTTLE_VCU:
can_data.throttle_vcu.vcu_r_rl = (int16_t) msg_data_a->throttle_vcu.vcu_r_rl;
can_data.throttle_vcu.vcu_r_rr = (int16_t) msg_data_a->throttle_vcu.vcu_r_rr;
can_data.throttle_vcu.vcu_k_rl = (int16_t) msg_data_a->throttle_vcu.vcu_k_rl;
can_data.throttle_vcu.vcu_k_rr = (int16_t) msg_data_a->throttle_vcu.vcu_k_rr;
can_data.throttle_vcu.vcu_r_max = (int16_t) msg_data_a->throttle_vcu.vcu_r_max;
can_data.throttle_vcu.stale = 0;
can_data.throttle_vcu.last_rx = sched.os_ticks;
break;
Expand Down Expand Up @@ -165,9 +160,6 @@ void canRxUpdate(void)
CHECK_STALE(can_data.LWS_Standard.stale,
sched.os_ticks, can_data.LWS_Standard.last_rx,
UP_LWS_STANDARD);
CHECK_STALE(can_data.throttle_remapped.stale,
sched.os_ticks, can_data.throttle_remapped.last_rx,
UP_THROTTLE_REMAPPED);
CHECK_STALE(can_data.orion_currents_volts.stale,
sched.os_ticks, can_data.orion_currents_volts.last_rx,
UP_ORION_CURRENTS_VOLTS);
Expand Down Expand Up @@ -201,22 +193,20 @@ bool initCANFilter()
CAN1->sFilterRegister[2].FR1 = (ID_LWS_STANDARD << 3) | 4;
CAN1->sFilterRegister[2].FR2 = (ID_MAIN_MODULE_BL_CMD << 3) | 4;
CAN1->FA1R |= (1 << 3); // configure bank 3
CAN1->sFilterRegister[3].FR1 = (ID_THROTTLE_REMAPPED << 3) | 4;
CAN1->sFilterRegister[3].FR2 = (ID_ORION_CURRENTS_VOLTS << 3) | 4;
CAN1->sFilterRegister[3].FR1 = (ID_ORION_CURRENTS_VOLTS << 3) | 4;
CAN1->sFilterRegister[3].FR2 = (ID_THROTTLE_VCU << 3) | 4;
CAN1->FA1R |= (1 << 4); // configure bank 4
CAN1->sFilterRegister[4].FR1 = (ID_THROTTLE_VCU << 3) | 4;
CAN1->sFilterRegister[4].FR2 = (ID_FAULT_SYNC_PDU << 3) | 4;
CAN1->sFilterRegister[4].FR1 = (ID_FAULT_SYNC_PDU << 3) | 4;
CAN1->sFilterRegister[4].FR2 = (ID_FAULT_SYNC_DASHBOARD << 3) | 4;
CAN1->FA1R |= (1 << 5); // configure bank 5
CAN1->sFilterRegister[5].FR1 = (ID_FAULT_SYNC_DASHBOARD << 3) | 4;
CAN1->sFilterRegister[5].FR2 = (ID_FAULT_SYNC_A_BOX << 3) | 4;
CAN1->sFilterRegister[5].FR1 = (ID_FAULT_SYNC_A_BOX << 3) | 4;
CAN1->sFilterRegister[5].FR2 = (ID_FAULT_SYNC_TORQUE_VECTOR << 3) | 4;
CAN1->FA1R |= (1 << 6); // configure bank 6
CAN1->sFilterRegister[6].FR1 = (ID_FAULT_SYNC_TORQUE_VECTOR << 3) | 4;
CAN1->sFilterRegister[6].FR2 = (ID_FAULT_SYNC_TEST_NODE << 3) | 4;
CAN1->sFilterRegister[6].FR1 = (ID_FAULT_SYNC_TEST_NODE << 3) | 4;
CAN1->sFilterRegister[6].FR2 = (ID_SET_FAULT << 3) | 4;
CAN1->FA1R |= (1 << 7); // configure bank 7
CAN1->sFilterRegister[7].FR1 = (ID_SET_FAULT << 3) | 4;
CAN1->sFilterRegister[7].FR2 = (ID_RETURN_FAULT_CONTROL << 3) | 4;
CAN1->FA1R |= (1 << 8); // configure bank 8
CAN1->sFilterRegister[8].FR1 = (ID_DAQ_COMMAND_MAIN_MODULE << 3) | 4;
CAN1->sFilterRegister[7].FR1 = (ID_RETURN_FAULT_CONTROL << 3) | 4;
CAN1->sFilterRegister[7].FR2 = (ID_DAQ_COMMAND_MAIN_MODULE << 3) | 4;
/* END AUTO FILTER */
CAN1->FA1R |= (1 << 6); // configure bank 6
CAN1->sFilterRegister[6].FR1 = (ID_LWS_STANDARD << 21);
Expand Down
27 changes: 8 additions & 19 deletions source/main_module/can/can_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
#define ID_MAX_CELL_TEMP 0xc04e604
#define ID_LWS_STANDARD 0x2b0
#define ID_MAIN_MODULE_BL_CMD 0x409c43e
#define ID_THROTTLE_REMAPPED 0x40025b7
#define ID_ORION_CURRENTS_VOLTS 0x140006f8
#define ID_THROTTLE_VCU 0x40025f7
#define ID_THROTTLE_VCU 0xc0025b7
#define ID_FAULT_SYNC_PDU 0x8cb1f
#define ID_FAULT_SYNC_DASHBOARD 0x8cac5
#define ID_FAULT_SYNC_A_BOX 0x8ca44
Expand Down Expand Up @@ -76,9 +75,8 @@
#define DLC_MAX_CELL_TEMP 2
#define DLC_LWS_STANDARD 5
#define DLC_MAIN_MODULE_BL_CMD 5
#define DLC_THROTTLE_REMAPPED 4
#define DLC_ORION_CURRENTS_VOLTS 4
#define DLC_THROTTLE_VCU 4
#define DLC_THROTTLE_VCU 6
#define DLC_FAULT_SYNC_PDU 3
#define DLC_FAULT_SYNC_DASHBOARD 3
#define DLC_FAULT_SYNC_A_BOX 3
Expand Down Expand Up @@ -224,7 +222,6 @@
#define UP_FILT_THROTTLE_BRAKE 15
#define UP_MAX_CELL_TEMP 500
#define UP_LWS_STANDARD 15
#define UP_THROTTLE_REMAPPED 15
#define UP_ORION_CURRENTS_VOLTS 32
#define UP_THROTTLE_VCU 15
/* END AUTO UP DEFS */
Expand Down Expand Up @@ -409,17 +406,14 @@ typedef union {
uint64_t cmd: 8;
uint64_t data: 32;
} main_module_bl_cmd;
struct {
uint64_t vcu_k_rl: 16;
uint64_t vcu_k_rr: 16;
} throttle_remapped;
struct {
uint64_t pack_current: 16;
uint64_t pack_voltage: 16;
} orion_currents_volts;
struct {
uint64_t vcu_r_rl: 16;
uint64_t vcu_r_rr: 16;
uint64_t vcu_k_rl: 16;
uint64_t vcu_k_rr: 16;
uint64_t vcu_r_max: 16;
} throttle_vcu;
struct {
uint64_t idx: 16;
Expand Down Expand Up @@ -497,21 +491,16 @@ typedef struct {
uint8_t cmd;
uint32_t data;
} main_module_bl_cmd;
struct {
int16_t vcu_k_rl;
int16_t vcu_k_rr;
uint8_t stale;
uint32_t last_rx;
} throttle_remapped;
struct {
int16_t pack_current;
uint16_t pack_voltage;
uint8_t stale;
uint32_t last_rx;
} orion_currents_volts;
struct {
int16_t vcu_r_rl;
int16_t vcu_r_rr;
int16_t vcu_k_rl;
int16_t vcu_k_rr;
int16_t vcu_r_max;
uint8_t stale;
uint32_t last_rx;
} throttle_vcu;
Expand Down
8 changes: 4 additions & 4 deletions source/main_module/car/car.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ void carPeriodic()
float t_req_pedal_r = 0;
if (!can_data.filt_throttle_brake.stale)
t_req_pedal = (float) CLAMP(can_data.filt_throttle_brake.throttle, 0, 4095);
if (!can_data.throttle_remapped.stale)
t_req_pedal_l = (float) CLAMP(can_data.throttle_remapped.vcu_k_rl, 0, 4095);
if (!can_data.throttle_remapped.stale)
t_req_pedal_r = (float) CLAMP(can_data.throttle_remapped.vcu_k_rr, 0, 4095);
if (!can_data.throttle_vcu.stale)
t_req_pedal_l = (float) CLAMP(can_data.throttle_vcu.vcu_k_rl, 0, 4095);
if (!can_data.throttle_vcu.stale)
t_req_pedal_r = (float) CLAMP(can_data.throttle_vcu.vcu_k_rr, 0, 4095);

t_req_pedal = t_req_pedal * 100.0f / 4095.0f;
t_req_pedal_l = t_req_pedal_l * 100.0f / 4095.0f;
Expand Down
5 changes: 4 additions & 1 deletion source/torque_vector/ac/ac_ext.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#ifndef _AC_EXT_H_
#define _AC_EXT_H_
#define NUM_ELEM_ACC_CALIBRATION 151

typedef struct {
float ax[151];
float ay[151];
float az[151];
} vec_accumulator;
} vec_accumulator;
#endif
Loading

0 comments on commit fd3c7d5

Please sign in to comment.