Skip to content

Commit

Permalink
add readme, add speed gauges
Browse files Browse the repository at this point in the history
  • Loading branch information
mixaal committed Aug 15, 2024
1 parent 3bb10a1 commit 50148d1
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install SDL2
run: sudo apt install -y libsdl2-gfx-dev libsdl2-image-dev libsdl2-dev libsdl2-ttf-dev
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test --verbose
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# rust-tello-contoller
Control DJI Ryze Tello from rust with XBOX gamepad

## Quick Start

```bash
sudo apt install libsdl2-gfx-dev libsdl2-image-dev libsdl2-dev libsdl2-ttf-dev
cargo run
```


## Gauge Description

from left to right, from top to bottom:
* battery; drone temperature, approx 75 is red; Vx, Vy, Vz; Wifi signal strength
* sensitvity setup; video screen ; light health
* left stick; yaw; horizon; flight log; right stick
* taken pictures carousel


![ui](doc/ui.png)


## Handling

* `A` - take picture
* `B` - toggle video on/off (default is off)
* `X` - zoom in image on the carousel
* `Horiz` - left/right - rotate the carousel
* `Left stick` - forward/slide
* `Right stick` - turn left/right
* `RT` - move up
* `LT` - move down
* `RB` - sensitivity up
* `LB` - sensitivity down
53 changes: 50 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{

use rust_gamepad::gamepad::{self, Gamepad, GamepadState};
use rust_sdl_ui::{
color::RgbColor,
desktop::{self, CommonWidgetProps, RawImage},
sdl,
};
Expand Down Expand Up @@ -59,8 +60,8 @@ impl UI {

let video = desktop::VideoWidget::new(
CommonWidgetProps::new(&canvas)
.place(0.5, 0.3)
.size(0.4, 0.3),
.place(0.5, 0.38)
.size(0.4, 0.5),
&mut canvas,
960,
720,
Expand Down Expand Up @@ -93,7 +94,7 @@ impl UI {
.on_window(&mut win);

let vert_thrust = desktop::VertThrustWidget::new(
CommonWidgetProps::new(&canvas).place(0.2, 0.2).rect(0.1),
CommonWidgetProps::new(&canvas).place(0.1, 0.2).rect(0.1),
)
.on_window(&mut win);

Expand Down Expand Up @@ -134,6 +135,40 @@ impl UI {
)
.on_window(&mut win);

let temperature = desktop::VertThrustWidget::new(
CommonWidgetProps::new(&canvas).place(0.25, 0.2).rect(0.1),
)
.on_window(&mut win);

let vx = desktop::VertThrustWidget::new(
CommonWidgetProps::new(&canvas).place(0.4, 0.1).rect(0.05),
)
.on_window(&mut win);
let vy = desktop::VertThrustWidget::new(
CommonWidgetProps::new(&canvas).place(0.5, 0.1).rect(0.05),
)
.on_window(&mut win);
let vz = desktop::VertThrustWidget::new(
CommonWidgetProps::new(&canvas).place(0.6, 0.1).rect(0.05),
)
.on_window(&mut win);

let flight_log = desktop::FlightLogWidget::new(
CommonWidgetProps::new(&canvas).place(0.65, 0.7).rect(0.12),
)
.on_window(&mut win);

let mut t = temperature.write().unwrap();
t.set_color1(RgbColor::new(0.0, 0.3, 1.0, 1.0));
t.set_color2(RgbColor::new(1.0, 0.0, 0.0, 1.0));
t.set(0.0);
t.set_color_scale_factor(0.65);
t.set_scale(0.01);
drop(t);
vx.write().unwrap().set_scale(0.05);
vy.write().unwrap().set_scale(0.05);
vz.write().unwrap().set_scale(0.05);

sensitivity.write().unwrap().inc();
let mut last_state = GamepadState::initial();
while playing {
Expand Down Expand Up @@ -178,6 +213,18 @@ impl UI {
imu.yaw as f32,
);
drone_yaw.write().unwrap().set(imu.yaw as f32);
temperature.write().unwrap().set(-imu.temperature as f32);
}
if let Some(mvo) = &log_record.mvo {
if let Some(v_x) = mvo.vx {
vx.write().unwrap().set(-v_x as f32);
}
if let Some(v_y) = mvo.vy {
vy.write().unwrap().set(-v_y as f32);
}
if let Some(v_z) = mvo.vz {
vz.write().unwrap().set(-v_z as f32);
}
}
}
drop(g_data);
Expand Down

0 comments on commit 50148d1

Please sign in to comment.