Struct tello_edu::TelloOptions

source ·
pub struct TelloOptions { /* private fields */ }
Expand description

Tello drone connection and other usage options.

Implementations§

source§

impl TelloOptions

source

pub fn with_state(&mut self) -> TelloStateReceiver

Request state updates from the drone.

nb As messages are sent to the UDP broadcast address 0.0.0.0 this only works in AP mode, ie using the drone’s own WiFi network

Returns the receiver end of the channel used to pass on updates

Examples found in repository?
examples/drone_state.rs (line 17)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
async fn fly() -> Result<()> {
    let drone = Tello::new()
        .wait_for_wifi().await?;

    let mut options = TelloOptions::default();

    // we want state updates...
    let mut state_receiver = options.with_state();

    // ...so spawn task to receive them
    tokio::spawn(async move {
        loop {
            let state = state_receiver.recv().await.unwrap();
            println!("STATE {state:#?}");
        }
    });

    // connect using these options
    let drone = drone.connect_with(options).await?;

    // go!
    drone.take_off().await?;
    drone.turn_clockwise(360).await?;
    drone.land().await?;

    Ok(())
}
source

pub fn with_video(&mut self) -> TelloVideoReceiver

Request video from the drone as a stream of h264-encoded 720p YUV frames.

nb As messages are sent to the UDP broadcast address 0.0.0.0 this only works in AP mode, ie using the drone’s own WiFi network

Returns the receiver end of the channel used to pass on frames

Examples found in repository?
examples/receive_video.rs (line 11)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
async fn main() {
    let mut options = TelloOptions::default();

    // we want video...
    let mut video_receiver = options.with_video();

    tokio::spawn(async move {
        loop {
            let frame = video_receiver.recv().await;
            println!("video frame: {frame:?}");
        }
    });

    fly(options).await.unwrap();

}
More examples
Hide additional examples
examples/show_video.rs (line 17)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let mut options = TelloOptions::default();

    // we want video...
    let video_receiver = options.with_video();

    // run async Tokio runtime in a thread...
    std::thread::spawn(move || {
        let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .unwrap();

        tokio_runtime.block_on(async {
            fly(options).await.unwrap();
        });
    });

    // ...because SDL must run on the main thread
    run_gui(video_receiver).unwrap();
}
source

pub fn with_command(&mut self) -> TelloCommandSender

Returns the sender end of a channel for issuing commands to the drone, eg for a remote control application.

Examples found in repository?
examples/remote_control.rs (line 33)
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn main() {
    let mut options = TelloOptions::default();

    // we want to send commands...
    let command_sender = options.with_command();

    // run async Tokio runtime in a thread...
    std::thread::spawn(move || {
        let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .unwrap();

        tokio_runtime.block_on(async {
            fly(options).await.unwrap();
        });
    });

    run_control(command_sender).expect("failed to run control");
}

Trait Implementations§

source§

impl Default for TelloOptions

source§

fn default() -> TelloOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.