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

How to create "parameters" inside launch files in ROS?

asked 2011-12-09 02:05:37 -0500

Felix Tr gravatar image

updated 2011-12-09 02:11:16 -0500

Hello all,

I am a little stuck, so some help be very appreciated very much. I would like to create a list of parameters/variables in the beginning of my launch file, in such a way, that it will available for the user to change the "contents" of the variables, but the rest of the launch file will not change!

Examples: Nowadays I have the next line in my launch file:

<node pkg="rosbag" type="rosbag" name="rosbag1" args="play -l $(find guiPackageParametersToCallback)/BagFiles/2011-12-05-10-55-01.bag" required="true"/>

But the name of the recorded bag file can change so I want to do something like that:

filename = 2011-12-05-10-55-01.bag
<node pkg="rosbag" type="rosbag" name="rosbag1" args="play -l $(find guiPackageParametersToCallback)/BagFiles/filename" required="true"/>

Or in the next case:

 <node name="republish1" type="republish" pkg="image_transport" output="screen" args="compressed in:=/bb2/left/image_rect raw out:=leftCameraTopic" required="true" />

I would like to something:

inputTopic = /bb2/left/image_rect
    <node name="republish1" type="republish" pkg="image_transport" output="screen" args="compressed in:=inputTopic raw out:=leftCameraTopic" required="true" />

Since I am interested to do it in the limits of the launch file itself, I am not sure that "remap" will solve the case here.

Thanks in advance, Felix.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-12-09 02:29:24 -0500

DimitriProsser gravatar image

The easiest way to do that is with the env tag. So, your code would look like this:

<node pkg="rosbag" type="rosbag" name="rosbag1" args="play -l $(find guiPackageParametersToCallback)/BagFiles/$(env BAG)" required="true"/>

At the command line, you would then type:

export BAG="2011-12-05-10-55-01.bag"; roslaunch your_package your_launchfile.launch
edit flag offensive delete link more

Comments

Hi Dmitri, thank you for your answer, but your way is not useful for many parameters. Anyway I have found a good way to do what I want, and this is using "arg" :)
Felix Tr gravatar image Felix Tr  ( 2011-12-09 02:47:53 -0500 )edit
Yes, arg is intended for your use case.
dornhege gravatar image dornhege  ( 2011-12-09 04:15:27 -0500 )edit

Question Tools

Stats

Asked: 2011-12-09 02:05:37 -0500

Seen: 788 times

Last updated: Dec 09 '11