Hexacopter unstable flight in gazebo

I have designed an hexacopter by myself, i made the URDF and it is spawning correctly but when i give the takeoff command, upto certain height it goes then become so unstable that ultimately crashes. I have checked multiple times, channels seems fine to me, liftdrag plugin for all 6 rotors are also seem fine to me, inertial and CG is also at good place, changed the param file for hexacopter X frame type but getting same result. I even checked the log files just before it started to get unstable it always shows “ekf:yaw reset”. Can someone please help me out in with this gazebo simulation

Hi @Vineet1605, can you share the URDF (or preferably SDF) for the model?

It could be a number of things, but I suspect that simulating the rotors as lifting surfaces using the lift-drag plugin may sometimes be problematic. I have seen similar stability issues on a couple of models I have adapted for Gazebo (@iampete’s 6DOF OmniCopter and a Swan-K1-HWing).

In both cases I’ve struggled to get a stable tune and I suspect it is due to noise in the physics time stepping coming from the joints, although I have not been able to rule out other causes. An alternative approach is to apply the thrust directly - Gazebo Garden has a plugin (MultiCopterMotorModel) which may be suitable. I’m planning to apply this to the two models mentioned above to see if I can get a stable simulation - it may be suitable for your hexacopter.

To use it you forward servo commands received by the ArduPilotGazeboPlugin onto topics consumed by the MultiCopterMotorModel plugin. This is only available for the new version of Gazebo and the plugin we support for that. No luck for Gazebo9/Gazebo11 I’m afraid.