如何将 XML 文件中的主路径作为环境变量? [英] How to put on the home path in an XML file as an environment variable?

查看:40
本文介绍了如何将 XML 文件中的主路径作为环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ROS 中有一个 .world 文件用于凉亭模拟,它是一个 XML 文件.

I have a .world file in ROS for gazebo simulation which is an XML file.

如何在 <uri> 标签中放置动态主路径而不是静态路径?

How can I put on a dynamic home path instead of the static path in <uri> tag?

这是我简化的 .world 文件:

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>

<小时>

如何使用 $HOME 而不是 /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>

推荐答案

根据 roslaunch wiki,你应该试试这个:

According to roslaunch wiki,you should try this:

<uri>$(env HOME)/catkin_ws/src/description/meshes/sonar.stl</uri>

这篇关于如何将 XML 文件中的主路径作为环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆