[ros-users] Using $(arg) substitution

Kartik Mohta kartikmohta at gmail.com
Sat Jan 29 07:31:44 UTC 2011


On Sat, Jan 29, 2011 at 2:05 AM, Patrick Bouffard
<bouffard at eecs.berkeley.edu> wrote:
> Kartik,
>
> You can think of launch files like subroutines, and of course, a
> subroutine needs to declare what arguments it takes and, optionally,
> default values of those arguments:
>
> ---
> Pseudocode:
> main:
>  call foo(arg1=false)
>
> subroutine foo(arg1, arg2=true):
>   if arg1: something
>   if arg2: something_else
>
> ---
>
> Launch file equivalent:
>
> main.launch:
> <launch>
>  <include file="foo.launch">
>    <arg name="arg1" value="false"/>
>  </include>
> </launch>
>
> foo.launch:
> <launch>
>  <arg name="arg1"/>
>  <arg name="arg2", default="true"/>
>
>  <node if="$(arg arg1)" pkg="somepkg" type="something" name="something"/>
>  <node if="$(arg arg2)" pkg="somepkg" type="something_else"
> name="something_else"/>
> </launch>
> ---
>
> This is essentially what the documentation tells you but I found it
> helped to think about the analogy between launch file arguments and
> subroutine/function arguments.
>
> Cheers,
>
> Pat
>

This analogy really helps, thanks Pat.

-- 
Kartik



More information about the ros-users mailing list