Web interface for a BeagleBone controlled robot

Given a situation where one needs to implement a simple RC interface for a robot. What’s more straightforward? We could create a thick client and implement a server application for the robot but that’s too complicated. In order to have something light-weight and portable I was thinking of implementing the RC interface using some HTML and possibly some cgi.

The outcome of this tutorial will be a webpage that looks like this:



After a bit of googling around I found out that there are plenty of light-weight html frameworks working from python, javascript, and various technologies.

I chose a framework called pico.

https://github.com/fergalwalsh/pico/wiki

Execute these steps on the BeagleBone:

git clone http://github.com/fergalwalsh/pico.git
opkg install python-distutils
opkg install python-compile
cd pico 
python setup.py install

This should install pico on your BeagleBone. Now you can cd into an example directory and try it out!

cd examples/helloworld
python -m pico.server

Now you can play a bit with the example and then I’ll continue.

Finished already? Let’s continue with putting something actually working behind the web interface.

****

If you don’t have any idea what to do for a start use this led blinker script below. I’ll create a script to send commands to my Arduino.

wget http://gigamega-micro.googlecode.com/files/gpiotester.py
****

Since I have an Arduino behind the BeagleBone for now I’ll have to communicate with that through serial port.

Let’s get and install pySerial.

wget http://pypi.python.org/packages/source/p/pyserial/pyserial-2.6.tar.gz
tar -xf pyserial-2.6.tar.gz
cd pyserial-2.6
python setup.py install

Easy isn’t it?

So now that we have a Serial class we can communicate with the Arduino from the BeagleBone using Python.

I wrote the script below to control the robot. Yeah, it’s not too elegant but will do for now.

http://buggers.svn.sourceforge.net/viewvc/buggers/robots/scarabeus/beaglebone/webcontrol/beagle2arduino.py?view=markup&pathrev=336

Note that I’m using string commands so I’m sending strings directly to my Arduino.

Now that we have something to call from a webpage, let’s create the page itself!

You should check out the codes in the example folder to get the hang of the framework, it shouldn’t take too long.

This is what I came up with in the end:

http://buggers.svn.sourceforge.net/viewvc/buggers/robots/scarabeus/beaglebone/webcontrol/index.html?revision=325&view=markup

Note: if you are experiencing some kind of lag or blocked messages, you can help it by running the following on the BeagleBone. This “wakes up” the serial port. The above python code of mine will require a bit more massage to get this effect.

screen /dev/ttyUSB0

And finally here’s a video of controlling my rover using the above web page:

Like if you like my whistling and of course comments are always welcome!

References

http://pypi.python.org/pypi/pyserial

http://www.mediacollege.com/internet/javascript/form/add-text.html

https://github.com/fergalwalsh/pico/blob/master/examples/helloworld/index.html

http://www.w3schools.com/

Advertisements

6 thoughts on “Web interface for a BeagleBone controlled robot

  1. Hi, I’m inspired by your project and doing a project on beaglebone controlling arduino boards through serial, could you share with me your beagle2arduino.py? it’s no longer in the link you pointed.

    regards,

    Henry

  2. Hi there, I like what you’re doing and as Henry was saying, it is inspiring.

    I’m doing a rover based on a traxxas Stampede truck. I’m using the beaglebone alone to control the direction servo, the ESC (via PWM). Headlight are also dimable from PWM control and I have a 2 axis tilt an swivel for a camera. All that is controlled with pybbio and the pico stuff you shared in this blog.

    My main web server is Lighttpd, the camera is streaming with mjpg-streamer and there is the PICO stuff talking to the servo and PWM libraries of PYBBIO

    I do have one question. You indicated how to run Pico from the command line and in their website, they’re talking about WSGI integration. (with Apache and mod_wsgi)

    Do you know of a way to make the same integration with lighttpd ?

    1. Unfortunately no. We are investigating more lightweight solutions now to this case.

      It’s cool to know that there are other rovers out there we could help with 🙂

  3. Hello,
    I recently got a beaglebone black which is running debian on it. I wanted to create a web based server for it. But I am unable to follow the steps you mentioned. When i try to go into the pico directory and try accessing the example folder it says no such file or folder exists. I don#t understand why my folder does not contain the examples..

    Could you kindly suggest something,
    Namita.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s