IMG_4114.JPGimage_4.jpeg

Intro

 

These days drones are getting very popular and affordable. There are numerous projects, tutorial, online shops and you can build a very simple one for couple of bucks or you can get a very sophisticated si-fi machine that can fly safely with your pricey video equipment. This tutorial is about my attempt to build a quadcopter for the purposes of IoT. I guess it is not something that you can't buy for a certain amount, but it is so much sweeter if you can build it by yourself, do experiments, POC or just have some fun. This specific one has been created for a POC and it had to be stable enough, look good and be able to carry all the prototyping devices. This is why it uses a ARF (almost ready to fly) frame and flight controller. I have a custom made quadctopter, which definitely doesn't look as good as this one.

So what a quadcopter can do for IoT? It can do really a lot of stuff. Credit cart sized computers are getting more and more powerful, so any calculations and data processing that a drone can do are increasing every day. If it was quieter, safer and had more flying time, it would be able to do even more. Here are some ideas that are on my mind and some of them are still in research - surveillance missions, topology maps, measurements, sensor data collection, manufacturing, construction building, rescue missions, emergency wireless network routers, remote telepresence robots and so on. I am sure you can think of more, because I hear new ideas every now and then.

In my case I want to start with something simple, but scalable and add functionality as this project grows.

You may wonder why I have chosen a quadcopter? It is more agile than any other robot. It doesn't care about the terrain and it can run indoors if it is small enough. It is easy to control, very flexible in flight, can carry big weights depending on the size and it is perfect for photography when in stable mode. I want to experiment with video feeds during remote missions and data collection, which makes it a good choice. Actually I have read an article recently how to transform it into a plane during a flight and increase the range/flight time, which makes it even a better choice.

I won't get into deep details of how quadcopters fly, you can read it here - http://en.wikipedia.org/wiki/Quadcopter

The project is a work in progress and the idea behind this one is illustrated here:

Slide1.jpg

 

BOM

 

Quadcopter Frame - http://www.getfpv.com/multi-rotor-frames/qav400-fpv-quad/qav400-fpv-frame-arf.html

Flight Controller Board - http://hobbyking.com/hobbyking/store/__31138__Multiwii_and_Megapirate_AIO_Flight_Controller_w_FTDI_ATmega_2560_V2_0.html

GPS - http://hobbyking.com/hobbyking/store/__31135__NEO_6M_GPS_Module.html

2x Battery - http://www.getfpv.com/lumenier-3300mah-4s-35c-lipo-battery.html

OnBoard Computer - Beaglebone Black - http://de.farnell.com/jsp/search/productdetail.jsp?sku=2422228

Camera - http://store.hermanstreet.com/electronics/logitech-c920-webcam/?&ICID=logitech-c920-2013-06-14&ofm

6x Sonar Range Finder - http://www.pololu.com/product/723  

Wireless - D-Link DWA-131

USB Hub

6 Channel Remote control with transmitter

A lot of spare propellers!

 

Build

 

So if you are about to build your custom quadcopter or you don't like the frame that I have selected, you should start looking around different configurations. The most important thing that you should care is what weight your quadcopter is going to carry apart from its own. Based on this you should select a size for the frame (this one is 400mm), which will bring you to what motors, ESC and propellers you should use. There are online calculators that you can seek for.

I was impressed by the frame that I have selected, because it has a lot of room for the components, integrated power lines inside the frame, special compartment for the ESCs, camera, battery, and something that I did not expect - vibration dampers, which decrease noise to the gyro and camera. Following the build instructions got me pretty quickly with a very cool  quadcopter frame, which is also very durable - one very important feature for a quadcopter, especially if you are a newbie.

Before writing about the flight controller and choices I will try to explain basic functions. A quadcopter has 4 motors - 2 rotating clockwise and two rotating counterclockwise. By doing so with equal speed the angular acceleration around the yaw axis (Z in xyz coordinate system) is zero, which is why it doesn't need additional motor like the helicopters. By changing the rotation speed of the individual propellers in specific configurations, the quadcopter can move in the 3D space. To have a flying machine you  need:

  1. Four motors
  2. Four propellers
  3. ESC - Electronic speed controller which you can control using PWM
  4. Frame - can be two x crossed carbon beams. You just need to attach the motors and controller somewhere.
  5. Flight controller - IC with attached gyroscope and accelerometer which translates the value from the two sensors and makes correction to the motors speed through the ESCs
  6. Battery - LIPo is the best as lightweight and high discharge rates
  7. Remote Control - there are ready sets which can work out of the box to any RC machine and provide a good range for flying. I use 6 channel one 4 for the axis and two for additional settings that the controller can accept

 

Once you have these, you just need a software and a field to start flying. Any other stuff is just addition that will make your flight easier and the machine more productive. As mentioned above you will find this configuration in many flavors around the internet. In this case I am using MultiWii software as it is developed by the community for some time and works with the most popular configurations of hardware and frames. It has enough options to make any quadcopter stable and flying. There are others as well, some are Arduino based, others are more complicated, but in this case the flight controller is just for stabilization and flight control, where any intelligence should be moved to the BeagleBone. In order to be on the safe side, the flight controller was selected to be MultiWii compatible and all required sensors embedded that the software supports. There are even projects where this is entirely implemented on the BeagleBone, but I had this MultiWii board and experience with it, so I decided to leave this functionality untouched for now and just interfere with the communication protocol.

The software is using a PID controller (PID controller - Wikipedia, the free encyclopedia) to make the adjustments to the motors speed. Every configuration for a quadcopter may need a bit of tweaking with these values in order to make it responding well with no vibrations and drift free. Fortunately MultiWii comes with a desktop application that can communicate over serial (wi-fi - uart, bluetooth module) and help with debugging sensor data or changing configurations. Both software are talking with a special protocol Multiwii Serial Protocol - MultiWii, which also supports RC commands that substitute the remote controller and something that I am planning to use over the BeagleBone.

If you setup the quadcopter as per the instructions (http://www.multiwii.com/) and also build the frame you are lucky to have the best RC toy ever I would recommend learning to fly it the normal way and try the different options to get used to the quadcopter behavior. It has specifics and surprises, but most of all – big time fun. If you select MultiWii as me, you can also use the magnetometer for a perfect heading flight, the barometer for altitude hold, the GPS for planned missions. There are software patches for Sonar + optical flow sensor altitude hold, which will make the quadcopter standing still in the air in just a meter above the ground.

Setting up the camera is a bit tricky. If you want to do photography, you should select an action cam that can record video in HD. If you want it to capture video, it is not a bad idea to have a camera gimbal as well, which will set the camera always in a horizontal position, no matter if the quadcopter is declining or steering in a direction. The video output is much more pleasant with a setup like this. The problem with these cameras is that they can’t stream real time video. Some of them have this option, but with big lag and in low range. So if you want to watch the flight through video glasses and FPV in real time, you will need a CMOS camera equipped with a transmitter (some of them are pretty powerful and illegal in some countries) and have a ground station where you can record the analog video and connect to the glasses.

In this particular setup I am trying to achieve something more. Since I want to do video processing in real time I need the video stream to be processed on the board, but also I want the ability to send it to a remote server. A particular example that might explain this is to send the quadcopter to measure the linear thermal expansion of the cables above a railway track. It will need the video stream to follow the tracks, but also send the processed data and initial analysis to an IoT router over the wireless networks (WI-FI/LTE/ZigBee), where hosted application can do further analysis on the data, such as summarize the results from all the sensors, process the video with further analytic tools and later report the compact results to the cloud. Another feature that it should have is to be able to provide a real-time data to a remote user, which is monitoring the operation. The quadcopter should also have backward communication, so in case there is a train coming to instruct it to move out of the railway.

This sounds pretty complicated, but I believe it is part of the new upcoming IoT technologies at full power. So in order to achieve a simpler scenario in this decade the quadcopter is equipped with a BeagleBone, WI-FI dongle for the prototyping purposes, a GPS, a Sonar for automatic lifting and landing and an HD Camera for the processing explained above. For stage two a second camera is expected for a 3D vision and depth measuring, more sonars to prevent collisions and a set of sensors like temperature, gas, noise to showcase how the quadcopter can gather sensor data and create histograms for particular spots.

All the software for this prototype is still in development. The quadcopter is fully functional, but not intelligent as it is expected. The first steps it should achieve is :

  1. Automatic lift off and landing – it turned out to be a tricky task. Mostly because it needs to do it smoothly and accurate. For example, if we set the height to reach to be 1 meter and auto lift off, it should use a PID controller to reach smoothly its goal. The initial tests were done using just the sonar which turned out not to be too reliable and accurate source. For example no matter how horizontal the quadcopter is, during the movement and depending on the surface it can create noise in the measurement. The pid controller can also make it erratically speed up form ground zero to its goal which might be dangerous for people. In case of sonar failure (connection breakage), the quadcopter should have a precaution code. It happened once and I was just lucky to have it grounded with a anchor during the experiments, otherwise it would be on its own increasing speed up to the sky   Another problem that I have found is that the sonar has minimum measurement of 7cm, which means it needs to be placed on higher legs. In some projects the GPS and barometer are used as a second source of altitude sensor. However the IoT quadcopter might need to work indoors like a fabric or a cave where these sensors might not work correctly, which we need to figure out how to overcome as early as possible.
  2. Remote control entirely over the network. The IoT quadcopter should have the ability to go to a remote unattended mission and user should be able to interact with it. This should be achieved with a gamepad or just command interface and keyboard.
  3. Video Streaming and processing. As mentioned above the video is one of the most important senses of an intelligent quadcopter. As for the start it should:
    1. Stream real-time HD video with h264 codec
    2. Do simple onboard processing – face recognition
    3. Based on the face it has found – adjust the position in space to keep a good focus
    4. It should recognize a single face and try to follow it or switch to a nearby one – it should not do erratic movements if it detects more than one face
    5. Limit the movement it should do while following a face
    6. Try recognizing an object using basic geometries and extract features that can be used for navigation (calibrating object > nearby object > by moving it scales and we can measure the movement based on it > next object and the path between them)
    7. Good to have 3D camera
  4. Sensor data gathering and transmit
  5. Basic machine learning based on the results from the achievements from above that will act as a second regulator on the flight decisions in the next steps


As on the picture above the final system should work like this:

  1. Motors are lifting everything based on aerodynamic forces
  2. Flight controller regulates the speed of motors to make the quadcopter fly in specific directions
  3. Flight controller receives input from embedded sensor to keep it stable and headed in specific position
  4. Flight controller receives commands over the serial interface through the specific protocol to make corrections in the flight heading
  5. Onboard computer (BBB) has a host USB where through USB hub are attached camera, WI-FI and flight controller (all this powered by the BEC inside the ESC – max 3 Amp)
  6. BBB is connected to ground control and IoT router over the WI-FI
  7. BBB is processing the video for navigation purposes (face follow), calculating the amount of change it needs – through PID controller and sending changes to the control application holding the serial connection.
  8. BBB does unicast streaming so the user can see what the copter sees
  9. BBB has open port for transmitting the data received from the flight board to the user and providing ability for the user to take over the control
  10. BBB is transmitting data for the onboard sensors – temperature, gas, so on…
  11. Ground station has the ability to change settings on the flight controller, display video stream, display results from onboard calculations, provide interface for remote control and further programming, capture all received data from the sensors and display a real-time histogram

 

Next Steps – work more on autonomous functions, better navigation, more functions and algorithms, increase range.


More pictures, videos and progress coming soon...