before input redesign

This commit is contained in:
franchioping 2026-02-06 18:35:23 +00:00
parent 249f319309
commit e776c641b5
4 changed files with 5 additions and 10 deletions

View File

@ -183,7 +183,8 @@ impl Drone {
let rb = world.bodies.get(self.rb_handle).unwrap(); let rb = world.bodies.get(self.rb_handle).unwrap();
self.controller.set_time(world.get_time()); self.controller.set_time(world.get_time());
// Pitch, Yaw, Roll // Pitch, Yaw, Roll
self.controller.set_angular_velocity(*rb.angvel()); self.controller
.set_angular_velocity(rb.rotation().inverse().transform_vector(&rb.angvel()));
self.controller.set_rotation(*rb.rotation()); self.controller.set_rotation(*rb.rotation());
} }

View File

@ -6,13 +6,9 @@ pub struct JoystickInput {
// Value should be between 0 and 1 // Value should be between 0 and 1
pub throttle_input: f32, pub throttle_input: f32,
// Rotation Directions: https://upload.wikimedia.org/wikipedia/commons/c/c1/Yaw_Axis_Corrected.svg pub roll_input: f32,
/*
* Values should be between -1 and 1.
*/
pub yaw_input: f32, pub yaw_input: f32,
pub pitch_input: f32, pub pitch_input: f32,
pub roll_input: f32,
} }
impl JoystickInput { impl JoystickInput {

View File

@ -58,7 +58,7 @@ impl StackedController {
Self { Self {
mixer: MotorMixer { mixer: MotorMixer {
motor_map: config.motor_map, motor_map: config.motor_map,
min_throttle: 0.0, min_throttle: 0.1,
max_throttle: 1.0, max_throttle: 1.0,
mixing_mode: mixer::MotorMixingMode::ThrottleAuthorityReasonable { min_scale: 0.5 }, mixing_mode: mixer::MotorMixingMode::ThrottleAuthorityReasonable { min_scale: 0.5 },
}, },

View File

@ -47,11 +47,9 @@ impl ControllerModule {
} else { } else {
setpoint setpoint
}; };
let rot = state.rotation;
let current = rot.inverse().transform_vector(&state.angular_velocity);
// Output of Rate PID = Desired Torque/Correction Force // Output of Rate PID = Desired Torque/Correction Force
processor.update(target_velocity, current, dt) processor.update(target_velocity, state.angular_velocity, dt)
} }
} }
} }