# RViz

**RViz**是[机器人操作系统](https://www.edgepedia.org/zh/robot-operating-system)（ROS）的三维可视化工具，而ROS是一个用于机器人开发的软件框架。它把传感器数据、机器人模型、坐标系、地图和标记渲染在一个三维场景中，让开发者能在机器人运行时看到其软件正在做什么。最初的RViz随ROS 1一同发布，重写后的版本RViz2在[ROS 2](https://www.edgepedia.org/zh/ros-2)中承担同样的角色。<sup>[1](https://github.com/ros2/rviz)</sup><sup> • </sup><sup>[2](https://index.ros.org/p/rviz2/)</sup>该工具于2008年作为ROS的可视化组件首次推出。<sup>[3](https://openarchive.nure.ua/bitstreams/a853139f-3061-4a90-9f5c-8ef757c5f5d7/download)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 用于ROS和ROS 2的三维可视化工具，包索引中称其为“ROS的三维可视化工具”<sup>[2](https://index.ros.org/p/rviz2/)</sup> |
| 首次发布 | 2008年作为ROS可视化工具推出<sup>[3](https://openarchive.nure.ua/bitstreams/a853139f-3061-4a90-9f5c-8ef757c5f5d7/download)</sup> |
| 许可证 | ROS 2代码库采用BSD-3-Clause-Clear许可证<sup>[1](https://github.com/ros2/rviz)</sup> |
| ROS 2启动命令 | `ros2 run rviz2 rviz2`；可用`-d`标志加载已保存的配置<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup><sup> • </sup><sup>[5](https://github.com/ros-controls/ros2_control_demos/blob/master/doc/index.rst)</sup> |
| 配置格式 | YAML格式的`.rviz`文件，存储显示项、工具、视图控制器和面板布局<sup>[6](https://ftp.osuosl.org/pub/ros/ros_wiki_mirror/visualization%282f%29ChangeList.html)</sup> |
| 渲染 | 基于OGRE三维渲染库构建；ROS 2代码库包含`rviz_ogre_vendor`包<sup>[1](https://github.com/ros2/rviz)</sup> |
| 可扩展性 | 可为显示项、面板、工具、视图控制器和坐标变换库编写插件<sup>[7](https://github.com/ros2/rviz/blob/rolling/docs/plugin_development.md)</sup> |

## 工作原理

RViz订阅ROS话题，并将其内容绘制在三维场景中。界面的核心元素是显示项：即某种在三维世界中绘制一类数据的组件，例如点云、机器人状态、激光扫描、占据栅格地图或相机图像。每个显示项都有自己的状态指示器，取值为正常、警告、错误或已禁用之一，在窗口左侧的“显示项”面板中以颜色和图标表示。<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup>显示项可通过“添加”按钮或Ctrl-N快捷键添加，也可以“按话题”选择，此时会列出当前可供显示的话题。<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup><sup> • </sup><sup>[8](https://docs.clearpathrobotics.com/docs/ros2humble/ros/tutorials/rviz/)</sup>

**坐标系。** RViz使用tf（ROS 2中为tf2）变换系统，将数据从其到达时所处的坐标系转换到一个全局参考坐标系。其中最重要的有两个坐标系。固定坐标系是“世界”的参考坐标系，通常是`map`、`world`或某个里程计坐标系；它不应相对世界发生移动，更改它会清除当前显示的所有数据，而不是对其重新变换。目标坐标系是相机视图的参考坐标系：如果目标坐标系是地图，看到的就是机器人在地图上四处行驶；如果目标坐标系是机器人的基座，则机器人停留在原地，其他一切相对它运动。<sup>[9](https://mirrors.nju.edu.cn/ros-wiki/rviz%282f%29UserGuide.html)</sup>变换问题是最常见的数据无法显示的原因；排查指南建议检查变换树是否存在，并作为快速测试，把固定坐标系和目标坐标系都设为那个未能显示的话题的`frame_id`。<sup>[10](https://ftp.osuosl.org/.1/ros/ros_wiki_mirror/rviz%282f%29Troubleshooting.html)</sup>

**工具与视图。** 工具栏中的工具都配有键盘快捷键：移动相机（m），为默认工具；交互（i），用于操作交互式标记；选择（s），支持单点选择和按住拖拽的框选，选中对象以青色包围盒标示，并配有“选择”面板；二维目标位姿（g），在`/goal_pose`话题上为导航栈发布目标位姿；二维位姿估计（p），在`/initialpose`上发布初始位姿以初始化定位。<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup>视图控制器控制视点和相机投影；该工具自带四种内置类型，“归零”按钮（快捷键z）可将视图重置为朝向原点。<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup>

**配置。** 配置文件存储显示项及其属性、工具及其属性、视图控制器类型和已保存视图，以及窗口布局和面板列表。RViz对待配置就像编辑器对待文件：打开、修改、保存会覆盖原文件。若未指定文件，RViz会加载`~/.rviz/default.rviz`，必要时创建该文件；标题栏中的星号表示有未保存的更改。<sup>[4](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)</sup>

## 标记与交互式标记

“标记”显示项绘制其他ROS节点通过`visualization_msgs/msg/Marker`消息在`visualization_marker`话题上发布的基本形状。对象类型包括箭头、立方体、球体、圆柱体、折线和线段列表、三角形列表以及文本；CUBE_LIST和SPHERE_LIST这类列表变体可批量渲染大量同尺度对象，渲染速度远快于逐个标记。<sup>[11](https://github.com/ros2/ros2_documentation/blob/rolling/source/Developer-Tools/Visualization/RViz/Marker-Display-types/Marker-Display-types.rst)</sup>标记的`frame_locked`参数控制RViz是在每个更新周期将其重新变换到其坐标系当前所在的位置，还是让它留在最初放置的位置。<sup>[11](https://github.com/ros2/ros2_documentation/blob/rolling/source/Developer-Tools/Visualization/RViz/Marker-Display-types/Marker-Display-types.rst)</sup>

“交互式标记”显示项于ROS Electric版本引入，作为一个或多个交互式标记服务器的客户端，让用户直接在主视图中操作通过ROS话题接收的三维对象；它使用与“标记”显示项相同的视觉图元。<sup>[12](https://apache.oregonstate.edu/pub/ros/ros_wiki_mirror/rviz%282f%29DisplayTypes%282f%29InteractiveMarker.html)</sup>

## 可扩展性

RViz以插件系统的形式构建。在ROS 2版本中，插件可以扩展五个扩展点，每个扩展点都有必需的基类：显示项（`rviz_common::Display`或`rviz_common::RosTopicDisplay<MessageType>`）、面板（`rviz_common::Panel`）、工具（`rviz_common::Tool`）、坐标变换库（`rviz_common::transformation::FrameTransformer`）以及视图控制器（`rviz_common::ViewController`）。插件通过`plugin_description.xml`文件注册，由pluginlib在运行时加载。<sup>[7](https://github.com/ros2/rviz/blob/rolling/docs/plugin_development.md)</sup>默认的显示项、工具和视图控制器位于`rviz_default_plugins`包中，另有独立的`rviz_visual_testing_framework`包支持插件的自动化截图测试。<sup>[7](https://github.com/ros2/rviz/blob/rolling/docs/plugin_development.md)</sup><sup> • </sup><sup>[1](https://github.com/ros2/rviz)</sup>

## 历史

RViz起源于[Willow Garage](https://www.edgepedia.org/zh/willow-garage)（威洛车库），即创建ROS的公司；源文件带有2008年Willow Garage的版权声明。<sup>[13](https://github.com/ros-visualization/rviz/blob/main/src/rviz/robot/robot.cpp)</sup>2011年12月，项目宣布自ROS Fuerte版本起，RViz将从wxWidgets图形界面库迁移到Qt，早期版本可在ROS Electric的`visualization_experimental`软件栈中获取。<sup>[14](https://www.ros.org/news/2011/12/)</sup>Groovy版本（1.9系列）做出了进一步的结构性改动：rviz成为独立的catkin包；保存配置的格式从类ini格式的`*.vcg`文件改为YAML格式的`*.rviz`文件；所有主要组件均可插拔；并为主要类添加了Python绑定。<sup>[6](https://ftp.osuosl.org/pub/ros/ros_wiki_mirror/visualization%282f%29ChangeList.html)</sup>

ROS 2移植版在ROSCon 2018上以“RViz：一个迁移到ROS 2.0的故事”为题做了介绍。<sup>[15](https://roscon.ros.org/2018/presentations/ROSCon2018_rviz_migration.pdf)</sup>这次迁移拆分了单体式包：面向用户的基类移至`rviz_common`，渲染代码移至`rviz_rendering`，默认插件移至`rviz_default_plugins`，选择机制则移入`rviz_common`的`interaction`子文件夹。<sup>[16](https://github.com/ros2/rviz/blob/rolling/docs/migration_guide.md)</sup>ROS 1分支继续并行发展；其列出的最后一个版本是2025年5月的1.14.26，该版本增加了关于ROS 1生命周期终止的警告对话框。<sup>[17](https://index.ros.org/p/rviz/)</sup>

## 今日的RViz2

`rviz2`包在各ROS 2发行版中发布并维护，包索引列出了从Bouncy到Rolling各发行版的版本，当前Rolling版本处于15.x系列。<sup>[2](https://index.ros.org/p/rviz2/)</sup>近期的发布反映了平台变化：14.2.5版增加了对Wayland会话的检测，从而自动使用X渲染，因为rviz2在没有X兼容层的情况下无法在Wayland下工作（手动变通方法是设置`QT_QPA_PLATFORM=xcb`）；15.x系列将默认Qt依赖从Qt5迁移到Qt6。<sup>[2](https://index.ros.org/p/rviz2/)</sup>显示功能也在增长；例如“地图”显示项处理`nav_msgs::msg::OccupancyGrid`消息，并可通过`map_msgs::msg::OccupancyUpdate`消息增量更新地图。<sup>[18](https://github.com/ros2/rviz/blob/rolling/docs/FEATURES.md)</sup>

RViz仍然是一个桌面端、ROS原生的工具，这也决定了它与Foxglove Studio等较新替代方案的比较格局——后者是一个基于Web的可视化平台。RViz需要正确安装的ROS环境，并且缺少内置的录制数据回放功能：可视化一个bag文件需要在可视化工具之外运行`rosbag`或`ros2 bag`等外部命令行工具。相比之下，Foxglove以Web应用或桌面应用的形式运行，可直接播放`.bag`、`.db3`和`.mcap`文件，并提供交互式拖动控制。<sup>[19](https://foxglove.dev/blog/foxglove-vs-rviz)</sup>

## References

1. [ros2/rviz repository README, GitHub](https://github.com/ros2/rviz)
2. [rviz2 package overview, ROS Package Index](https://index.ros.org/p/rviz2/)
3. [Simulation and visualization tooling lecture notes (Rviz introduced 2008), Kharkiv National University of Radio Electronics repository](https://openarchive.nure.ua/bitstreams/a853139f-3061-4a90-9f5c-8ef757c5f5d7/download)
4. [RViz User's Guide (rviz2/doc/index.rst), ros2/rviz on GitHub](https://github.com/ros2/rviz/blob/rolling/rviz2/doc/index.rst)
5. [ros2_control_demos documentation (rviz2 -d usage), ros-controls on GitHub](https://github.com/ros-controls/ros2_control_demos/blob/master/doc/index.rst)
6. [visualization/ChangeList, ROS wiki mirror](https://ftp.osuosl.org/pub/ros/ros_wiki_mirror/visualization%282f%29ChangeList.html)
7. [User's Guide to plugin development (docs/plugin_development.md), ros2/rviz on GitHub](https://github.com/ros2/rviz/blob/rolling/docs/plugin_development.md)
8. [Visualizing with RViz2, Clearpath Robotics documentation](https://docs.clearpathrobotics.com/docs/ros2humble/ros/tutorials/rviz/)
9. [rviz/UserGuide, ROS wiki mirror](https://mirrors.nju.edu.cn/ros-wiki/rviz%282f%29UserGuide.html)
10. [rviz/Troubleshooting, ROS wiki mirror](https://ftp.osuosl.org/.1/ros/ros_wiki_mirror/rviz%282f%29Troubleshooting.html)
11. [Marker: Display types, ros2_documentation on GitHub](https://github.com/ros2/ros2_documentation/blob/rolling/source/Developer-Tools/Visualization/RViz/Marker-Display-types/Marker-Display-types.rst)
12. [rviz/DisplayTypes/InteractiveMarker, ROS wiki mirror](https://apache.oregonstate.edu/pub/ros/ros_wiki_mirror/rviz%282f%29DisplayTypes%282f%29InteractiveMarker.html)
13. [rviz/src/rviz/robot/robot.cpp, ros-visualization/rviz on GitHub](https://github.com/ros-visualization/rviz/blob/main/src/rviz/robot/robot.cpp)
14. [ROS robotics news, December 2011 (rviz wxWidgets to Qt migration)](https://www.ros.org/news/2011/12/)
15. [RViz: The tale of a migration to ROS 2.0, ROSCon 2018](https://roscon.ros.org/2018/presentations/ROSCon2018_rviz_migration.pdf)
16. [Migration guide (docs/migration_guide.md), ros2/rviz on GitHub](https://github.com/ros2/rviz/blob/rolling/docs/migration_guide.md)
17. [rviz package overview, ROS Package Index](https://index.ros.org/p/rviz/)
18. [FEATURES.md, ros2/rviz on GitHub](https://github.com/ros2/rviz/blob/rolling/docs/FEATURES.md)
19. [Foxglove vs. RViz, Foxglove blog](https://foxglove.dev/blog/foxglove-vs-rviz)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Robot software, AI, and methods › Robot middleware, frameworks, and behavior architectures

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/rviz

English original: https://www.edgepedia.org/rviz
