Iris copter drifts in random direction after takeoff in gazebo in guided_nongps mode

I am trying to make quad takeoff hover for sometime and land when a certain altitude is reached. i am able to make the copter takeoff using /mavros/setpoint_raw/attitude topic but as it takesoff it starts drifting in random direction. Is there any way for stable takeoff and hover.

Non gps mode? I hope this isn’t a dumb question, but are you using some kind of positioning sensor besides gps?
If not, you will need to, or the drone won’t be able to hold position. If you are, then you can upload a flight log here and we can take a look at why it’s not able to.

Hi, I am an absolute beginner and trying to learn about ROS and autonomous drone development.Right now I am doing simulations on gazebo.I don’t have any external positioning sensor I am working with the IMU data from Pixhawk 2.1 . Is it possible to make a drone stable using relative positioning calculated from the data gathered from IMU.

In a word, no. This sort of “dead reckoning” inertial navigation is not supported for relative positioning by itself; the low cost IMUs used in these flight controllers simply aren’t good enough. For navigation-enabled flight modes, you will need GPS, optical flow, or some other positioning system like external cameras/beacons or SLAM.

Although while inertial navigation is not good enough to be used on its own, inertial measurements are used by the EKF to create a position estimate. This works because the error accumulation of inertial guidance is bounded by corrections from absolute positioning sensors like GPS.

Thank you for the explanation. I will use camera as external positioning system.