scaling into meatspace: a javascript engineer's persepctive
DESCRIPTION
A short presentation and demonstration of a robot I made at MLOC.JS 2013.TRANSCRIPT
![Page 1: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/1.jpg)
Scaling into MeatspaceRobotics from the perspective of a JavaScript engineer
![Page 2: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/2.jpg)
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
![Page 3: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/3.jpg)
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
![Page 4: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/4.jpg)
But isn’t JavaScript a terrible language to build robots with?
• JavaScript has bad timers• Very slow and memory inefficient compared
to close-to-the-metal languages like C/C++• All the C/Java guys I know are like, "What the
hell are you doing? Are you crazy?"
![Page 5: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/5.jpg)
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!
![Page 6: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/6.jpg)
What do we gain by using JavaScript?
• It makes a lot of high level tasks very easy• These days it can do way cool stuff• Big community FTW
![Page 7: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/7.jpg)
Who’s crazy now?
![Page 8: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/8.jpg)
What currently exists for JS robotics?
• The original talk: http://www.slideshare.net/nonken/robotic-javascript
• Nodecopter (nodecopter.com)• Nodeserial (@voodootikigod)• Firmata (Julian Gautier)• Johnny 5 (Rick Waldron)
![Page 9: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/9.jpg)
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
![Page 10: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/10.jpg)
What’s the ideal architecture?
![Page 11: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/11.jpg)
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
![Page 12: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/12.jpg)
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• Robot's canonical state kept on server, allows
autonomous behaviour
![Page 13: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/13.jpg)
Step up Raspberry Pi
• Modern ARM based SOC• Low power• Runs Linux• Loads of storage space• USB 2.0• Bonus onboard graphics processor
![Page 14: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/14.jpg)
Add some clever USB devices
• Wifi• Pololu– serial comms using serialport
• Phidget– http/serial bridge using phigetapi
![Page 15: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/15.jpg)
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
![Page 16: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/16.jpg)
Robot is online
![Page 17: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/17.jpg)
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 time
It’s going to get a lot more• Real time streaming HD video• Kinect vision• Firmata?
![Page 18: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/18.jpg)
Enough talk
• Drive the car around the stage• Get my Google Map on• Detect a crash• Damn
![Page 19: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/19.jpg)
Notes
Bibliography• Available on request
Shout outs• jashkenas• voodootikigod• RIAEvangelist• visionmedia
![Page 20: Scaling into Meatspace: A JavaScript engineer's persepctive](https://reader036.vdocument.in/reader036/viewer/2022062511/54bc5e394a7959a74f8b45a1/html5/thumbnails/20.jpg)
WWW.YAMMER.COM/JOBS@rayui
WE’RE HIRING