I am currently working with the PX4 SITL (Software-In-The-Loop) drone simulation in Gazebo, and I am encountering an issue related to the drone’s local position. Specifically, the drone’s home position is set at 3 meters in the Z-direction, and the drone appears to be operating at a height above the ground.
When I check the /fmu/out/vehicle_local_position
topic, it reports a Z value of 3 meters, which does not correspond to the drone’s actual position on the ground. Additionally, the home position is also set at 3 meters in the Z-direction. I suspect there may be a problem with the home location, or an issue related to the Gazebo simulation environment.
One hypothesis is that the Gazebo simulation or its navigation sensor might be providing incorrect altitude values. However, I have observed that the drone’s position does not oscillate, and there is no apparent issue in the horizontal plane. The only discrepancy is that the drone perceives itself to be 3 meters higher than its actual position on the ground.
For further validation, I am publishing both the drone’s real position from Gazebo and its estimated position from PX4, and I am visualizing both in RViz. Despite this, the problem persists. Any insights or suggestions would be greatly appreciated.
Thank you in advance for your assistance.
I also noted differences between the vehicle’s position and orientation obtained from ROS topics like /fmu/out/vehicle_local_position
and what you see in QGroundcontrol. This could be due to QGroundControl doing some transformations between FLU and NED frames. I am not sure, but you can ignore these differences. What you get from ROS topics is correct.
You are correct, I encountered a similar issue as well. I was able to resolve it through a specific transformation, which I believe could be valuable knowledge for developers facing similar challenges. From my understanding, I have not yet found an appropriate transformation to correctly obtain the attitude and position in ROS from PX4 topics. I will share this approach in a separate thread for further discussion.
Additionally, I would like to clarify my question: How is the home position determined, and what might be causing the horizontal position error?
Thank you for your assistance.
I don’t know how the home position is determined. But you can specify the home position in lat and long coordinates using the following commands
export PX4_HOME_LAT=28.452386
export PX4_HOME_LON=-13.867138
export PX4_HOME_ALT=28.5
make px4_sitl gazebo
Check this link for more details on setting the home position
https://docs.px4.io/v1.12/en/simulation/gazebo.html
If you are flying in gazebo, you don’t really need a home position. You can do with local coordinates.