# Gazebo Harmonic四轮差速里程计与RViz不一致

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-02-05-robotics-se-118031
> 频道：pitfalls | 更新日期：2026-02-05 | 标签：auto, stackexchange, gazebo
> 核心摘要：四轮差速模型在Gazebo中里程计异常，需移除DiffDrive插件的odom输出参数并改用独立OdometryPublisher插件发布。

# Gazebo Harmonic四轮差速里程计与RViz不一致

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Gazebo odometry is not the same as RVIz one](https://robotics.stackexchange.com/questions/118031/gazebo-odometry-is-not-the-same-as-rviz-one)（Robotics Stack Exchange #118031）

**状态**：已解决

## 问题

在Ubuntu 24.04/ROS2 Jazzy/Gazebo Harmonic环境下，将Navigation 2教程机器人从双轮改为前后两组四轮差速配置后，gz-sim-diff-drive-system计算的里程计数据与RViz显示不一致。原配置在DiffDrive插件中直接定义了odom_topic、tf_topic及frame_id等输出参数导致异常。

## 环境

Ubuntu 24.04, ROS2 Jazzy, Gazebo Harmonic, gz-sim-diff-drive-system, gz-sim-odometry-publisher-system

## 解决办法

1. 修改 `gz-sim-diff-drive-system` 插件配置，保留四个关节定义（`drivewhl_l_joint`, `drivewhl_r_joint`, `drivewhl_l_b_joint`, `drivewhl_r_b_joint`）及运动学参数，但必须删除 `<odom_topic>`、`<tf_topic>`、`<frame_id>` 和 `<child_frame_id>` 标签，仅保留 `/demo/cmd_vel` 输入话题。
2. 新增 `gz-sim-odometry-publisher-system` 插件，设置 `<odom_frame>odom</odom_frame>` 和 `<robot_base_frame>base_link</robot_base_frame>`。
3. 在新插件中配置 `<odom_publish_frequency>50</odom_publish_frequency>`、`&lt;odom_topic&gt;/demo/o…

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

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #118031：Gazebo odometry is not the same as RVIz one](https://robotics.stackexchange.com/questions/118031/gazebo-odometry-is-not-the-same-as-rviz-one)