Is the lag of the position controller normal?

Hi everyone,

This is the first time I have this issue.
I assume the attitude controller is acceptable but it is a big thanks if I can have your inputs. Now let’s get back to the position controller.
The tune may not be very good but this is what I observe: drone drifts when I release the stick. To have a better understanding, I conduct the test with these steps:

  1. Take-off in AltHold
  2. Stop at a point and switch to Loiter
  3. Facing the heading to the North, so it is easier to check the log PSCE_*
  4. Roll to the left and let go
  5. Roll to the right and let go
  6. Repeat 3 times
  7. Land

What I can see is that there is a lag (or delay) between my stick input with drone’s position and velocity. It took a few seconds to completely stop after I release the stick

The log is here and I hope you can have some time to help troubleshooting.

https://drive.google.com/file/d/1PK0tIlLxroiJNd6eBKdqoR39k4iKJogE/view?usp=sharing
Thanks.

This issue seems to be the same to mine Loiter is slow to respond about pilot control so I think tweaking the LOIT_ACC_MAX may work.

Please note that with same position controller parameters (PSC_*) the previous copter was fine. There is just a minor change about the hardness of the arm which can be ignores.

I tried a higher LOIT_ACC_MAX today, I increased from 150 to 700, each step of 100 but I saw no changes. The logs are attached and I hope you can help to diagnose.

Thanks,

Short test log: https://drive.google.com/file/d/1433H2btObqpWznMwUnF8UYe3RtxNhRGd/view?usp=share_link
Long test log: https://drive.google.com/file/d/1VroM1vJkBLZl3P2bg_X-LH3pp8bBszs_/view?usp=sharing

Try
LOIT_ACC_MAX,600
LOIT_BRK_ACCEL,300
LOIT_BRK_DELAY,0.3
LOIT_BRK_JERK,300

Thanks Shawn,
I definitely can do another tests with the parameters you recommend but this is one of my previous combinations and it is closed to yours
image

Therefore, I think it may not be the root cause somehow.

Access is denied to those logs

I am really sorry, permissions changed!

It looks to me like the copter is working as well as it can given the tuning.
Considering this copter flies reasonably well how it is, I would probably set all the things I mention below then run Autotune one axis at a time.
Then I would test Loiter and position controller performance after that.

The Loiter params do need some adjustment for each different copter, but try the ones I supplied, they work well enough on a range of our copters.

Set these:

ARMING_CHECK,1
INS_HNTCH_ATT,40
INS_HNTCH_FM_RAT,0.7
INS_HNTCH_REF,0.15

Check on the map of that flight and you’ll see the two GPS positions can be quite far apart. You might want to choose the best GPS with GPS_PRIMARY if they are any different and set
GPS_AUTO_SWITCH,4 // Use primary if 3D fix or better
rather than blend.
Also try

GPS_GNSS_MODE,5 // or 65, whichever works best for reliable HDOP
GPS_GNSS_MODE2  // same as above

EDIT:
your MOT_THST_EXPO value looks strange to me, given the other parameters you have.
You might need to do some descent and ascent test to check if it’s OK, and if you change it you’ll also need to adjust MOT_SPIN_ARM and MOT_SPIN_MIN. Hover thrust will need to relearn too, along with checking and changing the parameters reliant on that:
INS_HNTCH_REF
PSC_ACCZ_I
PSC_ACCZ_P

But back to your question:
The PSCE and PSCN data in the log looks good and there’s some overshoot or undershoot, but no delays. Like I said I think it comes down to general tuning and adjusting those Loiter params to suit.

Attitude control is similar - some overshoots and undershoots because of tuning, but compared to RC Inputs everything is aligned nicely.

ATC_INPUT_TC,0.1 is also expecting a bit much of a copter with large props.
Default is ATC_INPUT_TC,0.15 and ATC_INPUT_TC,0.20 is more common for larger copters.

You could increase ATC_ACCEL_P_MAX and ATC_ACCEL_R_MAX and see how that affects your copters responce to RC input. Something like 25000

Thanks Shawn,
You are my best supporter!

About the Loiter, it is worth saying that the copter holds position very well even having 5m/s-wind with gust. I tested that with its maximum TOW: 30Kg. The log file is avaialble and I would love to share if you are interested to see. Based on this well performing, I am kindly confident about my manual tuning. I don’t hestitate to do AutoTune following your suggestion but there are something I want to pointout:

  1. I have tried the AutoTune with smaller copters (5-inch, 10-inch, 29-inch size) and the procedure of doing AutoTune is in my mind now. They are all gone well because the AutoTune was successful, it did what it supposes to do. However, it is different on this copter (and my previous imbalance COG HexaCopter). I tried AutoTune for this Copter multiple time but the final results are always worse than my manual tuning. This copter has a high COG and non-even bending force on Roll and Pitch axis because of the H-frame configuration. The COG is higher than the center of thrust (COT) about 20cm

  2. About the GPS antenna position, I change GPS_POS1_* and GPS_POS2_* to meet the actual X/Y position where the antennas are mounted on the frame. They are quite far apart to implement the D-RTK (GPS for Yaw) feature.

  3. Thank you so much for pointing out GPS_GNSS_MODE which I am not aware of.

  4. MOT_THST_EXPO to be 0.65 because we are using T-Motor Alpha ESCs. I think this parameter has been okay for years for me. There are lots of discussions here in the forum talking about the ESC’s linearization and I believe the number 0.65 is fine. Descenting and ascenting were checked with 3m/s vertical speed and it is fine. No wobbling or losing thrust was observed.

  5. INS_HNTCH_REF, PSC_ACCZ_I and PSC_ACCZ_P were set following the value of MOT_THST_HOVER
    INS_HNTCH_REF = MOT_THST_HOVER
    PSC_ACCZ_I = 2 * MOT_THST_HOVER
    PSC_ACCZ_P = MOT_THST_HOVER

  6. ATC_INPUT_TC, ATC_ACCEL_P_MAX and ATC_ACCEL_R_MAX will be changed following your suggestion. I can share with you the previous log where I saw the copter when well to compare with the current situation. Do you mind to check and compare?

  7. Back to the very first question, I definitely saw the delay in actual drone’s response and from the log. I am doubt because you said it was not.

Hi Shawn,

I found a log in the past where I had a better position response of this copter. Here is the comparision between the old (left) and the new one. As you can see, at the moment the roll stick changed, the old log showed that we have a more instant response than the new one:

I can not explain this symptom, so I think you can help to point out why.
The older log is here: https://drive.google.com/file/d/1VGyElEXv9O3DojJ5yob5ZUgzOMWufuWK/view?usp=share_link

Looking closely in your previous log of 2023-04-12 you can see the attitude starts changing to meet the RC input within about 0.2 of a second

The shape of the attitude curve is never going to match the shape of the RC Input curve. That would be more likely with a much smaller quad that was very tightly tuned.

There are overshoots and also delays in returning to a static attitude - this is because of input shaping, filters and mostly the ATC_ACCEL_MAX values and physical inertia of the copter.

Send an updated log of a test flight with the updated parameters

Thanks Shawn,

We are actually focusing on the position here but the attitude. You may see clearly when the copter deaccelerates, it took a long time for it to stop in Loiter mode.

The problem is solved!
It turns out that the poor tuning in attitude controller will lead to the poor performance in position controller.
Thanks.

Thank you, i serch this answer a lot :crazy_face: