39
$\begingroup$

As somebody who is spending the majority of his time programming in JavaScript, what's the best route to get into small-robotics without needing to deviate too much from my current language focus?

Are there any project kits or tools that make use of the JavaScript language that might make the field more approachable for developers like myself? I would even be interested in virtual environments where all code is executed in a simulation.

$\endgroup$
  • 3
    $\begingroup$ You should checkout this post... weblog.bocoup.com/javascript-arduino-programming-with-nodejs It discusses a pure Js implementation of the protocol used for Arduino. Pretty cool stuff. $\endgroup$ – Chris Gutierrez Nov 7 '12 at 19:45
  • $\begingroup$ I'd like to see some nodejs implementation running on the robot. One might just control the robot over the web using websockets. $\endgroup$ – Lord Loh. Nov 7 '12 at 19:48
  • $\begingroup$ You do not programme in JavaScript - You write scripts(which are used on a browser for Client manipulation of the DOM) You can programme in JAVA - which is completely different. node.js it not javascript either. It is a C library that interprets AJAX calls as mini server and is used for high volume requests- for example on ebay- You do not need to refresh a page on an item that is ending because javascript synchronises the bidding price and time by using node.js extremely quick response while reducing traffic overhead) node.js is good for arduino cause it is C $\endgroup$ – Piotr Kula Nov 12 '12 at 17:24
  • $\begingroup$ So you would programme the bot in c and interface to it using node.js - which inherently uses JavaScript ajax for request but you can also use server requests or other clever code that is not related to JavaScript in anyway. $\endgroup$ – Piotr Kula Nov 12 '12 at 17:27
  • $\begingroup$ Is the Arduino code the only efficient way currently? $\endgroup$ – Huzo Feb 9 '17 at 15:47
22
$\begingroup$

There are a couple of projects out there that mate the Arduino platform to the Node.js javascript execution engine. Take a look at Johnny-Five, which is a library on top of the Arduino Firmata remote control protocol or node-reflecta, which is a Node.js interface for the Arduino Reflecta remote control protocol.

I've personally built a Node.js controlled robot called RocketBot, that combines node-reflecta with node-joystick on top of a Beaglebone and an Arduino so I can attest this approach works well.

$\endgroup$
12
$\begingroup$

Hmm, interesting question! I personally would suggest that you take a look at the Arduino platform. It's programmed in C, so the syntax is going to be... familiar, to a JavaScript writer. In my humble opinion, knowing how the syntax (while loops, if/than blocks, etc) is laid out is 70% of the battle, once you're familiar with that, you can plug and play. You can pick up a starter kit for around $30 online from the good folks at SparkFun.com or adafruit.com, you can program it on a PC, Mac or Linux machine, and it comes pre-loaded with enough examples to ease you into the language quickly. I'm not saying that you're just gonna drop some JavaScript code into it and be on your way, but I was a JavaScript programmer when I started out with Arduino, and I found it quite easy to pick up and run with. Good luck, as a part time teacher in robotics it's always awesome to see people getting into the field!

P.S. - you should also be familiar/comfortable with building electronic circuits (lights, motors and the like), but any good Arduino introduction kit worth its salt will get you started if you don't have any experience.

$\endgroup$
  • 3
    $\begingroup$ P.S. - A good question for the fledgling, newly minted Robotics.SE site, I think :) $\endgroup$ – Chris Nov 7 '12 at 19:39
  • 1
    $\begingroup$ Great answer, @Chris. I've heard of the Arduino platform from some other JavaScript developers. Perhaps that's the best gateway drug for a developer looking to get hooked. $\endgroup$ – Sampson Nov 7 '12 at 20:06
  • 1
    $\begingroup$ As a young JavaScript/web developer I find your question super interesting. As stated before there are platforms for node.js and other various versions, however if you are really comfortable in JavaScript, you could really easily learn any other language, which I would highly recommend. Not only does it expand your ability to understand fundamental computer science, but it also makes learning new things easier. $\endgroup$ – OneChillDude Nov 8 '12 at 1:18
8
$\begingroup$

Robot Operating System (ROS) offers the ability to use Javascript to control your robots. Specifically you will want to look at rosbridge. You will then need to use rosserial to interface with the microcontroller controlling your robot.

While I am a big fan of ROS this is an overly complicated way to begin exploring the field of robotics IMHO. You would be better served to pick up an Arduino and learning a little bit of C. Arduino does a great job of making the process simple and C is not a large deviation from JS from a syntax perspective.

$\endgroup$
5
$\begingroup$

Generally there are many ways to use node.js with a platform, like this one for the RPi. There are a lot more similar ones if you just search for them.

Another interesting one is ArduGate, which lets web pages communicate with the arduino via JS (though probably not exactly what you wanted since it doesn't compile and load to the arduino)

Though I really don't see what's wrong with using a different language. I myself write primarily in JS, but I find myself perfectly comfortable programming an Arduino in C++ (it also allows C and Java, and if you put in a bit of work, quite a few more languages ). Remember, we're not needing anything fancy for programming a robot--just normal ifs,fors,whiles,switches, and the occasional class. Learn the syntax, and you're good to go :) The only thing is that C/C++/Java are strongly typed (though if you're using the RPi, python is weakly typed but picky in a million more ways), so you may get a bit of frustration in the beginning when you have to specify types for everything. One advantage of using the native languages is that it's much easier to find APIs and example code on the net. For example, aside from ArduGate(which has it built in and is probably not what you wanted), I can't find any way to access the EEPROM--a common task. So, unless you want to stick to simple programs, it's just better to use the native languages.

$\endgroup$
2
$\begingroup$

A friend of mine actually has a pretty powerful tank robot that's controlled with NodeJS over wifi. The robot itself isn't exactly "small-robotics" at 150 pounds, but you could probably learn quite a bit from the source code. It has a netbook onboard running a webserver and talking to an Arduino. You can find the source code on his Github project page. The real-time control from a web browser on another computer is surprisingly responsive.

$\endgroup$
2
$\begingroup$

Microsoft Robotics uses a protocol called Decentralized Software Services Protocol (DSSP) and they released the specs under a license that allows anyone to implement it in any language. The DSSP protocol is totally compatible with current web standards and I think it would be a great idea to implement it in JavaScript and NodeJS. That can make it possible for your node application to interact with any DSS robotics services available today.

$\endgroup$
1
$\begingroup$

Programming the AR.Drone 2.0 with Javascript is super fun. Here's an example that makes a drone take off, move around, do a flip, then land, all using the node-ar-drone library:

var arDrone = require('ar-drone');
var client = arDrone.createClient();

client.takeoff();

client
  .after(5000, function() {
    this.clockwise(0.5);
  })
  .after(3000, function() {
    this.animate('flipLeft', 15);
  })
  .after(1000, function() {
    this.stop();
    this.land();
  });

The blog post NodeBots - the Rise of JS Robotics talks about advantages javascript has for robotics, specifically the natural way that real world objects and actions can be modeled as chainable, evented processes. The example code above to animate a drone looks very similar to using jQuery to animate an HTML element:

$("#foo")
  .slideUp(300)
  .delay(800)
  .fadeIn(400);
$\endgroup$
  • $\begingroup$ I've edited the answer to be more specific and add more context. Thanks for the feedback. $\endgroup$ – John Wiseman Aug 21 '13 at 19:02
  • $\begingroup$ Thanks John, that's a great edit, just the sort of thing that makes a future-proof answer. $\endgroup$ – Mark Booth Aug 22 '13 at 8:34
0
$\begingroup$

There is also a project called Espruino, which is a JavaScript interpreter for low power ARM microcontrollers. It is a rewrite of the tiny-js project, a small C++ interpreter for Javascript.

$\endgroup$
0
$\begingroup$

It might be helpful to look for javascript-based robotics projects online as javascript-based robotics community has been growing rapidly since this question was asked. For examples, the blogger behind https://burningservos.com documented processes of building a four-legged robot from scratch and discuss multiple libraries javascript the blogger evaluated or used. There is also "hardware" section in glitch (or even at Adafruit and Hackster.io) where people share their javascript-based hardware hacking projects where you can check out libraries they used.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.