Git Product home page Git Product logo

krodik / ardroneautopylot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simondlevy/ardroneautopylot

0.0 2.0 0.0 55.46 MB

Auto-Pilot the Parrot AR.Drone from Python (or Matlab or C)

Home Page: http://home.wlu.edu/~levys/software/ardrone_autopylot/

License: GNU Lesser General Public License v3.0

C 72.32% Objective-C 6.06% C++ 0.52% Makefile 17.13% Shell 0.21% Prolog 0.04% Perl 0.05% Assembly 3.46% Verilog 0.01% CSS 0.03% HTML 0.14% Python 0.02% MATLAB 0.01%

ardroneautopylot's Introduction

ARDroneAutoPylot

Auto-Pilot the Parrot AR.Drone from Python (or Matlab or C)

This repository contains source code for building a stubbed version of the AR.Drone AutoPylot program, which allows you to auto-pilot the Parrot AR.Drone 1.0 or 2.0 from source code written in Python, on a computer running 64-bit Ubuntu 14.04.
This video gives you an idea of what you can do with the drone in Python, using this package (see below for instructions). As the video shows, the update rate is fast enough to enable interesting experiments. With the AR.Drone 2.0 and my Sony VAIO Pro laptop, I have obtained update rates of around 30 Hz.

If you're interested in a more graphical-interface approach, you might also look into ROS.

Please note that I am only supporting this project on 64-bit Ubuntu. I do not have the resources to support other OSs.

To get started, make sure your AR.Drone has the current firmware -- easiest way is to download the current version of FreeFlight from the AppStore.

If you have a Logitech Extreme 30 Pro joystick or

Playstation PS3 controller, the only file you should need to modify immediately in the repository is the autopylot.makefile, to specify which kind of controller you have and its hexadecimal ID (which you can find by issuing the lsusb command in Linux). If you have some other kind of gamepad, like a Nintendo Wii, you'll have to modify autopylot_gamepad.c to reflect this. If you're using Python, make sure to get the Python development environment:
sudo apt-get install python-dev 

I set up the program so that the Logitech joystick axes work as follows:

Axis Stick Effect
0 Rock left/right Roll (sideways travel)
1 Rock forward/back Pitch (forward/backward travel)
2 Twist clockwise/anticlockwise Yaw (clockwise/anticlockwise turn)
5 Mini-joystick on top Altitude (forward=down; backward=up)

The Logitech buttons are labeled 1 - 12 on the joystick. I set up the program to work with them as

follows:

Button Effect
1 (trigger) Takeoff/Land
2 IN-FLIGHT EMERGENCY CUTOFF
3 Zap (toggle front/belly camera)
4 Toggle autopilot

I set up the program so that the PS3 axes work as follows:

Axis Stick Effect
0 Left-side stick left/right Roll (sideways travel)
1 Left-side stick forward/back Pitch (forward/backward travel)
2 Right-side stick left/right Yaw (clockwise/anticlockwise turn)
3 Right-side stick forward/back Altitude (forward=down; backward=up)

I set up the program to work with the PS3 buttons as follows:

Button Effect
8 (select) Exit program (IN-FLIGHT EMERGENCY CUTOFF)
9 (start) Takeoff/Land
3 (square) Zap (toggle front/belly camera)
2 (×) Toggle autopilot

These button and axis configurations can be modified by editing gamepad.c

Running the Default Program

Change to the repository directory and type make. This will build the ardrone_autopylot executable, as well as compiling the SDK (probably with a lot of warnings about type mismatches). Once you've built the program you can run it by typing ./ardrone_autopylot in the directory where you built it. The autopylot.makefile is set up to use Python, but you can modify it for Matlab or C. For Python, you should first make sure that your PYTHONPATH shell variable is set to include the current directory: either on the command line, or (better long-term solution) in your .bashrc file, put the following instruction:



export PYTHONPATH=$PYTHONPATH:.

The autopilot is intially off, so you are flying the AR.Drone manually. When you push the autopilot button (4 on the Logitech joystick, × on the PS3), control is transferred to the action function in autopylot_agent.py. Any subsequent joystick / gamepad action returns control to you, providing an emergency override. The function in autopylot_agent.py currently ignores the video and navigation data input and just makes the drone turn clockwise. (I've noticed that the program can take several seconds to report non-zero navigation data from the drone.) Note that the altitude and X/Y velocities are approixmate, and that the minimum reported altitude is around 230 mm. You can modify this function to do something more interesting.

The file autopylot_agent.m contains Matlab code equivalent to the Python code in autopylot_agent.py. To run the Matlab version, comment-out the Python lines (36-38) in autopylot.makefile, and un-comment the Matlab lines (45-47). you should have the following in your .bashrc file:



export MATLAB=/usr/local/MATLAB/R2013a # or whatever release you've installed



export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLAB/bin/glnxa64

You will also need the csh command, which is used by the Matlab Engine. To be sure you have this command, do sudo apt-get install csh in your Ubuntu shell.

If you prefer to program in C, comment-out the Python lines in autopylot.makefile, un-comment the C lines (50-51), and work with the code in autopylot_c_agent.c.

To run the example in the video, download greenball_tracker.py and this version of autopylot_agent.py. You will need OpenCV for Python, which you can install by following the instructions here.

Copyright and licensing information can be found in the header of each source file. Please contact me with any questions or suggestions.

ardroneautopylot's People

Contributors

simondlevy avatar

Watchers

James Cloos avatar Angel Martínez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.