Augmented Hardware RealityPosted: November 16, 2012
I’m always buying little bits and pieces of hardware gadgetry. Everything from pocket sized oscilloscopes, to vibrating joysticks. Of course I have myriad webcams, microcontroller cards, keyboards, mice, tv remotes, and the like.
I have a problem though. I want to interface with these devices in simple ways, and have them interact with a variety of systems across my hardware universe. For example, I want to use the joystick to browse channels on my Rikomagic TV Dongle. Although the TV dongle has a USB port, I don’t want to have to plug the joystick into that thing, and then unplug it to plug it into my PC to play a game. Rather, I want to be able to control which device the joystick will talk to by selecting something at the joystick.
This is where things are starting to become clearer for me. First of all, I need to add some basic smarts to the joystick. I’ll attach it to a Raspberry Pi. Why? I want to be able to do a few things.
1) I need to read the data coming from the joystick attached to a USB port
2) I need to transmit data over WiFi to the recipient device
3) I need to control the whole rig using nothing more than battery power if possible
With such requirements, it makes sense that a Raspberry Pi, or something equivalent, would be in the picture. I could even use a Rikomagic PC to do the same, as it has USB, and does WiFi.
The setup is simple, regardless of what compute node is used though. First of all, plug the joystick into the cpu node. Assuming Linux, read activity from the appropriate ‘/dev/input/eventxxx’ device.
Package up the data events, possibly converting them to some standard command set that is appropriate to what you’re connected to, and send a http:POST command to the waiting device. Get any response back as appropriate.
To make it a two way street, the response can be either informative, like turning on/off the vibration, or it can just be status ‘200 OK’.
But, this now makes for interesting theatre. Assuming I’ve got my joystick easily attached to some wireless compute node, I can send those REST calls to anywhere on the internet. I could just as easily control the camera in a conference room, as switching channels on my television at home. I could even control the Mars rover (in a very delayed way) from my same joystick. As long as everyone talks http/REST.
I know, the computer industry has gone through this refrain before. Technology that seems to solve all ills. But this time I really mean it! What’s the difference? I think it the fact of the capability density. Meaning, for $35 or less, you can get a computer node, which is capable of interacting with the world. You can easily attach various hardware devices, whether they be controllers, or actuators, or simple data recorders. Through the advent of the ubiquity of internet connectivity, you can connect things in all sorts of ways, across vast distances, without any real consideration as to how things get connected to each other.
At any rate, I came to this conclusion because I was experimenting with the Freedom 2.4 Cordless Joystick. I wanted to simply interface with it, get the various button presses, twists, and movements, and use that information to control an application. Doing so in Windows involved a lot of work with DirectX, which was quite a struggle. Then I just hooked it up to the Raspberry Pi, and suddenly I could read everything it had to offer with about 10 lines of code. That’s really easy. So now, if I want to control my app in Windows with the Joystick, I don’t connect the stick to the PC directly, I connect it to the Pi, and then have the Pi send appropriate commands back to the PC, and that’s that.
That’s a very curious thing. DirectX is an API that I’m not particularly in love with. DirectInput and COM programming in general, I find to be very hard. But, I need my PC because it has a super powerful graphics card in it, and I want to control it. So, my primary app has a simple http listener, which looks for the command signals from the joystick, and does what it needs to do.
In essence, WiFi is the new wireless. Everything from light switches to thermostats to joysticks, will be able to connect through wireless, WiFi (802.11xxx), and once that’s true, supporting http/REST can not be that far off.
This is how I’m augmenting my hardware reality.