Wednesday, December 31, 2014

More log analysis

I've written previously about using python and log parsing, which this writeup uses heavily.

I was testing position hold with the new 14 state INS the other day with Sparky2 on Seeing Spark. The new filter is working great. I ran autotune and 6 point calibration and engaged position hold and it held beautifully still. The new estimation of the z-axis accel bias worked as it should so there was no glitch in the altitude. The new magnetometer handling meant that the attitude was wonderfully locked in and not biased while tracking the heading really well. Spinning around while holding and it didn't budge a bit.

I wrote some code to calibrate the magnetometer while spinning which I think will be quite useful. It fits the data to a sphere as well as making sure the horizontal component has the appropriate magnitude (this prevents fitting to an edge condition).

You can see that the blue data (x versus y axis) quite nicely fits a circle. This is both an easier calibration procedure than 6 point and more useful since you can see the deviation from correct (the plot on the right shows the magnitude of the mag data) and the is performed with the motors running at hover. This will also work with the built in logging to flash.

Analyzing glitch

However, at one point it was just hovering and then started going to the side. I've occasionally seen things like this in the past and really wanted to get to the bottom of this. Whenever I started digging into navigation logs I typically end up writing the same lines in python over and over again. I finally decided to sit down and write a log analyzer to facilitate this.

./python/ -v TauLabs-2014-12-31_16-11-30.tll

This shows a snippet of the log file. The upper left panel shows the position and the upper right the velocity. You can see there is substantially less than a meter movement while holding and very low velocities. The bottom left shows the attitude and there are only a few degrees perturbation. The bottom right shows the gyro and shows that the quad was spinning around at the time. The interface also has a few options to toggle extra plots.

I zoomed in on when the hold deviation occurred:

What was extremely informative about this is that you can see the raw GPS position and velocity jump by a few meters at 188 seconds. Critically this occurs before the attitude deviates and not as a result of flying. Here is that time point zoomed in:

Again showing that there are clearly sample with the attitude nearly horizontal right up to the point where the bad position sample comes. In addition, you can see the INS racing to catch up (which wouldn't happen if there was a real change first since the accelerometers would sense it).

The end result of this bad position sample was the UAV flies the opposite direction to fix the perceived error. This is a tough problem since we have to trust the GPS generally to have any hope of a good position hold. It is also exactly what ArduCopter had to implement GPS glitch protection to solve. It has been extremely rare in my experience and within 2 seconds the GPS had corrected the error. However, it is definitely something where I'd like to get better logs.

Saturday, December 20, 2014

BrainFPV - cool new board using Tau Labs

I was lucky enough to get a BrainFPV from HeliShredder last week, which is a new flight controller that uses Tau Labs.

It is an impressive board with a lot of features in it's 36x36 mm size. Beyond having a full sensor suite (3-axis gyro, 3-axis accel, mag, and baro), its biggest unique feature is of course an integrated OSD.

This kind of integration also gives a lot of power - like the ability to switch OSD display modes on the fly.

I'll just paste from Brain's page for htFPV Specific Features:

FPV features:

  • Full-graphic OSD (360x266 for PAL):
    • Software adjustable black and white levels
    • PAL/NTSC autodetect
    • 4 fully user configurable OSD pages, selectable using switch on transmitter
  • Audio output (not yet supported by software)
  • 3 analog inputs for voltage, current, RSSI measurement
  • RSSI measurement using PWM, PPM, or analog input
  • Other Features:

Other features:

  • CPU: STM32F405RG (32bit, 168MHz, 192kB RAM, 1MB Flash)
  • 64Mbit flash for settings, way points, logging
  • InvenSense MPU-9250 latest generation 3-axis gyro/accel/mag
  • Barometer: MeasSpec MS5611
  • Receiver compatibility: PWM, PPM, S.Bus, DSM2, DSMX, HoTT SUMD/SUMH
  • Up to 10 PWM outputs (up to 400Hz update rate) 
  • Up to 3 serial ports for telemetry, GPS, RC receiver, etc.
  • External I2C port, can e.g. be used with an external HMC5883 compass
  • Micro USB port for configuration via PC 

Installing into MHQ Quadcopter

To test it out, I decided to use my foldable MHQ quadcopter from Steve (thingiverse link). First I had to splice a JST connector into the video line so it could plug into the BrainFPV controller.

This is the Pico camera from GetFPV with a mount that I designed to hold it in the MHQ. Then I plugged it into the BrainFPV and immediately had a nice little OSD showing.

Unfortunately my video recorder crops the edges so you can't see most of the OSD field. In the GCS you can also modify the layout, white black balance, and even switch the layout with a toggle of the switch.

HeliShredder did a nice job of fitting the OSD configuration into the configuration gadget. With it all tested, then I just had to finish reassembling my quadcopter.

It definitely makes the wiring really nice and simple having just that one board. I really need to get add a battery current/voltage sensor to this frame now, since the OSD can show that to me. I just hate soldering on the wiring harness :(

And all closed up and ready to fly. Time to practice my FPV flying ... indoors ...

You can see a bit of line noise from the motors. It is recommended to have a filter on the power line, but I don't have one at the moment. I'd recommend checking out HeliShredder's videos to better see the performance.

OSD History

I'm really stoked to see this board out there and running Tau Labs. Hopefully the hardware designs will be open sourced in the not-too-distant-future and it can become included as an official target.

Sambas (now with the LinuxDrone project) started the OSD project in 2011 back with OpenPilot. The original design had some issues and I ended up cutting up one of the prototypes to design a new way of syncing the two SPI channels together. 

The end result was we got it going, although with some issues that limited drawing to the edge of the screen and required running the microcontroller at a strange rate.

I believe some more work was done on the code subsequently, but ultimately the OSD with OpenPilot stagnated and nothing came of it. Luckily HeliShredder came along at picked up the code and ran with it. I believe he'd previously also had some experience developing on the Super-OSD project in the past.

Interestingly, he independently came up with a better way to sync the SPI channels that resolved those issues that Sambas and I had discussed way back when and it works great. There is also some nice tricks he used to also adjust the white / black balance to make sure it always looks nice that ended up an issue for us. He also did a lot of work to optimize the code so it can run with the flight controller jitter-free as well as the configuration interface to make it adjustable. 

Ultimately, this is a great example of open source where something would have otherwise died in a pile of unused code (sadly like my ESC has become) is now improved and used and I think will make a lot of people happy. Consistent with OSS principles, all his changes are available on github.

Final Thoughts

This board is going to be really popular, I suspect. Of course since it runs Tau Labs (and from my limited testing) it flies wonderful ;-) and I was able to simply import my configuration on this frame from when it was running Sparky and immediately it was tuned and flew well.

The OSD looks super crisp and sharp with good black and white levels and responds nice and quickly. I haven't even tried the modes where it shows waypoints and such, but apparently it does that. I can't wait to throw the battery monitor and GPS on there so I can see my speed, direction to home and battery status.

Between this and Gemini, I really need to spend more time FPVing.

Sunday, November 2, 2014

Seeing Spark - Sparky2 and SparkyBGC quad

Update: Sparky2 is available here

One of my longer term goals for a while is a system that can chase me around and film my friends and myself having fun. This seems to be a trendy topic this year with piles of kickstarter projects about this, so I won't pretend this is a unique idea. However I finally have something that is getting close. You can find this on Thingiverse.


Some of my recent boards have been coming together towards this aim (see this post for a longer discussion of boards and some history). Sparky BGC is a cleaned up revision on my previous daughter board for Sparky (providing BGC outputs to a normal Sparky) and adding an external sensor board for light weight gimbals. It also drops the whole thing into the standard 36x36 mm board size which makes it very convenient to stack up with a Sparky.

Tau Link is a miniature radio board that works with the Tau Labs Android GCS for telemetry. I ended up doing another revision that shrinks it down and adds a male USB connector which is more convenient when quickly plugging into an OTG cable or laptop.

Sparky 2 is a pretty major overhaul of Sparky 1, adding lots more IO and processing power, as well as radio capabilities which is convenient for communicating with Tau Link and ground stations.

One of the nice things about Sparky2 and SparkyBGC is that they both support CAN which provides a robust high-speed bidirectional communication bus between both boards. This means that Sparky2 (or Sparky1) can tell the gimbal about the desired angle to a position of interest for the camera.

Through discussion on IRC recently, I also realized that means it is possible to pass the heading measurements from the magnetometer on the gimbal (which is often fairly far from the motors) back to the flight controller to provide an external magnetometer for free. I'm pretty excited to try this.

All this means that the android application can easily pass the tablet or phone location up to the UAV, which can then point the camera at that location and acquire nice stabilized video. I have a few multirotors with gimbals that could be used for testing this, but they are all big and less conveinent for testing, so it was design time!

Power distro

I also really wanted to try out KISS ESC18A, which are tiny little things and also do not provide a BEC outputs. That seemed like a great motivator to make a power distro board that would route the PWM signals to these little ESCs and provide 5V to the flight controller. This board also provides current and voltage monitoring back to Sparky2 and comes in at just a hair below 30mm square.

You can see the wires for current voltage monitoring coming off the top, and for the ESC outputs below. The extra two outputs at the bottom at 5V and 0V. The footprints align to the KISS ESCs but can also be connected to any other ESCs. The connections for the PWM line are routed quite carefully around the edge to not obscure the power planes.

Frame Design

The goal was something about as small as I could achieve that could carry a mobius camera and stabilize it with the above hardware. I started with something similar in my mind as Flying Spark. I wanted a closed canopy over most of the hardware with the battery on the inside.  I also wanted the gimbal integrated into the main body to keep it compact.

 It wasn't possible to design a solid body that could hold all the components that could be assembled as a single piece. One thing I ended up doing to get it quite compact was to make a recessed pocket in the main body for the ESCs and PDB and hand the flight controller and gimbal controller from the top of the canopy, and then printing it upside down.

The arms have a little protective hub around the motors and a channel for the wires to run into the body.

The cables then go into the central body to the ESCs.

Here are the ESCs and power distribution board installed into the body of the frame.

And then Sparky2 and SparkyBGC installed into the bottom of the canopy and connected to the PDB ESCs and battery/voltage measurements.

And then covers placed over the boards and PDB to keep the battery away from them.

And here is the integrated gimbal on the front with the SparkyBGC sensor mounted to the top.

Camera Control

The camera is stabilized via the SparkyBGC board. This communicates via CAN (which is a nice high speed bidirectional bus) to the Sparky2 board. This allows information from Sparky2 to control the camera angle. For example, you can set it up to only correct part of the flight controller roll which creates a smooth video that still shows some of the action. You can also set up the pitch to be controlled via a slider or switch from the transmitter that is relayed via the flight controller.

Finally, you can also use the Tau Labs Android GCS to talk to the flight controller and pass the location of the phone or tablet. The FC then calculates the heading and camera pitch to focus on that point of interest and tracks it. This doesn't work perfectly because the phone GPS is sometimes noisy or slow, but generally works quite well. You can also work around this by directly dragging and moving the POI location rather than tracking the tablet.

Final Assembly and Flights

Here you can see it all put together.

And with an updated canopy that has smoother lines:

Here it is being used to do some simple point of interest tracking to my phone, being held by my lovely assistant.

Crashing :D

This quad got plenty of crashing :). You can see in the long video at the end where I plowed it into the ground upside down. The result was two broken arms:

I also had a good time taking it out this weekend. My friends dog also absolutely loved chasing it (he loves running). I'm still not the best at flying backwards at high speeds while leading a dog, though. One of the earlier flights I caught a tree enough to unscrew a prop nut. It landed flat enough and unharmed. Unfortunately despite ten minutes of a number of us looking, we couldn't find the nut and I foolishly forgot spares.

I turns out you can use a spacer screwed on with camping tongs to get airborne again :D

Unfortunately, that only lasted too long until I backed into another tree, this time much higher...

So back to the 3D printer. I think I might try and smooth some of the curves in the canopy anyway, and possibly reinforce the walls some more.

Friday, October 31, 2014

Gemini (powered by Tau Labs) tear down and review

One of the more exciting added in the latest Tau Labs release is support for the Colibri flight controller. This is the flight controller that is used in the Gemini hexcopter (designed in collaboration with an awesome designer William Thielicke of shrediquette fame). I've been lucky enough to have access to a Gemini for several weeks now for development and wanted to write up my thoughts.

Here is a video of me flying which also shows you the ground station and some chase shots. It uses some early PID settings and is a bit wobbly.

And here is a video from TBS that is better tuned and flies more smoothly:

The short version is impressive. What impresses me most is the level of system integration involved. This is what you get when you design the whole system for a purpose, rather than taking parts and figuring out how to put them together. In a way, this is the type of achievement we had hoped people would do from day one with CopterControl - creating something that is elegant and easy to fly.


Ok, this is the first time I have had a real "unboxing" experience with a multirotor. Probably because I never get prebuilt systems, but this was great. It comes in a slick traveling case, nicely embossed with a TBS logo and a hexcopter symbol.

Inside I found Gemini, spare props and the FPV antenna. The whole system was already wired up and ready to go (except for the receiver). I'm assuming the production versions will come enclosed in the canopy, but mine did not have one.


So here you see it! A very compact elegant setup.

And a side view shows the tilted motors. This is really well done with the frame material actually conformed to hold the motors at the right angle. I dread to think the cost of setting up prototypes of this. Despite the shaping, the frame feels incredibly strong.

The motors are tiny little T-Motors. Basically the size of my thumb. What is really nice is that the ESC wiring is integrated into the frame. This means no confusing which lead is which and no ugly wires to try and hide. You can also see the little OrangeRX satellite receiver I'm using in this shot. Also, the mount for the mobius camera is evident and hanging from the frame by four vibration damping mounts (with the tie wrap I use to secure it).

I also really like the elastic strap for mounting the battery. In the early photo you can see there is a little plastic stick through the ends of it on the top to secure it, rather than wrapping it around everything. Attention to detail is obvious in this design.

The arms also come with vibration dampeners between the frame and the motor mount. This two stage vibration isolation (arm and then at camera) works really well for larger frames and I think contributes to the video quality I'm getting. Plus higher RPM motors just produce much less jello.

You can also see that the motors attach to the frame wiring via JST connectors. Again, a nice detail focus was keeping the pinout the same for each motor and handling the lead swapping in the PCB layout. This makes sure no one can get confused. I will comment that the final version uses the opposite motor direction as our default orientation, so if you are configuring from scratch one must remember to reverse the motor directions in software. However, most people will use the configuration file provided by TBS and not need to deal with this.

Flight Controller and electronics

Colibri is a really small flight controller designed by Team Black Sheet that takes the Quanton design (by lilvinz of Quantec) and shrinks it down. TBS did the right thing from day 1 here - they approached Lilvinz and asked to make a derivative of his CC-BY-SA-NC design and he acquiesced. This is open source working the right way!

As you can see the board uses microtouch connectors. It is a really small design, but still packs in the full suite of barometer, magnetometer, 3-axis accel and 3-axis gyro and flash. The breakout headers give access to all the Quanton IO so in principle it supports 8 channels in and out, as well as a number of serial and I2C ports. Here it is compared to a quarter. Sorry non-Americans, this might not mean much to you.

The approach of a high-density powerful flight controller is not ideal for end users making their own frames, but is absolutely perfect for this custom, focused, miniatured design that doesn't want to sacrifice features. Kudos to TBS for the work required to miniature this design so much.

This board then sits on an IO board that breaks out the wire from Colibri for use on Gemini. This IO board has the 6 bulletproof ESCs, an receiver port breakout (supports PWM, PPM, DSM2/X, SBus) and a second serial port which can be used for telemetry or GPS. You can see the wire going to my OrangeRX satellite in the lower right.

Here is a closer front view of the electronics. You can see the TBS UNIFY 5.8 GHz 200mW transmitter connected to the TBS Core and the camera. It is hard to appreciate in this photo, but all of this is mounted as a plastic sub assembly to hold and mount the camera, support the vibration damping to the mobius, and provide the vertical support for the VTX. Again, a nice custom solution that got everything needed into a compact space.

And here are the electronics viewed from the back. This gives you another nice view of the 6 ESCs in parallel. The board mount approach is really space efficient and again contributes nicely to the compactness of the design. 

And lifting up Colibri reveals some nice foam used to protect the barometer from turbulence and get a clean measurement. The flight controller makes a very nice firm fit on these headers, despite the number of times I've had it on and off.

And finally the whole IO board can be lifted up to show the ESC connections from the bottom. The connections to the main frame is done through a series of standard 100-mil spaced headers. This routes the cables from the ESCs into the main frame wiring, as well as providing power to the IO breakout board.

You can see in this photos the soldered connections to the ESCs. It will be interesting to see how easy that is to remove and replace. The board mounts protrude 1 or 2 millimeters past the board which might make it easier to break the connection. However, it might be that a bit of flux and braid are required to really free them up. Either way, it wouldn't be worth the increased height and weight to have a connector for each ESC.

Finally the integrated wiring into the frame mentioned above is really nice. I'm not entirely sure the process that went into making a PCB laminate and then applying it to the frame with the twisted motors. The motor wires do run on straight segments of the frame, so perhaps that helped. Anyway, I don't envy the cloners who are trying to rush an mimic this process.

Crash resistance

Well I've only flown this for an hour or two. However, I have already done a good job of crashing it. One thing I'm less used to (flying mostly quads) is that it does a great job of crashing into things. I flew into a tree while in altitude hold mode and the flight controller totally recovered and had me floating in clear sky. 

I tried teaching a friend to fly it under a tree and only lost a prop.

I flew into a tree about 10 feet up and just had to pick it up and replace a prop.

Finally, I flew it at full throttle (probably 35+mph) into the bottom side of a bridge. Completely misjudged the height by a foot. I really expected to be picking up pieces, but in the end nothing important was damaged. The bolts holding the front two motors sheared. The frame was entirely intact. All electronics are ESC traces are good. Even the motor connectors on the frame are still attached. The plastic assembly that holds the flight camera either needs some glue or replacing. Overally, I was shocked by how minimal the damage was.


Ultimately, I am very impressed with this frame. There are a lot of fairly novel (if not entirely unique) concepts here that aren't in many frames. The integrated wiring with the frame as a PDB is pretty uncommon in anything this size (obviously things like Crazyflie have done it) and makes the lines really slick looking, not to mention aerodynamic. The twisted motors I first saw in William Thielicke's shreddiquette designs and they have done a nice job of taking that into a custom warped frame. 

The level of integration with the tiny Colibri flight controller, IO board that with integrated ESC connections and then the breakout into the frame is what really impresses me. This was all made custom for Gemini and just makes the whole thing light, compact, and probably quite robust to crashing. I also haven't see this approach to integration in any frame running open source software (maybe some proprietary frames are similar?).

A big congratulations to Team Black Sheep for making an awesome product and I'm glad they wanted to use Tau Labs to really get the most out of it. I'm sure this will be extremely popular with pilots and hopefully as a trickle down effect we will get some people active in the TL community.