before input redesign
This commit is contained in:
parent
249f319309
commit
e776c641b5
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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 },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue