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?  The /var/www/ content is served by the main webserver (apache, etc).  LegoR2D2.py runs a REST API on port 8000.  When the user clicks on a button on the web page served by apache, AJAX is used to send a HTTP GET to LegoR2D2.py'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, NC...cool 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.

17 comments:

  1. hi,

    I want to control ev3 with an online website hosting somewhere outside (not hosting in the ev3 brick) for control the basic movements at this momment. With this even though i am not connected to the same network as the ev3 connected, i can also control the its movements. Previously, i have tried with the leJOS firmware but it was hosted in the ev3 brick (device not connected to the same network not able to control ev3). I am still new to all this, wondering is this project does exactly the same to what i am thinking ?

    ReplyDelete
  2. If you want to control the ev3 remotely you have to have a server of some sort hosted on the ev3 that can receive the commands you want to send it. You also have to have IP connectivity to the ev3 if you want to control it via a web interface. I ended up using two servers for seanbot:

    #1 - apache to serve the web page with the controls
    #2 - A REST API server that listened for requests generated when the user clicked on a button presented by #1

    You could move the #1 server somewhere other than the ev3 but #2 you have to have on the ev3.

    I hope that helps. If not can you post some more details on exactly what it is you are working on?

    ReplyDelete
  3. Thank you very much for your help, it works very WELL and now i managed to control ev3 robot REMOTELY via a web interface hosted in my laptop for a absolute beginner in python :)) .

    ReplyDelete
    Replies
    1. how did you do it im trying to do the same thing with a tankbot i built. im trying to host apache and a webcam feed on a raspberry pi that is on the bot with the ev3 i think i got the networking established... i couldnt get apache 2 on ev3dev the raspberry pi is running raspbian

      Delete
  4. what is the apache server package name for apt-get?

    ReplyDelete
  5. what is the apache server package name for apt-get?

    ReplyDelete
    Replies
    1. apt-get couldnt find the package i know its availible on rasberry pi could you maybe edit the git repo u have so it listens for requests from #1 then responds... the pi will be responcable for a camera feed and recieving commands... the ev3 will just react... i also already got the webcam feed its just net controll... and do you think i could send the request through a usb cable instead of a network?

      Delete
    2. also ive been the person that keeps forking ur repo

      Delete
    3. srry about this I wish they could edit comments... how do I place the webpage content in var/www/

      Delete
  6. Awesome post! This is something that I wanted to do and I've based on this post to successfully built mine. I have written a step-by-step guide to share what I've encountered and solved and I hope it will help others who wants to get this built. Thanks again.

    http://pandaeatsbamboo.blogspot.hk/2016/07/using-web-and-cisco-spark-to-control.html

    ReplyDelete
  7. FYI there is an update to the seanbot web UI:
    http://programmablebrick.blogspot.com/2016/10/seanbot-20-smartphone-web-interface-for.html

    ReplyDelete