MCU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
TorqueControllerLoadCellVectoring Class Reference

#include <LoadCellVectoringController.h>

Inheritance diagram for TorqueControllerLoadCellVectoring:
Inheritance graph
Collaboration diagram for TorqueControllerLoadCellVectoring:
Collaboration graph

Public Member Functions

 TorqueControllerLoadCellVectoring (float rearTorqueScale, float regenTorqueScale)
 load cell TC with tunable F/R torque balance. Accel torque balance can be tuned independently of regen torque balance More...
 
 TorqueControllerLoadCellVectoring ()
 default contructor with balanced default values: rearTorqueScale = 1.0, regenTorqueScale = 1.0 More...
 
void tick (const SysTick_s &tick, const PedalsSystemData_s &pedalsData, const LoadCellInterfaceOutput_s &loadCellData)
 Calculates speed set point based on normal force applied to wheels individually. More...
 
TorqueControllerOutput_s evaluate (const SharedCarState_s &state) override
 
virtual TorqueControllerOutput_s evaluate (const SharedCarState_s &state)=0
 This mehod must be implemented by every controller in the Tc Muxer. This is called in the Muxer whenever the drivetrain command is obtained. TorqueControllerMux.cpp to see that in every tick of the system, the active controller must be ticked through this method. More...
 

Private Attributes

float frontTorqueScale_ = 1.0
 
float rearTorqueScale_ = 1.0
 
float frontRegenTorqueScale_ = 1.0
 
float rearRegenTorqueScale_ = 1.0
 
TorqueControllerOutput_s writeout_
 
float FIRTaps_ [numFIRTaps_]
 
int FIRCircBufferHead = 0
 
float loadCellForcesRaw_ [4][numFIRTaps_] = {}
 
float loadCellForcesFiltered_ [4] = {}
 
const int errorCountThreshold_ = 25
 
int loadCellsErrorCounter_ [4] = {}
 
bool FIRSaturated_ = false
 
bool ready_ = false
 

Static Private Attributes

static const int numFIRTaps_ = 5
 

Detailed Description

Definition at line 5 of file LoadCellVectoringController.h.

Constructor & Destructor Documentation

◆ TorqueControllerLoadCellVectoring() [1/2]

TorqueControllerLoadCellVectoring::TorqueControllerLoadCellVectoring ( float  rearTorqueScale,
float  regenTorqueScale 
)
inline

load cell TC with tunable F/R torque balance. Accel torque balance can be tuned independently of regen torque balance

Parameters
writeoutthe reference to the torque controller output being sent that contains the drivetrain command
rearTorqueScale0 to 2 scale on forward torque to rear wheels. 0 = FWD, 1 = Balanced, 2 = RWD
regenTorqueScalesame as rearTorqueScale but applies to regen torque split. 0 = All regen torque on the front, 1 = 50/50, 2 = all regen torque on the rear

Definition at line 51 of file LoadCellVectoringController.h.

◆ TorqueControllerLoadCellVectoring() [2/2]

TorqueControllerLoadCellVectoring::TorqueControllerLoadCellVectoring ( )
inline

default contructor with balanced default values: rearTorqueScale = 1.0, regenTorqueScale = 1.0

Definition at line 61 of file LoadCellVectoringController.h.

TorqueControllerLoadCellVectoring()
default contructor with balanced default values: rearTorqueScale = 1.0, regenTorqueScale = 1....

Member Function Documentation

◆ evaluate()

TorqueControllerOutput_s TorqueControllerLoadCellVectoring::evaluate ( const SharedCarState_s state)
overridevirtual
Note
refer to parent class for function documentation

Implements Controller.

Definition at line 96 of file LoadCellVectoringController.cpp.

97{
98 tick(state.systick, state.pedals_data, state.loadcell_data);
99 return writeout_;
100}
void tick(const SysTick_s &tick, const PedalsSystemData_s &pedalsData, const LoadCellInterfaceOutput_s &loadCellData)
Calculates speed set point based on normal force applied to wheels individually.
LoadCellInterfaceOutput_s loadcell_data
PedalsSystemData_s pedals_data

◆ tick()

void TorqueControllerLoadCellVectoring::tick ( const SysTick_s &  tick,
const PedalsSystemData_s pedalsData,
const LoadCellInterfaceOutput_s loadCellData 
)

Calculates speed set point based on normal force applied to wheels individually.

Parameters
SysTick_s&tick
PedalsSystemData_s&pedalsData
LoadCellInterfaceOutput_s&loadCellData

Definition at line 4 of file LoadCellVectoringController.cpp.

9{
10 // Calculate torque commands at 100hz
11 if (tick.triggers.trigger100)
12 {
13 // Apply FIR filter to load cell data
18
19 for (int i = 0; i < 4; i++)
20 {
22 for (int FIROffset = 0; FIROffset < numFIRTaps_; FIROffset++)
23 {
24 int index = (FIRCircBufferHead + FIROffset) % numFIRTaps_;
25 loadCellForcesFiltered_[i] += loadCellForcesRaw_[i][index] * FIRTaps_[FIROffset];
26 }
27 }
30 FIRSaturated_ = true;
31
32 // Do sanity checks on raw data
33 loadCellsErrorCounter_[0] = loadCellData.loadCellConversions.FL.raw != 4095 && loadCellData.loadCellConversions.FL.status != AnalogSensorStatus_e::ANALOG_SENSOR_CLAMPED ? 0 : loadCellsErrorCounter_[0] + 1;
34 loadCellsErrorCounter_[1] = loadCellData.loadCellConversions.FR.raw != 4095 && loadCellData.loadCellConversions.FR.status != AnalogSensorStatus_e::ANALOG_SENSOR_CLAMPED ? 0 : loadCellsErrorCounter_[1] + 1;
35 loadCellsErrorCounter_[2] = loadCellData.loadCellConversions.RL.raw != 4095 && loadCellData.loadCellConversions.RL.status != AnalogSensorStatus_e::ANALOG_SENSOR_CLAMPED ? 0 : loadCellsErrorCounter_[2] + 1;
36 loadCellsErrorCounter_[3] = loadCellData.loadCellConversions.RR.raw != 4095 && loadCellData.loadCellConversions.RR.status != AnalogSensorStatus_e::ANALOG_SENSOR_CLAMPED ? 0 : loadCellsErrorCounter_[3] + 1;
38
40
41 if (ready_)
42 {
43 // Calculate total normal force
44 float sumNormalForce = 0.0f;
45 for (int i = 0; i < 4; i++)
46 {
47 sumNormalForce += loadCellForcesFiltered_[i];
48 }
49
50 // Both pedals are not pressed and no implausibility has been detected
51 // accelRequest goes between 1.0 and -1.0
52 float accelRequest = pedalsData.accelPercent - pedalsData.regenPercent;
53 float torquePool;
54 float torqueRequest;
55
56 if (accelRequest >= 0.0)
57 {
58 // Positive torque request
59 // NOTE: using "torquePool" here instead of torqueRequest for legibility
60 torquePool = accelRequest * PhysicalParameters::AMK_MAX_TORQUE * 4;
61
66
71 }
72 else
73 {
74 // Negative torque request
75 // No load cell vectoring on regen
76 torqueRequest = PhysicalParameters::MAX_REGEN_TORQUE * accelRequest * -1.0;
77
82
87 }
88 }
89 else
90 {
92 }
93 }
94}
const int RR
Definition: Utility.h:9
const int FL
Definition: Utility.h:6
const int FR
Definition: Utility.h:7
const int RL
Definition: Utility.h:8
const float AMK_MAX_TORQUE
const float MAX_REGEN_TORQUE
float inverter_torque_limit[NUM_MOTORS]
float speeds_rpm[NUM_MOTORS]
veh_vec< float > loadCellForcesFiltered
veh_vec< AnalogConversion_s > loadCellConversions
T FL
Definition: Utility.h:19
T RL
Definition: Utility.h:21
T RR
Definition: Utility.h:22
T FR
Definition: Utility.h:20

Member Data Documentation

◆ errorCountThreshold_

const int TorqueControllerLoadCellVectoring::errorCountThreshold_ = 25
private

Definition at line 41 of file LoadCellVectoringController.h.

◆ FIRCircBufferHead

int TorqueControllerLoadCellVectoring::FIRCircBufferHead = 0
private

Definition at line 37 of file LoadCellVectoringController.h.

◆ FIRSaturated_

bool TorqueControllerLoadCellVectoring::FIRSaturated_ = false
private

Definition at line 43 of file LoadCellVectoringController.h.

◆ FIRTaps_

float TorqueControllerLoadCellVectoring::FIRTaps_[numFIRTaps_]
private
Initial value:
= {
0.07022690881526232,
0.27638313122745306,
0.408090001549378,
0.27638313122745306,
0.07022690881526232}

Definition at line 31 of file LoadCellVectoringController.h.

◆ frontRegenTorqueScale_

float TorqueControllerLoadCellVectoring::frontRegenTorqueScale_ = 1.0
private

Definition at line 10 of file LoadCellVectoringController.h.

◆ frontTorqueScale_

float TorqueControllerLoadCellVectoring::frontTorqueScale_ = 1.0
private

Definition at line 8 of file LoadCellVectoringController.h.

◆ loadCellForcesFiltered_

float TorqueControllerLoadCellVectoring::loadCellForcesFiltered_[4] = {}
private

Definition at line 39 of file LoadCellVectoringController.h.

◆ loadCellForcesRaw_

float TorqueControllerLoadCellVectoring::loadCellForcesRaw_[4][numFIRTaps_] = {}
private

Definition at line 38 of file LoadCellVectoringController.h.

◆ loadCellsErrorCounter_

int TorqueControllerLoadCellVectoring::loadCellsErrorCounter_[4] = {}
private

Definition at line 42 of file LoadCellVectoringController.h.

◆ numFIRTaps_

const int TorqueControllerLoadCellVectoring::numFIRTaps_ = 5
staticprivate

Definition at line 30 of file LoadCellVectoringController.h.

◆ ready_

bool TorqueControllerLoadCellVectoring::ready_ = false
private

Definition at line 44 of file LoadCellVectoringController.h.

◆ rearRegenTorqueScale_

float TorqueControllerLoadCellVectoring::rearRegenTorqueScale_ = 1.0
private

Definition at line 11 of file LoadCellVectoringController.h.

◆ rearTorqueScale_

float TorqueControllerLoadCellVectoring::rearTorqueScale_ = 1.0
private

Definition at line 9 of file LoadCellVectoringController.h.

◆ writeout_

TorqueControllerOutput_s TorqueControllerLoadCellVectoring::writeout_
private

Definition at line 13 of file LoadCellVectoringController.h.


The documentation for this class was generated from the following files: