Tuning of Multicopter Position Controller for Indoor flight

Hi Pixhawk team and users.

For several weeks we have been struggling with tuning the position control of our recently built drone intended for indoor use. The drone behaves nicely when controlled manually, with both critically dampened actions. However when it comes to the MPC (Multicopter Position Controller) we simply can’t get the drone tuned in.

We are using an Optitrack Motion Capture system to provide X, Y, Z and Yaw measurements to the drone. The average measurement standard deviation (the standard deviation varies slightly in the room hence an average) is around 1mm and the Mocap measurements is published to the ATT_POS_MOCAP topic with 50 Hz.
The log plots from an offboard control with the best tuning that we have been able to achieve is shown here: https://logs.px4.io/plot_app?log=cfed906a-ed95-400e-92ff-f16d85eee0ae
We are in general unhappy about the overshoot and especially that the position hold fluctuates +/- 25 cm.

If we increase the gains to try and lower the overshoots the drone ends up oscillating as seen in this video: https://www.dropbox.com/s/ph8dvvbq9u03j5i/2017-10-02%2010.41.18.mov

As a plan towards resolving some of the tuning issues we decided to try and tune the z-position controller only, to see if we could achieve any better z-position hold (the drone tends to wobble up and down).
What confuses me though, is that we were able to tune the z-position controller such that it didn’t make any fast oscillations and was able to hold the z-position nicely for 5-10 seconds, but the drone would always make a bigger drop in altitude (>20 cm) eventually and then slowly recover.
The log plots from the best altitude hold we have been able to achieve is shown here: https://logs.px4.io/plot_app?log=03149179-3878-4756-a16a-352a45f6f3e5

Do you have any suggestions what to try and in which direction we should look for the problem?
We have already tried to reduce vibrations as much as possible and we have verified (through the log) that the Mocap measurements are indeed available and are deemed steady and reliable.
Are the problems related to Position Controller tuning (MPC) or Position Estimator tuning (LPE)?

The Ulog flight logs can be downloaded from here:

Any suggestions?
We have now tried some further tuning and can not seem to get any better response.

Can the bad performance and tuning problems have anything to do with faulty Pixhawk hardware?

Hi @mindthomas

Do you have the lastest firmware version?

Do you have the same postition and orientation data in the topics /mocap/pose and local_position/pose ?

Yes, we are running the latest version: v1.6.5
The X,Y,Z and Yaw component of /local_position/pose seem to track the /mocap/pose nicely. So the state estimation seems good. I am quite confident that the problem is related to controller tuning.

Did you solve your problem? @mindthomas

Yesterday, I had a problem similar and I solved it modifying the lpe_pn_v parameter

I was wondering how well you have managed to make this work @Mario1577 / @mindthomas? I.e. How tightly can you follow position setpoint inputs.

For bonus points, any suggestions on how to get best performance improvements? or suggested values for key params like lpe_pn_v and lpe_vic_p for use with accurate mocap systems.

I’ve tried varying lpe_pn_v but seem to get pretty big position oscillations whatever I set this parameter to. A typical logfile is:
https://logs.px4.io/plot_app?log=c36c99b0-234f-4525-bf17-242bbe6a7783. Would also be great to see a link to a file of a well tuned system.

I think you should tune a good rate control parameter.