Sunday, December 11, 2011

NEW PROJECT: Robot Exploration and Mapping using Websockets

For some time now, I have been working on this project but I have not published anything until now. The goal of the project is to use a small mobile robot to explore and map an area. The real cool thing about it is that the map is built in real time and can be viewed using any browser that supports HTML5 and websockets.
HTML5 is the fifth revision of the HTML language for presenting content on the world wide web and, as of November 2011 is still under development. In this project I make extensive use of a new HTML element, introduced with HTML5 called the canvas element. It is basically used to draw images that are then displayed on the browser. Specifically, I use three canvas elements on top of each other with the first displaying the calculated position of the robot, the second displaying the map and the third displaying the occupancy grid.

Also exciting is the use of websockets to link the client browser (real time map builder application) with the server. Wikipedia states that "websocket is a technology providing for bi-directional, full duplex communications channels, over a single Transmission Control Protocol (TCP) socket".

On this project I have adapted a python script that implements draft 76 of the websockets protocol (available only on safari as the time of writing - other reference browsers have support for websockets but are now on a posterior, more robust and secure version. I don't feel like reprogramming my server to work with the new version of chrome so I chose to use safari for windows to still be able to use the older code - hoep this doesn't get auto updated as y copy of chrome did!

The python code above also receives serial data from the robot (sent over wireless radio using an xbee module) and makes it available to the client application. Also running on the same machine, besides this websocket server is a http server also written in python. Both scripts are adapted from scripts freely available on the internet.

I also make heavy use of javascript as the client page uses it to display information real time on the screen.

On the robot, I use pololu robot base with two arduinos, one connected to the xbee shield and the other connected to a custom shield that I built and that basically takes care of all sensor connections and basic electronics to allow them to be connected to the arduino. Both boards exchange data over an i2C link.

Currently I can send data from the mobile robot to the browser, and I can control the robot manually through the browser on a proof of concept application of data moving both ways over a websocket connection.

I will leave you here now, in a week or so, I will post some screenshots of the system in action and perhaps a demo video.

In the meantime, let me know if you have any questions.

No comments: