I have a .world
file in ROS for gazebo simulation which is an XML file.
How can I put on a dynamic home path instead of the static path in <uri>
tag?
Here's my simplified .world
file:
<?xml version="1.0" ?>
<sdf version='1.5'>
<world name='default'>
<visual name='base_link_visual_front_sonar'>
<pose>0.109 0 0.209 0 -0 0</pose>
<geometry>
<mesh>
<uri>/home/agn/catkin_ws/src/description/meshes/sonar.stl</uri> <!--Note-->
</mesh>
</geometry>
</visual>
</world>
</sdf>
How can I use $HOME
instead of /home/agn
?
I tried the following cases with the failed results:
<uri>~/catkin_ws/src/description/meshes/sonar.stl</uri>
<uri>$HOME/catkin_ws/src/description/meshes/sonar.stl</uri>
<uri>"$HOME/catkin_ws/src/description/meshes/sonar.stl"</uri>
<uri>${HOME}/catkin_ws/src/description/meshes/sonar.stl</uri>
<uri>"${HOME}/catkin_ws/src/description/meshes/sonar.stl"</uri>
<uri>"${sys:user.home}/catkin_ws/src/description/meshes/sonar.stl"</uri>
<uri>${sys:user.home}/catkin_ws/src/description/meshes/sonar.stl</uri>
<uri>${user.home}/catkin_ws/src/description/meshes/sonar.stl</uri>
<uri>"${user.home}/catkin_ws/src/description/meshes/sonar.stl"</uri>
According to the Gazebo tutorial Gazebo allows to find additional models at paths that are listed listed on the environment variable
GAZEBO_MODEL_PATH
.Adding a path to an environment variable is well described in How to correctly add a path to PATH? and can be done like
Now you are able to set the uri like
Note that there is also a hacks which allows changing the environment variable in the package.xml.