# URDF中使用STL文件定义的机器人链接在Gazebo不显示但RViz正常

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-04-03-robotics-se-113389
> 频道：pitfalls | 更新日期：2026-04-03 | 标签：auto, stackexchange, gazebo
> 核心摘要：用户使用ROS 2 Humble时URDF中STL链接在Gazebo不显示，可通过修改路径格式或配置ament hooks解决兼容问题。

# URDF中使用STL文件定义的机器人链接在Gazebo不显示但RViz正常

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Robot Links Defined with STL Files Not Showing in Gazebo](https://robotics.stackexchange.com/questions/113389/robot-links-defined-with-stl-files-not-showing-in-gazebo)（Robotics Stack Exchange #113389）

**状态**：有绕过办法

## 问题

URDF里预定义形状的链接在Gazebo显示正常，用`＜mesh＞`标签引用STL文件的链接无法在Gazebo显示，节点运行无报错；改用绝对路径后Gazebo显示正常，但RViz加载网格资源报错。

## 环境

软件版本：ROS 2 Humble，Gazebo，RViz；用户已正确source工作区。

## 解决办法

1. 若使用绝对路径，开头需添加`file://`前缀使RViz可正常加载。
2. 若使用`package://`路径，可通过ament hooks配置让Gazebo检索ROS share目录。

原问题作者：niato axel；采纳答案作者：Olivier Kermorgant。原内容依 CC BY-SA 4.0 授权，本页摘要同样依 CC BY-SA 4.0 授权。
:::

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #113389：Robot Links Defined with STL Files Not Showing in Gazebo](https://robotics.stackexchange.com/questions/113389/robot-links-defined-with-stl-files-not-showing-in-gazebo)