Category Archives: creativity

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. 😛 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

Update: If you would like to configure it to work with Opentrack (supports TrackIR games), you will need to map the axis 1:1 with the joystick output and then set all your curves and config up in Opentrack.

fscale(-90, 0, 0, 512, your_axis,0)
fscale(0, 90, 512, 1023, your_axis,0)

Update 1/16/2016: Uploaded code and working with Grégory Paul over on hackaday.io
https://hackaday.io/project/8952-elite-dangerous-headtracker

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!

How to find and organize gmail lost archived items.

Since we started the 21st century, I use the week between Christmas and New Year’s Day to clean house digitally. A synchronization of clocks, time servers, updates, firmware, and yearly maintenance with all things containing zeros and ones. The deleting of old emails, spam, and the archival of a picture folder entitled “2011.”

This year I stumbled on an interesting thing that gmail doesn’t do. It won’t show you mail that doesn’t have a label. Any mail that you “archived” to get off your in-box, without any categorization, dropped into this pit mixed with thousands of other labeled emails. Looking for these orphaned emails would involve looking through hundreds of pages of “All Mail.” I archived them for a reason (to go through them one day) otherwise I would have deleted them. Little did I know that finding these orphans would prove to be a challenge.

“Why do I need to see those old archived emails? If I ever need anything I’ll search for it and find it. “ – you might say.
The answer is the same as why you need a photo album and still like pawing through SkyMall. We are nostalgic creatures and sometimes (at least once a year) like to reflect on the past. Plus, a full catalog of information can result in more discovery. I’ll give two examples: 1. After rescuing my archived items I found a webcam picture of my dad with a cast on his arm. I barely remembered he broke it and seeing this picture gave me the memories back. 2. Listing out every sub-domain for UCI one day resulted in passport.uci.edu – weird way to find out that the University had its own passport office 1/4 mile from your house and you didn’t need to trek all over Orange County for mini-pictures and wait in a Post Office queue. I never thought either of these things existed and certainly wouldn’t have searched for them.

Gmail ninjas know about the Gmail advanced search options, but even here it specifically states: “There isn’t a search operator for unlabeled messages” Further searches looking for a fix resulted in a cobbled-together list of all your labels with a minus sign in front to indicate “anything not labeled this or that or etc.” Example: -(label:Subscriptions OR label:Ebay OR label:Rally OR label:Receipts) For some of you that never adopted labels, or only use 3 of them, this is great and might just work! For the rest of us, I noticed that after typing 6 or so of them into the search box and tried lables that had “Two Words” or “funky-ch@ract3rs/” search started to break. I think that nested labels makes this worse, but I stopped the experiment as I currently use 20+ labels.

In order to find your (labeled items archived in-box stuff orphaned never) you’re going to have to make the LIAISON pledge:

I {insert name here} promise to never blindly press the gmail archive button. I promise to make sure that 1 or 2 labels have been attached by filter or by my own key-press AND furthermore I promise to guard the secrets and ways of the Gmail ninja, never using my powers for evil.

Alright ninjas…
Add the ZZZ label

  • Start by making a new label. Something that you can search for in the future like “ZZZ”.
  • You will repeat the next steps many times as you go through all your labeled email.
  • START: View all of the mail in one label and click on the check-box in the upper left to select all mail.
  • At the top of the mail items a message will appear:
  • All 100 conversations on this page are selected. Select all ### conversations in “{your label}”
  • Click the link and now all the mail in that label is selected (be careful here)
  • Choose to add the ZZZ label to you messages:

  • Google with respond with a message. Feel free to click OK.
  • Find the rest of your  labels and tag them with ZZZ. It took me 5 minutes and you’ll never have to do it again.
  • If you still have labeled email to tag with ZZZ goto START
  • See that wasn’t so bad. 😀 Unless you have like 500 labels. 😐
  • If you do have more than 100 labels, I suggest 43 Folders.
  • Done!

Now you can use this magical search string:

-label:zzz -from:me -is:chat -in:inbox

Go ahead and paste that into your email search box. This means: Show me everything that IS NOT labeled ZZZ, that IS NOT from me, IS NOT a chat, and IS NOT already in the inbox. Since you tagged all the email you know about with ZZZ, items orphaned with no labels were not tagged. Your long lost archived items will appear! I had about 150 items that I selected and placed back into the inbox for me to go through in the next couple days.

What’s next?

  • Delete the ZZZ label now that you have no further use for it.
  • Never blindly hit the archive button again. You promised! 🙂
  • Get Google to make a search parameter for “label = null”
  • Enjoy your discovered conversations from the last few years!

Have a happy and prosperous New Year!

Make a Google Earth Fly-Over Video!

I organize a stage rally in Ridgecrest, California called the High Desert Trails. For the last three years we have run on a six mile road on private property. In order to grow the event we needed to find more roads. Stepping up to public roads means more insurance, permits, and logistics (more stuff). None of which we can afford if competitors think it’s still a small rally. Competitors (like myself) are often skeptical of new roads. It usually takes a couple of years before ‘everyone’ in the rally community knows what the roads are like at [rally name here]. How do you get rally drivers excited about an event with new roads today?

Google Earth! Imagine what it was like 10 years ago, before publicly available satellite imagery was a mouse click away. Rally Masters would spend hours driving around looking for roads. Even with updated topographic maps, you still have to get out there and check out what it actually looks like. Early in 2003 I spent some time looking for roads in New Hampshire and the topo maps don’t tell you about the flooded marsh, the rocky boulder filled road, or the intersection that home owners just piled dirt and brush on, so that neighborhood kids would stop using the route.

With Google Earth we were able to see what shape the roads were in, and we got an idea of how wide they were and if they were blocked, gated, etc. This reduced the number of ‘road scouting trips’ to a handful. We were even able to scout the route we had decided on when we got back to check for anything we had missed. The ability to see this kind of road detail is a game changer. “I’ve seen it from space.” is now a part of my vernacular.

It was only natural that I wanted my competitors to see it from space as well. I actually prefer this to coordinates, as I don’t want to reveal the exact route until the day of the event. For those rally folks reading this, I’m sure my methods can be re-produced and you could ‘discover’ the area outside of Ridgecrest that we’ll be using for the event. You are also aware of the pre-event testing rules, and the jeopardy to the event should you decide to do any pre-running. 🙂

How was it done?
* You’ll need a copy of Google Earth.
* You’ll need a screen capture program called CamStudio.
* Both of these programs are free!

Setup your view under Google Earth Options: Tools – Options – 3D View. Click ‘Show Terrain’ under ‘Terrain Quality’ and crank the slider to the max for detail. You’ll also need to edit the options for ‘Touring’ under Google Earth Options. Some of these options for recording refer to the Pro version of Google Earth which will make these videos in much higher res. A full version of Google Earth Pro is around $300. Highly recommended for a business or commercial venture. (but you can do just about the same thing for free with Cam Studio *cough) A good place to start is by setting the options to match what I have below. You’ll want to tweak your angles and heights continually to get the shot your looking for.

Go to the area of the map you want to make a movie of. Start by creating a path. A new window will pop up called ‘Google Earth New Path’. I suggest you change the name from ‘Untitled’. When you LEFT click on the map a point will appear. RIGHT click if you made a mistake. Use the controls in the top right to move around to your next point. Hit OK on the ‘Google Earth New Path’ window when you’re done. You can click on the path to add more later as well as changing the color and thickness of the line. You’ll want to hide this when you actually record your movie. This interface took me some time to get used to (especially in 3 dimensions) so be patient with it.

In CamStudio you’ll want to setup the video options to capture a ‘Fixed Region’ (I used 320 X 240). When you hit record a window will appear, place it over the Google Earth window as shown. Start the tour by clicking the “Start Tour” button: Record your shot and hit ‘Stop’ on CamStudio. You will be prompted to save your video.

For the rest of it I edited a group of videos and different shots with plain old Windows Movie Maker. Added a little royalty free music and uploaded to YouTube. As far a the rally is concerned, my first reactions were something like: “Woah! Helicopter? Oh Wait… this is awesome!” It will no doubt get peoples attention and hopefully we’ll get tons of competitors out to the High Desert Trails Rally on April 9th, 2011.

Five knots you should know.

Five knots you should know.
The Square Knot can’t save you, and just forget about the silly Sheepshank. You already know how to tie a half hitch, slip knot, and the noose, right? Whether sailing, camping, fishing, climbing, or rallying – Here are five knots that you should know.

Click more to see how you did…
Continue reading Five knots you should know.

WordPress 2.0 > 3.0 now with text!

“Going forward may not be the answer. Maybe I should go back.”

As an early adopter of WordPress (look through the archives some time…) I can clearly remember the departure that WordPress made around version 2.0. They started calling links ‘the blogroll’ like dumb hipsters and when the admin logged in, it said ‘Howdy!’ and lots of other weird things that had nothing to do with the ability to write / create / share were changed. The media uploader was so horrible at the time, I turned ‘upload.php’ back ON and kept my hacked up version WP 2.02+ and it’s been unchanged for years.

I finally started to like the new stuff from WordPress when I installed 2.8 on highdeserttrails.com. It’s now consistent and polished, and doesn’t feel hipster and untested. I’ve been putting off a major upgrade of planetkris WordPress for a while. Okay, I guess like four years. It looks as though the WP folks have forgotten about me in the same time a BMW lease takes to expire. Everything before 2.7.1 right now has a very fuzzy upgrade path. Like “Dude – you can’t export XML?! What the hell is wrong with you?” fuzzy.

After reading the ‘update your database until MySQL shoots out of your nose‘ posts out there, and not finding any clear update path for those of us stuck in time – I started to think back to how I got here. I imported my ENTIRE BLOG *gasp from a MovableType text file called mt-export.txt. Yeah… Like a UTF-8 TXT file I can open with notepad.exe – text file. I looked for many ways to export and import and it all came down to this post: WordPress Export to Movable Type or TypePad The idea was to just export everything in MT format, wipe WP 2.02, the folders, etc. Setup WP 3.0, new files, new database, import from MT. If I had to go back, I just restored the files already pointing to the old database.

This clever theme drops your entire blog, all posts, all comments, in a big long page which you can click ‘view source’ and save as an mt-export.txt!
Want to edit where all of your images are stored before you import? Go crazy! Want to not deal with a drop of MySQL and get your blog updated? Here you go! The other positives are that the install is fresh. A fresh database and WP install is ALWAYS going to be better then an ‘Upgrade to 2.1 > Upgrade to 2.3 > Upgrade to 2.5 > Upgrade to 2.7.1‘ ugly beast of a thing.

Compromise for some? I’m sure. All I wanted was the posts. I didn’t even really care if the comments came over, but they did. Categories, author, and dates too! You’ll have to figure out your links, pages, themes, etc. on your own. WordPress 3.0 feels good and I particularly like this quote from the dev team – “Normally this is where I’d say we’re about to start work on 3.1, but we’re actually not. We’re going to take a release cycle off to focus on all of the things around WordPress. – – The goal of the teams isn’t going to be to make things perfect all at once, just better than they are today.” Dumb hipster? Not these guys.

I’m rocking a slightly modified theme from Yashfa right out of the box. You like?