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

grouping launch file

asked 2021-04-13 10:26:38 -0500

LR1997 gravatar image

Hi everyone, I need to start different nodes in the launch file. At the moment I do it by defining 2 arguments (var1 and var2) and then by grouping the launch files. Something like:

<group if="$(arg var1)"> 
   start some nodes

<group if="$(arg var2)">
  start  other nodes

and launching from terminal the following:

roslaunch my_package my_launch_file var1:=true var2:=false

This works, but my question is: is there a way I could launch by defining only one arg? For example what I want to achieve is:

<arg name="variable"/> 

    <group if=**(variable=1)**>        --> How can I implement this?
    start some nodes

        <group if=(variable=2)>
start other nodes

and therefore using from terminal only:

roslaunch my_package launch_file variable:=1


roslaunch my_package launch_file variable:=2
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-04-13 12:56:14 -0500

tryan gravatar image

You can use if along with the $(eval <expression>) substitution as described in the roslaunch XML wiki.

$(eval <expression>) allows to evaluate arbitrary complex python expressions.

edit flag offensive delete link more



Thank you, this solved my problem :)

LR1997 gravatar image LR1997  ( 2021-04-14 01:50:30 -0500 )edit

Question Tools

1 follower


Asked: 2021-04-13 10:26:38 -0500

Seen: 368 times

Last updated: Apr 13 '21