Raspberry Pi Robotics Web Interface ----------------------------------- Lukas Platinsky, Jan Jachnik, Duncan White and Jacek Zienkiewicz We have prepared a simple framework that will allow you to display and visualise what your robot is doing via a web browser (whether on a PC, phone or tablet). The solution is based on a web server that runs on the Raspberry Pi and use node.js for real-time graphics output. You will also be able to upload your Python programs to the Raspberry Pi through the web. To set up the server please follow these instructions: 1. Log in to your Raspberry Pi (either via ssh or locally) and while in the home directory of the pi user execute the following commands > sudo update_brickpi > setup_nodejs setup_nodejs will prompt you to create a password required for accessing the website hosted on the Raspberry Pi (this can be the same as the password for the 'pi' user, but do NOT leave it blank). After you enter it, it will fetch all it needs and deploy the server. It may take a minute or so... 2. Once the installation is completed, you should be able to connect to the Raspberry Pi at port 9000 from your browser. Just go to http://YOUR_RASPBERRY_PI_IP:9000, e.g. http://129.31.209.7:9000/. **SEE 4. BELOW FOR A NEW EASY WEB-BASED WAY TO OBTAIN YOUR CURRENT IP ADDRESS** Enter "pi" as the username and the password you have chosen to access the site. In case the server doesn't start automatically, you can run it manually by executing: > sudo /etc/init.d/nodejs.sh start To stop the server, run: > sudo /etc/init.d/nodejs.sh stop The server is set up to start automatically on boot. You can check if the server is running by calling: > ps cax | grep node 3. In your browser you can now upload some Python files and they will appear on the left. You can run them by clicking on the file name. These files can be found in ~/prac-files directory on your Raspberry Pi. While on the Pi, you can also copy the files into the ~/prac-files directory and they should be automatically accessible via the web-browser. By default, there are two files in ~/prac-files, testDraw.py and test.py, that demonstrate how to use the drawing framework and get a real-time stream from the Python terminal. Please have a look at them. You can output simple 2D graphics from a Python program to the web interface which can be used to visualise the state of a particle filter or anything else. The Python program does not need to call any libraries to achieve this drawing. It simply has to print text in the correct format. While most print statements will lead to the raw text being displayed in the browser, if you print lines with the drawLine or drawParticles keywords they are picked up by the web server and interpreted as graphics commands. So in Python: Drawing lines: 'print "drawLine:" + str(line)', where line is a 4 tuple (x0, y0, x1, y1). Drawing particles: 'print "drawParticles:" + str(particles)', where particles should be a list of 3-tuples (x, y, theta). Known issue: - sometimes when you want to draw many (> 500) particles, or if you draw too quickly (sleep < 0.05) the lines get split and hence the drawing is not activated, but you get the numbers in the text output. - If you need to reinstall the server, please follow these instructions: 1. Make sure the server is not running: > sudo /etc/init.d/nodejs.sh stop 2. Remove the 'server' directory from your home directory. 3. Run setup_nodejs again. 4. New web-based interface to get the IP ADDRESS OF YOUR RASPBERRY PI: The following website allows to query the IP address of you Raspberry Pi based on the MAC address: https://www.doc.ic.ac.uk/~ajd/robotics Note that this website is only accessible if you are on the College network --- if you are using a phone or tablet, it must be connected to the Imperial-WPA WiFi network. It may ask for your college login details. If it finds your MAC address in the database checks that you have a running web-server. If so a link will appear to forward you right through.