Rosnodejs is currently deprecated.

Most of my efforts for JavaScript and robotics has been shifted to the Robot Web Tools project. I highly recommend taking a look at Robot Web Tools if interested in putting your robot on the web. Features include:

I still feel a Node.js interface into ROS is important. It would complement the goals of the nodebots movement while harnessing the awesome power and 1,000+ packages of the Robot Operating System.

rosnodejs Programming robots with JavaScript

Rosnodejs is a Node.js module that lets you use JavaScript to interact with the Robot Operating System, an open-source robot framework used by many of the top universities and research programs around the world.

Perform a range of robotic tasks, from controlling the motors on an Arduino to processing Kinect sensor data using JavaScript and Node.js.

The goal is to make the field of robotics more accessible to the countless intelligent web developers out there.

About ROS

One of the top frameworks to program robots with today is the Robot Operating System (ROS). ROS can run on a variety of robots, from a TurtleBot to a PR2 to an Arduino connected to a computer.

The beauty of ROS lies in its decoupled architecture. Everything is a node and nodes communicate by publishing and subscribing to messages.

The decoupled design between the nodes has a couple distinct advantages.

One advantage is that any part of the robot can be replaced. For example, the Kinect sensor may be replaced with a newer sensor. As long as this sensor publishes the same message type, none of the other nodes will notice a difference.

Another important advantage of decoupling and open-source is that anyone can contribute a node or a package of nodes. A team at one company may actively be working on nodes related to the Kinect while another team at a university is creating a stack for the Arduino. There's hundreds of packages in the ROS ecosystem that will perform many robotic operations for you.

How to get started with ROS?

The Beginner Level Tutorials on are an exceptional source, walking you through everything from installing ROS to making your first package and node. These tutorials are the best way to get started.

If you follow the tutorials, you'll notice the code samples are in Python or C++. That's because there's a ROS client library for Python and a ROS client library for C++. A client library is a set of libraries for a language that enables use of that language to interact with ROS. Rosnodejs is a client library for JavaScript.

About rosnodejs

Rosnodejs is a JavaScript client library for ROS, which means you can make a Node.js module that interacts with ROS. Rosnodejs is an NPM module and can be installed and required like any other NPM module.

Why use rosnodejs over the excellent Python and C++ client libraries?

A few reasons include:

  • HTTP/TCP/UDP performance. Node.js has strong built-in support for HTTP, TCP, and UDP, the basic transport layers used by the Robot Operating System.
  • The rapidly growing Node.js ecosystem. Many libraries like Socket.IO have strong first-party support for Node.js.
  • Familiarity. Robots are hard enough; write code in what you know.

The How To sections provide code examples on using rosnodejs natively on the robot, generating JavaScript files for the message definitions, turning your robot into a web server, and running ROS code in the browser.

How to install

Before rosnodejs can be installed, Node.js and ROS need to be set up on the machine first.

Rosnodejs is an NPM module. Simply create a directory for the project (which will act as a ROS package) and install rosnodejs with npm install rosnodejs in that directory.

How to use rosnodejs

to publish messages

], function(String) {
  var node = ros.node('talker');
    { topic: 'publish_example', messageType: String }
  ], function(publishExample) {
    // Uses the ROS command line tool rostopic to echo messages published
    // over the 'publish_example' topic.
    var subscribeCommand = 'rostopic'
      + ' echo'
      + ' /publish_example';
    var child = exec(subscribeCommand, function(error, stdout, stderr) {

    var message = new String({ data: 'howdy' });
    setTimeout(done, 1500);
to subscribe to messages

], function(String) {
  var node = ros.node('listener');
    { topic: 'subscribe_example', messageType: String }
  ], function(subscribeExample) {
    subscribeExample.subscribe(function(message) {'howdy');

    // Uses rostopic to publish a message on the subscribed to topic.
    var publishCommand = 'rostopic'
      + ' pub'
      + ' /subscribe_example'
      + ' std_msgs/String'
      + ' howdy';
    var child = exec(publishCommand, function(error, stdout, stderr) {