Showing posts with label Drones. Show all posts
Showing posts with label Drones. Show all posts

Wednesday, June 7, 2017

Setting up a Drone Programming Environment using DroneKit on Windows 7

1) Download and install APM Planner 2 for Windows.
2) Download and install Python 2.7 for  Windows. Make sure the following options are set.
    1. Install for all users
    2. Destination directory: C:\Python2.7
    3. Add python.exe to Path
3) Open a command prompt (cmd.exe) to test if the installation was successful.
    1. >python -V
4) Install virtualenv
    1.  >pip install virtualenv
5) Create and activate the dronekit virtual environment.
    1. >md SRG-Bots 
    2. >cd SRG-Bots
    3. >virtualenv dronekit_env
    4. >dronekit_env\Scripts\activate.bat
6) Install the required packages. This may take a while.
    1. >pip install dronekit dronekit-sitl mavproxy wget
7) At this point the required packages have been installed. Start dronekit-sitl.
    1. >dronekit_env\Scripts\dronekit-sitl.exe copter-3.3
8) Open a new command prompt then run mavproxy.
    1. >cd SRG-Bots
    2. >dronekit_env\Scripts\activate.bat
    3. >python dronekit_env\Scripts\mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551
9) Run APM Planner 2.
10) Open a new command prompt. Download and run an example.
    1. >cd SRG-Bots
    2. >dronekit_env\Scripts\activate.bat
    3. >python
    4. >>>import wget
    5. >>>wget.download('https://github.com/dronekit/dronekit-python/raw/master/examples/simple_goto/simple_goto.py')
    6. >>>quit()
    7. >python simple_goto.py --connect "udp:127.0.0.1:14551"


Thursday, September 29, 2016

Setting up a Drone Programming Environment using DroneKit on Ubuntu 16.04

This guide describes how to setup an environment for programming drones using DroneKit. The main requirement is an Ubuntu 16.04 box. Using this environment will allow testing of code before they are run on an actual drone. To run the code on a drone, simply update the connection parameters.

The procedure will require four terminals which will be used for different purposes. In the steps that follow, SRG-Bots is the working directory.

Terminal Zero - Used for installing the required packages 

$cd ~/Downloads
$wget  http://firmware.eu.ardupilot.org/Tools/APMPlanner/apm_planner2_2.0.23_ubuntu_xenial64.deb
$sudo dpkg -i apm_planner*.deb
$sudo apt-get -f install
$sudo dpkg -i apm_planner*.deb
$sudo apt-get install python-pip
$pip install virtualenv
$mkdir SRG-Bots
$cd SRG-Bots
$virtualenv dronekit_env
$source dronekit_env/bin/activate
$pip install dronekit dronekit-sitl mavproxy

 
Terminal One -  and running the simulator

$cd SRG-Bots
$source dronekit_env/bin/activate
$dronekit-sitl copter

In case the initialization is taking too long, you can reset the simulation.
$dronekit-sitl--reset


Terminal Two - Used to allow multiple connections on the drone

$cd SRG-Bots
$source dronekit_env/bin/activate 
$mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 127.0.0.1:14550 --out 127.0.0.1:14551

Terminal Three - Used to run APM Planner


$apmplanner2

Go to the menu, then select Communications -> Add Link -> UDP. Set the UDP Port field to 14550. Connection to the copter will be established.

Terminal Four - Used to run programs

$cd SRG-Bots
$source dronekit_env/bin/activate
$wget https://github.com/dronekit/dronekit-python/raw/master/examples/simple_goto/simple_goto.py
$python simple_goto.py --connect "udp:127.0.0.1:14551"

You can observe the behavior of the drone on the APM Planner as the code gets executed.


Monday, August 29, 2016

Drone 101

We have been lucky to be awarded with some funds to buy some drone kits. Since July, I spent my weekends playing around with the Erle-Copter assigned to me which I named Red-SRG-Bot. This kit is powered by Linux and therefore opens up a lot of possibilities programmatically. I have a presentation that documents my activities in this area and another for an extension work. Below is a video of one of our outdoor flight tests.