Trust in Software

I had some fun with the Quad this evening.  I’ve been flying it in my father-in-law garden (the only fairly large private space that I have access to) testing the new 2 axis gimbal and the fake SJ4000 that I was given by Rob.  The first flight went really well, but I wasn’t doing anything more advanced than hovering in loiter mode and giving it a bit of yaw now and then.  Everything was fine (except for the stupid hard landing)

I went out about an hour later to have another go.  Immediately I’d noticed that the wind had picked up, but if I kept fairly low, this shouldn’t be a problem, and certainly not outside the envelope.  I armed in stabilise mode and took off in Loiter.  Everything looked really sweet so I let the altitude climb a little to get a nice aerial of the garden. I probably went up to about 15m (I’ve not checked the logs yet) and did two slow spins in yaw.  It was obvious the the wind was pushing the quad around quite a lot, but the GPS seems solid and Loiter was holding position nicely. I decided to come down.

Nothing happened.

My first thought was that the wind was quite blustery and must be keeping the quad aloft, so I dropped the throttle even more, in fact, I had it right down, but the quad still hung there, perhaps coming down very slowly, but certainly not listening to me. Adrenaline was pumping and figuring the best thing to do now was to try and remove any autonomous behaviour from the FC, I went back to stabilise mode.

Despite the heart thumping adrenaline, I had the presence of mind to put the throttle back up to mid stick, so that the quad wouldn’t just fall out of the sky.  Nothing. The quad still hung there.  It was still coming down very slowly and was probably about 10m when dramatically, and 5 or so seconds after commanding it, stabilise kicked in.

What happened next is never going to be a coherent story, I was panicked and outside my range of experiences with quad flying. Despite having about 50% throttle, the quad came down rapidly, not quite free fall or autorotation, but far faster than I’d hoped for.  It hit the edge branches of a small tree at about 5m which knocked it off level and it hit the ground hard but still upright, breaking both front leg extensions and burying the gopro clone lens down in the lawn.  The damage looked not much more than cosmetic so I started breathing again and pushed the throttle down and to the left to disarm, as the props were still spinning.

But they didn’t stop. I looked down at the TX in my hands and was horrified to see it dead.  No power at all.  I cycled the power button, but nothing, still dead.  I looked at the damaged quad on the lawn. I couldn’t approach it like this to pull the battery without disarming it,  and with a dead TX, it was a very dangerous and live machine.

As I watched it spinning at fairly low revs and wondering how long it would take for the batteries to die, or it to disarm it’s self, everything suddenly got much, much worse.  Without any warning, the quad throttled up to full power, and shot upwards, hitting the same tree as it had done on the way down.  It lurched wildly in the air, and I watched it, with the dead TX still in my hand shoot up and away from me at full power into the sky.  Every story, every post, every video I’d seen about fly-aways came into my head at that moment, and I knew not only had I lost it, but there was a significant chance it might damage some property on the way down.

As I think back to it now (this all happened about 2 hours ago) I can almost see the branching control structures in the code and the variables updating from the Accelerometers and gyros as the Flight Controller followed logic and paths that I had no idea about.

It dawned on me slowly as I watched the rapid gain in altitude back up into the strong winds, and the damaged legs swinging around in the down-draft from he props, that all may not be lost. The Quad was under it’s own control, in Fail-safe, attempting to execute a “return to launch”.  The first element of which is a rapid ascent to 15m in order to get clear of any danger. Still powerless to control it, with no life magically returned to the TX, I crossed fingers as the software brought the quad back to above it’s first received GPS coordinates, and a slow stable descent back to Terra Firma. Ir disarmed within a few seconds of coming to rest on the two remaining legs and the camera gimbal.  At this point, I knew it was over.

Flying multirotors is about gaining experience and tonight was a valuable lesson.  Not only about getting some new, better nicads in my TX but in how to deal with emergencies and the partnership between the human operator and the onboard software.

Printing Again

IMG_20150625_080301

It’s been a long haul getting the printer up and running again. I left it with a half finished Z probe for Automatic Bed Levelling, but it never worked quite as intended.  I’ve been spending a few hours with it this week and I’ve got it running sweet.  To celebrate I printed one of the first bespoke, made to measure parts I’ve ever done.  Talk about starting simple,  it was a replacement for a 11mm x 20mm dowel that had fallen out of one of Joe’s wooden trucks.  I sized the part in blender but despite importing a 1cm cube STL for size reference and setting the scale accordingly, I still had to scale up 1000x in Repiter, the printing software. However, in the end it was really nice to get a part out of the printer that was absolutely fit for purpose and slotted into the hole it was designed to fit.  The look on Joe’s face this morning when he saw it was worth the hours of buggering about with stupid Chinese servos and reams of configuration.

First taste of water…

I’ve just finished work on the prototype of the moisture sensor. As I type, it’s sitting, powered by batteries, with it’s probes in a hanging basket, sending data to my server in the cloud.

IMG_20150528_225628

Inside the large tuppaware box there is a 4xAA battery box, from a defunct string of Ikea Christmas lights. This powers the breadboard which still has an FTDI converter plugged into it, along with the ESP8266 ESP-12 in it’s freshly breadboard ready formfactor. The moisture sensor it’s self is a cheapo ebay special and very prone to all sorts of horribleness. Which is why I’ve powered it from a digital pin on the ESP-12, so I can keep it powered on for only as long as I need to.

It’s working, it’s sending data, the scale is wrong, and I don’t like Tupperware, but other than that I’m super happy with it.

and… REST

Along with building a prototype for the moisture sensor, I needed to get some kind of prototype endpoint up and running for dumping the data into.  I had always intended this to be a restful interface, but I didn’t know the quickest way of building one.  I’d looked at services such as thingspeak.com/ and data.sparkfun.com but I felt that I should be laying the foundations here for something that I’d be building on later. Ultimately, the server side system will be a Node or Ruby app, but I don’t have time to build that right now, I needed a shortcut.

A quick bit of googling brought me to ArrestDB which was very easy to set up and gave me a fantastically easy endpoint to push data into. It sits on top of PHP and Mysql (just like something else) so I I dropped it onto my existing VPS. As the data grows it will need a server of it’s own, but we arn’t there yet. The only thing about ArrestDB that troubles me is that there is no security out of the box (other than the obvious care you took creating a MySQL user with only the permissions your app needs on the DB it’s going to use), anyone can connect to your endpoint and start spamming/scraping it. I’m planning on adding in a simple secret token to the flow which should stop 90% of naughtiness occurring.

http://example.com/mytest/things_id/iot_test3_10min?limit=5000&by=id&order=desc

[ {
"id": "6021",
"ts": "2015-05-29 15:48:03",
"thing_id": "iot_test3_10min",
"value": "769"
},
{
"id": "6020",
"ts": "2015-05-29 15:47:52",
"thing_id": "iot_test3_10min",
"value": "771"
},
{
"id": "6019",
"ts": "2015-05-29 15:47:41",
"thing_id": "iot_test3_10min",
"value": "769"
},
]

For now, ArrestDB scores 7/10 on my list of cool things I downloaded from github this week.

DIY breakout for ESP-12

DSC_0196

I needed to prototype the soil moisture sensor on a breadboard, but as we all know, the ESP8266’s in their many different guises aren’t the most breadboard friendly modules you’ll ever come across. The secret here (for me anyway) was some tripad stripboard that I had lying around. I dropped two rows of 8pin headers into the breadboard so they were either side of the central divide, and cut a piece tripad big enough to allow the ESP-12 to sit on it, while the headers sat below. I pushed the tripad onto the top of the headers that were in the breadboard and soldered them on.

IMG_20150523_111922

IMG_20150523_113234

I then got some thin copper wire and soldered about 15mm to each contact of the ESP-12. This was fiddly, but didn’t take nearly as long as I’d thought it would. (In the photo you can see that I used a bit of White tape to protect the ESP-12 from the grip of the crocs on my helping hands.) Once soldered, I bent the wires on one side nearly 90º downwards and fanned them out a bit so they would fit through the 2.54mm spacing on the tripad. These were then soldered in place. Next, was the other side, this had to be bent a bit more aggressively, and then fanned out again to get through the holes on the triboard, and when I’d got the module sitting nearly level, I soldered these in too.

IMG_20150523_114626

I think it looks surprisingly tidy for my work, the module sits above the tripad by about 4mm suspended on rows of copper legs. It works great too. allowing for a rapid breadboard prototype to be built.

IMG_20150523_115125

Drone Ingredients

Yesterday, two new videos surfaced both shot with drones. It’s really nice to see something interesting being filmed for once, and shows how easy it is to make slow, aerial footage look spectacular. For the Antarctica video the ingredients are: Soft ambient piano based music, trendy sans-serif font (Avenir Next Ultra Light), and slow fades. No added Jump cuts, fast snaps, or crash zooms needed.

The National Geographic film on the Nubian pyramids (which is truly amazing) goes for a much more wholefood approach, honest no-frills commentary. On board audio of the ubiquitous drone insectile buzz, and zero postpro stabilisation.

Laptop Battery check

I just found something really useful in Windows 8 (Shock!) I’ve been worried about the performance of my laptop battery and though I’d see what was out there to check it out. I found that Win8 has a built in report for this which can be run from this command:

powercfg /batteryreport /output %USERPROFILE%Desktopbattery_report.html

This saves an .HTML file to your desktop with more info on your battery than you thought possible.  Good stuff MS.