#drone #parrot #ar-drone

parrot_ar_drone

This is a Rust API to control Parrot AR Drone 2.0

4 releases

0.1.3 Mar 24, 2020
0.1.2 Mar 24, 2020
0.1.1 Feb 23, 2020
0.1.0 Feb 10, 2020

#2 in #parrot

GPL-3.0-or-later

46KB
883 lines

parrot_ar_drone

Introduction

This is a Rust API to control Parrot AR Drone 2.0. It is based upon ps_drone (the Python API), and may be taken down if the author of that API requires it (hopefully not).

Cargo

parrot_ar_drone = "0.1.0"

Example Code

    use parrot_ar_drone::*;
    use navdata::NavDataValue;
    use std::{time, thread};

    fn main() {
        let mut drone = get_drone();
        
        let test_result = drone.startup();
        match test_result {
            Ok(()) => {
                println!("Drone connection successful.");
                thread::sleep(time::Duration::from_secs(3)); // It is advised to wait a bit for the connections to establish.
                drone.trim();
                let mut i = 0;
                drone.takeoff();
                loop {
                    thread::sleep(time::Duration::from_secs(1));
                    match drone.get_navdata("demo_battery") {
                        Some(NavDataValue::Uint(a)) => { println!("Battery: {}%", a); }
                        _ => { println!("Battery status unknown!"); }
                    }
                    match drone.get_navdata("header_seq_num") {
                        Some(NavDataValue::Uint(a)) => { println!("Seq num: {}", a); }
                        _ => { println!("Seq num unknown!"); }
                    }

                    match drone.get_navdata("demo_altitude") {
                        Some(NavDataValue::Int(a)) => { println!("Alt: {}", a); }
                        _ => { println!("Altitude unknown!"); }
                    }
                    i += 1;
                    if i == 10 {
                        break;
                    }
                }
                drone.land();
                drone.shutdown();
            }
            _ => {}
        }
    }

Dependencies

~1.5MB
~21K SLoC