首页 > 解决方案 > 用于在 urdf 文件中加载网格的文件名,干扰加载包含它的 urdf 文件

问题描述

在对我的机器人执行校准后,我必须在 urdf 文件(本质上是一个 xml 文件)中查找并替换关节描述。所以我计划制作一个使用urdfpy库的python脚本。但是网格的文件名已在 urdf 文件中定义为

<geometry>
        <mesh
            filename="package://rcve/src/rcve_description/meshes/RCVE_stl.STL" />
</geometry>

调用时会干扰URDF.load(filename)函数。

我加载文件的代码:

from urdfpy import URDF 
import os

os.chdir(os.path.dirname(__file__))
os.chdir('..')
dirname = os.path.abspath(os.curdir)
robot = URDF.load(os.path.join(dirname, 'rcve_description/urdf/RCVE_stl_cal.urdf'))

我得到的最后几行错误:

File "/home/akash/.local/lib/python3.8/site-packages/urdfpy/urdf.py", line 581, in _from_xml
    meshes = load_meshes(fn)
  File "/home/akash/.local/lib/python3.8/site-packages/urdfpy/utils.py", line 225, in load_meshes
    meshes = trimesh.load(filename)
  File "/home/akash/.local/lib/python3.8/site-packages/trimesh/exchange/load.py", line 108, in load
    ) = parse_file_args(file_obj=file_obj,
  File "/home/akash/.local/lib/python3.8/site-packages/trimesh/exchange/load.py", line 587, in parse_file_args
    raise ValueError('string is not a file: {}'.format(file_obj))
ValueError: string is not a file: /home/akash/Documents/rcve/catkin_ws1/src/rcv_autonomous/rcve/src/rcve_description/urdf/package://rcve/src/rcve_description/meshes/RCVE_stl.STL

感谢任何建议,以帮助我成功加载 urdf 文件或有关我的方法的任何其他反馈。

标签: xmlfilefilenamesrostrimesh

解决方案


推荐阅读