I want to spawn my robot to a random position but failed modifying the launch file.
Hi,
I'm pretty new to ros, and is struggling to find a way to spawn my robot in a random position every time I launch my robot.
The file I want to launch looks like this
<launch>
<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="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"/>
<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)"/>
</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)"/>
</include>
</group>
</launch>
And this calls spawn_mav.launch file, which I want to pass my random values to
<?xml version="1.0"?>
<launch>
<arg name="mav_name" default="firefly"/>
<arg name="namespace" default="$(arg mav_name)"/>
<arg name="model" default="$(find rotors_description)/urdf/$(arg mav_name)_base.xacro"/>
<arg name="tf_prefix" default="$(optenv ROS_NAMESPACE)"/>
<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="3"/>
<arg name="enable_logging" default="false"/>
<arg name="enable_ground_truth" default="true"/>
<arg name="log_file" default="$(arg mav_name)"/>
<arg name="wait_to_record_bag" default="false"/>
<arg name="enable_mavlink_interface" default="false"/>
<!-- send the robot XML to param server -->
<param name="robot_description" command="
$(find xacro)/xacro '$(arg model)'
enable_logging:=$(arg enable_logging)
enable_ground_truth:=$(arg enable_ground_truth)
enable_mavlink_interface:=$(arg enable_mavlink_interface)
log_file:=$(arg log_file)
wait_to_record_bag:=$(arg wait_to_record_bag)
mav_name:=$(arg mav_name)
namespace:=$(arg namespace)"
/>
<param name="tf_prefix" type="string" value="$(arg tf_prefix)"/>
<!-- push robot_description to factory and spawn robot in gazebo -->
<node name="spawn_$(arg namespace)" pkg="gazebo_ros" type="spawn_model"
args="-urdf
-model $(arg namespace)
-x $(arg x)
-y $(arg y)
-z $(arg z)
-param robot_description"
respawn="false" output="screen">
</node>
</launch>
I want to pass random values generated from my python file to the args -x -y -z, but have no idea how to do achieve this. I have tried to define a param like thie post https://answers.ros.org/question/3666... and add the -param random_postion to the args of the node, but seems like it's not recognizing it ...