Sunday, November 9, 2014

SeanBot - An EV3 robot controlled via a web interface

I built a cool little robot recently and even managed to convince myself that it was somewhat work related.  Sean, one of my co-workers at Cumulus Networks, and his wife were expecting their first child so Sean wasn't going to risk making the trip to California for a quarterly meeting since it was too close to their due date.  I hadn't done a cool mindstorms project recently so I offered to build a little robot that he could control via the web and drive around the offices at headquarters.  The idea was to have the robot hold an iPhone running Skype so that Sean could drive around the desk during the meetings and chat with everyone.

I decided to use one of the EV3 bonus models, EV3D4, as the robot.  It is small but very mobile so it seemed like a good choice.  That and it is based off of the Star Wars robot R5-D4 (the little red robot the Jawas were selling along with R2-D2 and C-3PO in Episode IV) so that just makes it extra cool.  Originally I told my 5-year old that it was R2-D2 but he called me out with "Daddy that isn't R2-D2, it needs to be white and blue to be R2-D2, not white and red".  Outsmarted by a 5-year old...

HiTechnic's Rotacaster
In terms of the hardware the main change I made was to use an omniwheel, officially I used a Rotacaster from HiTechnic.  An omniwheel rotates like a normal wheel but can also slide from side to side...they are handy if you have robot that needs to spin in circles.  I also used a very small wifi dongle called 'The Pi Hut' but be warned you can't use this with the standard EV3 software...more on that in a bit.

You can see the robot in action here with the omniwheel front and center, iphone mounted, etc. Sean used Skype to dial the iphone from his desk so that is him on the phone there.

For the hardware I didn't change much from the stock Lego instructions but for the software I took a very different approach.  I needed the robot to run a web server that would allow Sean to control the robot via a web browser.  I couldn't find a way to do this via the standard software that ships with the EV3 but good news, there is a great little project call ev3dev that built a debian linux distribution that will run on the EV3.  In other words you just boot debian linux on your EV3!!  This gives you tons of flexibility and it means that you no longer have to use the graphical programming language provided by Lego.  Python is my favorite language and it turns out that with ev3dev you can program the EV3 in python...perfect!!

All of the code for this project is available on github, feel free to use it:

How does the code work?   When the user clicks on a button on the web page, AJAX is used to send a HTTP GET to's REST API (it is listening on port 8000) to tell it to move forward, backward, etc.  When the user releases the button we send another HTTP GET to tell it to stop.

The Star Wars page on the left of Sean's screen is the web page served by the robot.  You just click the arrows to make the robot move.

Here is SeanBot in action for the quarterly meeting, SeanBot is in Mountain View, CA but Sean is driving it from Apex, stuff.

And last but not least here is Sean's beautiful daughter :)  She was born a few weeks after the meeting in California ended and is keeping Sean and his wife plenty busy.