baalexander / rosnodejs

A ROS client library using node.js
http://baalexander.github.com/rosnodejs/
MIT License
36 stars 8 forks source link

Support shutting down a node. #11

Open baalexander opened 12 years ago

baalexander commented 12 years ago

Right now, a node can only be shutdown using rosnodejs by killing the process. There should probably be a clean way to shutdown a node as well as query the state of being shutdown (see rospy's is_shutdown()) and handling a shutdown (handling a 'shutdown' event?).

baalexander commented 12 years ago

I originally wrote this issue for v0.0.1. With v0.1.0, we now can access individual topics easier. It may make more sense to shut these down individually or the node as a whole. Here's an API proposal:

ros.types([
  'std_msgs/String'
], function(String) {
  var node = ros.node('talker');
  node.topics([
    { topic: 'example', messageType: String }
  ], function(example) {
    example.subscribe(function(message) { });

    // Calls unregister subscriber on master
    example.shutdown();
  });
});