how to check in the launch file, whether a node is already running?
Hi, how to check in the launch file (inside the node tag), whether that node is already running?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org |
Hi, how to check in the launch file (inside the node tag), whether that node is already running?
I'd suggest using plain old roslaunch xml.. You can create launch files for the modules, and then you can create a launch file that includes in a "large" launch file. This way you can compose your application as needed. You can also run the launch files for the individual modules yourself at the command prompt, if you'd like to "hotswap" functionality.
You can also have multiple launch files for the different use cases.. take a look at the hector_quadrotor project for some really cool examples.
Hope this helps!
I don't think a launch file can do this. But you can check it from command line with ps aux | grep your_node_name
, or you can write a shell/python script to do this.
if="$(eval not [s for s in eval('_' + '_import_' + '_(\'rosnode\')').get_node_names() if eval(robot_name) in s])"
You can use this package to load launch-files, start all or indiviual nodes and monitor their status. It might be an overkill for your purposes, however.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2016-09-08 01:39:43 -0500
Seen: 1,613 times
Last updated: Sep 09 '16
Can you explain a little more about the motivation for the request? For example, if a node is already running, will you want the "launch file" do something different?
@SL Remy I think of adding separate launch files for each modules. So i can run the modules separately or combined (By executing each launch files in sequence).
@SL Remy But few modules requires a common node to run. So if that node is executed by the first launch file, then subsequent launch file terminates it by restarting the same node.
@SL Remy I can create a single launch file for executing multiple modules. But i feel the approach of individual launch files is better than single big launch file.