ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to run or stop a process from a ros node

asked 2012-09-06 12:03:48 -0600

searchrescue gravatar image

Hi, I wonder if we can run or stop a binary from a nos node. Can we integrate it into the launch file somehow. For example, i want the camera on the robot to start and stop recording while the commanding node is alive for the robot. Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2012-09-06 21:23:40 -0600

Thomas gravatar image

updated 2012-09-07 03:40:05 -0600

It is possible for a process to spawn another process (see man 3 exec on Linux). A (better, IMHO) alternative is using the appropriate API to start/stop the recording from the initial process.

Launch file can only spawn ROS binaries (a binary located in a ROS package) but it is trivial to wrap any binary into a ROS binary. Python SubProcess can help there or you can also use the "system" function call.

A more general comment is: in ROS, a classical method for designing an infrastructure is:

  1. Launch all the nodes. They start in an "idle" state where they do nothing.
  2. Under an external event (like the reception of a request from some kind of supervisor), they will start working (in this case recording).
  3. Under another external even the behavior may be stopped and restarted but the node never dies.

In this case, you really have two layers with a one way communication. The ROS Launch layer and the nodes layer. There is no way to "communicate" with ROS launch or making it do smart stuff such as stopping nodes on an event.

IMHO this is not a limitation and ROS launch is very well as it is, but it forces you to adopt the previously described point of view when you design your own architecture :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-06 12:03:48 -0600

Seen: 2,695 times

Last updated: Sep 07 '12