Autotune activated by flightmode (SOLVED)

Hi Michal, Tnx for your answer but I will prefer use my own data or I have to re-tune. Your differnent weights and distribution pluss other motor version, pixhawk firmware etc. Also main is that each built is different and we need to do our own to learn. :slight_smile:

I use MAVExplorer to view the logs, so it’s pretty easy to pull the messages out. Here’s your tuning values:

2022-08-10 11:49:09.326 AutoTune: Roll complete
2022-08-10 11:49:09.326 AutoTune: Roll Rate: P:0.440, I:0.440, D:0.0169
2022-08-10 11:49:09.326 AutoTune: Roll Angle P:14.218, Max Accel:95923

2022-08-10 11:52:48.977 AutoTune: Pitch complete
2022-08-10 11:52:48.977 AutoTune: Pitch Rate: P:0.337, I:0.337, D:0.0106
2022-08-10 11:52:48.977 AutoTune: Pitch Angle P:12.190, Max Accel:83166

Don’t get too worried about the rounding between 3 and 5 decimal places. The extra digits become insignificant.

Normally at the end of an autotune flight you will see a message that says the values for pitch and roll (and yaw if you did that too) have been saved. That message was not in your log. Also in MavExplorer you can check what parameters have been changed during a flight. That check should show the changed tuning values but that turned up nothing.

1 Like

Thank you so much Allister!
Hope Roll Angle P:14.218, Max Accel:95923 and Pitch Angle P:12.190, Max Accel:83166 are correct to write in the Stabilize Roll&Pitch columns.
My understanding is then:


Tnx and Please review.
Tali Pixhawk1-1M AC V4.2.2 after AutoTune Roll&Pitch Allister 11.08.2022.param (15.6 KB)

Regards Espen

Yup, that looks like what I’d do.

Like after all autotune flights, go easy on the controls at first till you know the tune is good.

Thanks a lot! I did the Yaw Autotune today. Had drift to left side and there was not much wind. I will check the results, testflight use roll, pitch and yaw. Then look at log. ATT
Anyway thanks for help so far to Dave and Allistar, could not done this without your help. Now I learned a bit more, this community is so nice!
Regards Espen
https://drive.google.com/file/d/1f6YkaKO3Yw3gXWq-zIqy3exyFKilJ18Q/view?usp=sharing
Tali Pixhawk1-1M AC V4.2.2 after AutoTune Roll&Pitch Allister AFTER Yaw 12.08.2022.param (15.6 KB)

1 Like

Had a test of the Roll, Pitch and Yaw today. Worked fine exept could need a bit shorter break in Loiter. Overall very good and super stable in loiter, and holds altitude good in AltHold.
Tnx a lot!
I dont understand very well what happend with yaw alignment, can spot a few resets during flight. Anyway I will watch the Yaw messages going forward. I someone have time to take a look at the log, its here: https://drive.google.com/file/d/15XRo-s5j-lvEmbiQFbNijKArvOQCbvcj/view?usp=sharing

Regards Espen

The first message:

EKF3 IMU1 MAG0 in-flight yaw alignment complete

That’s normal to see that once just after take off. That’s a good thing.

Seeing it again, and the message with the mag anomaly isn’t normal. This quad might benefit from setting up the CompassMOT. Advanced Compass Setup — Copter documentation

Edit: I see you have COMPASS_MOT set up, but it’s on compasses 2&3. However you are using compasses 1&2. Not sure what’s happened there but if you sort that out it might help. This is one of those cases where some of the lists start with 0 and others start with 1.

1 Like

Tnx Allister, I believe I ran COMPASS_MOT early in setup, and then later on fiddled with the compass calibration again. Maybe compasses was set to 1&2 later? Anyway, I will run again CompassMOT and after testrun again Roll, Pitch and Yaw. Is there any logging parameters to switch on?
Have to mention that I dont have a PowerModule, so Current readings are bad.
Regards Espen

Then performing compassmot is pointless. And Magfit will be a better job anyway and it’s easier and safer to do.

1 Like

Hi Dave, I dont have the build/sim environment and no knowlegde on using the magfit_WMM.py utility
I read that by using magfit on a flightlog it can give adjustmets to a number of Parameters for improvements.
I found a post from Tridge, magfit performing on another log resulting these parameters changed: The tool gives the following parameters to apply:

*COMPASS_OFS_X *
*COMPASS_OFS_Y *
*COMPASS_OFS_Z *
*COMPASS_DIA_X *
*COMPASS_DIA_Y *
*COMPASS_DIA_Z *
*COMPASS_ODI_X *
*COMPASS_ODI_Y *
*COMPASS_ODI_Z *
*COMPASS_MOT_X *
*COMPASS_MOT_Y *
*COMPASS_MOT_Z *
*COMPASS_SCALE *

just save those to a file then load the parameters using MissionPlanner or another GCS.

So once again I ask for your help / advice here. Regards Espen

It’s very easy using MAVExplorer. Install it, add a link to the desktop and drag a log file and drop it on the link. Nothing to it.
Magfit
MAVExplorer

You are getting a current reading, although I agree, it seems suspect. @dkemxr is right, you need to get that sorted before you can get the MOT working. What are you taking the current reading from right now if you don’t have a power module? Are you using ESC?

1 Like

Figure_1

MAV> magfit
Attitude source ATT mtypes=[‘GPS’, ‘MAG’, ‘ATT’, ‘BAT’]
Earth field: Vector3(156.51, 9.11, 485.27) strength 510 declination 3.3 degrees
Extracted 4210 points
Current: Vector3(0.31, -17.33, 61.54) diag: Vector3(1.01, 1.01, 0.99) offdiag: Vector3(0.01, 0.01, -0.01) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
Optimization terminated successfully (Exit mode 0)
Current function value: 20.87262608110785
Iterations: 19
Function evaluations: 97
Gradient evaluations: 19
New: Vector3(40.03, -8.76, -64.01) diag: Vector3(1.00, 1.00, 1.00) offdiag: Vector3(0.00, 0.00, 0.00) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
COMPASS_OFS_X 40
COMPASS_OFS_Y -8
COMPASS_OFS_Z -64
COMPASS_DIA_X 1.000
COMPASS_DIA_Y 1.000
COMPASS_DIA_Z 1.000
COMPASS_ODI_X 0.000
COMPASS_ODI_Y 0.000
COMPASS_ODI_Z 0.000
COMPASS_MOT_X 0.000
COMPASS_MOT_Y 0.000
COMPASS_MOT_Z 0.000
COMPASS_SCALE 1.00
So above is result for Mag(0). But I have Compass 1&2 Shall i redo this for Mag(1 and 2) or what, I am stuck here. :slight_smile:

Yes, and check the elliptical box so it generates those too. Don’t bother with CMOT unless you have calibrated current. In fact disable that by setting the _MOTCT parameter to 0 so bad values are not used.

Be sure to use a log with plenty of Yaw action and as the guide says window the data so takeoff and landing is not factored.

Ok, so I will readup on window the data so takeoff and landing is not factored.
I tested to now to run only flightmode loiter, hope that is ok or I will have to do a new log with lot of Yaw. Its night here now, I will look into this tomorrow. Good night!


Figure_1

C:\Users\troll\AppData\Local.mavproxy\Rover.xml Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

Attitude source ATT mtypes=[‘GPS’, ‘MAG’, ‘ATT’, ‘BAT’]
Earth field: Vector3(156.51, 9.11, 485.27) strength 510 declination 3.3 degrees
Extracted 4210 points
Current: Vector3(0.31, -17.33, 61.54) diag: Vector3(1.01, 1.01, 0.99) offdiag: Vector3(0.01, 0.01, -0.01) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
scipy\optimize_optimize.py:284: RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds
Optimization terminated successfully (Exit mode 0)
Current function value: 15.82464099291572
Iterations: 55
Function evaluations: 620
Gradient evaluations: 55
New: Vector3(10.53, -74.26, 60.01) diag: Vector3(0.95, 0.87, 0.80) offdiag: Vector3(-0.03, 0.05, 0.09) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
COMPASS_OFS_X 10
COMPASS_OFS_Y -74
COMPASS_OFS_Z 60
COMPASS_DIA_X 0.946
COMPASS_DIA_Y 0.868
COMPASS_DIA_Z 0.800
COMPASS_ODI_X -0.034
COMPASS_ODI_Y 0.053
COMPASS_ODI_Z 0.085
COMPASS_MOT_X 0.000
COMPASS_MOT_Y 0.000
COMPASS_MOT_Z 0.000
COMPASS_SCALE 1.00
MAV>
I feel that this might be wrong, I am on thin ice here :slight_smile:

That’s fine for the compass offsets and elliptical data. If you get to a point where Motor Compensation can be run then some portion of the flight in Stabilize is a good idea to get some higher current. Unless you juice the Loiter parameters as I do!

Not sure I understand what to do next. Shall I put in these parameters?
Even though I dont have the PowerModule I think this drone use about 20Amp for hoover and maybe 30Amp as max if this shall be corrected in some parameters?
Regards Espen

Yea, run it for each mag you are using and then enter the values in the Full Parameter list.
Forget about motor compensation until you have calibrated current.

Maybe first set which compass you use most or check if they’re set properly (parameters). Recalibrate both compases (internal and that from GPS). And than check what’s going on with them. I have compass 0 - internal in Pixhawk and 1 - external on GPS via I2c.
I have only that yaw aligment for both compases after takeoff.

Hi Dave,
For Magfit I use Mag(0) and Mag(1) and hope they are same as Compass(1) and Compass(2). Please confirm.


New Magfit updated parameters:

Loiter 165s Mag(0)
C:\Users\troll\AppData\Local.mavproxy\Rover.xml Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
Attitude source ATT mtypes=[‘GPS’, ‘MAG’, ‘ATT’, ‘BAT’]
Earth field: Vector3(156.51, 9.11, 485.27) strength 510 declination 3.3 degrees
Extracted 4210 points
Current: Vector3(0.31, -17.33, 61.54) diag: Vector3(1.01, 1.01, 0.99) offdiag: Vector3(0.01, 0.01, -0.01) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
scipy\optimize_optimize.py:284: RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds
Optimization terminated successfully (Exit mode 0)
Current function value: 15.82464099291572
Iterations: 55
Function evaluations: 620
Gradient evaluations: 55
New: Vector3(10.53, -74.26, 60.01) diag: Vector3(0.95, 0.87, 0.80) offdiag: Vector3(-0.03, 0.05, 0.09) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
COMPASS_OFS_X 10
COMPASS_OFS_Y -74
COMPASS_OFS_Z 60
COMPASS_DIA_X 0.946
COMPASS_DIA_Y 0.868
COMPASS_DIA_Z 0.800
COMPASS_ODI_X -0.034
COMPASS_ODI_Y 0.053
COMPASS_ODI_Z 0.085
COMPASS_MOT_X 0.000
COMPASS_MOT_Y 0.000
COMPASS_MOT_Z 0.000
COMPASS_SCALE 1.00
MAV>

Loiter 165s Mag(1)
C:\Users\troll\AppData\Local.mavproxy\Rover.xml Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
Attitude source ATT mtypes=[‘GPS’, ‘MAG’, ‘ATT’, ‘BAT’]
Earth field: Vector3(156.51, 9.11, 485.27) strength 510 declination 3.3 degrees
Extracted 4210 points
Current: Vector3(36.26, 143.39, 28.93) diag: Vector3(0.89, 0.97, 1.02) offdiag: Vector3(-0.03, 0.00, 0.02) cmot: Vector3(4.70, 0.08, 0.37) scale: 1.06
scipy\optimize_optimize.py:284: RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds
Optimization terminated successfully (Exit mode 0)
Current function value: 30.41246787437812
Iterations: 95
Function evaluations: 1072
Gradient evaluations: 95
New: Vector3(-111.26, 46.72, 165.63) diag: Vector3(0.80, 0.80, 0.80) offdiag: Vector3(-0.20, 0.14, -0.13) cmot: Vector3(0.00, 0.00, 0.00) scale: 1.00
COMPASS_OFS2_X -111
COMPASS_OFS2_Y 46
COMPASS_OFS2_Z 165
COMPASS_DIA2_X 0.800
COMPASS_DIA2_Y 0.800
COMPASS_DIA2_Z 0.800
COMPASS_ODI2_X -0.200
COMPASS_ODI2_Y 0.136
COMPASS_ODI2_Z -0.127
COMPASS_MOT2_X 0.000
COMPASS_MOT2_Y 0.000
COMPASS_MOT2_Z 0.000
COMPASS_SCALE2 1.00
MAV>

Suggest to remove the old COMPASS_MOT values set up on compasses 2&3 since I have no correct current readings? Please confirm if agreed.
|COMPASS_MOT_X|0|
|COMPASS_MOT_Y|0|
|COMPASS_MOT_Z|0|
|COMPASS_MOT2_X|4,699496| suggest set to 0
|COMPASS_MOT2_Y|0,08365554| suggest set to 0
|COMPASS_MOT2_Z|0,3667168| suggest set to 0
|COMPASS_MOT3_X|0,8796702| suggest set to 0
|COMPASS_MOT3_Y|-0,6789339| suggest set to 0
|COMPASS_MOT3_Z|-1,159323| suggest set to 0
Regards Espen