Achieving precision loiter stability , AC-4.5.7

Hello developers, thank you for your work on ardupilot and providing such a vast open-source resource for the users. I have been using arducopter for quite a while and was using them with bigger (10 inch +) drones until now, However due to availability of smaller form factor FC and AIO that natively support arducopter, I am more inclined towards making smaller UAVs with prop size 3 inch fly using arducopter and achieve some basic functionality that a DJI avata provides or a mini provides, I am using a MicoAir H743 AIO with arducopter 4.5.7 and along with I use MicoAir M10 gps with QMC5883, RM3100 over I2C, MTF-01 flow sensor and Skydroid H12 ground station all paired to a 3.5 Inch Cinewhoop frame, battery being used is a 4200mAh li-ion battery. After completing all the stepwise calibration, upping the loop rate to 1000 and using Quicktune and FFT based harmonic notch filter, the stability and feel of the drone feels perfect and it flies great.

However, it is not able to hold accurate position in loiter mode weather using flow or gps, It will drift around in a radius of 30-40 cm while keeping the same co-ordinate locked with 25+ satellites, yaw is perfect, roll, pitch is good, but it just keeps moving around the same point.

Now comparing this with a DJI mini 2, it also has the same peripherals as the setup I use, flow sensor, M9 gps, and a rangefinder, but using these same set of positioning and velocity peripherals and not using stereoscopic visual odometery, it has a better lock on position even in slightly windy environments, How are they achieving this, and what should I change or do for getting the same position stability as a normal DJI drone, even tello hold better position that the setup I use. Will be sharing log files according to your suggestions soon, @andyp1per @rmackay9

It would be useful to see a .bin log where this is happening. It sounds like “toilet bowling” which is usually compass interference and vibrations.
Be aware that using Li Ion batteries on copters can make matters worse, since they have a significant magnetic field (compared to LiPo’s). Each and every time you remove the battery for recharging and refit it, the battery can go back in a slightly different position (or orientation if you are not paying attention) and changes the compass calibration. It’s handy to have some way of ensuring the Li Ion pack is always in exactly the same place and orientation.

2 Likes

Sure, will be sharing log files as per your recommendations, what would you like to see , a simple take off and land, or a specific pattern such as square or anything to see GPS positioning ?

If you have to do a new flight for this do some maneuvering - plenty of yaw, circles, ascents and descents - that way we can use the log for an offline compass calibration if that is all that is wrong. Also hover to show the condition you speak of.
Upload the .bin log to a filesharing service and provide the link.

Thank you, will update the topic with all the requested data soon.

https://drive.google.com/drive/folders/1X9_F5xJ5JVZNqZQv-kukUjk4Dyabi-jy?usp=sharing

here is a link containing the flight data of different conditions for this build, LOG1 to LOG5 contain useful data with gyro noise and such, other files are just random incomplete data only pasted for reference. This folder also contains the param file and a lua script that runs on this build for setting up origin and changing transition modes

Sometimes the drone need to be flown a few times and Loitor will most likely improve as well as using S6 voltage. Regarding the battery’s on top I like bottom mounting best. Its possible you have a slight twist to the frame that need to be adjusted. One way around it is slightly rotate the drone the opposite direction and hit the level button.

Should there be any specific learning mode enabled for this to work ? Or does loiter itself tries to fix the lock anytime while flying

Good question I believe some of this can be learned in flight. Also the Baro can acclimate. Oh Nice work BTW.

I looked at a log, there’s not much useful data.
I would set logging back to something useful:

INS_LOG_BAT_MASK,1
INS_LOG_BAT_OPT,4
LOG_BITMASK,180222

Adjust these notch filter settings:

INS_HNTCH_ATT,40
INS_HNTCH_BW,30
INS_HNTCH_FREQ,140
INS_HNTCH_OPTS,2

Do a test flight with hovering to demonstrate the problem, plus plenty of maneuvering with yaw, circles and ascents and descents.

Sure, will provide this data soon, thank you for replying

https://drive.google.com/drive/folders/1X9_F5xJ5JVZNqZQv-kukUjk4Dyabi-jy?usp=drive_link

Here are 2 log files with requested behaviour and the parameter file for the same, also in the folder is a video showing inability to hold position in loiter mode flight when sticks are released. Please let me know if anything else is required from my side.

In the video it sounds like oscillations, which is just attitude control and tuning.
Set all these, some of which should settle down the position control at least.

ARMING_CHECK,1
ATC_THR_MIX_MAN,0.5
BATT_FS_LOW_ACT,2
BATT_CRT_VOLT,12.00
BATT_LOW_VOLT,12.40
EK3_ALT_M_NSE,3
GPS_GNSS_MODE,5  //or 65, whichever gives the lowest HDOP in your area
INS_LOG_BAT_MASK,1
LOG_BITMASK,180222
LOG_REPLAY,0
LOIT_ACC_MAX,600
LOIT_ANG_MAX,30
LOIT_BRK_ACCEL,200
LOIT_BRK_DELAY,0.3
LOIT_BRK_JERK,300
PSC_VELXY_D,0.25
SCHED_LOOP_RATE,400
SERVO_DSHOT_RATE,0

Work through whatever fails the arming checks rather than just disabling the checks.
Be aware PILOT_TKOFF_ALT is in centimeters so 100 or 200 might be better than just 2

Try these for attitude control:

ATC_ANG_PIT_P,8.0
ATC_ANG_RLL_P,8.0
ATC_RAT_PIT_D,0.0015
ATC_RAT_PIT_I,0.05
ATC_RAT_PIT_P,0.05
ATC_RAT_RLL_D,0.0015
ATC_RAT_RLL_I,0.05
ATC_RAT_RLL_P,0.05
ATC_RAT_YAW_D,0.0
ATC_RAT_YAW_I,0.02
ATC_RAT_YAW_P,0.20

Also set these updated compass parameters:

COMPASS_USE2,0
COMPASS_OFS_X,-157.73924
COMPASS_OFS_Y,-51.663643
COMPASS_OFS_Z,-137.01308
COMPASS_DIA_X,1
COMPASS_DIA_Y,1
COMPASS_DIA_Z,1
COMPASS_ODI_X,0
COMPASS_ODI_Y,0
COMPASS_ODI_Z,0
COMPASS_MOT_X,2.8859832
COMPASS_MOT_Y,-1.5199691
COMPASS_MOT_Z,3.2273057
COMPASS_SCALE,0.9717352
COMPASS_ORIENT,2
COMPASS_MOTCT,2

Do everything listed here in one go - dont try to just set one parameter or a few of them and see if that fixes the problems. I’ve checked over everything (given my abilities :slight_smile: ) and come up with all those parameters as a starting point to work from.

Now do another flight with AltHold and Loiter - start in AltHold and listen for high frequency oscillations and land after a minute or less to check motor temperatures.
If everything seems OK do a long flight with plenty of turns and altitude changes. Switch between Loiter and AltHold sometimes.

1 Like

Thank you for these, trying the values out and reporting back soon, also I would like to add that IMU0 (BMI088) doesnt work well on this build and it oscillates so much that it is unflyable, due to that you might be seeing the logging data of IMU1 (BMI270) and use of that IMU only in every flight, including the INS_LOG_BAT_MASK parameter

New log files, videos, params are updated to the original drive link, the motors are cool and don’t seem to heat up even at high speed manuevers, braking is very laggy and quadcopter stops after oscillating in a very dangerous way, rest all seems fine.

https://drive.google.com/drive/folders/1X9_F5xJ5JVZNqZQv-kukUjk4Dyabi-jy?usp=drive_link

Hi shawn, I hope I am not disturbing you in something important, just wanted to know about if you had the chance to look at the new files yet ?

Thanks in advance.

You might be able to set:

INS_ENABLE_MASK,2
INS_USE,0
INS_LOG_BAT_MASK,2

to disable that first IMU if is that bad. I would consider getting another flight controller.

Attitude control is a bit wobbly, I would probably just do Autotune one axis per session.
Use AUTOTUNE_AGGR,0.10
After that do a test flight in AltHold and Loiter.

After changing the Flight controller and manually tuning as per methodic configurator, things have improved quite a lot but not to the level of perfection, files no 0006-0009 are some examples to review.
https://drive.google.com/drive/folders/1hbJEjKk4nL_IuYecXUrEPmKXmt7o62yC?usp=drive_link

Post the files generated by ArduPilot Methodic Configurator.
It created them in the vehicle directory that you created.

Disable the 2nd notch filter, you dont need it at all
INS_HNTC2_ENABLE,0
and you probably dont even need the first notch filter. It’s not a hard and fast requirment if noise is not getting past INS_GYRO_FILTER.
Vibrations are incredibly low, which is great, but it makes me think the flight controller might be over-damped.
However attitude control is excellent, so we can leave that alone for now.

This will fix your compass calibration:

COMPASS_OFS_X,-70.02371
COMPASS_OFS_Y,-112.08348
COMPASS_OFS_Z,19.9086
COMPASS_DIA_X,1.0062853
COMPASS_DIA_Y,1.0189534
COMPASS_DIA_Z,0.97476125
COMPASS_ODI_X,-0.013599786
COMPASS_ODI_Y,0.15532872
COMPASS_ODI_Z,-0.009991449
COMPASS_MOT_X,0.07815401
COMPASS_MOT_Y,-1.5050092
COMPASS_MOT_Z,-1.0626649
COMPASS_SCALE,0.9737507
COMPASS_ORIENT,2
COMPASS_MOTCT,2

Be aware that LiIon batteries have a strong magnetic field, so moving the battery pack even slightly will affect the compass calibration.

You can see in the map where the GPS position and the IMU-calculated position differ, especially at those sharp corners.

Change your GPS_GNSS_MODE to use just two constellations, test to see which gives you the lowest HDOP in the quickest time from cold boot. Usually GPS plus one other, probably Galileo (probably not Beidou).
The graph of GPA.Delta should be a straight line at the 200ms mark.

You need to set these:

BATT_ARM_VOLT,12.70
BATT_CRT_VOLT,12.00
BATT_LOW_VOLT,12.40
MOT_BAT_VOLT_MAX,16.40
MOT_BAT_VOLT_MIN,11.20

and you should set:

ANGLE_MAX,4500
ARMING_CHECK,1
BATT_FS_LOW_ACT,2
INS_LOG_BAT_MASK,0
INS_LOG_BAT_OPT,0
LOIT_ACC_MAX,600
LOIT_BRK_ACCEL,200
LOIT_BRK_DELAY,0.3
LOIT_BRK_JERK,300
PSC_POSXY_P,1
PSC_VELXY_D,0.25
PSC_VELXY_P,2.0

I suspect the position problems you are having is because of a poor GNSS update rate, with too many constellations, and some unrealistic Loiter and PSC parameters. The compass calibration probably even plays a part.
Don’t go crazy on notch filters if you dont have to, you probably dont need any. We never used to have notch filters at all - it does make life a bit easier though.

Do the next test flight in AltHold then switch to Loiter.