Inav: Free Mag alignment with cli not possible

Created on 12 Feb 2020  ·  8Comments  ·  Source: iNavFlight/inav

Since a few Days, multiple Problems occured in Inav Facebook Group.
Problem: Users who mounting Magnetometer with Compass on a 30degree Tilt Angle Backwards, are not able to get this working with set mag_align_tilt = 300 or -300.

Or Simply cannot calibrate it if it's mounted flat anyway.

Lot of them build a dozen quads with inav and tiltet/flat mount mag/gps. And now got it only working with a flat mount magnetometer. (EG bn880 with cw270 flip and mag_align_pitch = -300

Or mean this:
// on-board mag alignment. Ignored if externally aligned via *DeciDegrees.

That cw270flip would be ignore and you need to set
Mag_align_pitch = -300
mag_align_roll = 1800
mag_align_yaw = 2700

Or if mag is mounted with cw270 flip
Flip is now roll and values are mean sensor axis itself?

Screenshot_20200212_214547_com facebook katana

https://github.com/shellixyz/inav/commit/1f8d73c638facfcf07d2ca959f06132fee69f517

All 8 comments

I also have this problem with magnetometer. I want to mount it on a quadcopter. Angled backwards so when I fly the GPS looks directly up. It allows the unit to see more satelites constantly.

When the GPS+Compass unit (BN-880) is flat, it works perfectly. When it's tilted backwards, after calibration the heading readings are messy.

I tried setting align_mag_pitch to -300, 300 (for 30* angle that I have), calibrating after every change. Also i tried replicating the "CW270Flip" setting, in case that it's ignored when using the pitch angle cli command. Nothing works. I tried current firmware and also INAV 2.2.0

I was calibrating on a 2m cable, so no interference during calibration, also no interference from the quad, because when mounted flat in the same spot mag works perfectly. The tilt is the problem.

Hello, just wanna say. I found this in the betaflight Code.
That mean: eg a BN880 with cw270flip results in following values:
flip over pitch axis 180degree and rotate over Yaw axis 270degree=

set mag_align_pitch = 1800
set mag_align_yaw = 2700
save

Means for 30degree backwards tilted, reduce roll at value -300

set mag_align_roll = -300
save

Because Roll Axis of Magnetometer is in relative to pitch axis of FC and vice versa

Also use:
set align_mag = custom
save

#define CUSTOM_ALIGN_CW0_DEG ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 0, .yaw = 0 }})

define CUSTOM_ALIGN_CW90_DEG ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 0, .yaw = 90 }})

define CUSTOM_ALIGN_CW180_DEG ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 0, .yaw = 180 }})

define CUSTOM_ALIGN_CW270_DEG ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 0, .yaw = 270 }})

define CUSTOM_ALIGN_CW0_DEG_FLIP ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 180, .yaw = 0 }})

define CUSTOM_ALIGN_CW90_DEG_FLIP ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 180, .yaw = 90 }})

define CUSTOM_ALIGN_CW180_DEG_FLIP ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 180, .yaw = 180 }})

define CUSTOM_ALIGN_CW270_DEG_FLIP ((sensorAlignment_t){ .values = { .roll = 0, .pitch = 180, .yaw = 270 }})

void buildRotationMatrixFromAlignment(const sensorAlignment_t* alignment, fp_rotationMatrix_t* rm);
void buildAlignmentFromLegacyRotation(sensorAlignment_t

Maybe this short hint can be added to the inav Wiki?
Added this short Explanation to the INAV Wiki, so other Users get information of that function.

Can be closed

Hello everyone!
I found something not right in the those CLI
in INAV2.5.0 should be :
set align_mag_roll = 300
set align_mag_yaw = 900
set align_mag_pitch = 1800

And what value is wrong?

align_mag_roll
mag_align_roll

As a rookie, I am a little confused. @@!

Im confused too because These cli variables at betaflight are correct. So it seems inav use the variables as you describe. Why i didnt notice that? I Look about that tomorrow.

Should be correct now
Bf use also mag_align "custom" which is not existent in inav. Some Times it's confusing if you use multiple inav and bf fcs 😅

Was this page helpful?
0 / 5 - 0 ratings