MCU
Loading...
Searching...
No Matches
DrivebrainController.h
Go to the documentation of this file.
1#ifndef __DRIVEBRAINCONTROLLER_H__
2#define __DRIVEBRAINCONTROLLER_H__
3
5#include "DrivebrainData.h"
6#include "BaseController.h"
7#include "SharedDataTypes.h"
8#include <cmath>
9
10// TODO - [x] need to validate that the times that are apparent in the drivebrain data
11// and ensure that they are within tolerence to current sys-tick
12
13// TODO - [x] if the drivebrain controller is currently the active controller,
14// the latency fault should be latching
15
16// meaning that if we fail any of the latency checks while active we cannot clear the timing failure fault
17// unless we switch to another controller and back again. in reality, the CAN line or ethernet conditions
18// probably wont improve randomly during runtime so it will keep faulting. primarily this is just to make sure
19// we dont keep going from latent to not latent while driving and thus the driver gets jittered and the
20// drivetrain will keep "powering up" and "powering down"
21
22// TODO - [x] correctly measure latency between drivebrain and MCU
23//
24// measure latency by subtracting the latest MCU millis stamped message from the drivebrain from the
25// current system millis to
26
27
53{
54public:
55
60 ControllerMode_e assigned_controller_mode = ControllerMode_e::MODE_4)
61 : _emergency_control(1.0f, 1.0f)
62 {
66 }
67
72
76
77private:
78 struct
79 {
80 unsigned long allowed_latency;
83
86 bool _timing_failure = false;
87 unsigned long _last_setpoint_millis = -1;
89};
90
91#endif // __DRIVEBRAINCONTROLLER_H__
ControllerMode_e
Base class for all controllers, which define drivetrain command containing different variations of
Drivebrain Controller for fail-safe pass-through control of the car RESPONSIBILITIES AND DOCUMENTATIO...
struct DrivebrainController::@0 _params
unsigned long _last_worst_latency_timestamp
DrivebrainController(unsigned long allowed_latency, ControllerMode_e assigned_controller_mode=ControllerMode_e::MODE_4)
constructor for the drivebrain controller class
TorqueControllerOutput_s evaluate(const SharedCarState_s &state)
evaluate function for running the business logic
bool get_timing_failure_status()
getter for the current status of whether or not the controller has had a timing failure during operat...
unsigned long _last_setpoint_millis
ControllerMode_e assigned_controller_mode
TorqueControllerSimple _emergency_control
car state struct that contains state of everything about the car including
Packages drivetrain command with ready boolean to give feedback on controller successfully evaluating...