Drone Flies Stable in AltHold, but oscillates in Loiter

My bird flies good in Althold mode, but as soon as i switches to Loiter it starts oscillating.

Hardware Configuration :

FC : Cube Orange Plus

FW : 4.6.2

Configuration : Quad

Motors are connected to Servo Aux Out( 9-12)

MTOW : 6800gm

Prop : 28"

I’m looking for reason which are causing ccurrence of oscillations.

From wiki i’m assuming that bad PIDs might be the reason but still looking for guidance on the same.

Attaching log file and video of last flight :

@amilcarlucas I’m not sure about use of AMC, their might be chances of skipping some steps while setting up parameters.

Thank you in advance :slight_smile:

Desired and Actual attitude seems synced, Viberations in all axes are below 10, RCout Shows variance in PWM, the thing which i think is abnormal is alt reading from GPS, I’m using two GPS which are placed at same height, but log shows 10m variance through out.

From params GPS Switch is set to Use best and log shows variance between alt of both gps, can it be the reason ???

GPS_Auto_Switch : 1 : Use Best

GPS_Primary : 0 : First

No offsets have been given for both the GPS

Both the GPS are placed more than 20cm apart, and at same height.

I can have a test flight by configuring use of primary GPS only or by disabling second GPS to formulate Root cause??? Will this be right approach ??? @amilcarlucas @andyp1per @xfacta

Flying well in alt hold, and Oscillations on loiter?

I think that means that the basic Rate/attitude PIDs might be decent, but the position/velocity control PIDs might be too energetic or quick.

You said you have used large 28 inch props. Those large props must be having huge inertia, and thus, high motor spool times. And if the drone is correcting the position faster than the motors can react, this can result in Oscillations might be.

And, I think these params may be too high, and you can try reducing them down by a 50% value (as AMC suggests) :

PSC_POSXY_P, PSC_VELXY_P and the “I and D” params also

1 Like

FYI

No need to ping everyone you can think of, plenty of people will look and check through the issues.

First thing I notice you dont need any harmonic notch filter at all. There’s essentially nothing to filter and the configuration was wrong anyway.
Set these to put back a known-good state:

ATC_THR_MIX_MAN,0.5
BATT_FS_CRT_ACT,1
INS_ACCEL_FILTER,10
INS_HNTCH_ENABLE,0
LOG_BITMASK,180222
LOIT_BRK_DELAY,0.5
PSC_ACCZ_I,0.4
PSC_ACCZ_P,0.2
PSC_POSXY_P,1
PSC_POSZ_P,1
PSC_VELZ_P,1

That would probably just about fix it. The Loiter brake delay at 0 makes the copter too sensitive to stick inputs and variations in the RC signals. Some of these reverse your vertical acceleration adjustments, but we can re-assess that later - I predict they wont be needed, or at least not as aggressive.

If I assume the ATC parameters are the result of pitch and roll Autotune, then lets make some changes to smooth things out a bit:

ATC_ACCEL_P_MAX,56226  -> 45000
ATC_ACCEL_R_MAX,65640  -> 52500
ATC_ANG_PIT_P,11.34    -> 10.2
ATC_ANG_RLL_P,12.5025  -> 11.25
ATC_ANG_YAW_P,4.5      -> 6.0
ATC_INPUT_TC,0.15      -> 0.20
ATC_RAT_YAW_I,0.018    -> 0.05
ATC_RAT_YAW_P,0.18     -> 0.5
ATC_SLEW_YAW,6000      -> 3000
PILOT_Y_RATE,202       -> 60

This is ACCEL values -20% assuming you will have a payload, and Angle P’s -10%. Some Yaw PID increases to get it behaving properly.

Try these loiter params to suit larger copters when you are happy with all the other changes.

LOIT_ACC_MAX,300
LOIT_ANG_MAX,25
LOIT_BRK_ACCEL,125
LOIT_BRK_JERK,200

I recommend you make ALL of my changes at once (some of them are linked) and do another test flight. You can leave those last Loiter parameters until later, they are not so critical.
Send the next .bin file and your observations.

2 Likes

Thank You @xfacta

I’ll make the changes and update here after having flight

You should set the log bitmask back to default as suggested and then for that flight controller set INS_RAW_LOG_OPT,9 so we can really see what’s going on for the notch filter. You don’t need 644MB worth of log file to get the job done here… Way too much box clicking for the bitmask.

1 Like

Had few test flights today,

@xfacta Thank you, your suggested changes helped us to have good flight today, below are tests which we carried out and observations which we made.

Flight first:

Changes:

  1. Changed Parameters as suggested by Shawn

Results:

  1. Oscillations reduced, vehicle now is able to hover steadily in loiter.

Observations:

  1. Their are few oscillations which are being observed.
  2. Vehicle is drifting vertically with error difference of 1-2m meters.

Logs:

Second flight

Third flight

Test case : Waypoint navigation, planned mission, default altitude 10m for every waypoint.

Observations:

  1. Vehicle was lossing altitude upon reaching Waypoints.
  2. Few jerks observed while transitioning between waypoints, this jerks were never observed previously. (This jerks were too aggressive)

Logs

Thank you in advance.

Hello @dkemxr @xfacta Any further recommendations for me???

Set this for the notch and then disable Raw Logging. It’s only used for short flights to configure the notch otherwise it creates huge files like one of those.

Then give Auto Tune a try.

Thank you @dkemxr , I’ll have a test flight tomorrow with mentioned changes and update here about the same.

80hz is too high for 28", something like this is more appropriate.

EDIT:
You need to take a look that your motors are in level or COG issues because motor connected to output 8 works much less than others, it can cause instabilities

1 Like

Yes, I think you are right. Could add the 2nd harmonic too as it’s a shade over 50dB. Or not.

Alright then i’ll move ahead with changes recommended by mike and update here.

Thank you @mike_tk @dkemxr

I disagree.
There’s no need for any harmonic notch filter at all. You’ll just be introducing unnecessary PID lag or similar artefacts.
See in this graph the post-filter (INS_GYRO_FILTER) is practically a flat line across the bottom of the graph at close to zero amplitude. On the db scale some noise nearly comes up to just under -50db and most noise is less than -100db. It does not get much better than that.

The parameter you need is: INS_HNTCH_ENABLE,0
and INS_RAW_LOG_OPT,0 since I think this is no longer needed.

I’ll look of the rest of the logs.

2 Likes

Try these for altitude:

PSC_ACCZ_I,0.4
PSC_ACCZ_P,0.2
PSC_VELZ_P,2

EDIT: The primary GNSS unit is switching The GNSS units are changing which is primary based on their different signal quality. This is possibly what’s causing the odd behaviour at waypoints, even though the switch-over is not actually at waypoints - it may just appear that way.

Try these settings:

GPS_AUTO_CONFIG,2
GPS_AUTO_SWITCH,4
GPS1_GNSS_MODE,37
GPS2_GNSS_MODE,37

If your throttle stick is spring-centred then set PILOT_THR_BHV,7 and it wont change any of the tuning but should be more natural for hovering and so on.

Let’s see another log. Do some more manual yaw, maximum yaw rate and a few altitude changes.

1 Like

Hello @xfacta

Made changes suggested by you and had few flights, attaching logs for reference.

Observations:

  1. Oscillations reduced in comparison to previous flight.
  2. No major drifts in altitude in GPS assisted modes.

@mike_tk & @dkemxr Am i still required to go give a try to autotuning???

Thank you

This is very important:
BATT_FS_CRT_ACT,1
The copter is already doing an RTL from hitting the Low battery voltage threshold. This action, Land, at the critical voltage level is the copters last chance to save itself if the pilot cancelled RTL, or RTL just has not reached home yet.

The barometer is still highly affected by prop wash and is a source of altitude problems. See if you can shield the flight controller from prop wash.

Load this magfit file to improve the compass calibration. After this do not do a manual compass calibration unless you change something major.
MAGFit-Swatej.param (898 Bytes)

If you can help the barometers and load that magfit file I would try Autotune again, certainly for pitch and roll. Yaw looks reasonable and may not need any extra treatment.

Thank You @xfacta

Will change actions for battery failsafe’s.

For barometer i’ll say, my bird has puller configuration, Propellers are under frame pulling air downward. Apart from it my FC is completely enclosed in canopy. Please let me know if any other changes which can be made for resolve the same.

I Will load provided values for compass and try Autotune for Pitch and roll axes.

Will update you on same

Thank you