Strange behavior in Loiter: the vehicle moves backward after it brakes

Hi guys,

I used to reach an accepatable position controll tune flying in Loiter mode. With the new tune, I could not get to that good. I realize the attitude tuning is not very good in both cases but with the current ATC_RAT_* and filters params, I really need your helps to optimize the postion controller. By comparing 2 parameter set, I do not see much different.

Previous acceptable position:


Log: previous_acceptable_psc_control.bin - Google Drive

Current bad tune:


Log: current_bad_psc_control.bin - Google Drive

Thanks.

Good performance:

PSC_POSXY_P	0.5
PSC_VELXY_I	0.5

Poor performance

PSC_POSXY_P	0.4
PSC_VELXY_I	0.2

The rest are the same.
Look for the advices.

Thanks.

When flying in PosHold, there was not much overshoot observed compare to Loiter.

Somehow, is the reason about the conversion between Desired Velocity to Target Velocity in Loiter, because in PosHold, there is no desired value.

I attach the link of the log for further analysis: posHold_vs_Loiter.bin - Google Drive

I had a new test increasing Loiter speed to 10m/s instead of 3m/s in the previous test and this is the result

Compared to last time with loiter speed = 3m/s

You can see the huge gaps between Desired value, Target value and Actual value are gone.

I would improve the basic tuning first as there’s a few issues there.
If you look at the “map” when examining the log in MissionPlanner, you can see the GPS position (blue) and IMU position (red) never really align with each other. Often this is because of vibrations, but I think in your case it might be some lag in the system somewhere. Therefore I’m recommending reducing logging and updating to latest Stable, especially since there are important fixes.

Also these changes will improve GPS performance (maybe) and HNOTCH effectiveness, amongst a few other improvements:

ARMING_CHECK,1
ATC_THR_MIX_MAN,0.5
EK3_PRIMARY,1
GPS_GNSS_MODE,65
GPS_GNSS_MODE2,65
INS_HNTCH_FREQ,35
INS_HNTCH_REF,0.15
LOG_BITMASK,178174
PSC_ACCZ_I,0.4
PSC_ACCZ_P,0.2

I would even run Autotune since the PIDs you have are working the best.

And change to these Loiter params:

LOIT_ACC_MAX,600
LOIT_ANG_MAX,30
LOIT_BRK_ACCEL,300
LOIT_BRK_DELAY,0.3
LOIT_BRK_JERK,300

Some of yours were quite low and would allow loiter to take a long time to make changes, and then you are comparing it to PosHold which is much more manual like Stabilise mode with GPS position and altitude enhancement. In fact I would avoid using poshold since it’s not very tunable and Loiter offers so much more.
Just use Stabilise, AltHold and Loiter.
Of course we should all practice in Stabilise for safety, and then AltHold and Loiter the rest of the time is most suitable for tuning and normal use.

Thanks Shawn,

About the not alligning GPS and IMU, I believe that it is because of parameters GPS_POS_* that I intend to change because I have the dual antenna in the system. If I enable the second GPS and switch to Blended mode, the blended GPS will be match IMU position.

Other parameters you mentioned have been modified properly.

Autotune - Autotune has never given a better tune than the manual tune in this frame. I am aware of this issue and will try to make it work someday.

Sorry but I don’t think the Loiter would take longer when I have a slower maximum Loiter speed. In the log, there were some overshooting of acceleration, not only velocity.

It seemed like the target velocity changed the sign during braking and it crossed the zero and change the sign again which causes moving backward.
Something made the target velocity increase when both desired accel and desired velocity are coming to zero

Bad:

Good:

You may see that the LOIT_BRK_ACCEL was 30 m/s/s in both cases and it is not the cause.