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

Setting machine-dependent args in launch files?

asked 2016-03-30 18:06:35 -0600

sr71 gravatar image

Is there any way to set arguments in launch files as a function of machine name/HOSTNAME?

Specifically, I would like to run the same launch file on multiple machines, but with 1 of the args changing based on machine name. I am aware there are (currently) no arg comparators in roslaunch (only if/unless statements), and have investigated the <machine> tag, but was not successful in getting this to work.

Thanks ahead

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-03-30 21:19:03 -0600

ahendrix gravatar image

You can read environment variables from a launch file using $(env VAR). You could use this to read the HOSTNAME variable if that is useful, or you could set a custom environment variable on a per-host basis and use that.

A more complete example would be:

<arg name="host" value="$(env HOSTNAME)"/>
edit flag offensive delete link more

Comments

Was hoping to avoid that and have everything included in .launch files, but agreed that works.

sr71 gravatar image sr71  ( 2016-03-31 16:00:51 -0600 )edit

There are clever ways to use includes, if you have unique hostnames. For example <include file="$(find my_package)/hosts/$(arg host).launch"/>

ahendrix gravatar image ahendrix  ( 2016-03-31 16:15:32 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-03-30 18:06:35 -0600

Seen: 421 times

Last updated: Mar 30 '16