Create an Internet Controlled Robot Using Livebots

by XicoMBD in Circuits > Raspberry Pi

108134 Views, 188 Favorites, 0 Comments

Create an Internet Controlled Robot Using Livebots

Screenshot (109).png
Here you will learn how to create an internet controlled robot or other installation using Livebots.

Livebots is a project I'm working on which consists of an easy to use website for all the robots that people can interact with through the internet.


As an example I will be using a simple Arduino UNO with a LED connected to an Raspberry Pi to show you the concept, but of course you can use anything that can be receive messages by the serial port and any computer you would like.

Here is it:
 

And here is another example:

 

Program the Arduino

arduino.png
Attached is a simple arduino program that reads the messages form the serial port and lights the LED when they contain "HIGH" and turns it off when "LOW".

Feel free to adapt it to your own needs.

Downloads

Add the Robot to the Livebots Website

Screenshot (112).png
Screenshot (113).png
Screenshot (115).png
Screenshot (120).png
Screenshot (116).png
Screenshot (117).png
Start by creating an account (http://livebots.cc/Account/Register).

Click Add a Robot and upload your bot's picture (http://livebots.cc/Upload/1).

Then you can add your robot information that will appear on the robot's page.

Install PySerial

vlcsnap-2013-01-12-19h58m48s113.png
vlcsnap-2013-01-12-19h59m04s29.png
vlcsnap-2013-01-12-20h51m58s237.png
vlcsnap-2013-01-12-20h52m12s156.png
vlcsnap-2013-01-12-20h52m25s49.png
vlcsnap-2013-01-12-20h53m08s218.png
vlcsnap-2013-01-12-20h53m34s218.png
vlcsnap-2013-01-12-20h53m51s138.png
In order to let python communicate with arduino you will need to install pySerial: http://pyserial.sourceforge.net/  

1. Download and click open: http://sourceforge.net/projects/pyserial/

2. Unzip and untar the files

3. Install pySerial. On a terminal window, navigate to the folder where you have the files and run the following command:
cd pyserial-2.5
sudo python setup.py install

For more info on how to do this on raspberry pi go here:
http://www.doctormonk.com/2012/04/raspberry-pi-and-arduino.html

PS: If you're on Windows make sure you have python installed: http://www.python.org/getit/windows/ (Thanks msandersmay10 for pointing this out!)

Get Livebots Python Class

vlcsnap-2013-01-12-20h54m15s103.png
vlcsnap-2013-01-12-20h54m23s207.png
vlcsnap-2013-01-12-20h54m38s98.png
vlcsnap-2013-01-12-20h54m57s32.png
vlcsnap-2013-01-12-20h55m15s179.png
vlcsnap-2013-01-12-20h55m29s91.png
vlcsnap-2013-01-12-20h55m56s120.png
vlcsnap-2013-01-12-20h56m40s41.png
We have a respository for the pyhon code we use to control the robots, you can find it here: https://bitbucket.org/XicoMBD/livebots

In order to use it to control your own robot just follow this steps:

1. Download livebots.py from the repository and save it somewhere convenient

2. Open the terminal window and navigate to the folder where you saved the class
cd ..

3. Run python:
python

4. Import the library:
>>>from livebots import *

5. Create the livebot (Enter the Livebot number on the first field and the serial port name on the second):
>>>livebot('9','/dev/ttyACM0')

Get the Webcam Streamer for Raspberry Pi

vlcsnap-2013-01-12-23h22m35s19.png
vlcsnap-2013-01-12-23h23m22s209.png
vlcsnap-2013-01-12-23h23m46s237.png
vlcsnap-2013-01-12-23h24m35s205.png
vlcsnap-2013-01-12-23h25m10s44.png
vlcsnap-2013-01-12-23h25m45s139.png
vlcsnap-2013-01-12-23h37m57s245.png
vlcsnap-2013-01-12-23h26m48s1.png
vlcsnap-2013-01-12-23h27m18s41.png
Screenshot (94).png
Screenshot (95).png
Screenshot (96).png
Screenshot (97).png
To stream the webcam video using raspberry pi, mjpg-streamer should be the best option: http://sourceforge.net/apps/mediawiki/mjpg-streamer/

I
n order to install it on your pi follow the steps:
1. Install subversion:
sudo apt-get update
sudo apt-get install subversion

2. Go to the folder where you want to have the mjpg-stremer, for example /home/pi
cd /home/pi

3. Get mjpg-streamer:
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer

4. Install libjpeg8-dev
sudo apt-get install libjpeg8-dev

5. Install ImageMagick
sudo apt-get install imagemagick

6. Make the project:
cd mjpg-streamer/mjpg-streamer
make

7. When it finishes you should be ready to start streaming your video. To do so, enter the following command:
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"

8. Now you should be able to view the stream from other computer on your network. Open a web browser and open the following link:
http://{name or IP-address of the Raspi}:8080

9. However, to let the stream be viewed from outsite your network you will need to port forward your router. This varies from router to router, so please search on google how to do it on yours.


For more information go here: http://wolfpaulus.com/journal/embedded/raspberrypi_webcam

Put the Stream on Livebots and Setup the Control Mode

Screenshot (115).png
Screenshot (121).png
Screenshot (122).png
Screenshot (123).png
Screenshot (124).png
Screenshot (125).png
Screenshot (126).png
Screenshot (128).png
If you're using mjpg-streamer select it on the Stream Mode combobox and paste your URL on the Stream URL textbox (for example: http://79.169.49.122:8090)

The you can choose your control mode. If you go for the Buttons, select it on the Control Mode combobox and add your buttons content on table.

If you want color on the buttons add one of the following tags to the cell:
  • #Green
  • #Red
  • #Blue
  • #Orange
Uncheck the Is Draft box, check the LIVE box and it's done!

Now your robot will appear on the robots list and on the front page.

Have Fun!