Giter Site home page Giter Site logo

reactual / rosnodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rethinkrobotics-opensource/rosnodejs

0.0 3.0 0.0 1.01 MB

Client library for writing ROS nodes in JavaScript with nodejs

Home Page: http://wiki.ros.org/rosnodejs/overview

License: Apache License 2.0

JavaScript 100.00%

rosnodejs's Introduction

rosnodejs Build Status

Install

npm install rosnodejs

Start a node

const rosnodejs = require('rosnodejs');
rosnodejs.initNode('/my_node')
.then(() => {
  // do stuff
});

Publish/Subscribe

const nh = rosnodejs.nh;
const sub = nh.subscribe('/chatter', 'std_msgs/String', (msg) => {
  console.log('Got msg on chatter: %j', msg);
});

const pub = nh.advertise('/chatter', 'std_msgs/String');
pub.publish({ data: "hi" });

Services

const service = nh.advertiseService('/add_two_ints', 'beginner_tutorials/AddTwoInts', (req, resp) => {
  res.sum = req.a + req.b;
  return true;
});

const client = nh.serviceClient('/add_two_ints', 'beginner_tutorials/AddTwoInts');
client.call({a: 1, b: 2});

Params

nh.setParam('val', 2);
nh.getParam('val')
.then((val) => {
  // do stuff
});

Messages

const sensorMsgs = rosnodejs.require('sensor_msgs');

const image = new sensorMsgs.msg.Image();
const temperature = new sensorMsgs.msg.Temperature({ temperature: 32 });

const SetCameraInfo = sensorMsgs.srv.SetCameraInfo;
const setRequest = new SetCameraInfo.Request();

// messages can be used when advertising/subscribing
const StringMsg = rosnodejs.require('std_msgs').msg.String;
const sub = nh.subscribe('/chatter', StringMsg, (msg) => { ... });
const pub = nh.advertise('/chatter', StringMsg);

const AddTwoInts = rosnodejs.require('beginner_tutorials').srv.AddTwoInts;
const service = nh.advertiseService('/add_two_ints', AddTwoInts, (req, resp) => { ... });
const client = nh.serviceClient('/add_two_ints', AddTwoInts);

Run the turtlesim example

Start:

roscore
rosrun turtlesim turtlesim_node
rosrun turtle_actionlib shape_server

Then run

node src/examples/turtle.js

or, if you are running an older version of node:

npm run compile
node dist/examples/turtle.js

Catkin-Like

Checkout rosnodejs_examples for a more catkin-inspired take on using rosnodejs.

Inspired By

rosnodejs was inspired by other work that you can learn more about here

rosnodejs's People

Contributors

chris-smith avatar iantheengineer avatar chfritz avatar mjyc avatar rethink-rlinsalata avatar manzato avatar jamesgiller avatar rethink-neil avatar

Watchers

James Cloos avatar Stephen Richardson  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.