diff --git a/src/action/components.rs b/src/action/components.rs index 705df20..1652477 100644 --- a/src/action/components.rs +++ b/src/action/components.rs @@ -81,11 +81,8 @@ impl Default for CatControllerSettings { pub struct CatControllerState { pub roll_integral: f32, pub roll_prev: f32, - pub pitch_integral: f32, - pub pitch_prev: f32, decay_factor: f32, roll_limit: f32, - pitch_limit: f32, } impl Default for CatControllerState { @@ -93,11 +90,8 @@ impl Default for CatControllerState { Self { roll_integral: Default::default(), roll_prev: Default::default(), - pitch_integral: Default::default(), - pitch_prev: Default::default(), decay_factor: 0.99, roll_limit: 1.5, - pitch_limit: 0.1, } } } @@ -107,9 +101,6 @@ impl CatControllerState { if self.roll_integral.abs() > 0.001 { self.roll_integral *= self.decay_factor; } - if self.pitch_integral.abs() > 0.001 { - self.pitch_integral *= self.decay_factor; - } } pub fn update_roll(&mut self, error: f32, dt: f32) -> (f32, f32) { @@ -120,16 +111,7 @@ impl CatControllerState { (derivative, self.roll_integral) } - pub fn update_pitch(&mut self, error: f32, dt: f32) -> (f32, f32) { - let lim = self.pitch_limit; - self.pitch_integral = (self.pitch_integral + (error * dt)).min(lim).max(-lim); - let derivative = (error - self.pitch_prev) / dt; - self.pitch_prev = error; - (derivative, self.pitch_integral) - } - - pub fn set_integral_limits(&mut self, roll: f32, pitch: f32) { + pub fn set_integral_limits(&mut self, roll: f32) { self.roll_limit = roll; - self.pitch_limit = pitch; } } diff --git a/src/action/systems.rs b/src/action/systems.rs index 88605c9..f119bf5 100644 --- a/src/action/systems.rs +++ b/src/action/systems.rs @@ -16,8 +16,6 @@ use crate::{ input::InputState, }; -const PITCH_SCALE: f32 = 0.2; - fn yaw_to_angle(yaw: f32) -> f32 { yaw.powi(3) * FRAC_PI_4 } @@ -86,8 +84,6 @@ pub(super) fn falling_cat( let bike_right = xform.right(); - let world_right = xform.forward().cross(world_up).normalize(); - let roll_error = bike_right.dot(target_up); let pitch_error = world_up.dot(xform.back()); @@ -107,16 +103,6 @@ pub(super) fn falling_cat( } } } - - // we can do pitch correction any time, it's not coupled to roll - let scaled_pitch_error = pitch_error * PITCH_SCALE; - let (derivative, integral) = - control_vars.update_pitch(scaled_pitch_error, time.delta_seconds()); - let mag = - (settings.kp * scaled_pitch_error) + (settings.ki * integral) + (settings.kd * derivative); - if mag.is_finite() { - forces.torque += world_right * mag; - } } /// Apply forces to the cyberbike as a result of input.