MCU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CASESystem< message_queue > Class Template Reference

this class with both take in sensor inputs as well as handle calculations for various derived states of the car. More...

#include <CASESystem.h>

Collaboration diagram for CASESystem< message_queue >:
Collaboration graph

Public Member Functions

 CASESystem ()=delete
 
 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. More...
 
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 pstate_ and returns controller result More...
 
DrivetrainCommand_s get_current_drive_command ()
 
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.accelPercent - pedals_data.regenPercent -> where accelpercent is to what percent the acellerator is pushed and the regen percent is the amount of regenerative braking currently applied More...
 
float get_rpm_setpoint (float final_torque)
 retrieves rpm setpoint based on final torque value More...
 

Private Attributes

DrivetrainCommand_s current_command_
 
CASEConfiguration config_
 
message_queue * msg_queue_
 
HT08_CASE case_
 
unsigned long vn_active_start_time_
 
unsigned long last_eval_time_
 
unsigned long vehicle_math_offset_ms_
 
unsigned long last_controller_pt1_send_time_
 
unsigned long last_controller_pt2_send_time_
 
unsigned long last_controller_pt3_send_time_
 
unsigned long last_vehm_send_time_
 
unsigned long controller_send_period_ms_
 
unsigned long lowest_priority_controller_send_period_ms_
 
unsigned long last_lowest_priority_controller_send_time_
 

Detailed Description

template<typename message_queue>
class CASESystem< message_queue >

this class with both take in sensor inputs as well as handle calculations for various derived states of the car.

Template Parameters
message_queuethe msg queue that is being used with the underlying msging interfaces

Definition at line 96 of file CASESystem.h.

Constructor & Destructor Documentation

◆ CASESystem() [1/2]

template<typename message_queue >
CASESystem< message_queue >::CASESystem ( )
delete

◆ CASESystem() [2/2]

template<typename message_queue >
CASESystem< message_queue >::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 
)
inline

constructor for state estimator system.

Parameters
can_queuethe pointer to the message queue that will have the CAN messages put onto it
send_period_msthe period in which messages will be put into the queue to be sent in milliseconds.
vehicle_math_offset_msthe offset in ms from controller message sending that the vehicle math messages will be sent

Definition at line 104 of file CASESystem.h.

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 }
unsigned long vn_active_start_time_
Definition: CASESystem.h:181
CASEConfiguration config_
Definition: CASESystem.h:177
HT08_CASE case_
Definition: CASESystem.h:179
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
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

Member Function Documentation

◆ calculate_torque_request()

template<typename message_queue >
float CASESystem< message_queue >::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.accelPercent - pedals_data.regenPercent -> where accelpercent is to what percent the acellerator is pushed and the regen percent is the amount of regenerative braking currently applied

Parameters
pedals_datahas accel and regen percent
max_torquenot used right now
max_regen_torqueused for calculation of torque request
max_rpmnot used right now
Returns
float representing the calculated request

◆ evaluate()

template<typename message_queue >
DrivetrainCommand_s CASESystem< message_queue >::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 pstate_ and returns controller result

Parameters
tickcurrent system tick
body_velocity_msbody velocity vector
yaw_rate_radsyaw rate in rad / s
steering_normsteering value between -1 and 1 ish
wheel_rpmswheel rpms
pedals_datacurrent pedals data
load_cell_valsload cell forces in N
power_kwcurrent electrical power in kilo-watts
reset_integralbool of whether or not to reset integral term
Returns
controller output

◆ get_current_drive_command()

template<typename message_queue >
DrivetrainCommand_s CASESystem< message_queue >::get_current_drive_command ( )
inline

Definition at line 149 of file CASESystem.h.

149{ return current_command_; }
DrivetrainCommand_s current_command_
Definition: CASESystem.h:176

◆ get_rpm_setpoint()

template<typename message_queue >
float CASESystem< message_queue >::get_rpm_setpoint ( float  final_torque)
inline

retrieves rpm setpoint based on final torque value

Parameters
floatfinal_torque
Returns
The maximum RPM from the case configuration if torque is positive, otherwise 0.

Definition at line 163 of file CASESystem.h.

164 {
165 if (final_torque > 0)
166 {
167 return config_.max_rpm;
168 }
169 else
170 {
171 return 0;
172 }
173 }

Member Data Documentation

◆ case_

template<typename message_queue >
HT08_CASE CASESystem< message_queue >::case_
private

Definition at line 179 of file CASESystem.h.

◆ config_

template<typename message_queue >
CASEConfiguration CASESystem< message_queue >::config_
private

Definition at line 177 of file CASESystem.h.

◆ controller_send_period_ms_

template<typename message_queue >
unsigned long CASESystem< message_queue >::controller_send_period_ms_
private

Definition at line 181 of file CASESystem.h.

◆ current_command_

template<typename message_queue >
DrivetrainCommand_s CASESystem< message_queue >::current_command_
private

Definition at line 176 of file CASESystem.h.

◆ last_controller_pt1_send_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_controller_pt1_send_time_
private

Definition at line 181 of file CASESystem.h.

◆ last_controller_pt2_send_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_controller_pt2_send_time_
private

Definition at line 181 of file CASESystem.h.

◆ last_controller_pt3_send_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_controller_pt3_send_time_
private

Definition at line 181 of file CASESystem.h.

◆ last_eval_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_eval_time_
private

Definition at line 181 of file CASESystem.h.

◆ last_lowest_priority_controller_send_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_lowest_priority_controller_send_time_
private

Definition at line 181 of file CASESystem.h.

◆ last_vehm_send_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::last_vehm_send_time_
private

Definition at line 181 of file CASESystem.h.

◆ lowest_priority_controller_send_period_ms_

template<typename message_queue >
unsigned long CASESystem< message_queue >::lowest_priority_controller_send_period_ms_
private

Definition at line 181 of file CASESystem.h.

◆ msg_queue_

template<typename message_queue >
message_queue* CASESystem< message_queue >::msg_queue_
private

Definition at line 178 of file CASESystem.h.

◆ vehicle_math_offset_ms_

template<typename message_queue >
unsigned long CASESystem< message_queue >::vehicle_math_offset_ms_
private

Definition at line 181 of file CASESystem.h.

◆ vn_active_start_time_

template<typename message_queue >
unsigned long CASESystem< message_queue >::vn_active_start_time_
private

Definition at line 181 of file CASESystem.h.


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