Drone keeps spiralling in simulation


I was trying to simulate a custom drone using gazebo and PX4 SITL. The drone spirals out of control as soon it leaves the ground in takeoff mode. Kindly refer to the attached image. In manual control mode, the drone takes off and moves upward in a straight line but still continues to spin about the yaw axis.

I have two hypotheses:

  1. It is a magnetometer calibration issue similar to the one described here. If so, how does one go about calibration in a simulation?

  2. It’s a GPS estimate error, as the projected GPS is extremely unstable. Not sure how to approach this either.

I am still quite new to drones and px4. Any help would be greatly appreciated.

Thanks in Advance,

Can you fly it in position flight mode?