# Align PX4 local\_position and Gazebo Classic reference frame

**URL:** <https://discuss.px4.io/t/align-px4-local-position-and-gazebo-classic-reference-frame/34038>\
**Category:** PX4 Autopilot\
**Created:** [August 30, 2023, 10:37am UTC](https://discuss.px4.io/t/align-px4-local-position-and-gazebo-classic-reference-frame/34038 "2023-08-30T10:37:26Z")\
**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:** [August 30, 2023, 10:37am UTC](https://discuss.px4.io/t/align-px4-local-position-and-gazebo-classic-reference-frame/34038/1 "2023-08-30T10:37:27Z")

</div>

Greetings,  
I am using Gazebo Classic to simulate a quad-copter running PX4 and ROS2, but I have a little issue with the coordinate systems.

The drone is spawned on Gazebo at a fixed location different from the Gazebo origin.  
I either need to spawn the drone at the origin or advertise the PX4 topics to set the current location (which is initialized as x=0, y=0, z=0) at the real Gazebo coordinates.

Can you help me with this matter?

The only idea that I had was to change the parameters of the simulated drone trough QGroundControl to set up PX4 to receive an external odometry such I have done for the Vicon, but it seems to me an unnecessary convoluted solution for the matter.

---

<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:** [August 31, 2023, 9:24am UTC](https://discuss.px4.io/t/align-px4-local-position-and-gazebo-classic-reference-frame/34038/2 "2023-08-31T09:24:03Z")

</div>

If someone face the same problem.  
I found how to change the spawn location of the models in Gazebo Classic.

Go to `PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/`, there a file called sitl\_run.sh (which the bash script which one of the bash script that is executed by the make p4\_sitl gazebo-classic command).

Around line 130 (PX4 v1.14 at the time of writing) you will find the following text:

```plaintext
while gz model --verbose --spawn-file="${modelpath}/${model}/${model_name}.sdf" --model-name=${model} -x 1.01 -y 0.98 -z 0.83 2>&1 | grep -q "An instance of Gazebo is not running."; do
		echo "gzserver not ready yet, trying again!"
		sleep 1
	done

```

You can change the -x -y -z field to spawn the vehicle wherever you want!

I am still wondering if I can advertise somehow the /fmu/vechicle\_odometry or /fmu/vehicle\_local\_position to send to it the position and attitude of the model to align them with Gazebo without spawning it right at the origin.
