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

#include <SimpleController.h>

Inheritance diagram for TorqueControllerSimple:
Inheritance graph
Collaboration diagram for TorqueControllerSimple:
Collaboration graph

Public Member Functions

 TorqueControllerSimple (float rearTorqueScale, float regenTorqueScale)
 simple TC with tunable F/R torque balance. Accel torque balance can be tuned independently of regen torque balance More...
 
void tick (const PedalsSystemData_s &pedalsData)
 calculates torque output based off max torque and simple torque scaling metric defined in constructor and adjusts writeout_ accordingly 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

TorqueControllerOutput_s writeout_
 
float frontTorqueScale_ = 1.0
 
float rearTorqueScale_ = 1.0
 
float frontRegenTorqueScale_ = 1.0
 
float rearRegenTorqueScale_ = 1.0
 

Detailed Description

Definition at line 8 of file SimpleController.h.

Constructor & Destructor Documentation

◆ TorqueControllerSimple()

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

simple 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 22 of file SimpleController.h.

23 : frontTorqueScale_(2.0 - rearTorqueScale),
24 rearTorqueScale_(rearTorqueScale),
25 frontRegenTorqueScale_(2.0 - regenTorqueScale),
26 rearRegenTorqueScale_(regenTorqueScale)
27 {
29 writeout_.ready = true;
30 }
TorqueControllerOutput_s writeout_
const DrivetrainCommand_s TC_COMMAND_NO_TORQUE
Definition: BaseController.h:9
DrivetrainCommand_s command

Member Function Documentation

◆ evaluate()

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

Implements Controller.

Definition at line 43 of file SimpleController.cpp.

44{
45 tick(state.pedals_data);
46 return writeout_;
47}
void tick(const PedalsSystemData_s &pedalsData)
calculates torque output based off max torque and simple torque scaling metric defined in constructor...
PedalsSystemData_s pedals_data

◆ tick()

void TorqueControllerSimple::tick ( const PedalsSystemData_s pedalsData)

calculates torque output based off max torque and simple torque scaling metric defined in constructor and adjusts writeout_ accordingly

Parameters
pedalsDatacontroller calculates acceleration request from the pedals based off of this data

Definition at line 3 of file SimpleController.cpp.

4{
5
6 // Both pedals are not pressed and no implausibility has been detected
7 // accelRequest goes between 1.0 and -1.0
8 float accelRequest = pedalsData.accelPercent - pedalsData.regenPercent;
9 float torqueRequest;
10
11 if (accelRequest >= 0.0)
12 {
13 // Positive torque request
14 torqueRequest = accelRequest * PhysicalParameters::AMK_MAX_TORQUE;
15
20
25 }
26 else
27 {
28 // Negative torque request
29 torqueRequest = PhysicalParameters::MAX_REGEN_TORQUE * accelRequest * -1.0;
30
35
40 }
41}
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]

Member Data Documentation

◆ frontRegenTorqueScale_

float TorqueControllerSimple::frontRegenTorqueScale_ = 1.0
private

Definition at line 14 of file SimpleController.h.

◆ frontTorqueScale_

float TorqueControllerSimple::frontTorqueScale_ = 1.0
private

Definition at line 12 of file SimpleController.h.

◆ rearRegenTorqueScale_

float TorqueControllerSimple::rearRegenTorqueScale_ = 1.0
private

Definition at line 15 of file SimpleController.h.

◆ rearTorqueScale_

float TorqueControllerSimple::rearTorqueScale_ = 1.0
private

Definition at line 13 of file SimpleController.h.

◆ writeout_

TorqueControllerOutput_s TorqueControllerSimple::writeout_
private

Definition at line 11 of file SimpleController.h.


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