Marcus Ramberg <insert something deeply moving and profound>

Lessons from building a 270 racing quad

quad in the grass

After buying A little toy quad copter this summer, I got very interested in RC flying. My wife would probably say obsessed. :) In particular I'm interested in First Person View racing.

This is a hobby where you crash a lot, so I decided to build it from scratch so I would be able to service it. Turns out it is a lot of work! Yesterday I finally reached my goal of flying FPV, and it was glorious. This post is about some of the pitfalls I met on the way, so you might avoid them.

Bought a glass fiber frame

Glass fiber is cheap, but it's heavier and softer than carbon fiber. I'm now slowly replacing all the parts. One upside of glass fiber is that it does not conduct electricity. But really, you want carbon fiber.

Discharged my lipo

In order to power a quad, you need to discharge a lot of electricity in a short time. The best batteries for this task are lithium polymer batteries. They capable of discharging a lot of amps. However they have some significant disadvantages.

For one they are highly flammable. What I didn't know is that they get unstable and unable to hold charge. While I was building and testing, the motors suddenly stopped. Turned out I had depleted it, and my charger refused to charge it. I tried forcing it to take current, but when it started heating up and swelling I decided to accept defeat and bought another.

Put the motors on in the wrong order

In order to create lift, quadcopters need to have two clockwise and and two counterclockwise motors. Brushless motors can spin both ways. You just need to switch two of the cables to change the direction. Unfortunately the screws holding the propellers are ordered. I mixed up these, so the propellers kept unscrewing themselves when I was attempting to take off. Spectacular fail. I didn't want to remount all the motors, so I changed the flight controller to use a custom mix, and reversed the order of all my motors.

Put the flight controller in the wrong orientation

My first test flight was quite disheartening. As soon as I tried taking off, the copter flipped around and broke its propellers. After some digging, I realized this was because the I had mounted the naze32 flight controller sideways. Luckily you can tell the flight controller which direction is forwards. You can see if you have this problem by checking the visualization of the copter in cleanflight configurator

Attached the motors with nylon screws

One bright idea I had when building the copter was using nylon screws to attach my motors. The thinking was that I would rather have the motor come off than break an arm in a crash. That part worked fine, however the nylon screws can't take all the load from the motors, so they started snapping even when I wasn't crashing. This meant I needed to remount all the motors after all.

Bought the wrong kind of 5.8ghz antenna.

I didn't know this, but there's two different standards for the 5.8 ghz antennas commonly used for video transmission from the copter to the pilot. One is SMA, and the other is RP-SMA. Of course I managed to buy the wrong one, and ended up with two male pins facing each other. Not good! Fortunately, I managed to find an adapter at the newly opened kjell & co.

These are the main mistakes I've made so far. I'm still a newbie in this hobby, but I'm hoping that I'll be able to increase my build-to-fly ratio in the next months, and work more on my pilot skills. I still have some improvements planned tho, for one I probably need to make the quad more winter proof. I'm sure I still have many mistakes to come :)

Too much scifi not enough MCs

Once again, it's the end of the month, and I did not manage to keep my promise to myself, and write my blog posts earlier than last month. So, in order to not lose my bet with @jhthorsen, I will tell you about the last four books I finished. It just so happens they are all scifi, and they are all set in the near future, even if their themes are quite different.


By Neal Stephenson

I've been following Neal Stephenson for a long time, after he hooked me with the magnificent Snow Crash and The Diamond Age. Although he almost lost me with the sometimes long winded Baroque cycle, I feel like he's returning to old form lately, with REAMDE, which I enjoyed very much, and now Seveneves.

A meteorite has hit the moon, and shattered it into pieces. In itself this is a huge event, but earth scientists soon calculate that it will spell the end of most life on earth, and start exploring alternatives for survival. This book follows one of the most promising plans, making the international space station into an Ark where mankind can survive until earth once more is inhabitable.

As you can imagine, life in space is not without peril, and I found myself turning the pages quite quickly as we approached the climax. The somewhat cryptic title of this book is related to the ending, but I won't say more than that. Definitely worth checking out.

The Martian

By Andy Weir

I first heard about this book through the trailer for the blockbuster movie adoption coming out this fall. The concept of a astronaut stranded on Mars seemed very interesting, so both me and the spouse decided to read the book first.

While not as far reaching as Seveneves, the survival story is quite strong, and the writing is witty, and sprinkled with scientific tidbits that keep you interested throughout the book. Some of the drama in the book seemed a little forced, and I didn't enjoy the bits going on at Houston as much as the space survival parts. Still had a good time, and we will be getting a baby sitter to see this one in the cinema.

The Periphial

By William Gibson

Gibson was one of my favorite writers growing up. Books like Neuromancer, The Difference Engine and Mona Lisa overdrive shaped my views on the near future. While I also enjoyed his contemporary works, I have to say that even more than with Neal Stephenson, this book represents an explosive return to old form.

The book is set in two different time lines. One is a bleak near future, with sprawls and cyborg warriors, quite similar to his older books. In the other timeline we are quite a bit further into the future. Humanity has survived near extinction, and have developed quite advanced telemetry and genetic technology which allows them to create remotely controlled "meat puppets". These two timelines start to converge as a mysterious worm hole is formed between them.

I enjoyed all of this book, and I think you will too. It didn't hurt that autonomous quadcopters played an important role either.


By Ernst Cline

This is the second book from Cline, after the very popular Ready a Player One, which tapped into pop culture nostalgia around 80s arcade gaming, together with a pervasive virtual world, to make a very popular and entertaining book.

I have tried very hard not to judge this book based on his debut novel. The story is a bit similar to Orson Scott Card's Ender's Game, with a young boy fighting aliens. however I think the writing is not nearly as good.

I was also bored with a lot of the fpv multiplayer references. I don't really enjoy these kinds of games, so I guess a lot of the pop references was lost on me. Still, it's a decent youth novella, but not in the same class as the previous three.

Porting AnsibleModule to Perl.

“All animals are equal, but some animals are more equal than others.”
― George Orwell, Animal Farm

Ansible is a great orchestration tool, which I've used extensively for the last years to build infrastructure, or even to accomplish routine tasks like restarting a group of web servers one by one or patching a bunch of servers for critical security issues.

Ansible is written in Python, but you can write modules in anything that can generate JSON. In fact, I wrote about making a Perl based cloudflare module earlier. However, to quote the official documentation:

As mentioned, if you are writing a module in Python, there are some very powerful shortcuts you can use. Modules are still transferred as one file, but an arguments file is no longer needed, so these are not only shorter in terms of code, they are actually FASTER in terms of execution time.

Python is a fine language, but I'm more efficient at writing Perl, so I set out to port AnsibleModule to Perl. However, as I started looking at this new style of argument parsing, I got increasingly horrified. Seems that native Ansible modules are pre-processed to insert a lot of boilerplate code, including the passed arguments passed as a Python struct. Parsing this isn't really feasible from any other language than Python, so I decided to use the JSON support for non-native modules instead. Unfortunately, this argument passing still happens by passing a filename on the command line to the module, and the module slurping this in. Ansible also slurps in the entire file into memory to look for the WANT_JSON flag.

In the future I would love to see the module runner checking if the module opens STDIN, and pass the the module arguments directly as a JSON struct. This seems like the most efficient and agnostic way to go. Reliably detecting if stdin is open over ssh might be troublesome, but even an explicit way of setting JSON_MODE (ENV?) would be an improvement over today's situation.

Using my AnsibleModule port still provides quite a bit of convenience though. For instance, you can do complex argument checking easily:

  my $m = AnsibleModule->new(
    argument_spec => {
      name    => {required => 1},
      enabled => {default  => 0, aliases => [qw/turned_on active/]},
      type    => {type => choices => [qw/one two three/]},
      similar => {type => 'dict'}
    required_one_of => [qw/type similar/]

Note that due to the malleability of Perl, we don't really care about typing beyond String/List/Dict and Bool (which supports the same values as the Python AnsibleModule bools). Everything else is treated as a scalar.

AnsibleModule also helps with supporting check mode in your module, just like the original Python module. I also provide Test::AnsibleModule which lets you simply write unit tests for your module. As a convenience, you can test this module directly through the ansible-perl script command like this:

   ansible-perl -p -m <module> -a '{"foo":"bar"}'

Use -h to see all the available options. The -p flag means ansible-perl uses App::Fatpacker to help you pack up your dependencies inside your Ansible module (as long as they are pure Perl). Mojolicious is fat-packable, and provides a great basis for writing HTTP-related Ansible modules. Incidentally I used it to write AnsibleModule as well.

As a bonus, if you fatpack your modules, you will automatically include the WANT_JSON text that Ansible is looking for in your module source code. Note that if you don't want to pack your module, you will have to include it yourself somewhere in your source code.

Once you've packed your module, you can just put it into library/ in your Ansible project, and use it directly. As long as your hosts have Perl installed, everything should just work.

I'm still putting the finishing touches on the module for the cpan 0.1 release, but meanwhile you can get it from GitHub. Please create an issue or make a pull request if you find any bugs or you miss any features. It might also be useful to look at the examples used in the unit tests.

offline decentralized single sign-on in the browser #

Recently, browsers have just begun to implement web cryptography. This means that browsers are now capable of the same kind of passwordless decentralized authentication schemes we've had server-side with ssh and tls asymmetric keys for decades.

I think this is super interesting. I wonder if users are going to be able to understand how to use it tho. I do want to try.

Fixing the Thinkpad Buttonless Touchpad #

The default configuration of the xf86-input-synaptics driver makes the clickpad almost unusable (on the T440s). Clicks/Taps do not register properly, misclicking, no palm detection, no soft buttons where they should be, and so on... The following configuration can be put in /etc/X11/xorg.conf.d/99-synaptics.conf As a result the clickpad will react a lot more 'calm' than before and the middle & right click button areas match with the printed ones on top of the clickpad.

New laptop, new woes