npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@panshengjie/rosnodejs

v3.0.8

Published

Native ROS for nodejs

Downloads

1

Readme

rosnodejs Build Status

This is a version optimised by panshengjie

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
});

Generating Messages

Messages can be generated in a number of ways depending on the versions of ROS and Node.js you're using.

  • catkin - works in ROS Kinetic and later for Node.js v6+.
$ catkin_make
OR
$ catkin build
  • loadAllPackages() - One-time "build" call available through rosnodejs for versions of ROS before Kinetic and Node.js v6+. Should be called separately and in advance of processes attempting to use messages.
const rosnodejs = require('rosnodejs');
rosnodejs.loadAllPackages();
  • On the fly - all versions of ROS and Node.js 4.5+. When generating on the fly, messages can not be required until the node has initialized.
const rosnodejs = require('rosnodejs');
await rosnodejs.initNode('my_node', { onTheFly: true })
const stdMsgs = rosnodejs.require('std_msgs');

| |Pre-Kinetic|Kinetic & Later| |:---:|:---:|:---:| |Node.js >= v6|loadAllPackages(), on the fly|catkin, loadAllPackages(), on the fly| |Node.js < v6|on the fly|on the fly|

Using 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);

Actions (Experimental)

const nh = rosnodejs.nh;
const as = new rosnodejs.ActionServer({
  nh,
  type: 'turtle_actionlib/Shape',
  actionServer: '/turtle_shape'
});

as.on('goal', function (goal) {
  goal.setAccepted();
});

as.start();

const ac = new rosnodejs.ActionClient({
  nh,
  type: 'turtle_actionlib/Shape',
  actionServer:'/turtle_shape'
});

ac.sendGoal({edges: 3, radius: 1});

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