How to autotune the PID params

You can never port code from Ardupilot since the PX4 project has a different license.