Ask Your Question

How to combine string args in launch file?

asked 2017-07-21 07:32:46 -0500

marcoresk gravatar image

updated 2017-07-21 07:33:18 -0500

This is my starting .launch file

<!-- usb webcam video0 -->
  <node name="usb_cam0" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video0" />

Now I would like to pass that zero as an argument by a command like

roslaunch mypackage mylauncher.launch N:=0

so I thought

<arg name="N"/>
<!-- usb webcam video number N as indicated in the argument -->
  <node name="usb_cam0" pkg="usb_cam" type="usb_cam_node" output="screen" >
   <param name="video_device" value="/dev/video$(arg N)" />

Of course it does not work. I'm not an axpert at all of xml-like files... maybe the error is the combination of the string? Or there is a way to do this better?

My final purpose is to allow the access to any video source with inputs in the launchfile



Thank you in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-07-21 08:30:07 -0500

gvdhoorn gravatar image

updated 2017-07-21 08:30:55 -0500

Of course it does not work

can you tell us what you see, if it does not work?


  <arg name="n" />
  <param name="something" value="/dev/video$(arg n)"/>

started as roslaunch my_pkg test.launch n:=4 result in:

something: /dev/video4

on my system.

See wiki/roslaunch/XML/arg and wiki/roslaunch/XML/param.

edit flag offensive delete link more


I tried again after some time, now it works. Thank you for the proof.

marcoresk gravatar image marcoresk  ( 2017-09-01 05:30:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-07-21 07:32:46 -0500

Seen: 1,377 times

Last updated: Jul 21 '17