instagram

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/logview.py -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.