Autonomous Drone Hovers Fine and then Drops Suddenly

My partner and I are trying to create an autonomous indoor drone. We are using the Intel Aero RTF drone and Dronekit. We are using the Ardupilot version that came with the drone APM3.5.5. Since the GPS and the barometer readings are inconsistent indoors, we have attached a 1D downward-facing lidar (LeddarOne) to give accurate height estimations and a 2D lidar (RPLiDAR A2) on top. The 2D lidar is connected to the onboard computer, which is running BreezySLAM to give us position estimates. We, then, used those position estimates to design a PD control system in our Python script that controls the horizontal positioning of the drone by telling it what attitude is needed to correct the position. The system we have now works great at maintaining a hover for about 15 seconds, and then, it yaws slightly to the left and drops in height. We have tried telling the drone to yaw right and left, and it maintains its hover fine. It seems like over time, some error builds up that causes the drone to drop. The drone will drop to the ground and then come back and then eventually drops again. Could this be a problem with the battery or ESCs? It’s a strange problem because it doesn’t happen until a few seconds in. This is the last problem we need to fix in order to move on with our senior design project or we might have to change projects, so any help is appreciated!

We have tried a lot of different things, so I will list them here in case it helps narrow down solutions:

  1. We have tried updating to the newest firmware APM 3.6.6.; however, the new firmware prevents us from using the rangefinder data as the altitude source for some reason. We can see the rangefinder data working correctly, and EK2_ALT_SOURCE is set to the rangefinder and EK2_HGT_USE = 70%. Since we couldn’t get the altitude to read correctly, we couldn’t test to see if the new version would fix the problem. Is there a fix to this problem? (We used all the same parameters that allowed us to use the rangefinder as the altitude source in APM 3.5.5)

  2. We have run HectorSLAM and passed the positional data straight to the flight controller using MAVROS. The data is passed as visual position estimates. In APM 3.5.5, we can see the VISION_POSITION_ESTIMATE information flowing in through the Mavlink inspector, but it doesn’t seem to be using it for position estimation since we still cannot used Guided mode. We also cannot run our dronekit python script while MAVROS is running. Does MAVROS block out any dronekit connection? In APM 3.6.6, it tells us that external navigation data is being used, but since the altitude is inconsistent, we cannot really test it. I did try arming and taking off from the GCS in Guided mode, but the mavlink-router seems to crash every time I do this, and I lose connection.


You probably already figured out the issue, however just adding my 2 cents here - “It seems like over time, some error builds up that causes the drone to drop” – could be perhaps you need to include the integral controller as well (since that is what deals with steady-state error over time)…