/ariot2016

Raiders of the Lost Pi's solution.

Primary LanguagePython

Arctic IoT Challenge 2016

Raiders of the Lost Pi

Welcome to our drone/RasPi repo. Our front-end repo is at: https://github.com/magnusbae/raider-cc-ui

The Concept

In a tunnel or a mine shaft, an accident can potentially cause very dangerous situations and even fatalities. The time from a collision to the situation is under control is critical. The first thing an accident responder team will have to do is map out the situation. In a tunnel, gases and fire can prevent a team from going into the tunnel. Dangerous gases from a fire can behave differently in a tunnel because of chemical properties, some rising and others sinking.

Norway has a lot of long tunnels, some over 20 kilometers. Connectivity in a tunnel is, as we all know, usually not very good. Laying out internet connection to cover the whole tunnel might be very costly.

Our solution: Tunnel Raiders

The Solution

Tunnel Raiders are Parrot AR Drones, the idea is to control the drones through the internet using a Raspberry Pi 2 and performing REST calls, the drones are equipped with various sensors to analyze the tunnels. A Node.js Express server for the Parrot AR Drone 2.0. The server uses the node-ar-drone and ardrone-autonomy libraries to fly the drone with REST calls.

Getting Started

  1. SSH into a Raspberry Pi and clone this repository.
  2. Download and install Node.js.
  3. Start up cmd or terminal and execute the following command:

npm install

This installs the following framework and libraries:

  • Express framework, which is a lightweight version of Node.js.
  • nodemon, which monitors changes in the server source code and automatically restarts the server.
  • node-ar-drone library: This library is used to fly the drone.
  • ardrone-autonomy library: This library helps us automate the drone, for instance, enabling us to send predefined flying coordinates.
Sensors!

We are using SensorTag to analyze data inside the tunnels. The Raspberry Pi connects to the SensorTag through bluetooth:

  1. Run the install.sh script.
  2. node sensortag-irtemp.js to start the SensorTag

PS: All the steps above are run on the Raspberry Pi device, through SSH.

Connecting to the Drone through a Raspberry Pi using SSH

Once the drone is turned on, it will send out WiFi signals like a router. Connect your Pi to the drone via WiFi. Like a router, the drone uses the IP 192.168.1.1 by default.

Start up an SSH shell, connect to the Pi, navigate to repl.js and execute the following command:

nodemon repl.js

This establishes a connection to the (default) IP of the drone at 192.168.1.1. While connected to the drone, in terminal, execute the following command:

takeoff()

This takes off the drone, and it will start hovering in the air. Land the drone by executing the following command:

land()

There are many other commands you can experiment with, more information provided here.

Flying the Drone with REST Calls

Now that we are able to establish a connection to the drone and test fly it, we are now ready to control it with REST calls using Node.js. Start up cmd or terminal and navigate to node_server.js, then execute the following command:

nodemon node_server.js

This establishes a connection to the drone and starts up a local express Node.js server at port 1337. As you can see in node_server.js, we have defined serveral GET requests. Start up your browser and go to http://localhost:1337, you should be greeted by the message Welcome to my Parrot AR node server!

Try to control the drone by sending GET requests to your local Node.js server:

  • http://localhost:1337/takeoff takes off the drone, starts hovering it for 5 seconds and then lands it.
  • http://localhost:1337/takeoffAndSpin takes off the drone, starts hovering it for 4 seconds, spins it clockwise and then lands it after 1 second.
  • http://localhost:1337/land lands the drone immediately.

Automating the Drone Flight Path (NOT SAFE)

We can also automate the flight path of the drone, by providing predefined x,y coordinates. You can do this by doing a call to http://localhost:1337/takeoffAndFly and then appending the call with the coordinates. Here is an example:

  • http://localhost:1337/takeoffAndFly?c=8,5&c=4,5 takes off the drone, flies it to x,y coordinates [8,5], [4,5] and then lands it.