From 4a805547405d2f7d83459bf6bfcd83dc56d87199 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Fri, 17 Feb 2023 21:53:34 -0800 Subject: [PATCH] add pitch_scale for pid controller --- src/action/components.rs | 2 +- src/action/systems.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/action/components.rs b/src/action/components.rs index 34cf983..be3cf5b 100644 --- a/src/action/components.rs +++ b/src/action/components.rs @@ -85,7 +85,7 @@ impl Default for CatControllerState { pitch_prev: Default::default(), decay_factor: 0.99, roll_limit: 1.5, - pitch_limit: 0.8, + pitch_limit: 0.2, } } } diff --git a/src/action/systems.rs b/src/action/systems.rs index 37ab2e9..1aba8f6 100644 --- a/src/action/systems.rs +++ b/src/action/systems.rs @@ -16,6 +16,8 @@ use crate::{ input::InputState, }; +const PITCH_SCALE: f32 = 0.2; + /// Disable gravity in Rapier. pub(super) fn zero_gravity(mut config: ResMut) { config.gravity = Vec3::ZERO; @@ -46,7 +48,7 @@ pub(super) fn falling_cat( let wright = xform.forward().cross(wup).normalize(); let roll_error = wright.dot(bike_up); - let pitch_error = wup.dot(xform.back()); + let pitch_error = wup.dot(xform.back()) * PITCH_SCALE; // only try to correct roll if we're not totally vertical if pitch_error.abs() < 0.8 {