Andrew Nesbitt: JavaScript in the Real World

Orde Saunders' avatarPublished: by Orde Saunders

Andrew Nesbitt (@teabass) was speaking at Full Frontal about taking over the world with a fleet of JavaScript powered quadcopters, these are my notes from his talk.

Any application that can be written in JS can be written in JS will be written in JS. ~Jeff Atwood. The Linux kernel has been cross-compiled in JS. You can compile JS in JS! People are taking JS out of the browser into hardware examples - build cat is on GitHub.

Why JS? It's already there in C. JS is higher level, removes the need to worry about pointers and memory allocation - moore's law is working for us here. We can use better abstractions and get more done faster. It's async so we don't have to wait for the hardware to come back and stop blocking our code. It lowers the barrier to entry, lots of people are already doing JS - close to one million JS repos on GitHub.

Hardware

Arduino

The classic, lots of resources avaialble. JS won't run on the Arduino so we talk to Firmata (via the Johnny Five NPM module) which will then talk to the Arduino. Johnny Five is the jQuery for the hardware - abstracts the implementation details into a nice code interface.

Kinect controlled robot arm. The kinect has a npm module so we can read from this and then send the read data to the Arduino that runs servos that matches the joint movements.

Rabbit with laser eyes. Randomly fires two servos to set a position and then triggers the laser pointer.

Lego

Lego Mindstorms EV3 kit has some really useful modules but the core is a Linux machine with Bluetooth so we can talk to it with a serial port. There is a npm module to connect to Mindstorm. Can hook up an Xbox controller (which has an npm module) and use it as an input and then send the commands to the Lego.

There is a new thing that will actually run node on the Mindstorm Linux core.

Nodecopter

Parrot AR drone runs Linux on board and has loads of sensors - basically a flying Android phone. There is an npm module to control the drone. Code to do this is very easy but it's a flying robot - it's never that simple but it's still lots of fun!

With such a high level API we have quadcopter as a service. We don't have to worry about the mechanics of flying, that is handled by the lower levels so we can get on with doing stupid and fun things!

JavaScript microprocessor

Tessel should be available next year - also Espruino. These will run completely autonomously. The RaspberryPi will also run node onboard. Arduino Yun is like a RPi/Arduino mashup. All of these are under £75 and have different use cases.

JavaScript hardware in the browser

The development that has happened in node is now coming back into the browser - FirefoxOS is a great example of this. Future APIs include UDP, NFC, USB and Bluetooth. Enables us to react to the physical world in a web page. You can use web dev skills to control hardware from a browser.


Comments, suggestions, corrections? Contact me via this website