How to assign random values to robot's initial position args in launch file
Hi Everyone,
I want to try giving my robot random positions and orientations every time it spawns in the Gazebo model but I have no idea how to randomize the value of the args. I've already seen one other question with a similar problem and the solution didn't help me since it was regarding setting the value of "param"s with a python code which didn't work for me, at least with my knowledge of ROS. I'm trying my luck with a husky robot simulation so that, if successful, it can be tested on another robot. I'm using UBUNTU 16.04 and ROS Kinetic. My launch is as follows :
<launch>
<arg name="laser_enabled" default="true"/>
<arg name="ur5_enabled" default="false"/>
<arg name="kinect_enabled" default="false"/>
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find husky_gazebo)/urdf/description.gazebo.xacro
laser_enabled:=$(arg laser_enabled)
ur5_enabled:=$(arg ur5_enabled)
kinect_enabled:=$(arg kinect_enabled)
" />
<arg name="x" default="-0.25"/>
<arg name="y" default="-1.25"/>
<arg name="z" default="0"/>
<node name="spawn_husky_model" pkg="gazebo_ros" type="spawn_model" args=" -unpause -urdf -param robot_description -model mobile_base -x $(arg x) -y $(arg y) -z $(arg z)"/>
</launch>
I will appreciate any help. If I should use a python file as a random number generator please explain to me how. Thank you
Without knowing what "didn't work" for you we can't help, but it seems like solving those issues ..
.. would be the thing to do here because there is no built-in way to "assign random values" in
roslaunch
.So please describe what didn't work for you with the approaches that you already found and perhaps forum members can help you then.
Similar to #q216303 but new launch features may provide for a better answer.
#q216303 didn't work for me because it was referring to how use "param"s in a launch file and not "arg"s. I tried implementing the same approach with a python file as a random number generator for the args that I'm using but I got errors for using methods that were meant for "param"s for "arg"s ...
I have no problem of using a python script as a random number generator and based on #q216303 I believe this approach is the best way of doing it but I just need more elaboration on the subject of how to use the python script for "arg"s in this context and how to address it properly in the launch.
Hello. I've been having the exact same problem with you (trying to set the arg values into random so that urdf positions would be set as random) and I couldn't find any solutions just yet. I was curious if you managed to resolve the issue and if possible, share how you solved the problem