# Gazebo Simulation, Odometry initialization

**URL:** <https://discuss.px4.io/t/gazebo-simulation-odometry-initialization/36032>\
**Category:** PX4 Autopilot\
**Created:** [December 22, 2023, 4:50pm UTC](https://discuss.px4.io/t/gazebo-simulation-odometry-initialization/36032 "2023-12-22T16:50:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![biagio](https://discuss.px4.io/user_avatar/discuss.px4.io/biagio/32/15351_2.png) [@biagio](https://discuss.px4.io/u/biagio)\
**Post date:** [December 22, 2023, 4:50pm UTC](https://discuss.px4.io/t/gazebo-simulation-odometry-initialization/36032/1 "2023-12-22T16:50:45Z")

</div>

Hi, I am currently using Gazebo to test out some algorithms with ROS2, and to spawn the vehicle I am using the command

```Bash
PX4_GZ_MODEL_POSE="0,0,0,0,0,0" make px4_sitl gz_x500

```

I noticed that the spawned vehicle’s odometry (from /fmu/out/vehicle\_odometry) is off by almost 20cm on every axis (it oscillates between 0 and 40 cm) and that the drone starts with a 90-degree rotation around the z-axis, always according to the odometry.

Is there a way to initialize the odometry to 0 on every field by setting some parameters? My current idea is to publish an “initial position” onto the visual odometry topic to set it to 0 at the start of the simulation.

---

<div class="post-metadata">

**Author:** ![Benja](https://discuss.px4.io/user_avatar/discuss.px4.io/benja/32/11872_2.png) [@Benja](https://discuss.px4.io/u/Benja)\
**Post date:** [December 27, 2023, 12:38pm UTC](https://discuss.px4.io/t/gazebo-simulation-odometry-initialization/36032/2 "2023-12-27T12:38:16Z")

</div>

Hi @biagio  
`PX4_GZ_MODEL_POSE` sets the model pose with Gazebo convention (ENU/FLU). Therefore when you set `yaw=0` and you align the Gazebo `x` axis with the drone `x` axis, in the PX4 convention (NED, FRD) you obtain the 90° rotation.  
The odometry is computed from the perturbed measurements of the simulated GPS, this is why you don’t have perfect measurements. You can check the true pose inspecting the Gazebo topics.

You can use the `gz_x500_vision` model, which uses the gazebo odometry plugin, to have perfect data. Look at the differences w.r.t. the standard `gz_x500` in terms of model file and airframe (default parameters).
