-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoThrottle.h
44 lines (34 loc) · 1.08 KB
/
AutoThrottle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef AUTOTHROTTLE_H
#define AUTOTHROTTLE_H
#include <Arduino.h>
#include "AutoTunePID.h"
class AutoThrottle {
public:
// Constructor
AutoThrottle(float minThrottle, float maxThrottle, TuningMethod method = ZieglerNichols);
// Configuration methods
void setTargetSpeed(float targetSpeed);
void updateCurrentSpeed(float currentSpeed);
float computeThrottle();
void reset(); // Reset PID and throttle
// Advanced Configuration
void setTuningMethod(TuningMethod method);
void setManualGains(float kp, float ki, float kd);
void enableThrottleSmoothing(bool enable, float rampRate = 5.0);
// Status and debugging
float getThrottle() const;
bool isStable(float tolerance = 0.1) const;
private:
// AutoTunePID instance
AutoTunePID _pid;
// Throttle and speed parameters
float _input, _output, _setpoint;
float _minThrottle, _maxThrottle;
// Smoothing settings
bool _smoothingEnabled;
float _rampRate;
float _currentThrottle;
// Helper methods
float applyThrottleSmoothing(float desiredThrottle);
};
#endif