MCU
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
BaseLaunchController Class Referenceabstract

#include <BaseLaunchController.h>

Inheritance diagram for BaseLaunchController:
Inheritance graph
Collaboration diagram for BaseLaunchController:
Collaboration graph

Public Member Functions

 BaseLaunchController (int16_t initial_speed_target)
 Constructor for parent launch controller. More...
 
void tick (const SysTick_s &tick, const PedalsSystemData_s &pedalsData, const float wheel_rpms[], const VectornavData_s &vn_data)
 ticks launch controller to progress through launch states when conditions are met. The conditions are explained above the launch states enum. all launch controllers use this class' implementation of tick. tick conatains the current system tick controlled by main.cpp pedalsData conatins the brake and accelerator values wheel_rpms[] contains how fast each wheel is spinning, order of wheels in this array is defined in SharedDataTypes.h and Utility.h vn_data contains vector states of the car that will be provided to the calc_launch_algo method called in the LAUNCHING state of this set of modes More...
 
LaunchStates_e get_launch_state ()
 
virtual void calc_launch_algo (const VectornavData_s &vn_data)=0
 calculates how speed target (the speed the car is trying to achieve during launch) is set and/or increased during launch This updates internal speed target variable launch_speed_target_ More...
 
TorqueControllerOutput_s evaluate (const SharedCarState_s &state) override
 all launch controllers share the same evaluate method implemented in this class implementation. More...
 
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...
 

Protected Attributes

TorqueControllerOutput_s writeout_
 
uint32_t time_of_launch_
 
double initial_ecef_x_
 
double initial_ecef_y_
 
double initial_ecef_z_
 
LaunchStates_e launch_state_ = LaunchStates_e::LAUNCH_NOT_READY
 
uint32_t current_millis_
 
float launch_speed_target_ = 0.0
 
int16_t init_speed_target_ = 0
 

Detailed Description

Definition at line 36 of file BaseLaunchController.h.

Constructor & Destructor Documentation

◆ BaseLaunchController()

BaseLaunchController::BaseLaunchController ( int16_t  initial_speed_target)
inline

Constructor for parent launch controller.

Parameters
initial_speed_targetused only in simple launch controller algorithm
Note
requires one method: calc_launch_algo

Definition at line 53 of file BaseLaunchController.h.

54 : init_speed_target_(initial_speed_target)
55 {
57 writeout_.ready = true;
58 }
TorqueControllerOutput_s writeout_
const DrivetrainCommand_s TC_COMMAND_NO_TORQUE
Definition: BaseController.h:9
DrivetrainCommand_s command

Member Function Documentation

◆ calc_launch_algo()

virtual void BaseLaunchController::calc_launch_algo ( const VectornavData_s vn_data)
pure virtual

calculates how speed target (the speed the car is trying to achieve during launch) is set and/or increased during launch This updates internal speed target variable launch_speed_target_

Parameters
vn_datavector data needed for calulations eg. speed and coordinates
Note
defines important variation in launch controller tick/evaluation as the launch controllers share a tick method defined in this parent class implementation
all launch algorithms are implemented in LaunchControllerAlgos.cpp

Implemented in TorqueControllerLookupLaunch, TorqueControllerSimpleLaunch, and TorqueControllerSlipLaunch.

◆ evaluate()

TorqueControllerOutput_s BaseLaunchController::evaluate ( const SharedCarState_s state)
overridevirtual

all launch controllers share the same evaluate method implemented in this class implementation.

Note
refer to parent class for function documentation

Implements Controller.

Definition at line 110 of file BaseLaunchController.cpp.

111{
112 tick(state.systick, state.pedals_data, state.drivetrain_data.measuredSpeeds, state.vn_data);
113 return writeout_;
114}
void tick(const SysTick_s &tick, const PedalsSystemData_s &pedalsData, const float wheel_rpms[], const VectornavData_s &vn_data)
ticks launch controller to progress through launch states when conditions are met....
speed_rpm measuredSpeeds[NUM_MOTORS]
PedalsSystemData_s pedals_data
DrivetrainDynamicReport_s drivetrain_data
VectornavData_s vn_data

◆ get_launch_state()

LaunchStates_e BaseLaunchController::get_launch_state ( )
inline

Definition at line 70 of file BaseLaunchController.h.

70{ return launch_state_; }
LaunchStates_e launch_state_

◆ tick()

void BaseLaunchController::tick ( const SysTick_s &  tick,
const PedalsSystemData_s pedalsData,
const float  wheel_rpms[],
const VectornavData_s vn_data 
)

ticks launch controller to progress through launch states when conditions are met. The conditions are explained above the launch states enum. all launch controllers use this class' implementation of tick. tick conatains the current system tick controlled by main.cpp pedalsData conatins the brake and accelerator values wheel_rpms[] contains how fast each wheel is spinning, order of wheels in this array is defined in SharedDataTypes.h and Utility.h vn_data contains vector states of the car that will be provided to the calc_launch_algo method called in the LAUNCHING state of this set of modes

Definition at line 3 of file BaseLaunchController.cpp.

8{
9
10 if (tick.triggers.trigger100)
11 {
12
13 current_millis_ = tick.millis;
14
15 int16_t brake_torque_req = pedalsData.regenPercent * PhysicalParameters::MAX_REGEN_TORQUE;
16
17 float max_speed = 0;
18 for (int i = 0; i < 4; i++)
19 {
20 max_speed = std::max(max_speed, abs(wheel_rpms[i]));
21 }
22
23 writeout_.ready = true;
24
25 switch (launch_state_)
26 {
27 case LaunchStates_e::LAUNCH_NOT_READY:
28 // set torques and speed to 0
33
34 writeout_.command.inverter_torque_limit[FL] = brake_torque_req;
35 writeout_.command.inverter_torque_limit[FR] = brake_torque_req;
36 writeout_.command.inverter_torque_limit[RL] = brake_torque_req;
37 writeout_.command.inverter_torque_limit[RR] = brake_torque_req;
38
39 // init launch vars
41 time_of_launch_ = tick.millis;
42 // check speed is 0 and pedals not pressed
44 {
45 launch_state_ = LaunchStates_e::LAUNCH_READY;
46 }
47
48 break;
49 case LaunchStates_e::LAUNCH_READY:
50 // set torques and speed to 0
55
56 writeout_.command.inverter_torque_limit[FL] = brake_torque_req;
57 writeout_.command.inverter_torque_limit[FR] = brake_torque_req;
58 writeout_.command.inverter_torque_limit[RL] = brake_torque_req;
59 writeout_.command.inverter_torque_limit[RR] = brake_torque_req;
60
61 // init launch vars
64
65 // check speed is 0 and brake not pressed
67 {
68 launch_state_ = LaunchStates_e::LAUNCH_NOT_READY;
69 }
71 {
72
73 initial_ecef_x_ = vn_data.ecef_coords[0];
74 initial_ecef_y_ = vn_data.ecef_coords[1];
75 initial_ecef_z_ = vn_data.ecef_coords[2];
76
77 launch_state_ = LaunchStates_e::LAUNCHING;
78 }
79
80 // check accel above launch threshold and launch
81 break;
82 case LaunchStates_e::LAUNCHING:
83 { // use brackets to ignore 'cross initialization' of secs_since_launch
84 // check accel below launch threshold and brake above
86 {
87 launch_state_ = LaunchStates_e::LAUNCH_NOT_READY;
88 }
89
90 calc_launch_algo(vn_data);
91
96
101
102 break;
103 }
104 default:
105 break;
106 }
107 }
108}
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
virtual void calc_launch_algo(const VectornavData_s &vn_data)=0
calculates how speed target (the speed the car is trying to achieve during launch) is set and/or incr...
const float AMK_MAX_TORQUE
const float MAX_REGEN_TORQUE
float inverter_torque_limit[NUM_MOTORS]
float speeds_rpm[NUM_MOTORS]
double ecef_coords[3]

Member Data Documentation

◆ current_millis_

uint32_t BaseLaunchController::current_millis_
protected

Definition at line 45 of file BaseLaunchController.h.

◆ init_speed_target_

int16_t BaseLaunchController::init_speed_target_ = 0
protected

Definition at line 47 of file BaseLaunchController.h.

◆ initial_ecef_x_

double BaseLaunchController::initial_ecef_x_
protected

Definition at line 41 of file BaseLaunchController.h.

◆ initial_ecef_y_

double BaseLaunchController::initial_ecef_y_
protected

Definition at line 42 of file BaseLaunchController.h.

◆ initial_ecef_z_

double BaseLaunchController::initial_ecef_z_
protected

Definition at line 43 of file BaseLaunchController.h.

◆ launch_speed_target_

float BaseLaunchController::launch_speed_target_ = 0.0
protected

Definition at line 46 of file BaseLaunchController.h.

◆ launch_state_

LaunchStates_e BaseLaunchController::launch_state_ = LaunchStates_e::LAUNCH_NOT_READY
protected

Definition at line 44 of file BaseLaunchController.h.

◆ time_of_launch_

uint32_t BaseLaunchController::time_of_launch_
protected

Definition at line 40 of file BaseLaunchController.h.

◆ writeout_

TorqueControllerOutput_s BaseLaunchController::writeout_
protected

Definition at line 39 of file BaseLaunchController.h.


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