Easier, Better, Arduino IMU Head Tracker

mainI’ve recently been immersed in a space sim called Elite:Dangerous. (It’s in Gamma and will be out shortly 12/16/2014.) I play with a small casual group that’s not about to build a ship cockpit in our living rooms or all splurge for a dev kit VR Oculus Rift. Some of us have played Elite on the Oculus and the first thing you miss is “head look”. The game is designed for it, and once you use it dog-fighting in an asteroid field, watching your enemy turn sharp high above you while you cut power and rotate at the same time whilst avoiding giant floating rocks, you don’t want to give it up. This is one of those games (much like a flight simulator) that takes 30 minutes just to map your controller(s).

My brother linked me to a UK group that was doing head tracking with an Arduino (SparkFun Pro Micro) and a Gyroscope / Accelerometer (MPU-6050) over at edtracker.org.uk, “Can you build this?” he asked.

“I can build a better one.” - and you can too.

  • No drift – Use hardware that incorporates a magnetometer (compass)
    (The new edtracker 9150 version uses a magnetometer to remove drift)
  • No calibration GUI – Place flat on table when powering on
  • No PCB – Four connections. SCL, SDA, +5, GND

Here’s what makes up the easier better IMU head tracker:

The first thing I noticed was the drift problem. The EDTracker guys have since put out a second version with magnetometer compensation, but they didn’t have it from the start and the hardware difference is around $6. I picked an IMU hardware package that has a great tested library for it. The calibration and angle calculation built into the Pololu libraries – specifically the code from Michael Baker Pololu_Open_IMU (Inertial Measurement Unit) as it uses the Madgwick algorithm is particularly brilliant. It outputs pitch, yaw, and roll angles. Watch a video of the Madgwick algorithm in action.

joy_cplI knew from past experience that the Teensy 2.0 can emulate many types of USB devices right out of the bag. “Joystick.X(value);” was simple to integrate and the device needs no emulation software or additional CPU to work. It just shows up in joy.cpl as a Joystick. You wouldn’t think that an Arduino could handle complex Euler angles and lots of float math on its own, but it has no problem. With the Teensy Joystick, the X,Y, and Z can be directly mapped 0 – 1023.

Lastly there are PCB boards being built for this, and  I’m really not sure why. These are not PCB’s with components on them like an ATMEGA32U4′s and the 9 Degree of Freedom hardware already built in. These are PCB’s just to connect a 9-DOF board with an Arduino. This is all of 4 connections, and the two pins on the Teensy 2.0 are D0 (SCL) & D1 (SDA) and they line up fine on both the Adafruit and Pololu breakouts for an above mount setup.

2pins_2wires

Yes, I cover the Teensy reset button. The PJRS software has a great auto-loader and you just don’t need it. You also don’t need a fancy PCB – two pins will do.

With the hardware finalized, I mounted it in a small box with a dab of hot glue and a cut-out for  the mini-usb. Here’s the test:

For the head tracking code I used Fscale to scale map the angles to the joystick. This is the part where you amplify a tiny amount of head movement into a larger amount of in-game head-look movement.  I settled on a 50° angle for pitch and roll, and an 80° angle for left and right (yaw). You’re more than welcome to try a different scale by changing the low and high Fscale numbers (-25 & 25 = 50° of movement translates into -90° & 90° of game movement) Everything else is directly from Michael Baker mikeshub/Pololu_Open_IMU. Such a tiny amount of code here is from me that I don’t even want credit for it. :P I’m just a lowly hardware guy that can smash out some C#. Example:

if (pitch < 0){pitch = fscale(-25, 0, 0, 512, pitch,0);} else {pitch = fscale(0, 25, 512, 1023, pitch,0);}
Joystick.Y(pitch);

Here’s a list of what you will need for software:

The device calibrates when it it powered on, make sure it’s flat and motionless. After that it takes an initial heading reading and starts to blink. 20 more seconds of being on, and that heading is locked in. I commented out all of the serial outputs and zip tied it to my headset:


Results: After playing for 3 hours I had zero drift. It stays pointed at the direction of your monitor forever. I considered adding a curve to the scaling to provide a “dead zone”, but the game has a dead zone setting built-in and I’d rather just output 100% and let the game / user control the settings. I also mapped the roll axis and one could use it to fire the roll thrusters in the game. For ~$45 you now have a cool little IMU that you can experiment with!

finished

Christmas build 12/7/2014:
Several people who lack soldering irons and hot glue have contacted me about building them one. I plan to build a bunch of these and give them out for Christmas gifts. If you are at all interested in getting one for $65, let me know. I’ll include the case, a 10ft USB cable, and ground shipping in the US.

My ix2 is EOL and doesn’t finish strong – or secure…

Disappointing finish for my Iomega StorCenter ix2. The second drive failed and it has been replaced with a Synology DiskStation DS212j with WD Red drives. (more on that later) I was doing some consolidation and cleaning of the computer room yesterday and I decided it was time to wipe some hard drives including the ix2 NAS.

The replacement WD Green and the old original 500GB Seagate spin up and after a few minutes I can login via the web interface. I go into the manage disk section and I’m excited to see there is an Erase Disks section under Manage Disks. The first message tells you that you’ll need to delete all the shares (including the built in ones?!) before using the wipe functionality. The second message talks about how securely erased your drives will be. For those of you who don’t know me – here is the setup..

iomega unsecure disk wipeSecure Erase:
All data is permanently erased and overwritten to prevent recovery, user information is removed, and the device is reset to factory defaults. Disk erase is a secure operation to ensure all data on your Iomega StorCenter device is irrecoverably deleted. The disk erase process overwrites all disks with random data to prevent recovery of existing or deleted data, users, and passwords.

…and the outcome? Well I clicked it, confirmed it, and watched as the red light came on and the drives started to chug. Just like when it gets stuck doing a rebuild, I wanted to see what it was up to. I was also curious if this would affect my ability to SSH into the machine. Not only could I still log in to the ix2, I found the program that it was running to wipe the drive:

/usr/bin/shred -v -n 1 /dev/sda2
/usr/bin/shred -v -n 1 /dev/sdb2

I looked quickly at the man page for shred. The default setting is 25 times. Older versions list the default at 3. Iomega changed it to make a single 1 time pass! :(

Think you might donate or craigslist your old NAS drive? Well if it’s an Iomega – don’t rely on the built in “Secure Erase” to protect your data! A single pass (while at least random data) is going to be slightly better then a “quick format”. When it finished and re-initialized I restarted it, and I STILL had root access. (read: factory defaults) To which I ran my own shred on both /dev/sda2 and /dev/sdb2.
Ciao ix2!

iomega_shred

Content (not surprisingly) is (still) King

Long time no post? Yeah… I was off building content on other sites instead of pushing content to my own. I spent some time with twitter and facebook. I did some advertising. I did some experiments, and I’m back to where I am the decider!

Monetization; Nothing is ever really free, and recently the squeeze of the all mighty dollar has been put on social media. Twitter was used to directly push eyeballs to NBC for the Olympics this year and Facebook has been slowly filtering out your feed. Now with fresh API’s and IPO’s respectively, social media is using every trick in the bag to get advertisers and it’s audience together.

Both sites control media, content, and make filtered decisions on your behalf. Remember when you saw EVERY post from your friends on facebook? They started to slowly show more of the people you interacted with. A year ago they implemented a subscribe feature that no one can figure out and opts everyone out of your feed. Soon you were asking your friends: “When did you post that?!” because FB decided that it wasn’t important. Facebook Pages are in even worse shape. Only 30% of the people that like your page will be shown any particular update from that page. “Will be shown” as in – 70% just won’t ever see it on their feed unless they directly go to your page, or you pay for that update to be promoted. Twitter has a similar model that suggests people follow you and pushes your tweets to their page.

One of my close friends liked Verizon on facebook. Or at least facebook told me that they did. Are you kidding me? Verizon has a pretty good network, but no one actually likes them. This made me suspicious and it turns out this is just another advertisement option trick.

Third party apps suffer: What I want is an app that will broadcast my words across multiple channels and outlets. I want an app that reads and parses everything from all outlets under my control. Post to facebook, twitter, wordpress, google+, etc. Show your entire timeline, all tweets, all posts. The reality is that those apps are being crushed or filtered so badly that no one will see the content when it gets there. Nothing is ranked higher then you typing an update directly into facebook.com. Hootsuite, Seesmic, Twitter, SMS, etc. will all be ranked lower (show up on less feeds) then your eyeballs on their site and their apps – looking at their ads. Google+ doesn’t even play the game. You just can’t post on G+ if you’re not on the page or using their app.

Why are we playing this game? It’s only going to get worse. We are social creatures, but at what (Buy Coke) point is the (Doritos) interaction going to be (Target) spoiled? Twitter just feels like a bunch of people yelling on mountaintops with no engagement happening. I have evidence to suggest that facebook just makes up demographic data. For example I ran an ad targeting anyone in the US that likes “rallying” OR “WRC”. It was over 250,000 people?! I can tell you that this demographic is more like 10k to 15k people on it’s best day – and that’s if I count the 25% of the population that is NOT on facebook!

Push them to the website: I’m retreating to safe waters. I pay for the server, I have a pro flickr account, my rally blog runs some ads to cover the $90 a year, and I get to post and promote whatever I want. I’ll still be on the social networks, but my goals have changed. I just want people to visit my sites and enjoy my work. If they’re interested they can sign up for updates via email or RSS. Google search loves unique content and is more likely to find viewers then a lousy facebook ad. I’m experimenting with IFTTT.com and a microblog with microposts on rallynotes.com. Instead of content ending up there, content STARTS there, where it remains king.

WordSequence For KeePass 2 = XKCD Passwords

If you’re not familiar at all with the title, click here to check out the fabulous comic in question.

“Lolz” right? Well I completely agree with it – and I’m finding that my passwords are getting longer and longer and you really have no hope of remembering them. Take at look at this monster: !J$?e04uGh=eDP (89 Bits) You have no choice but to store this in a program like KeePass, never actually look at it, and hope that your password database stays backed up. :(

Password enforcement has gotten better, and worse at exactly the same rate. Here’s an example excerpt from Cal Poly’s password document. (This was discovered when my sister in-law tried 15 times to make a password that she could actually remember for her access):

Passwords must contain at least one character from three of the following lists:
1. Uppercase Alphabetic (A‐Z) 2. Numbers (0‐9) 3. Lower case Alphabetic (a‐z) 4. These Special Characters are allowed: ! $ % & , ( ) * + ‐ . / ; : < = > ? [ \ ] ^ _ { | } ~ These special characters are not permitted: # " @ and the space character

Passwords must not contain any of the following:
1. Your previous passwords used within the last two (2) years 2. Passwords less than 16 characters must not contain any of the following: a. Any words of three or more characters, including non‐English words b. Any groups of three or more characters of the same character type c. Any names, person, places, or things found in a common dictionary d. Any of your names (first, middle, last), any current Cal Poly username e. Repetitive characters (sequences)

The second part ensures that no password can be easily memorized. This string has to be written down. Once it’s written down, the whole reason for having passwords fails everyone, and after staring at the logic for 5 minutes I came up with something like this: 50Fu40Yo (42 Bits)

If you network admins are listening, you need to get over trying to corner users into crazy strings of letters and numbers. Dictionary words are easy to guess, but strings of dictionary words with random characters in there are just as good, if not infinitely better for users to actually remember. Lets look at this example: Wool+BladeFriction5 (105 Bits) A brute force attack is just going to go through every possible character in every possible position, and there’s 19 of them. Now for our ‘easy to remember’ Cal Poly password, the length is only 8 because I would never actually want to make it more then the minimum. Do you want a short useless password that gets written down? Or a long somewhat complex one that is memorized?

The challenge is to make a complex password that is easy to remember. The password should also satisfy usual requirements for length, capitalization, and numbers or uncommon characters. Here’s what I use:
KeePass 2 & WordSequence

Search the web and drop a couple thousand words (I used nouns and prepositions) into the window. I came up with some common substitutions (like @ for a, etc. – ‘b@ke m0re p1e’) and created complex easier to remember passwords like: Cheese4TigerDinner! (88 Bits) Most normal websites would accept this as a excellent password for the length and the special characters, and most humans could remember the phrase: Cheese for tiger dinner!