MCU
Loading...
Searching...
No Matches
SteeringSystem.h
Go to the documentation of this file.
1#ifndef __STEERINGSYSTEM_H__
2#define __STEERINGSYSTEM_H__
3
6#include "Filter_IIR.h"
7#include "SysClock.h"
8#include "SharedDataTypes.h"
9#include "TelemetryInterface.h"
10// Digital Encoder = Primary Sensor
11// Analog Encoder = Secondary Sensor
12
13// Definitions
14// TODO: evalaute reasonable thresholds for agreement
15#define STEERING_DIVERGENCE_ERROR_THRESHOLD (60.0) // Steering sensors can disagree by x degrees before output is considered erroneous
16#define STEERING_DIVERGENCE_WARN_THRESHOLD (8.0) // Warning condition will be raised when steering sensors diverge x degrees
17#define NUM_SENSORS 2
18#define DEFAULT_STEERING_ALPHA (0.0)
19
20
21
22// Structs
24{
25 const SysTick_s &tick;
26 const AnalogConversion_s &secondaryConversion;
27};
28
29
31{
32private:
36
45
47public:
49 : SteeringSystem(primarySensor, telemInterface, DEFAULT_STEERING_ALPHA)
50 {}
51
52 SteeringSystem(SteeringEncoderInterface *primarySensor, TelemetryInterface *telemInterface, float filterAlpha)
53 : SteeringSystem(primarySensor, telemInterface, filterAlpha, filterAlpha)
54 {}
55
56 SteeringSystem(SteeringEncoderInterface *primarySensor, TelemetryInterface *telemInterface, float filterAlphaPrimary, float filterAlphaSecondary)
57 : primarySensor_(primarySensor)
58 , telemHandle_(telemInterface)
59 {
60 steeringFilters_[0] = Filter_IIR<float>(filterAlphaPrimary);
61 steeringFilters_[1] = Filter_IIR<float>(filterAlphaSecondary);
62
63 }
64
68 void tick(const SteeringSystemTick_s &intake);
69
73 {
74 return steeringData_;
75 }
76
78 const float angle,
79 const float filteredAngleEncoder,
80 const float filteredAngleAnalog,
81 const uint8_t systemStatus,
82 const uint8_t encoderStatus,
83 const uint8_t analogSensorStatus);
84};
85
86#endif /* __STEERINGSYSTEM_H__ */
#define DEFAULT_STEERING_ALPHA
#define NUM_SENSORS
const SteeringSystemData_s & getSteeringSystemData()
Get a reference to the steering system's data.
void reportSteeringStatus(const float angle, const float filteredAngleEncoder, const float filteredAngleAnalog, const uint8_t systemStatus, const uint8_t encoderStatus, const uint8_t analogSensorStatus)
SteeringEncoderInterface * primarySensor_
TelemetryInterface * telemHandle_
float filteredAnglePrimary_
SteeringSystem(SteeringEncoderInterface *primarySensor, TelemetryInterface *telemInterface, float filterAlphaPrimary, float filterAlphaSecondary)
void tick(const SteeringSystemTick_s &intake)
Computes steering angle and status of the steering system.
SteeringSystem(SteeringEncoderInterface *primarySensor, TelemetryInterface *telemInterface, float filterAlpha)
SteeringEncoderConversion_s primaryConversion_
SteeringSystem(SteeringEncoderInterface *primarySensor, TelemetryInterface *telemInterface)
float filteredAngleSecondary_
SteeringSystemData_s steeringData_
Filter_IIR< float > steeringFilters_[NUM_SENSORS]
const AnalogConversion_s & secondaryConversion
const SysTick_s & tick