chromvis

  • *
  • 117
AuxMag calibration possible bug
« on: August 21, 2016, 09:01:45 pm »
In last three days I struggle with mag calibration on all my copters. I posted question/problem here https://forum.librepilot.org/index.php?topic=2175.msg15614#msg15614

Today I decided to go back in time and set LP GSC r812 from July 17 and perform all setup and calibration on two revo boards with attached external GPS/mag board (as it is shown in very nice instruction video from Laurent.
 
Sure enough, both my revos show excelent behavior with less than 1% error on both mags
I went back to LP GSC release r980 from 8.18.16 and got all bad behavior back again.
I noticed that in UAV Object Browser when I press SavePosition last time (6th) in r980 release there are saving action in AuxMag Settings and second saving when I press Save button. Video here:

At the end of this video there are two instances of parameter modification. (Check events at 1:15 and 1:22 ). It did not happen in r812 GSC version (next video attached)

Could you please check?
« Last Edit: August 21, 2016, 09:24:36 pm by chromvis »

Re: AuxMag calibration possible bug
« Reply #1 on: August 21, 2016, 10:03:16 pm »
There was a bug in the old GCS it did not remove the aux mag board rotation before calibration.
The new GCS temporarily removes aux mag board rotation during calibration.
I think the issue is that you can't use the scope to compare aux vs. onboard mags during calibration anymore.
You should be able to do that after it is calibrated though.

Another minor issue is that the aux mag can be mounted a few degrees different than the Revo.  The best way to adjust for that is to use Basic with Attitude mode, and adjust Rotate Virtual for motionless hover (no wind).  Then use INS13 with Attitude mode and adjust Aux Mag board rotation for motionless hover (no wind).

chromvis

  • *
  • 117
Re: AuxMag calibration possible bug
« Reply #2 on: August 21, 2016, 10:15:03 pm »
I did direct comparison on the same revo-mag setup (on two of them). I calibrated with zero rotation on all axes and "use Both" settings. One did with r812 release (July 17) - works perfect. after that I reinstall GCS to r980 (Aug.18) updated and erased firmware and repeat calibration - results are terrible.
It is obvious that the latest version does not work as it should. I do not see why I should physically rotate mag. If aux. mag is fixed in its position relative to revo board and does not move. The rest should be easily done with calibration and proper treatment of the results.

Mateusz

  • *
  • 808
Re: AuxMag calibration possible bug
« Reply #3 on: August 21, 2016, 10:28:39 pm »
If aux. mag is fixed in its position relative to revo board and does not move. The rest should be easily done with calibration and proper treatment of the results.

I am not an expert here, but unless your Mag chip is in the same orientation as the Mag chip on Revo, then this is true. Otherwise, any mag board can have Mag  chip soldered up-side-down, rotated or all possible orientations, so in many cases rotation in GCS has to be configured, otherwise firmware assumes both Mag are oriented in the same way. Which may not always be the case.

f5soh

  • *****
  • 4572
    • LibrePilot
Re: AuxMag calibration possible bug
« Reply #4 on: August 22, 2016, 02:11:28 am »
Looks like there is something wrong with AuxMag initial settings while starting calibration.

If you want quick workaround, try this:
- Start the Mag calibration (Start button)
- Save using the icon in UAVBrowser.
- Continue calibration

Re: AuxMag calibration possible bug
« Reply #5 on: August 22, 2016, 03:12:30 am »
You said "erase firmware" did you "erase settings" each time?

If you did, then I think the work around proposed by @f5soh won't help?

chromvis

  • *
  • 117
Re: AuxMag calibration possible bug
« Reply #6 on: August 22, 2016, 05:42:24 am »
I think there are some misunderstanding. I bolted revo board to GPS board (two of them) using nylon screws and 1 cm spacers (similar to what Laurent did). Connected I2C (Flexi) to mag and Main port to revo. Install LP GCS (r812 July 17 release) on my laptop. Connect USB and update/erase firmware. Update config to correct hardware and correct magnetometer connection and use. Disconnect USB. Hookup Battery power (through BEC) and after that connect USB.
Proceed with calibration outside in the field on wooden table. I actually, tested with OpLink and with Usb cable - no difference.
Calibration went OK. I surely had to adjust auxMag orientation, it is OK. I got perfect calibration and dynamic synchronous behavior of both mags on both boards.
After that, I uninstall GCS r812 and install new one (r980 from 8.18.16), connect USB to revo. Update/erase firmware (after this I got all zeroes in AuxMag  Settings).
I carefully repeat all steps described above but with new GCS software.
I repeated calibration several times on each board but was unable to get any reasonable (below 15% error) results. One time I got onboard mag OK and AuxMag 50% error, another time situation was vice-versa. Pretty erratic.
Just out of simple logic If on the same piece of hardware one version of software works fine and another version does not work - this clearly means that this second version is erroneous, isn't it?

Re: AuxMag calibration possible bug
« Reply #7 on: August 22, 2016, 05:18:48 pm »
Quote
I repeated calibration several times on each board
This is part where the work around that @f5soh says will help.  From what I understand, without the work around, it will not calibrate correctly.  I can say that I have had some problems with calibration lately too.  I eventually get something that will fly, but less than perfect.

Quote
one version of software works fine and another version does not work - this clearly means that this second version is erroneous, isn't it?
It seems that each one has a different error.  The early version does not remove AuxMagSettings.BoardRotation and so something like roll axis uses pitch calibration (90 degree rotation) or bias is wrong +- sign (180 degree rotation) or such.  It may work with a mag that is symmetrical (bias close to zero or roll axis gain equals pitch axis gain).  The later version handles this correctly, but there is a problem with low level code when it thinks you ask it to do the same thing twice and it hasn't finished doing it the first time.

chromvis

  • *
  • 117
Re: AuxMag calibration possible bug
« Reply #8 on: August 22, 2016, 09:11:19 pm »
I did not quite get the principle of workaround suggested by f5soh. I will try to play more this evening.

Actually, I always calibrate with zeroed board and auxmag rotation. I found that it is very convenient to find proper rotation combination while looking on raw magnetometers response and testing different settings. Complete overlay of both onboard and auxmag responses in each axes is the optimum configuration.
And you are probably right, TheOtherCliff, that there are different errors. It is just my feelings from calibrations/testing which I did.
I can do some more testing, but I think, it would be good if developers will look into mag signal treatment algorithm and code. I am scientist and not that proficient in this area.
 

f5soh

  • *****
  • 4572
    • LibrePilot
Re: AuxMag calibration possible bug
« Reply #9 on: August 23, 2016, 12:33:18 pm »
Currently there is an issue while one uavo called two times and give an error, just after the calibration starts using wrong initial values.

https://bitbucket.org/librepilot/librepilot/pull-requests/306/lp-388-workaround-for-2-telemetry-errors/diff

Re: AuxMag calibration possible bug
« Reply #10 on: August 24, 2016, 05:56:30 am »
The work around is to start the mag calibration, go to the System tab, go to AuxMagSettings, and press the Save (red up arrow) button at the top of the page.  I am a little unsure if it should be this Save button, or the one on the calibration page (which may be inactive).  Also, it may be that you need to change some data to get the Save button to save?

I wonder if this would work too:  Before doing calibration, reset aux mag calibrations to defaults by going to System -> AuxMagSettings.  Set AudMagSettings.mag_bias to 0,0,0 and mag_transform to 1,0,0,0,1,0,0,0,1
then just do mag calibration normally.
« Last Edit: August 24, 2016, 06:00:04 am by TheOtherCliff »

chromvis

  • *
  • 117
Re: AuxMag calibration possible bug
« Reply #11 on: August 24, 2016, 06:59:04 am »
I can split calibration window and add UAVObjrct browser there

chromvis

  • *
  • 117
Re: AuxMag calibration possible bug
« Reply #12 on: August 24, 2016, 07:39:01 pm »
Great. Workaround works.
I tested on two systems: NH200 with Revo and NightHawk clone 280 with Sparky2
GCS and firmware r980 compiled on 8.15.16.
I set mag_transform to 1,0,0,0,1,0,0,0,1 and board rotation to 0,0,0 .
I did not set mag_bias to all zero, though (forgot, but it was still working)
I set GCS in the form on picture. Started calibration on NH200 than press "save to board" in UAVO browser and proceed with calibration.
On NH280 I started calibration then press save-position 5 times than "save-to-board" on UAVO browser than calibration (quad rotation) and "save-position" than final Save.
After that I set Pitch to 180 (both of my mags are UBlox) and approximately after 1 min all bars went to 0 and raw_mag  responses on scopes coincide for each axes.

Question. Does mag_transform parameters "r0c0" refer to base plane type and rotation?  Does it mean "r" - rotation, and "c" - coordinate? Does it similar to basic crystallography planes? Or I am completely wrong?

Re: AuxMag calibration possible bug
« Reply #13 on: August 26, 2016, 06:35:49 pm »
Good to know about the work around.

A 3x3 matrix like this can generally rotate and scale the vector (direction and strength) of the 3d mag.  Currently we only use the "diagonal" of the matrix and that means that it only scales the individual x,y,z components (no rotation).  I think that r0c0 is supposed to mean row0column0 of the matrix with these addresses starting at 0, not 1.