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

#include <LookupLaunchController.h>

Inheritance diagram for TorqueControllerLookupLaunch:
Inheritance graph
Collaboration diagram for TorqueControllerLookupLaunch:
Collaboration graph

Public Member Functions

 TorqueControllerLookupLaunch (int16_t initial_speed_target)
 
 TorqueControllerLookupLaunch ()
 default constructor for slip launch controller: DEFAULT_LAUNCH_SPEED_TARGET = 1500(rpm) More...
 
void calc_launch_algo (const VectornavData_s &vn_data) override
 increases speed target based on distance from start to ensure the speed target is progressing as the car begins to move More...
 
- Public Member Functions inherited from BaseLaunchController
 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...
 

Private Attributes

bool init_position = false
 

Additional Inherited Members

- Protected Attributes inherited from BaseLaunchController
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 10 of file LookupLaunchController.h.

Constructor & Destructor Documentation

◆ TorqueControllerLookupLaunch() [1/2]

TorqueControllerLookupLaunch::TorqueControllerLookupLaunch ( int16_t  initial_speed_target)
inline

Lookup Launch Controller This launch controller is based off of a matlab and symlink generated lookup table. This has been converted to a C array with some basic python code using the array index as the input for the controller

Parameters
initial_speed_targetthe initial speed commanded to the wheels

Definition at line 23 of file LookupLaunchController.h.

24 : BaseLaunchController(initial_speed_target) {}

◆ TorqueControllerLookupLaunch() [2/2]

TorqueControllerLookupLaunch::TorqueControllerLookupLaunch ( )
inline

default constructor for slip launch controller: DEFAULT_LAUNCH_SPEED_TARGET = 1500(rpm)

Definition at line 26 of file LookupLaunchController.h.

TorqueControllerLookupLaunch()
default constructor for slip launch controller: DEFAULT_LAUNCH_SPEED_TARGET = 1500(rpm)

Member Function Documentation

◆ calc_launch_algo()

void TorqueControllerLookupLaunch::calc_launch_algo ( const VectornavData_s vn_data)
overridevirtual

increases speed target based on distance from start to ensure the speed target is progressing as the car begins to move

Implements BaseLaunchController.

Definition at line 21 of file LaunchControllerAlgos.cpp.

22{
23
25
26 double dx = vn_data.ecef_coords[0] - initial_ecef_x_;
27 double dy = vn_data.ecef_coords[1] - initial_ecef_y_;
28 double dz = vn_data.ecef_coords[2] - initial_ecef_z_;
29
30 double distance = sqrt((dx * dx) + (dy * dy) + (dz * dz));
31
32 /*
33 Distance-lookup launch algorithm. Takes in the vel_dist_lookup
34 generated from Luke's matlab/symlink to set speed targets based
35 on distance travelled from the start point.
36 This can also and may be better to replace with an integration
37 of body velocity.
38 */
39
40 uint32_t idx = (uint32_t)(distance * 10); // multiply by 10 to be used as index for meters in steps of 1/10
41 idx = std::min(idx, (uint32_t)(sizeof(vel_dist_lookup) / sizeof(float)));
42 float mps_target = vel_dist_lookup[idx];
43
44 float new_speed_target = mps_target * METERS_PER_SECOND_TO_RPM;
45 launch_speed_target_ = std::max(launch_speed_target_, new_speed_target);
46}
constexpr const float METERS_PER_SECOND_TO_RPM
const float vel_dist_lookup[750]
Definition: accel_lookup.h:6
double ecef_coords[3]

Member Data Documentation

◆ init_position

bool TorqueControllerLookupLaunch::init_position = false
private

Definition at line 13 of file LookupLaunchController.h.


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