Years ago I was given a shiny, silver Robosapien. It’s an awesome humanoid robot controlled and programmed with an infrared remote. Unfortunately with 90+ commands and functions the remote is pretty cumbersome. So I always intended to see if I could put something together to control him from a PC, but I never got around to doing it.

My 5 year old is in his first year of school and since he now has some basic reading skills I thought I’d try to introduce him to programming. Initially I tried out Scratch and whilst he loved playing with the outputs the UI was too abstract and complex for him to grok. However he is enamored with robots, gears, motors and inventions, so I figured that controlling something physical with a simple set of commands would work better for him.

And so Project Frankensapien was born.

First off I decided that I didn’t want to do anything invasive to the Robosapien (now know as Frank). This means that my interface to him would need to be via IR, emulating his remote control. Secondly I want to be able to control him from a PC to shorten the development and testing/hacking cycle. Additionally I’d like to play with some computer vision stuff and I figured that I’d go RoboCup styles, using the processing grunt of the PC as the brains of the robot and broadcasting simple instructions to the robot to carry out.

Lastly I’d like to try make Frank autonomous by strapping a Raspberry Pi to him!

With this in mind I purchased an USB Infrared Toy v2. Its USB interface means it can be plugged into my PC and into the Raspberry Pi. The device is also both an IR receiver and transmitter which means I can use it to record, analyse and emulate the IR command sequences sent by Frank’s remote.

The first step in the project was to be able to send Frank’s commands via the USB Infrared Toy. To do this I settled on trying to get WinLIRC up and running. This software is a Windows port of LIRC and provides tools to capture and execute IR commands. Better yet it has direct support for the USB Infrared Toy and its config files are compatible with LIRC so I should be able to use the same configuration files on the Raspberry Pi.

I fired WinLIRC up and… nada. It did not like the configuration at all :( Additionally the COM port for the USB Infrared Toy (yes, you talk to the USB Infrared Toy via a serial over USB connection) kept disappearing on me. Things were not looking good at all.

After digging around on the web I found that I could use the IRGraph to get a visualization of what the USB Infrared Toy is receiving. This generated a graph looking like this:

and showed that the toy was able to read the IR commands sent by Frank’s remote.

Next up I tried to use the IRRecord tool to record commands from Frank’s remote and then generate a LIRC config file. The tool seemed to have real issues dealing with the Robosapien remote and the config file that it generated did no work. It did however generate a good config for my Samsung TV remote.

Looking at the software for the USB Infrared Toy, I discovered a tool called irtoy that records and plays back IR commands. So I thought I’d give this a try. Unfortunately it required a firmware update and when I tried the update it got stuck in bootloader mode and I could not access the USB Infrared Toy! After some cursing and switching of USB ports (and waiting), windows finally found the toy (which turns into a USB human interface device in bootloader mode) and I was able to complete the firmware upgrade. Phew!

The irtoy tool recorded and played back a command so further confirmed that the USB Infrared Toy could be used to communicate with Frank. So (slightly in frustration) I bought a copy of AnalysIR which apparently supported LIRC export and the USB Infrared Toy.

Whilst I waited for the license key for AnalysIR, I figured I’d try to roll a config by hand. Using info gleaned from the following links:

I put together a config file that only handled the STOP command, fired it up and got Frank to… fart! (the OOPS command). Which was pretty funny but also slightly indicative of my feelings towards my efforts so far.

Comparing the bitmasks of the STOP and OOPS commands, I didn’t see much correlation. I figure I just got lucky and managed to send some junk that Frank managed to understand.

0x8E - 10001110 - STOP
0xC7 - 11000111 - OOPS (Fart)

However I did get something useful out another of WinLIRC’s tool, RawCodes, when pressing the STOP button on Frank’s remote:

Next up I plan to cobble together a simple web interface so that Frank can be controlled via a browser. Unfortunately the USB Infrared Toy’s range seems a bit limited (about 50cm max) so I may have to accelerate the plan to strap the Raspberry Pi to Frank so that I can keep the IR emitter permanently near his head. I also want to have a good play with AnalysIR tool, whose license turned up just as I succeeded in hand coding the LIRC config.