Ask Your Question
2

get roslaunch arg value from a file?

asked 2015-12-07 12:14:15 -0600

zqpm gravatar image

I have a system with multiple homogeneous robots with an id assigned to each based on the MAC address of it's ethernet interface. I would like to know the best way for my main launch file to get the robot's id from a look up table and use it to set an id parameter (so the robot knows who it is) and include another launch file specific to that robot (i.e., for setting parameters that may differ between robots). Basically I want to get the robot's id as an arg variable in the launch file.

I'm currently setting an environment variable at login inside .bashrc and reading that it, but it would be nice if there was a solution that was more self-contained to my code repository.

Or maybe there is a better way to do what I'm am trying to accomplish?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-07 18:38:56 -0600

130s gravatar image

AFAIK, ROS does not currently provide a method to associate hardware-specific info with any identification credentials.

Here's what I might do in order to use MAC Address as a key:

  1. Write my own mechanism; it can be a small script that looks up the table to find a pair of MAC and id, and export the id as either an env var or ROS parameter.
  2. In your launch file, find the exported id. In a launch files, you can use env arg to refer to the existing env vars, or use param tag to get the existing ROS parameters.

This way may not be the most elegant but still self-contained to your code repository, and no manual operation is needed to assign an id to a robot.

edit flag offensive delete link more

Comments

That's sort of what I'm doing now, but setting an environment variable has to be done before starting roslaunch (as a script can't set an environment variable in the parent process). Setting a param with the command option works, but there is no substitution rule for using params in a launch file.

zqpm gravatar imagezqpm ( 2015-12-08 08:27:43 -0600 )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

Stats

Asked: 2015-12-07 12:14:15 -0600

Seen: 327 times

Last updated: Dec 07 '15