Skip to main content

Building Autonomous Drone with Raspberry Pi and APM 2.8

I am a total newbie to hardware and was pushing my limits to see how far I can reach on with hardware projects (which sparked my interest lately). I have set out on a very ambitions mission to control a drone from raspberry pi.I began the research for this around 2 months ago and had brought a raspberry pi, drone body kit and apm flight controller. The key difference of this project from common drone projects is that I'm trying to avoid the use of and RC and instead use the raspberry pi to control it. 

Hardware Installation Setup:

  • I am using APM 2.8 and Mission Planner.
  • I am using RPi 3 to control the APM 2.8 via Telem port of APM
  • I am planning to power the apm via the battery to ESC (Electronic Speed Controllers)

Now, documenting my steps below:

Day 1

Watch Tutorial

To get started with APM flight controller, I watched this video tutorial [1] which gives a gentle introduction about APM board. 

Setup APM board and Calibrate Sensors

I downloaded the APM Mission Planner software for mac and installed the firmware for quadcoper. Then, the accelerometer and compass were calibrated. It was easier than what is explained in [1] may be because I'm using the latest version of mission planner.

Read Tutorial

After going through numerous forum discussions and other videos. I was a bit confused about the connection link between APM and RPi. Finally I bumped into a good tutorial [2]. 

APM after calibration

Day 2

I'm currently wasting time on deciding if I should proceed with raspbian OS [3] or ROS [2] to be installed in raspberry.

Day 5

I decided to go ahead with raspbian but was finding no success with connection to raspberry using mavlink when I do the steps in [2] i.e.

  1. Install dependency softwares in raspbian
  2. Change params via Mission Control
  3. Run 'arm throttle' from rpi

Revelation 1: Power APM via Battery from ESC (not via USB)

Finally after 2 days of trial and error I noticed a slide in [2] saying that the Telem/UART connection won't work if I am powering APM using usb cable. So I started trying to run the APM on battery power. For this you have to connect battery to ESC and connect the ESC to the APM output pins. But the APM was not turning on no matter what I do I just get a message like "Waiting for heartbeat from /dev/ttyAMA0" 

Revelation 2: Connect the JP Circuit in APM when you power via OUTPUTS

After spending another day trying to fix it I came across a blogpost [4] with the power line path highlighted. You can notice that the OUTPUTS line is independent of the other links. So in order to power the full APM I may have to connect the JP1 pins together. And yes I remember getting a connector that fits exactly there when I purchased the APM. I gave it a try and yes! it works!

Now lets try the messaging again!
It works, I'm getting the heartbeat. yay!

But the param set ARMING_CHECK command doesn't seem to work. :(

Revelation 3 : Downgrade mavproxy version to 1.5.2

Now as per [5] & [6] I am running 'sudo pip install -I MAVProxy==1.5.2'
Waiting...... YES! THIS DID THE TRICK! 

Posting my very success log printing below at the bottom of this page [log]





root@raspberrypi:/home/pi# --master=/dev/ttyAMA0 --baudrate 57600 --aircraft MyCopter
Connect /dev/ttyAMA0 source_system=255
no script MyCopter/mavinit.scr
Log Directory: MyCopter/logs/2017-07-03/flight4
Telemetry log: MyCopter/logs/2017-07-03/flight4/flight.tlog
MAV> Waiting for heartbeat from /dev/ttyAMA0

y to FLY online system 1
APM: ArduCopter V3.2.1 (36b405fb)
APM: Frame: QUAD
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
Received 306 parameters
Saved 306 parameters to MyCopter/logs/2017-07-03/flight4/mav.parm
fence breach
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
param show APM: PreArm: RC not calibrated
APM: PreArm: RC not calibrated
ARMING_APM: PreArm: RC not calibrated
parAPM: PreArm: RC not calibrated
STABILIZE> Unknown command 'pa'
APM: PreArm: RC not calibrated
param set ARMING_CHECK 0
Init GyroAPM: Initialising APM...
**APM: Calibrating barometer
APM: barometer calibration complete
arm throttle
STABILIZE> Got MAVLink msg: COMMAND_ACK {command : 400, result : 0}
APM: Initialising APM...

Popular posts from this blog

ICFAI Sikkim Distance MBA Review From My Experience

After a long research I joined for the ICFAI distance MBA program in 2012. Now I've completed 2 semesters ( as of 2013 ). I wanted to write this review so that people who are looking for a good MBA program can get a hand-on review about the distance MBA offered by the ICFAI Sikkim. I've been through all the cycles of this program and this review might help you make the right choice about the program. This article presents my own ( and unbiased ) view of the program and is in no way associated with the course provider.

Is the MBA ICFAI Sikkim Approved By UGC?  As per the latest AICTE regulations, a distance education program must have the approval of a joint commission of  UGC- University Grant CommissionAICTE- All Indian Council for Technical EducationDEC- Distance Education CouncilICFAI Sikkim doesn't have this approval (don't get disappointed, it's not over yet). Only institutes and colleges affiliated to a University are required to take AICTE approval. So ICFAI be…

Best Places To Eat at Trivandrum

Are you searching for the most amazing places to eat at Trivandrum? Well, this article is a collection of places from where I've carried the taste after eating. All of them are located in Trivandrum. There is no specific focus for a single kind or restaurant, I've written about the latest hot-spot cafes to ethnic and traditional places at the heart of the city and people for decades.
General Places Azad Hotel Azad Hotel is a hotel-chain all over India and they are one of the best hotels in Trivandrum too. They claim to have introduced the popular dish 'biriyani' in India. However, they provide a good ambience and tasty food. There are all kind of popular non-vegetarian dishes available here. They have a long tradition of serving quality food and that's what makes them the best. There are
Zam Zam This is the most sought after destination in city for the best cooked chicken dishes. The 'Shawai' is the all time best seller of Zam Zam. It's very rushy alwa…

Is MacBook Air Good For Programming / Blogging ?

I'm a passionate java developer who just migrated from a Windows PC netbook ( Dell mini ) to a 13 inch MacBook Air. Before the netbook I owned a Dell inspirion 1501. I'm quite a bit of an avid blogger as well. I purchased Dell mini just as it was launched hoping that it's compact and mobile architecture would solve all of my need as a programmer and a writer. Unfortunately it turned out that it was a worthless device.The rest of the story goes...

Do Not Compare a Netbook With MacBook AirMacBook's astonishing features far exceeds anything that of a normal Netbook.Before
Buying a netbook for programming and blogging was one of the biggest blunders I ever made on choosing a machine. The screen was 11 inch and clumsy icons of the Windows were a disgrace all the time.The tightly arranged keys in the keyboard made typing a pain. It's slow Intel Atom Processor is too sluggish to run even VLC player.

After  The Mac's backlit spacious keyboard layout, 1440x900 resolution d…