How to make my robot spawn at random positions whenever the simulation is reset

Hi again :smiley:
First of all, thanks for the course and the OpenAI_ROS package. Thanks to the package, I have successfully implemented my custom environment to RL framework.

But, recently I came up this one question, that to enhance the exploration of my agent, I want to make my robot to be respawned at random position. I have been trying out this since last month, and haven’t found a solution to implement this. Could you help me out with this?

What I tried so far is to pass the argument from the spawn_mav.launch file to higher launch file mav.launch. This way, I could launch my robot in a specified position by entering the argument when launching my mav.launch file in the command line.

  <arg name="mav_name" default="firefly"/>
  <arg name="world_name" default="basic"/>
  <arg name="enable_logging" default="false"/>
  <arg name="enable_ground_truth" default="true"/>
  <arg name="log_file" default="$(arg mav_name)"/>
  <arg name="debug" default="false"/>
  <arg name="gui" default="true"/>
<!--   <arg name="headless" value="true"/> # headless -->
  <arg name="paused" default="true"/>
  <!-- The following line causes gzmsg and gzerr messages to be printed to the console
      (even when Gazebo is started through roslaunch) -->
  <arg name="verbose" default="false"/>
  <arg name="x" default="0"/>
  <arg name="y" default="0"/>
  <arg name="z" default="12"/>

  <env name="GAZEBO_MODEL_PATH" value="${GAZEBO_MODEL_PATH}:$(find rotors_gazebo)/models"/>
  <env name="GAZEBO_RESOURCE_PATH" value="${GAZEBO_RESOURCE_PATH}:$(find rotors_gazebo)/models"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find rotors_gazebo)/worlds/$(arg world_name).world"/>
    <arg name="debug" value="$(arg debug)" />
    <arg name="paused" value="$(arg paused)" />
    <arg name="gui" value="$(arg gui)" />
    <arg name="verbose" value="$(arg verbose)"/>

  <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" default="$(arg x)"/>
      <arg name="y" default="$(arg y)"/>
      <arg name="z" default="$(arg z)"/>


Does this have to be implemented inside our task and robot env setting? Is there a way to do this?
Any sort of comment would be appreciated :smiley:

Thank you always