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

How to check the existence of a node in .launch

asked 2014-06-06 08:18:39 -0600

I'm starting with launch files and I couldn't find any tutorial about it. If you can share any paper, guide or explanatory website I would really appreciate it.

In addition, I want to put an "if" inside the launch file in order to create a node only IF it doesn't exits yet. ¿How can I do it?

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
2

answered 2014-06-07 12:21:47 -0600

gvdhoorn gravatar image

I'm starting with launch files and I couldn't find any tutorial about it.

Have you tried the roslaunch wiki page? The Tutorials section should help you get started.

In addition, I want to put an "if" inside the launch file in order to create a node only IF it doesn't exits yet. ¿How can I do it?

Roslaunch cannot check for the (non)existence of a specific node. There is partial support for conditionals (if and unless), but it is used for conditional inclusion / evaluation.

edit flag offensive delete link more
1

answered 2014-06-06 09:32:35 -0600

Hamid Didari gravatar image

you can use this tutorial for starting with launch file.

edit flag offensive delete link more
0

answered 2023-01-10 03:19:59 -0600

if="$(eval not [s for s in eval('_' + '_import_' + '_(\'rosnode\')').get_node_names() if 'NODE_NAME' in s])"
edit flag offensive delete link more
0

answered 2014-06-06 10:08:15 -0600

Jérôme gravatar image

In addition you can't run two node with the same name, so by the way it's not possible to have two same node running at a time !

edit flag offensive delete link more

Comments

Only node names need to be unique (within the same namespace that is): you can certainly run the same binary twice, as long as they use different names (or are anonymous).

gvdhoorn gravatar image gvdhoorn  ( 2014-06-07 12:23:07 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-06-06 08:18:39 -0600

Seen: 1,991 times

Last updated: Jun 07 '14