Struct tello_edu::TelloOptions
source · pub struct TelloOptions {
pub state_sender: Option<UnboundedSender<TelloState>>,
}Expand description
Tello drone connection and other usage options.
Fields§
§state_sender: Option<UnboundedSender<TelloState>>Implementations§
source§impl TelloOptions
impl TelloOptions
sourcepub fn with_state(&mut self) -> UnboundedReceiver<TelloState>
pub fn with_state(&mut self) -> UnboundedReceiver<TelloState>
Request state udpates 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(())
}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