created acceleration controller. not implemented yet. forgot files
This commit is contained in:
parent
6225173006
commit
55fbc7830a
|
|
@ -28,6 +28,8 @@ pub struct ControllerStackConfig {
|
||||||
/// PID for the rotation (angle → angular rate) layer
|
/// PID for the rotation (angle → angular rate) layer
|
||||||
pub rotation_pid: PidConfig,
|
pub rotation_pid: PidConfig,
|
||||||
|
|
||||||
|
pub acceleration_pid: PidConfig,
|
||||||
|
|
||||||
/// PID for the angular rate (angular rate → torque) layer
|
/// PID for the angular rate (angular rate → torque) layer
|
||||||
pub rate_pid: PidConfig,
|
pub rate_pid: PidConfig,
|
||||||
/// Maximum angular rate (rad/s) that joystick input maps to
|
/// Maximum angular rate (rad/s) that joystick input maps to
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,13 @@ pub struct PositionInput {
|
||||||
pub alt: f32,
|
pub alt: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct AccelerationInput {
|
||||||
|
pub x: f32,
|
||||||
|
pub y: f32,
|
||||||
|
pub z: f32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Default, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct RotationInput {
|
pub struct RotationInput {
|
||||||
pub roll: f32,
|
pub roll: f32,
|
||||||
|
|
@ -31,14 +38,16 @@ pub enum ModeInput {
|
||||||
#[default]
|
#[default]
|
||||||
Acro,
|
Acro,
|
||||||
Rotation,
|
Rotation,
|
||||||
|
Acceleration,
|
||||||
Navigation,
|
Navigation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Default, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
pub joystick: JoystickInput,
|
pub joystick: JoystickInput,
|
||||||
pub position: PositionInput,
|
pub acceleration: AccelerationInput,
|
||||||
pub rotation: RotationInput,
|
pub rotation: RotationInput,
|
||||||
|
pub position: PositionInput,
|
||||||
pub mode: ModeInput,
|
pub mode: ModeInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,9 +121,8 @@ impl InputRecording {
|
||||||
pub fn add_input_from_keyboard(&mut self, current_time: f32) -> Input {
|
pub fn add_input_from_keyboard(&mut self, current_time: f32) -> Input {
|
||||||
let input = Input {
|
let input = Input {
|
||||||
joystick: JoystickInput::from_keyboard(),
|
joystick: JoystickInput::from_keyboard(),
|
||||||
position: Default::default(),
|
|
||||||
rotation: Default::default(),
|
|
||||||
mode: ModeInput::Acro,
|
mode: ModeInput::Acro,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
let last_input = self.records.last();
|
let last_input = self.records.last();
|
||||||
match last_input {
|
match last_input {
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ use crate::config::PidConfig;
|
||||||
use crate::drone::stacked::DroneState;
|
use crate::drone::stacked::DroneState;
|
||||||
use nalgebra as na;
|
use nalgebra as na;
|
||||||
|
|
||||||
pub mod rate;
|
pub mod angular_rate;
|
||||||
pub mod rot;
|
pub mod rotation;
|
||||||
|
|
||||||
pub use rate::AngularRateController;
|
pub use angular_rate::AngularRateController;
|
||||||
pub use rot::RotationController;
|
pub use rotation::RotationController;
|
||||||
|
|
||||||
pub trait ControllerModule {
|
pub trait ControllerModule {
|
||||||
type Input: Clone + Default;
|
type Input: Clone + Default;
|
||||||
|
|
@ -61,6 +61,9 @@ pub struct Position(pub na::Vector3<f32>); // meters
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct Velocity(pub na::Vector3<f32>); // m/s
|
pub struct Velocity(pub na::Vector3<f32>); // m/s
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
|
pub struct Acceleration(pub na::Vector3<f32>); // m/s
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct Rotation(pub na::Vector3<f32>); // radians
|
pub struct Rotation(pub na::Vector3<f32>); // radians
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue