My thoughts on tech, stuff, and nonsense.

Category Archives: Drogon Quadcopter

Drogon’s not dead! While it’s been over a year since my last post on the topic, I have been working away. Although I went most of the year without touching it, the pace has picked back up over the last few months and I’ve worked through a number of changes and improvements.

The only hardware change was swapping out the frame for a new Q450 V3 Fiberglass Quadcopter Frame (450mm) from Hobby King. It’s a bit smaller but lighter. So far I really like it. All the electronics are the same.

First, I had attempted to ditch the transmitter/receiver a bit too early in development, relying completely on wifi and the Raspberry Pi. This required a lot of support software that took away from the more important, and fun, flight control software. It ended up being too much of a distraction, so back on the receiver went. I re-integrated the receiver code and back on track I was. On the plus side I now have streaming video to an Android app from the Raspberry Pi’s camera. I also swapped out the Java code on the Pi to a new Python app (It’s all in my Github repos). All it’s really doing now is capturing logs from the Arduino and providing video streaming.

Next, I developed a self-tuning addition to the PID algorithm. This should hopefully be saving time and producing a better tuned PI. It still requires manual tuning to get it started, which I’m working through now, but progress is being made. I also re-calibrated the accelerometer-gyroscope relationship and how the data is pulled into a single position, so I am getting much better and cleaner data. I also incorporated rotational correction. This uses the Gyroscopes Z-axis by increasing opposite motors and decreasing the other opposite motors to control and take advantage of the motor/propeller torque.

The last major area was in test rigs. I’ve gone through a few iterations of test rigs. The first test rig I used, which is in my first videos, was tethering to the floor. This had several issues in not giving the quadcopter enough freedom of motion and significantly impacted flight. The second test rig I used was hanging from the ceiling. This was much better at providing more range of motion, but still had issues in giving it too much freedom while still having too much effect on flight. My current test rig is now a balance beam. It is basically two 2x4s perpendicular to each other, with one raised slightly. This works well with my current frame. When I get the PID tuning working well, I may graduate to the hanging rig (hanging, with pulleys to small weight to pull slack).

I decided to create a Wiki for the Drogon Quadcopter project to have something that is better suited for that type of content. Blog posts on the topic will stay at joemonti.org, but all information, documentation, etc will be at drogonquad.com. Just in case you forgot:

It has been too long since my last update, so here is what’s been going on. Up to my last update where I was testing under full manual control I was in a hurry to get the robot running. In that, I was successful. I got the hardware assembled, access to the hardware via the Arduino, and verified it all worked. The next big step was to develop the flight control software to keep the robot stable in flight and to be able to move where I want it to move. That is what I am working on now.

I have made a few attempts at flight, mostly tethered. There was one untethered test with unsuccessful results although I did get off the ground for the first time which I was not able to do under manual control:

The flight control algorithm approach I am using has three components:

Continual Learning — Measures success of PID Control to make adjustments to PID algorithm parameters.

I am approaching these components in order, with as much flight testing as I consider safe during the process to work out bugs, see how it performs, and gather data. I plan on developing a relatively simple Position algorithm so I can develop the PID Control algorithm and model the best PID algorithm parameters I am able to manually tune. Hopefully with that I will get more flight data to improve the Position algorithm and gather data for the Continual Learning algorithm. Then I will tackle the software for the Continual Learning algorithm. I don’t yet have a full plan for that, but I have many ideas on where to start.

The first challenge is simply getting accurate positional data from the accelerometer and gyroscope. First, the sensors measure different things. The accelerometer measures acceleration, which can give some indication of position by effect of the acceleration due to gravity since the acceleration due to gravity is constant. The gyroscope measures rotational velocity in degrees per second. Second, both are fairly noisy, especially with the motors going and the copter starts moving. Right now I have a very simple algorithm to combine the two sensors into a single angular offset of the pitch and roll (ignoring yaw for now) with a running average filter. I have also developed the main PID control algorithm, with some potential improvements to try once I get it running.

To tie these pieces together and to turn them into final motor adjustments, I have a series of translation steps that need to be made. First I have to translate the coordinate space of the robot, which is how the position of the robot is tracked, to the coordinate space of the motors because the motors are offset 45 degrees from the axis of the robot (called an “x” configuration quadcopter as opposed to a “t” configuration). This translates the position of the robot, through rotation matrices, to determine the position of each motor. To determine the error value to use in the PID algorithm, I use the arc-length of the offset of each motor from the zero-position (to achieve robot motion, instead of the zero-position, the offset will be from a target position which would cause the desired motion). Two error adjustments are calculated and applied oppositely to opposite motors by adding (or subtracting for the opposite motor) to a target motor speed. The target motor speed is currently determined by the receiver channel 3 value.

I am currently modelling the PID algorithm to guess at good PID algorithm parameters by feeding position changes into the algorithm and analyzing the results. More on this later.

As part of the development process for Drogon, I wanted the first attempt at flight to be under full manual control. I did not expect to be able to fly, I wanted to see what happened. At the very least I hoped to validate things like the motors providing enough lift and to collect sensor data to help build the stabilization algorithms.

During the manual control testing I am only working from the Arduino. The Raspberry Pi is only acting as a logger, reading the stream of sensor and control data from the Ardruino over the serial connection. The Raspberry Pi won’t really be used until I get further along with the stabilization, control, and management software.

The first set of tests were tethered to a wood pallet. The pallet is large and heavy enough to give the quadcopter a safe and restricted environment to test flight controls. In my first attempt, the tether lines were too long so it ended up just tipping over and the propellers slammed into the pallet. Fortunately it came away with no real damage.

Here’s a picture:

And here’s a short video clip:

The next tethered test was more successful. I shortened the tether lines and was able to gain lift off the ground and even verify the manual direction controls worked.

Now that the controls were validated with tethered testing, I moved on to outdoor un-tethered flight testing. As expected, full manual control did not achieve flight. Just a lot of tipping over. Below is a shorter clip from the test session.

Next steps are to begin work on the stabilization algorithm. I expect that to be a gradual process as I build out, tweak, redesign, tweak some more, and optimize the code and algorithm constants. As it stands at the time of this post I have made some progress on the stabilization algorithm and even made a few test flight attemps. I hope to write up a post on it soon. Check out my YouTube playlist with all of the test videos:

Assembly is just about complete now on the Drogon Quadcopter at least to be able to do initial flight tests. Motors and speed controllers are all mounted with the wires secured. The speed controllers have been programmed with the programming card and have been verified that they spin in the correct direction. Next steps are to finish up the coding and attempt first flight.

Here are some photos:

I did run into a few issues. The big one was that when I first hooked everything up I setup a test to make sure the motors, speed controllers, etc worked. Well, they didn’t. None of the motors from any of the four I/O pins I was using worked. I couldn’t even arm the speed controllers which I thought I had worked out. After testing everything from the control signal to the basic I/O of the I/O pins, I traced it back to not even being able to read 3.3v with a multimeter when setting the pins with digitalWrite to HIGH. I may have reversed polarity when I was first making sure everything got power. Whatever the cause, those pins (2-5) were dead. To work around the issue so I didn’t have to buy and wait for a new Arduino quite yet, I rewired the 4 pins (8-11) intended for the LEDs instead to the motors, updated the code, and right away I got the speed controllers arming and spinning up without issue. I still need to re-wire the LEDs. I added a new header to the Arduino shield to borrow 4 unused pins.

I also still need to mount the Raspberry Pi Camera module. I have the mount, screws, and standoffs. I just need to drill everything out and mount it. But I think I will hold off until I make first flight. As an alternative, how about a Google Hangout? I can mount an old Anrdoid phone on the Quadcopter. Let me know if you’d like to join the hangout.

I have started mounting and wiring more parts on Drogon. Here’s a photo:

The first is that I have mounted and wired the LEDs for each arm. They will blink relative to the speed of their corresponding motors. Also, the two front arms have red LEDs and the two back arms have green LEDs so I can better tell the front from the back. The LEDs came mounted in a small plastic housing meant to pressure fit into a hole, so I chose to drill through the arms (hopefully this wont compromise the strength too much!) so the LEDs came out the bottom. This way they would be most clearly visible while the quadcopter is above you.

Second, I had only enough screws to mount one motor (the rest are coming soon) so that is now mounted along with its speed controller. For now the wires are a little loose because I may need to reverse the direction of the motor.

Next I added the USB hub to manage power for the Raspberry Pi. And finally I made the wire and connected the serial line between the Raspberry Pi and the Arduino.

Quick project update. The boards (arduino+custom shield, RaspberryPi, and receiver) now have their holes drilled and are mounted on the frame. I also have added the rigging for the battery (rubber mat and velcro strap). Here are a few photos.

I needed to order a few additional parts for mounting motors and Raspberry Pi camera module. So now waiting on those.

The HoverDrone project has been given a new name: Drogon. Named after one of Daenerys Targaryen‘s 3 dragons, Drogon, from the A Song of Ice and Fire book series (A Game of Thrones, A Clash of Kings, and others) by George R.R. Martin. I think the name is fitting for the project, although I hope it never breaths fire (either intentionally or unintentionally). I’m not a big fan of the word “drone” given its negative connotations and implication that it is unintelligent and/or human controlled.

I have started a few new Github projects for the Drogon software systems:

Received more parts today. Most importantly the rest of the motors and speed controllers, along with some miscellaneous parts. Soldered a bunch of connectors and the wire harness. I have almost everything I need. Still waiting on another shipment of miscellaneous parts and I’m sure I’ll need more random parts as I assemble it all. I was hoping to get all of the motors and speed controllers mounted, but the motor screws I got are too long. Getting close!

Photo of the four motors/propellers….

Closeup of the wire harness to split the power from the battery to the speed controllers, Arduino, and Raspberry Pi (needs large heat shrink tube)…