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

Revision history [back]

What you are looking to use are launch arguments (arg tags) and not parameters (param tags). Here is a link to the roslaunch arg tags.

Basically, what you are trying to do is add an argument to your higher level launch file that you pass down. Here is a decent guide on them for more detail.

The answer to the question you link uses bash (command line) to generate a random number and pass it as a launch argument to their launch file. How it would look like for you:

High level launch file:

  <launch>
  ... other args ...
  <arg name="x" default="0"/>
  <arg name="y" default="0"/>
  <arg name="z" default="3"/>

 ... empty world include ...

  <group ns="$(arg mav_name)">
    <include file="$(find rotors_gazebo)/launch/spawn_mav.launch">
      <arg name="mav_name" value="$(arg mav_name)" />
      <arg name="model" value="$(find rotors_description)/urdf/$(arg mav_name)_base.xacro" />
      <arg name="enable_logging" value="$(arg enable_logging)" />
      <arg name="enable_ground_truth" value="$(arg enable_ground_truth)" />
      <arg name="log_file" value="$(arg log_file)"/>
      <arg name="x" value="$(arg x)"/>
      <arg name="y" value="$(arg y)"/>
      <arg name="z" value="$(arg z)"/>
    </include>
  </group>
</launch>

And then after that, since the arguments are already in the spawn_mav.launch file, you just need to call roslaunch.

roslaunch package file.launch x:=1 y:=2 z:=3

This will spawn the robot at 1,2,3. Change the input as you see fit.

As described in the other question you link, you can randomize it based on some bash input. The comments for the answer mention the roslaunch Python API. I have not used it, but might be worth exploring to generate the random numbers with Python.