I mostly flew done outdoor and didn’t noticed altitude holding is even harder indoor.
Recently I have been poking around sonar distance sensor, ekf2, px4flow and position controller for more accurate indoor navigation with px4 firmware.
I thought altitude hold is quite easy task however it obviously not as the result is not consistent with every flight.
Here is one example.
This log is a text example of how altitude holding should be like
And here is another one with exact same setup and flew a few minutes later with another fully charged battery.
In the above plot, drone starts drift up and down and at some point it loses its set point and drop significantly.
A minute later, drone become settled and starts holding altitude quite accurately as before.
I don’t know why this happen because they are all flying in the same area, no wind, perfectly flat floor.
Maybe I didn’t put the drone on the ground more gently then before?
I am bit confused. Anyone has similar experience? How did you solve this problem?
I sort of figured this problem myself and would like to share my experience.
This problem is originated from noisy sonar data and especially when sonar become unreliable at about its maximum range.
According to the sonar specification, it can detect range of about 5m however it can only measure distances about 2.5m and it gets even worse when motor and prop is spinning. When throttle is about 50%, sonar’s maximum detection range significantly reduced to about 1.4m. If this occurs during the flight, ekf2 believes the vertical speed is going negative(towards the ground) when the drone is actually going up.
In the above picture, velocity Z shows becomes below -1.5m/s at some point.
After replacing the sonar with different one, which gives more reliable data above 2m height, gives better result.
Then here’s another problem with accel/gyro sensors combined.
In the above plot, raw accelerometer data have blank spot at around 233 seconds into the flight.
This affects the overall performance of ekf estimation especially about vertical speed.
So I was able to control the attitude but could not get vertical position stabilization.
This issue does not happen very often but I think it has to be monitored and warn the user to safely land the drone immediately.
I am still having issue with failing vertical z estimation in ekf2.
In the log below, velocity in z direction explodes after about 40 seconds into the flight.
This happens quite often and it is not recoverable and forced to change into stabilize mode.
Disabling RNG_AID didn’t help.
I tried to replace the fc board and realized that this error is maybe relates to power starvation.
When replacing the board, I measured the output of the 5v rail from power regulator with no power drain and found it only output 2.7~8 volts.
I hardly can believe fc can be powered with this voltage but surprisingly the output voltage recover to 5.0v when fc is connected to the regulator.
I suspect now this voltage maybe under powered (less currents) especially when flying.
So I test again with new power regulator and yes! the problem is gone!
I know it is important to have stable and constant voltage into the fc but I actually thought fc or gyro/accel sensor would stop working if power is not enough and not degrading like this.
I also should have checked the power earlier but I couldn’t because the drone is quite tightly spaced.
Now I need to find better power source that can make more accurate and reliable 5v output.