Elixir Robots

My robot hobby is picking up steam. After going through the Python examples that came with the GoPiGo, I got inspired by some embedded Erlang videos on YouTube and decided to see if I could control the GoPiGo with Elixir. After watching Elixir Sips, I learned of a project called Elixir/Ale, an Elixir library for embedded programming. With Elixir/Ale, you can talk to the GPIO ports on the Raspberry Pi and some common hardware bus protocols: I2C and SPI. I2C is used by the GoPiGo board, so Elixir/Ale looked like what I needed. So I looked up some Elixir docs, typed mix new exgopigo, and started coding. The result is ExGoPiGo. All it lets you do right now is turn on and off the robot’s two front LEDs, but it does that by writing to the I2c bus. Controlling the motor and such shouldn’t be too hard.

I also ordered an USB kit for my robot arm. This lets you plug the arm into your computer. The software that comes with it only runs on Windows, but the Internet is a wonderful thing. Somebody reverse engineered the protocol and wrote a C program to talk to the arm via the USB port. Somebody else wrote a Mac OS X app using IOKit to talk to the arm via USB. There’s also a Python project that uses libusb to talk to the arm. At first, it didn’t seem like I could use Elixir to control it, but I found an article on Elixir’s Ports and NIFs, which lets Elixir talk to external code. Using that example as a base, I modified the C program to talk to the USB port like the C program in the reverse engineered protocol article and created an Elixir module to talk to my new C program via a port. The result is ExRobotArm, which ables you to fully control the arm with Elixir. I tried it on both Mac OS X and my Raspberry Pi. Now it is totally plausible to attach the arm to whatever robot has a Raspberry Pi controlling it.

My compass and GPS module for the GoPiGo have arrived, so that’s next. Then more work on ExGoPiGo.

comments powered by Disqus