Struct 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)
10async fn fly() -> Result<()> {
11    let drone = Tello::new()
12        .wait_for_wifi().await?;
13
14    let mut options = TelloOptions::default();
15
16    // we want state updates...
17    let mut state_receiver = options.with_state();
18
19    // ...so spawn task to receive them
20    tokio::spawn(async move {
21        loop {
22            let state = state_receiver.recv().await.unwrap();
23            println!("STATE {state:#?}");
24        }
25    });
26
27    // connect using these options
28    let drone = drone.connect_with(options).await?;
29
30    // go!
31    drone.take_off().await?;
32    drone.turn_clockwise(360).await?;
33    drone.land().await?;
34
35    Ok(())
36}
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)
7async fn main() {
8    let mut options = TelloOptions::default();
9
10    // we want video...
11    let mut video_receiver = options.with_video();
12
13    tokio::spawn(async move {
14        loop {
15            let frame = video_receiver.recv().await;
16            println!("video frame: {frame:?}");
17        }
18    });
19
20    fly(options).await.unwrap();
21
22}
More examples
Hide additional examples
examples/show_video.rs (line 17)
13fn main() {
14    let mut options = TelloOptions::default();
15
16    // we want video...
17    let video_receiver = options.with_video();
18
19    // run async Tokio runtime in a thread...
20    std::thread::spawn(move || {
21        let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
22            .enable_all()
23            .build()
24            .unwrap();
25
26        tokio_runtime.block_on(async {
27            fly(options).await.unwrap();
28        });
29    });
30
31    // ...because SDL must run on the main thread
32    run_gui(video_receiver).unwrap();
33}
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)
29fn main() {
30    let mut options = TelloOptions::default();
31
32    // we want to send commands...
33    let command_sender = options.with_command();
34
35    // run async Tokio runtime in a thread...
36    std::thread::spawn(move || {
37        let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
38            .enable_all()
39            .build()
40            .unwrap();
41
42        tokio_runtime.block_on(async {
43            fly(options).await.unwrap();
44        });
45    });
46
47    run_control(command_sender).expect("failed to run control");
48}

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.