Raspberry Pi bot progress
I’ve been chipping away at my Raspberry Pi/Arduino bot here and there so I decided it was time for an update.
I’ve added more general functionality, such as turning left & right. That was easy with Firmata by setting a pin to a mode such as Digital Input or PWM and setting it Low. For example
this.firmata.digitalWrite( this.right.forward.pin, this.firmata.LOW);
would turn the stop the right wheel from moving forward.
Once I got the new controls wired into Socket.io, I improved the interface. I forked a neat little project called virtualjoystick.js /by +Jerome Etienne. It is a canvas joystick library that supports touch on mobile (with a mouse fallback.) The primary directions are mapped to their respective socket.io method calls. Therefore, I can drive the bot directly from my android phone’s mobile browser. While it doesn’t show much, here’s a screenshot:
Easy remote access with localtunnel
When building an internet-enabled device, you need to a way to get to it through the internet (duh.) Using an internal IP works when you’re on the same network. When outside the network, you need a proxy of some kind. Localtunnel is “the easiest way to share localhost web servers to the rest of the world.” There’s a great port for Node.js that I got working in minutes.
Simple app for accessing multiple devices
I could get the local IP & localtunnel url and write it to std.out but that’s not useful from my phone or laptop. I wrote a simple App Engine app I’m calling DHD that logs devices and their addresses. Here’s another mildly-useful screenshot:
It basically takes a POST and stores it App Engine’s NoSQL db. Nothing too fancy, really. I imagine that addressing is a common problem for networked/internet-connected devices (I wonder how other projects like Electric Imp deal with it?) I may open source the code when it becomes more sophisticated, seeing as other internet-connected device projects might need something like a DHD.
I plan on writing an init.d script that uses Forever to fire up the bot code whenever the machine starts & always keep it running. I also would like a shell script that tries to join open networks when nothing else is found.
I picked up that Rover 5 from +SparkFun Electronics as well as a sweet accelerometer, gyro & compass unit from +Pololu Robotics and Electronics. Between having more motors, optical encoders and the IMU might mean I need to upgrade to an Arduino Mega. No biggie.
I still have a pipe dream to do some OpenCV/SimpleCV tracking or use an obsolete CMUcam I have lying around. We’ll see.
Hopefully I’ll have some more fun updates the next time I decide to blog.