Home arrow Enthusiast Projects arrow 914 Web Interface
914 Web Interface
Monday, 22 January 2007
Here's my first enthusiast software project, a web interface for the 914. This is the very first development version that's good enough for public consumption so there are a few important things to say first:


This is very much in development so needless to say there are many improvements to be made. It is also written in a combination of Perl and Python, this is because the original version was completely written in Python but there were some issues with the development webserver that comes with Python, hence I ported the web front end to run in Perl within a CGI script on Apache, but left the back end process/comms in Python. You can always port the IP/comms part to another language but I feel that Python is more readble to someone who programs in neither Perl or Python.

USE THIS SOFTWARE AT YOUR OWN RISK. It is provided as a demonstration of what can be done easily with free software and to make a point that a web interface is a handy thing to have. Be very careful if you make this internet facing as there is no authentication or security in this version. This software provides the very very basic functionality, but of course feel free to use it on your internal network etc. You may also want to use it as a basis to build your own web interface, all of the source is text readable due to the nature of Python and Perl.


Currently, using BRIAN, the 914 can only be controlled remotely by making a direct IP connection from BRIAN GUI to the BRIAN service that runs on the 914. However, if you are behind an http proxy firewall, like I am at work, then you’ll be unable to connect as the proxy blocks all direct connection, only fetching web pages that you request from it and returning them to you. The only way that you’d be able to control the 914 is via a web page.

Secondly, BRIAN GUI is only for Windows, so you cannot control the 914 on Linux or another O/S unless you install Player/Stage or write your own application. However, a web page can be viewed on any O/S that has a supported web browser.

Development version 1

This is development version 1, the ‘development’ part of the title is important as stated above. This version has the following features and functionality:

-Runs on Apache web server, or any web server that supports CGI and Perl.

-Allows a simple web page to be viewed where you can click on various buttons to drive the 914 forward/back and turn left/right. You can also turn on/off IR assisted driving.

-Has a back end process that communicates with the BRIAN service on the 914 over IP, effectively replacing BRIAN GUI for the functionality listed above.

The software can be used in a variety of ways. The simplest way to run it is on the 914 itself so that you would navigate to the Bot’s IP in your browser to control it from another PC. You could also install it on another PC or server leaving just the BRIAN service only on the 914 and navigating to the server’s IP in your browser. The server would in turn talk to BRIAN over IP. Either way, the web server must have IP connectivity to the 914 and the operator must have http connectivity to the server.

Option 1: Install it all on the 914 and access the 914 through a browser:


Option 2: Install it on another PC/server and have that talk to the 914, access the server in your browser:


How to make it work

To make it all work from scratch on Windows you will need to install the following:

-Download and install Apache web server. I used version 2.2.4 which is current at the time of writing. Install this with the default settings with the exception of the server and domain name which should be set to: localhost

-Once Apache is installed you should be able to navigate to http://localhost in a browser (on the same PC you installed it) and see a page that says ‘it works’ on it.

-Install ActivePerl, I used version 5.5.8 which is current at the time of writing. Install with the defaults.

-You will then need to modify your httpd.conf file to allow CGI and Perl to work, this is located in C:\Program Files\Apache Software Foundation\Apache2.2\conf . Here is my working httpd.conf file so you can overwrite the original, assuming you installed Apache in the default location it should work, otherwise you’ll have to edit the various Directory path sections.

-Download and install Python, I used version 2.5 which is current at the time of writing. Install with all the defaults.

-Download this file, webv1.zip, which contains all of the 914 Web software. Unzip it into the C:\Program Files\Apache Software Foundation\Apache2.2\htdocs directory, overwrite anything that is there now. It should look like this.

You should now find that if you navigate to http://localhost in your browser you see a page that says ‘Robot Control’ in the title bar and just says ‘Enter’ on the page. Feel free to click enter and you should see four green arrows, a stop button, and some other stuff.

Image Operation

So far, you should have a web page that you can access on the PC where you installed it, or from another PC on the network. When you click on the arrows or any other hyperlink you should notice that the value=x line at the bottom changes to a different value. If you inspect a file called ‘value.txt’ which is also in the htdocs directory (where you unzipped everything), you’ll notice that the value from the web page gets written there each time you update it.

Next, you need to attach the web service to BRIAN so it can be controlled from each command. For this, there is a separate script written in Python called ‘command.py’, which reads the contents of value.txt and translates each into a BRIAN command, then sends them over IP to control the 914.

Provided you have installed Python ok, you should be able to simply double click on this file and have it run. It will pop up in a black shell box and attempt to connect to BRIAN on port 13000, if it is successful it should display a message that says “I think I’m connected to BRIAN on port 13000” – this is because it will connect to anything on 13000 that will accept incoming connections.

Now, as you click on the buttons on the web page you should see the command.py program send the commands to BRIAN, hopefully BRIAN will react by moving the 914 around. Note: if you did not install this software on the 914 itself, then you’ll have to edit the command.py file in notepad or another text editor, change the line right at the top that currently says : IP = "localhost", change it to the IP of the 914 / where BRIAN is running.

Testing and debugging

Obviously there are quite a few things that are required to make this work and many things that could go wrong. Things to remember are:

-Apache and Perl are required for the webpage to be displayed and update the value to value.txt.

-Python is required to do the comms, although you could port this portion to another language easily as I mentioned in the beginning.

-The web server must be able to communicate with the 914 over IP on port 13000, if BRIAN GUI runs between the same computers ok then this should work too.

I’ve also provided an additional file called ‘tcpserver_debug.py’ which pretends to be BRIAN – listening and accepting connections on port 13000, but just displaying the commands it receives. If you get stuck with the IP/comms portion of this, or you just don’t have a 914 with BRIAN on it, you can use this program for testing and debugging.

If you double click on the tcpserver_debug.py file to run it (requires Python), it should sit waiting for a connection on port 13000 from either the command.py program, BRIAN GUI, or anything else that tries to connect on port 13000. Once something connects it will display the IP they connected from and then print data to the screen as it is received.

You can run this whole thing on a PC without a 914 at all using the tcpserver_debug.py file. Check out this screenshot of me doing just that. Top right is the web page, top left is the command.py window sending data as you click on the web page buttons, and bottom left is the tcpserver_debug.py program receiving and displaying the commands it receives.

The Future

There are obviously many improvements to be made and extra functionality added, probably too many to list here. Some of the immediate ones are:

-Provide feedback from the 914 for sensor status and various other things that you can get at in BRIAN GUI.

-Add many extra features for sending commands to the 914 such as speech and everything else.

-Provide authentication and review security for making it internet facing.

-Make the command.py program run as a service, you can register it as a service with the instsrv.exe program that comes with the Windows 2000 resource kit. Or it could be ported to C++ / some other language and written as a windows service. Maybe add ‘connect/disconnect’ functionality from within the web page.

-Use a database like MySQL instead of a text file, this will allow better performance and easier addressing of the data going backwards and forwards.

You could of course achieve the same thing in a variety of other ways, including Flash Action Script, PHP/MySQL, and many others. Feel free to use hack around with this software and even use it to control another program completely that talks on IP. Apache / Perl and Python are all free software, all the files can be directly edited as text in notepad or another text editor to add extra features.

Discuss this article on the forums. (3 posts)
< Prev   Next >