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

Passing arguments from .launch file to .yaml file

asked 2021-11-24 06:34:41 -0500

WarTurtle gravatar image

updated 2022-01-31 09:43:40 -0500

lucasw gravatar image

Hello, I am having problems with passing an argument into a .yaml file.

The problem is this:

map_type: costmap
observation_sources: scan
scan: {sensor_frame: $(arg namespace)/base_scan, data_type: LaserScan, topic: $(arg namespace)/scan, marking: true, clearing: true}

I am passing the argument, "BotN" for N robots in the launch file, e.g:

  <include file="$(find deploy)/launch/make_robot.launch" >
    <arg name="model"          value="burger"/>
    <arg name="namespace"      value="Bot1" />
    <arg name="initial_pose_x" value="-2.5"/>
    <arg name="initial_pose_y" value="4.0"/>
  </include>

But I get an insanely long error that doesn't really outline the issue.

Writing this in the .yaml file works, but I need it to work for multiple robots

scan: {sensor_frame: Bot1/base_scan, data_type: LaserScan, topic: Bot1/scan, marking: true, clearing: true}

Any idea?

edit retag flag offensive close merge delete

Comments

I think most people just create a separate yaml file for each robot. It's the quickest way, and the easiest to debug when things to wrong.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-11-25 08:33:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-24 07:30:05 -0500

miura gravatar image

I don't think you can use $(arg namespace) in .yaml. You can try using remap and tf_remap.

I'm not familiar with tf_remap, so I apologize if I'm wrong about it.

It should be used in make_robot.launch as follows.

<node pkg="tf" type="tf_remap" name="tf_remapper">
  <rosparam param="mappings">
    [{old: /base_scan, new: /$(arg namespace)/base_scan}]
  </rosparam
</node>

<node pkg="move_base" type="move_base" name="move_base">
  <remap from="/scan" to="/$(arg namespace)/scan" />
  ...
</node>
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-11-24 06:34:41 -0500

Seen: 176 times

Last updated: Nov 24 '21