I want to build a robotbut I hate solderingI love codingbut I hate the pain of embedded languagesI want pro gear: servos, motors, accelerometers, GPS, etc.but I don’t want to have to care about TTL, parity checks, serial cables or baud ratesI want it on the webI want it nowtomorrow is acceptable
We have modern, low wattage RISC based ARM processorsWe have modern interpreters (i.e. V8) that are very good at optimising our code at run timeWriting device drivers in C/C++ is a total chore for most people and should be avoided if at all possibleWe can buy off the shelf components that can do our time critical stuff and still talk high level protocolsIt’s not the 90s! Why are we even talking about writing device drivers?
It makes a lot of high level tasks very easyproduce a working prototype, fastavoid boring tasks that have already been solvedall the wholesome goodness of the Internet OOBeventscan everyone say "behaviour"?These days it can do cool things likebe a serverreal time Internet using WebSocketsspeak protocols other than Internet, e.g. serialBig communityJS is the World's most popular programming language and is FTW
Nodecopter helps us talk to a proprietary helicopter dronethat's just talking to a robot that someone else built.Nodeserial helps us talk to the serial portthis is great because it's useful for all sorts of devices but it doesn't tell us how to talk to our devicesFirmataLovely idea but just tells us how to talk, not what to sayJohnny5 helps us control an Arduino with JSagain, great but if I want cool stuff like GPS I still have to wire it myselfstill doesn't help with our goal of fully integrating both meat and cyber spaces
Model-Collection-Controller/Model-View-CollectionDiscrete physical devices are represented as discrete models in memory on serverModels bound to device change eventsControllers talk to client via WebSocketsRobot's canonical state kept on server (the car itself!), allowingautonomous behaviournetwork failover handled gracefully
WifiPololu (serial using serialport)Phidget (http/serial bridge using phigetapi)
Solving the robot problem• I want to build a robot• I love coding• I want pro gear – servos – motors – accelerometers – GPS – etc• I want it on the web• I want it now
So, this robot…• has physical devices that attach simply• is running a software framework that – talks to those physical devices – exposes their properties to the web – responds to user input from the web in as close to real time as possible – can express a degree of autonomy – is fast to develop in
Those guys don’t know everything• We have modern, low wattage RISC based ARM processors• We have modern interpreters (i.e. V8) that are very good at optimising our code at run time• Writing device drivers in C/C++ is a total chore for most people• We can buy off the shelf components that can do our time critical• It’s not the 90s!
What do they do for us?• Nodecopter helps us talk to a proprietary helicopter drone• Nodeserial helps us talk to the serial port• Firmata helps us talk with an Arduino• Johnny5 helps us control that Arduino with JS
What’s the ideal architecture?• We want a familiar interface• Web pages are good• Something REST-like would be ideal• Express helps• BackboneIO (Backbone over WebSockets)• State machine representation of physical devices• Adding a new physical device should be as simple as plugging it in
What’s the ideal architecture?• Model-Collection-Controller/Model-View- Collection• Discrete physical devices are represented as discrete models in memory on server• Models bound to device change events• Controllers talk to client via WebSockets• Robots canonical state kept on server, allows autonomous behaviour
Step up Raspberry Pi• Modern ARM based SOC• Low power• Runs Linux• Loads of storage space• USB 2.0• Bonus onboard graphics processor
Add some clever USB devices• Wifi• Pololu – serial comms using serialport• Phidget – http/serial bridge using phigetapi
Add Node.JS and the SPD framework• Listens on local TCP/IP network• Serves up dynamic web pages• Uses Backbone API• Automagically builds models on client• Changes in remote hardware bound directly to client-side events• Looks to all the world exactly like a web site• We don’t even have to care about transport
Give me that checklist• It’s got servos• It’s got motors• It’s got GPS• It’s got accelerometers• It’s got Arduino (should you really need non-USB based sensor arrays)• It communicates with the web in real timeIt’s going to get a lot more• Real time streaming HD video• Kinect vision• Firmata?
Enough talk• Drive the car around the stage• Get my Google Map on• Detect a crash• Damn
NotesBibliography Shout outs• Available on request • jashkenas • voodootikigod • RIAEvangelist • visionmedia