pub struct Tello<S = NoWifi> { /* private fields */ }Expand description
For interacting with the Tello EDU drone using the simple text-based UDP protocol.
The basic flow from the user’s point of view is
SEND command → drone does something → RECEIVE response when it’s finished
Messages are plain ASCII text, eg command forward 10 → response ok
use tello_edu::{Tello, Result};
#[tokio::main]
async fn main() {
fly().await.unwrap();
}
async fn fly() -> Result<()> {
// create a new drone in the `NoWifi` state
let drone = Tello::new();
// wait until the host computer joins the drone's WiFi network
// (joining the network is not automatic - how it happens is up to you)
let drone = drone.wait_for_wifi().await?;
// establish connection and put the drone in "command" mode
let drone = drone.connect().await?;
// fly!
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}Implementations§
source§impl Tello<NoWifi>
impl Tello<NoWifi>
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new drone in a completely unconnected state.
Examples found in repository?
More examples
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
async fn wifi_wait_for_connection() -> Result<()>{
let drone = Tello::new();
println!("Created drone: {drone:?}");
let drone = drone.wait_for_wifi().await?;
println!("WiFi available, drone is now: {drone:?}");
let drone = drone.connect().await?;
println!("connected, drone is now: {drone:?}");
let drone = drone.disconnect();
println!("disconnected, drone is now: {drone:?}");
Ok(())
}sourcepub async fn wait_for_wifi(&self) -> Result<Tello<Disconnected>>
pub async fn wait_for_wifi(&self) -> Result<Tello<Disconnected>>
Wait until the host joins the drone’s WiFi network
nb exactly how the the network is joined is up to you
Examples found in repository?
More examples
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
async fn wifi_wait_for_connection() -> Result<()>{
let drone = Tello::new();
println!("Created drone: {drone:?}");
let drone = drone.wait_for_wifi().await?;
println!("WiFi available, drone is now: {drone:?}");
let drone = drone.connect().await?;
println!("connected, drone is now: {drone:?}");
let drone = drone.disconnect();
println!("disconnected, drone is now: {drone:?}");
Ok(())
}source§impl Tello<Disconnected>
impl Tello<Disconnected>
sourcepub async fn connect(&self) -> Result<Tello<Connected>>
pub async fn connect(&self) -> Result<Tello<Connected>>
Examples found in repository?
More examples
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
async fn wifi_wait_for_connection() -> Result<()>{
let drone = Tello::new();
println!("Created drone: {drone:?}");
let drone = drone.wait_for_wifi().await?;
println!("WiFi available, drone is now: {drone:?}");
let drone = drone.connect().await?;
println!("connected, drone is now: {drone:?}");
let drone = drone.disconnect();
println!("disconnected, drone is now: {drone:?}");
Ok(())
}source§impl Tello<Connected>
impl Tello<Connected>
sourcepub fn disconnect(&self) -> Tello<Disconnected>
pub fn disconnect(&self) -> Tello<Disconnected>
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
async fn wifi_wait_for_connection() -> Result<()>{
let drone = Tello::new();
println!("Created drone: {drone:?}");
let drone = drone.wait_for_wifi().await?;
println!("WiFi available, drone is now: {drone:?}");
let drone = drone.connect().await?;
println!("connected, drone is now: {drone:?}");
let drone = drone.disconnect();
println!("disconnected, drone is now: {drone:?}");
Ok(())
}sourcepub async fn send(&self, command: &str) -> Result<String>
pub async fn send(&self, command: &str) -> Result<String>
Sends a command to the drone using the simple Tello UDP protocol, returning the reponse.
The basic flow from the user’s point of view is
SEND command → drone does something → RECEIVE response when it’s finished
Messages are plain ASCII text, eg command forward 10 → response ok
commandthe command to send, must be a valid Tello SDK command string
sourcepub async fn send_expect_ok(&self, command: &str) -> Result<()>
pub async fn send_expect_ok(&self, command: &str) -> Result<()>
Sends a command, resolving to an error if the response is not “ok”
commandthe command to send, must be a valid Tello SDK command string
sourcepub async fn send_expect_nothing(&self, command: &str) -> Result<()>
pub async fn send_expect_nothing(&self, command: &str) -> Result<()>
Sends a command, expecting no response at all from the drone.
commandthe command to send, must be a valid Tello SDK command string
sourcepub async fn query_battery(&self) -> Result<u8>
pub async fn query_battery(&self) -> Result<u8>
Queries the drone battery level as a percentage.
sourcepub async fn emergency_stop(&self) -> Result<()>
pub async fn emergency_stop(&self) -> Result<()>
Immediately stop all motors
warning! this will make the drone drop like a brick
sourcepub async fn take_off(&self) -> Result<()>
pub async fn take_off(&self) -> Result<()>
Take off and hover.
Examples found in repository?
More examples
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn land(&self) -> Result<()>
pub async fn land(&self) -> Result<()>
Land and stop motors
Examples found in repository?
More examples
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn turn_clockwise(&self, degrees: u16) -> Result<()>
pub async fn turn_clockwise(&self, degrees: u16) -> Result<()>
Turn clockwise.
degreesAngle in degrees 1-360°
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.turn_clockwise(360).await?;
drone.land().await?;
Ok(())
}sourcepub async fn turn_counterclockwise(&self, degrees: u16) -> Result<()>
pub async fn turn_counterclockwise(&self, degrees: u16) -> Result<()>
Turn counter-clockwise.
degreesAngle in degrees 1-360°
sourcepub async fn move_up(&self, distance: i16) -> Result<()>
pub async fn move_up(&self, distance: i16) -> Result<()>
Move straight up.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn move_down(&self, distance: i16) -> Result<()>
pub async fn move_down(&self, distance: i16) -> Result<()>
Move straight down.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn move_left(&self, distance: i16) -> Result<()>
pub async fn move_left(&self, distance: i16) -> Result<()>
Move straight left.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn move_right(&self, distance: i16) -> Result<()>
pub async fn move_right(&self, distance: i16) -> Result<()>
Move straight right.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn move_forward(&self, distance: i16) -> Result<()>
pub async fn move_forward(&self, distance: i16) -> Result<()>
Move straight forwards.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}sourcepub async fn move_back(&self, distance: i16) -> Result<()>
pub async fn move_back(&self, distance: i16) -> Result<()>
Move straight backwards.
distanceDistance to travel, 20-500 cm
Examples found in repository?
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn fly() -> Result<()> {
let drone = Tello::new()
.wait_for_wifi().await?;
let drone = drone.connect().await?;
drone.take_off().await?;
drone.move_up(50).await?;
drone.move_down(50).await?;
drone.move_left(50).await?;
drone.move_right(50).await?;
drone.move_forward(50).await?;
drone.move_back(50).await?;
drone.land().await?;
Ok(())
}