Changed internal PID math

The system new reduces itself by 1000 internally before output,
hopefully making the precision much higher (IE NOT needing to use tiny
ass inputs to make anything reasonable)
This commit is contained in:
2026-06-13 13:53:22 -05:00
parent 19bbcfd7ab
commit 16107036e7
+4 -4
View File
@@ -38,14 +38,14 @@ impl PID {
integral: 0.0, integral: 0.0,
prev_error: 0.0, prev_error: 0.0,
set_point: 0.0, set_point: 0.0,
output: 0.0 output: 0.0,
} }
} }
} }
impl Default for PID { impl Default for PID {
fn default() -> Self { fn default() -> Self {
PID::new(Config{ PID::new(Config {
kp: 0.0, kp: 0.0,
ki: 0.0, ki: 0.0,
kd: 0.0, kd: 0.0,
@@ -93,9 +93,9 @@ impl PID {
//Calculate and store the output //Calculate and store the output
let output = match self.config.accel { let output = match self.config.accel {
0.0 => f + p + i + d, 0.0 => (f + p + i + d) * 0.0001,
_ => { _ => {
let pre_output = f + p + i + d; let pre_output = (f + p + i + d) * 0.0001;
let change = pre_output - self.output; let change = pre_output - self.output;
let change = change.clamp(-self.config.accel, self.config.accel); let change = change.clamp(-self.config.accel, self.config.accel);