MCU
Loading...
Searching...
No Matches
CASESystem.h
Go to the documentation of this file.
1#ifndef CASESYSTEM
2#define CASESYSTEM
3
4#include "HT08_CASE.h"
5#include "HytechCANInterface.h"
6#include "PedalsSystem.h"
7#include "DrivetrainSystem.h"
8#include "SteeringSystem.h"
9#include "MCUStateMachine.h"
10#include "ProtobufMsgInterface.h"
11// #include "ParameterInterface.h"
12
14{
16 float yaw_pid_p;
17 float yaw_pid_i;
18 float yaw_pid_d;
23 float tcs_pid_i;
24 float tcs_pid_d;
35 float launchSL;
86
87 float max_rpm;
90};
91
93// this class will also handle output onto the CAN bus of data
95template <typename message_queue>
97{
98public:
99 CASESystem() = delete;
105 message_queue *can_queue,
106 unsigned long controller_send_period_ms,
107 unsigned long vehicle_math_offset_ms,
108 unsigned long lowest_controller_send_period_ms,
109 CASEConfiguration config)
110 {
111 msg_queue_ = can_queue;
112 case_.initialize();
114 config_ = config;
119
120 controller_send_period_ms_ = controller_send_period_ms;
122 vehicle_math_offset_ms_ = vehicle_math_offset_ms;
123 lowest_priority_controller_send_period_ms_ = lowest_controller_send_period_ms;
124 }
125
138 const SysTick_s &tick,
139 const VectornavData_s &vn_data,
140 const SteeringSystemData_s &steering_data,
141 const DrivetrainDynamicReport_s &drivetrain_data,
142 const veh_vec<AnalogConversion_s> &load_cell_vals,
143 const PedalsSystemData_s &pedals_data,
144 float power_kw,
145 CAR_STATE fsm_state,
146 bool start_button_pressed,
147 uint8_t vn_status);
148
150
158 float calculate_torque_request(const PedalsSystemData_s &pedals_data, float max_torque, float max_regen_torque, float max_rpm);
159
163 float get_rpm_setpoint(float final_torque)
164 {
165 if (final_torque > 0)
166 {
167 return config_.max_rpm;
168 }
169 else
170 {
171 return 0;
172 }
173 }
174
175private:
178 message_queue *msg_queue_;
179 HT08_CASE case_;
180
182};
183
184#include "CASESystem.tpp"
185#endif
CAR_STATE
this class with both take in sensor inputs as well as handle calculations for various derived states ...
Definition: CASESystem.h:97
CASESystem()=delete
unsigned long vn_active_start_time_
Definition: CASESystem.h:181
DrivetrainCommand_s current_command_
Definition: CASESystem.h:176
CASEConfiguration config_
Definition: CASESystem.h:177
HT08_CASE case_
Definition: CASESystem.h:179
float get_rpm_setpoint(float final_torque)
retrieves rpm setpoint based on final torque value
Definition: CASESystem.h:163
unsigned long last_eval_time_
Definition: CASESystem.h:181
CASESystem(message_queue *can_queue, unsigned long controller_send_period_ms, unsigned long vehicle_math_offset_ms, unsigned long lowest_controller_send_period_ms, CASEConfiguration config)
constructor for state estimator system.
Definition: CASESystem.h:104
unsigned long controller_send_period_ms_
Definition: CASESystem.h:181
unsigned long last_lowest_priority_controller_send_time_
Definition: CASESystem.h:181
unsigned long vehicle_math_offset_ms_
Definition: CASESystem.h:181
DrivetrainCommand_s get_current_drive_command()
Definition: CASESystem.h:149
DrivetrainCommand_s evaluate(const SysTick_s &tick, const VectornavData_s &vn_data, const SteeringSystemData_s &steering_data, const DrivetrainDynamicReport_s &drivetrain_data, const veh_vec< AnalogConversion_s > &load_cell_vals, const PedalsSystemData_s &pedals_data, float power_kw, CAR_STATE fsm_state, bool start_button_pressed, uint8_t vn_status)
function that evaluates the CASE (controller and state estimation) system. updates the internal pstat...
float calculate_torque_request(const PedalsSystemData_s &pedals_data, float max_torque, float max_regen_torque, float max_rpm)
uses pedal data to determine the torque to be requested from the motors pedals_data....
unsigned long lowest_priority_controller_send_period_ms_
Definition: CASESystem.h:181
unsigned long last_controller_pt3_send_time_
Definition: CASESystem.h:181
unsigned long last_controller_pt1_send_time_
Definition: CASESystem.h:181
message_queue * msg_queue_
Definition: CASESystem.h:178
unsigned long last_vehm_send_time_
Definition: CASESystem.h:181
unsigned long last_controller_pt2_send_time_
Definition: CASESystem.h:181
float tcs_pid_p_lowerBound_rear
Definition: CASESystem.h:21
float yawPIDMaxDifferential
Definition: CASESystem.h:39
float yawPIDCoastThreshold
Definition: CASESystem.h:42
float TCSWheelSteerLowerBound
Definition: CASESystem.h:65
float tcs_pid_upper_rpm_front
Definition: CASESystem.h:57
float discontinuousBrakesPercentThreshold
Definition: CASESystem.h:47
float launchSL_startBound_Rear
Definition: CASESystem.h:76
float tcs_saturation_rear
Definition: CASESystem.h:62
float TCS_SL_startBound_Front
Definition: CASESystem.h:78
float maxNormalLoadBrakeScalingFront
Definition: CASESystem.h:60
float tcs_pid_p_lowerBound_front
Definition: CASESystem.h:19
float launchVelThreshold
Definition: CASESystem.h:37
float MechPowerMaxkW
Definition: CASESystem.h:54
float tcs_saturation_front
Definition: CASESystem.h:61
float TCS_SL_endBound_Front
Definition: CASESystem.h:79
float TCS_SL_startBound_Rear
Definition: CASESystem.h:80
float launchDeadZone
Definition: CASESystem.h:36
float decoupledYawPIDBrakesMaxDIfference
Definition: CASESystem.h:46
bool useRPM_TCS_GainSchedule
Definition: CASESystem.h:67
float yaw_pid_brakes_i
Definition: CASESystem.h:44
float TCSGenLeftRightDiffLowerBound
Definition: CASESystem.h:63
float yaw_pid_brakes_d
Definition: CASESystem.h:45
float launchSL_endBound_Rear
Definition: CASESystem.h:77
bool useNL_TCS_GainSchedule
Definition: CASESystem.h:68
float TCS_NL_startBoundPerc_FrontAxle
Definition: CASESystem.h:69
float tcs_pid_lower_rpm_rear
Definition: CASESystem.h:58
float tcs_pid_p_upperBound_front
Definition: CASESystem.h:20
float AbsoluteTorqueLimit
Definition: CASESystem.h:15
bool useDiscontinuousYawPIDBrakes
Definition: CASESystem.h:33
float tcs_pid_p_upperBound_rear
Definition: CASESystem.h:22
float TCS_SL_NLPerc_endBound_Front
Definition: CASESystem.h:83
float TCS_SL_NLPerc_endBound_Rear
Definition: CASESystem.h:85
float TCSWheelSteerUpperBound
Definition: CASESystem.h:66
float launchSL_endBound_Front
Definition: CASESystem.h:75
float tcs_pid_lower_rpm_front
Definition: CASESystem.h:56
float BrakeTorquePercentFront
Definition: CASESystem.h:53
float TCS_NL_endBoundPerc_RearAxle
Definition: CASESystem.h:72
float TCS_NL_startBoundPerc_RearAxle
Definition: CASESystem.h:71
bool useTractionControl
Definition: CASESystem.h:29
bool useDecoupledYawBrakes
Definition: CASESystem.h:32
float yaw_pid_brakes_p
Definition: CASESystem.h:43
float tcsSLThreshold
Definition: CASESystem.h:34
float TCS_SL_endBound_Rear
Definition: CASESystem.h:81
float TCS_SL_NLPerc_startBound_Front
Definition: CASESystem.h:82
float TCSGenLeftRightDiffUpperBound
Definition: CASESystem.h:64
float launchSL_startBound_Front
Definition: CASESystem.h:74
float max_regen_torque
Definition: CASESystem.h:88
float yawPIDVelThreshold
Definition: CASESystem.h:41
float DriveTorquePercentFront
Definition: CASESystem.h:52
float TCS_NL_endBoundPerc_FrontAxle
Definition: CASESystem.h:70
float tcs_pid_upper_rpm_rear
Definition: CASESystem.h:59
float TCS_SL_NLPerc_startBound_Rear
Definition: CASESystem.h:84
float launchLeftRightMaxDiff
Definition: CASESystem.h:55
float tcsVelThreshold
Definition: CASESystem.h:38
bool useNL_TCS_SlipSchedule
Definition: CASESystem.h:73
bool useTCSLimitedYawPID
Definition: CASESystem.h:27
float yawPIDErrorThreshold
Definition: CASESystem.h:40
Stores setpoints for a command to the Drivetrain, containing speed and torque setpoints for each moto...
generic data vector type that can be used with tire and / or anything to do with 4 corners of the car...
Definition: Utility.h:17