pub struct TelloOptions { /* private fields */ }
Expand description
Tello drone connection and other usage options.
Implementations§
Source§impl TelloOptions
impl TelloOptions
Sourcepub fn with_state(&mut self) -> TelloStateReceiver
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}
Sourcepub fn with_video(&mut self) -> TelloVideoReceiver
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
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}
Sourcepub fn with_command(&mut self) -> TelloCommandSender
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
impl Default for TelloOptions
Source§fn default() -> TelloOptions
fn default() -> TelloOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TelloOptions
impl RefUnwindSafe for TelloOptions
impl Send for TelloOptions
impl Sync for TelloOptions
impl Unpin for TelloOptions
impl UnwindSafe for TelloOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more