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

how to check in the launch file, whether a node is already running?

asked 2016-09-08 01:39:43 -0500

dharanikumar gravatar image

Hi, how to check in the launch file (inside the node tag), whether that node is already running?

edit retag flag offensive close merge delete

Comments

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 gravatar image SL Remy  ( 2016-09-08 12:42:16 -0500 )edit

@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).

dharanikumar gravatar image dharanikumar  ( 2016-09-08 23:25:45 -0500 )edit

@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.

dharanikumar gravatar image dharanikumar  ( 2016-09-08 23:28:44 -0500 )edit

@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.

dharanikumar gravatar image dharanikumar  ( 2016-09-08 23:29:18 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
1

answered 2016-09-09 08:51:46 -0500

SL Remy gravatar image

updated 2016-09-09 08:52:24 -0500

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!

edit flag offensive delete link more
0

answered 2016-09-08 02:42:29 -0500

Shay gravatar image

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.

edit flag offensive delete link more
0

answered 2023-01-10 03:20:26 -0500

if="$(eval not [s for s in eval('_' + '_import_' + '_(\'rosnode\')').get_node_names() if eval(robot_name) in s])"

edit flag offensive delete link more
0

answered 2016-09-08 02:53:23 -0500

LorenzH gravatar image

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.

http://wiki.ros.org/node_manager_fkie

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-09-08 01:39:43 -0500

Seen: 1,832 times

Last updated: Sep 09 '16