How It Works

Tom Tilley edited this page May 13, 2015 · 1 revision


The original version of the control and telemetry code for Lollybot grew out of code I had written for various projects that used hacked joysticks. The code was written in Object Pascal using Delphi. Unfortunately, there are currently no free versions of Delphi available (although Lazarus is a possible alternative) so students wanting to build or modify the code for themselves would have to pay for a development environment. In addition this code will only run on Windows machines.

My teenage son had been learning some JavaScript in an after-school class and suggested that I make an HTML5/JavaScript version of the code that could run in a web-browser. I thought this would be a great idea - the tools to develop or modify the code would be free and it would be cross-platform. Unfortunately, web-browsers are sandboxed so the browser wouldn't be able to communicate with the robot via USB.

The solution was to use Node.js - a stand alone version of Google's V8 JavaScript engine that could talk to the robot via USB and send/receive data from a web-page.


The software uses a plug-in for Node.js called node-hid that can communicate with USB devices like keyboards, mice, bar-code readers, joysticks, etc. Node-hid is a JavaScript wrapper for the HID API library. Another plug-in called Socket.IO is used to send telemetry data and receive control signals to/from a web-interface written in HTML5 + JavaScript (see the image below).


Both Node.js and the web-browser can be run on the same machine but it is also possible to connect to a Node.js server running on another machine over a network (via the "Settings" panel on the Lollybot software). Node.js is available for Windows, Linux, and Mac OS and the web-interface will run in any modern HTML5 compliant browser so this provides an environment for Lollybot that is cross-platform, free, and the client can be running across a network. See the image below.


Server Code

The Node.js server code is in the file 'lollybot-server.js'. In addition to node-hid and, it also relies on another plug-in called Commander.js which is used to read command-line options for the server.

Client Code

The HTML mark-up, JavaScript code, and CSS layout for the web-interface client are contained in three files:

  • [index.html](,
  • [lollybot-control.js]( in the '[scripts/](' directory, and
  • [lollybot.css]( in the '[css/](' directory'

    The JavaScript code also makes use of:

  • jQuery which abstracts over browser differences and makes JavaScript easier to use,
  • the jQuery.Sparklines plugin which is used to draw the analog joystick graphs, and
  • the client-side code for Socket.IO.
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.