really basic and bad NON PID controller
This commit is contained in:
parent
3e331d9b83
commit
937a203e15
|
|
@ -1,7 +1,7 @@
|
|||
use macroquad::prelude::*;
|
||||
|
||||
const MOVE_SPEED: f32 = 1.0;
|
||||
const LOOK_SPEED: f32 = 0.1;
|
||||
const LOOK_SPEED: f32 = 0.01;
|
||||
|
||||
pub struct FirstPersonCamera {
|
||||
pub position: Vec3,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use rapier3d::prelude as rp;
|
|||
use crate::engine::{ColliderExtraData, World};
|
||||
|
||||
pub mod controller;
|
||||
pub mod fpvcontroller;
|
||||
use controller::*;
|
||||
|
||||
pub struct MotorCharacteristics {
|
||||
|
|
@ -17,6 +18,9 @@ impl Default for MotorCharacteristics {
|
|||
Self {
|
||||
/*
|
||||
* Motor position indices
|
||||
* ^ - Front
|
||||
* |
|
||||
* |
|
||||
* 1 --- 0
|
||||
* | |
|
||||
* | |
|
||||
|
|
@ -125,6 +129,8 @@ impl Drone {
|
|||
rp::vector![0.0, -torque, 0.0]
|
||||
};
|
||||
drone_rb.add_torque(torque, true);
|
||||
println!("Torque: \n{:?}", torque);
|
||||
println!("Thrust: \n{:?}", thrust);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
23
src/main.rs
23
src/main.rs
|
|
@ -10,7 +10,7 @@ mod rendering;
|
|||
|
||||
mod graphics_util;
|
||||
|
||||
use crate::rendering::Renderer;
|
||||
use crate::{drone::fpvcontroller::JoystickInput, rendering::Renderer};
|
||||
|
||||
fn window_conf() -> mq::Conf {
|
||||
mq::Conf {
|
||||
|
|
@ -18,7 +18,7 @@ fn window_conf() -> mq::Conf {
|
|||
window_resizable: true,
|
||||
// fullscreen: true,
|
||||
platform: mq::miniquad::conf::Platform {
|
||||
linux_backend: mq::miniquad::conf::LinuxBackend::WaylandOnly,
|
||||
// linux_backend: mq::miniquad::conf::LinuxBackend::WaylandOnly,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
|
|
@ -44,11 +44,19 @@ async fn main() {
|
|||
None,
|
||||
);
|
||||
|
||||
let mut controller = drone::fpvcontroller::FPVController::default();
|
||||
controller.set_input(JoystickInput {
|
||||
throttle_input: 0.25,
|
||||
yaw_input: 0.0,
|
||||
roll_input: 0.0,
|
||||
pitch_input: 0.05,
|
||||
});
|
||||
let mut drone = drone::Drone::new(
|
||||
&mut world,
|
||||
Box::new(drone::controller::DefaultController::new(1.0)),
|
||||
Box::new(controller),
|
||||
drone::MotorCharacteristics {
|
||||
max_thrust: 2.0 * 3.5 * 0.25,
|
||||
max_thrust: 20.0,
|
||||
max_torque: 2.0,
|
||||
..Default::default()
|
||||
},
|
||||
0.350,
|
||||
|
|
@ -76,13 +84,16 @@ async fn main() {
|
|||
|
||||
// Physics
|
||||
world.step();
|
||||
drone.process_tick(&mut world);
|
||||
let _ = clearscreen::clear();
|
||||
drone.process_tick(&mut world);
|
||||
println!(
|
||||
"{:}",
|
||||
world.bodies.get(drone.rb_handle).unwrap().translation()
|
||||
);
|
||||
println!("{:?}", drone.controller.get_motor_throttles());
|
||||
println!(
|
||||
"Motor Throttles: {:?}",
|
||||
drone.controller.get_motor_throttles()
|
||||
);
|
||||
|
||||
// Rendering
|
||||
renderer.draw(&mut world);
|
||||
|
|
|
|||
Loading…
Reference in New Issue