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

grouping launch file

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

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>

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

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>

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

and therefore using from terminal only:

roslaunch my_package launch_file variable:=1

or

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

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Comments

1

Thank you, this solved my problem :)

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

Question Tools

1 follower

Stats

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

Seen: 430 times

Last updated: Apr 13 '21