Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed aligment tool #2025

Merged
merged 2 commits into from
Apr 18, 2024
Merged

Conversation

RomanLut
Copy link
Contributor

Fixes #1955

@DzikuVx DzikuVx added this to the 7.1.1 milestone Apr 15, 2024
@DzikuVx DzikuVx merged commit f96eef3 into iNavFlight:master Apr 18, 2024
DzikuVx added a commit that referenced this pull request Apr 18, 2024
@Jetrell
Copy link

Jetrell commented Apr 26, 2024

@RomanLut Thanks for your work on this.
I tested the changes, and have found the flight controller mounting orientation now works well at any position. Right way up or flipped. And any yaw offset.

Although the compass orientation preset is only based around CW270FLIP. And altering that preset when the hardware requires it, does not work.
Which means if the user happens to purchase a GNSS module with compass. That has a different orientation preset, based on the magnetometer chip, and its Arrow or Plug faces the rear of the aircraft. Then the arrow in the virtual image of the alignment tool is incorrect.. Which means the setup is not correct either.
An example of this is the Walksnail M181 GPS. Which has an Orientation preset of CW180FLIP.
I have one of these units mounted at Yaw 180° in a plane, with the plug facing forward... The alignment tool provides the wrong settings, to what is required for it to work.

I have written more information on the subject of Orientation Preset and GNSS units like the M181. To provide a more in depth explanation. https://github.com/iNavFlight/inav/wiki/GPS-and-Compass-setup#setting-up-the-compass-alignment

@samsab1
Copy link

samsab1 commented Apr 27, 2024

many thanks for your gps/magneto wiki
from your experience , can you tell me how to align the HGLRC M100-5883 M10 GPS where no arraw id displayed.
https://fr.aliexpress.com/item/1005006083972371.html

i have a big doubt about orientation, and i do not know how to clear that doubt.
best regards from france

@Jetrell
Copy link

Jetrell commented Apr 27, 2024

many thanks for your gps/magneto wiki from your experience , can you tell me how to align the HGLRC M100-5883 M10 GPS where no arraw id displayed.
i have a big doubt about orientation.

It looks to be the same layout as the Walksnail M181.
Its orientation preset would then be CW180FLIP. With the arrow facing towards the front of the aircraft, along with the flight controller arrow facing the same way.

If it had an arrow. It would be like this.

gps

@RomanLut
Copy link
Contributor Author

RomanLut commented Apr 27, 2024

image

Y and Y marking on this picture is incorrect.

Screenshot_20240427_131140_Chrome

There a is dot marking pin 1 of the chip.
Pins are numbered counter clockwise,

X axis is along pins 1,2,3,4
Y Axis is along chip making reading direction.

You also can see this on qmc5883 module:

image

Y axis on matek module should point down.
The arrow placed on Matek module points in the opposite direction to Y axis.

m100
Update: Axes are correct, Arrow is wrong

@RomanLut
Copy link
Contributor Author

RomanLut commented Apr 27, 2024

walksn
Update: Axes are correct, arrow is wrong

@Jetrell
Copy link

Jetrell commented Apr 27, 2024

I did make a mistake in the wiki.. But I added this image to help explain it better.

Clockwise Orientation reference chart

Y and Y marking on this picture is incorrect.

I agree, that image in not perfect. Although the main issue is caused by the manufacturer mounting the mag chip any direction they want. With respect to the plug being at the rear. And lately not even providing a reference arrow.

Because manufactures like Walksnail and HGLRC are not following the default orientation preset of CW270FLIP. We require that function to work independently of the PRY magnetometer alignment sliders.

Please don't take my statements as criticism. I very much respect your work and efforts towards this complex issue.
I spent ages trying work out how to get the M181 working with its FC last year. And it was confusing.. And after trying practically every mag alignment and orientation preset there is to get it working. This is how I know there is still an issue with the tool.

@Jetrell
Copy link

Jetrell commented Apr 27, 2024

@RomanLut This may help you visualize the issue withe the M181.

These are the only settings I could find to make this plane work correctly. And its now had over 50 flights.

align_mag = CW180FLIP
align_mag_pitch = 1800
align_mag_yaw = 1800
align_board_yaw = 1800

This is the aircrafts layout. With the FC's arrow facing rearward. And the compass plug facing forward, based on the magnetometer chips orientation.

mounting

And this is what the tool shows with this PR.. The FC arrow is correct, But the mag arrow is off by 90.. The plug should be facing forward (and the arrow backwards if this unit provided one).

alignment tool

@RomanLut
Copy link
Contributor Author

Please don't take my statements as criticism.

Everything is Ok, Testing ang bug reports are appreciated! I am interested in making it work correct, but I do not use theese combined GPS modules.

Now I understand that my assumption that arrow points to the opposite side of axis Y is correct for Matek m10q only.
Moreover two other modules listed above does not have arrow at all.
So basically we should add correct 3d model for each combined GPS module on the market.

This will be problematic. Instead of this I think I should add 3D models of dummy sensor PCBs like:
image
with dot and markings on magnethometer chip clearly visible, for each sensor supported by inav.

Users wil be able to find orientation by matching orientation of the chip on the PCB and the chip on physical setup.
I will do it next week.

@Jetrell
Copy link

Jetrell commented Apr 29, 2024

So basically we should add correct 3d model for each combined GPS module on the market.

That's a lot of extra work for you Roman.. And there is nothing stopping other manufactures releasing a combine module that has the mag chip set in a different position.

To make it easier for you. Another option could be to use the PLUG as the orientation preset reference, based on the magnetometer dot.. Using the clockwise chart I left above, showing the mags chips dot position on all four orientations.

The only prerequisites for that will be.

  • The user must have the plug facing them, when they're looking at the magnetometer dot and the chart to extract the Orientation Preset required to be used for their specific combine module.
  • The GNSS/Mags Orientation Preset must be entered before altering the Pitch, Roll, Yaw align_mag figures via the sliders.

Then once the Orientation preset is established with the Plug position as the reference... The rendered image of the GNSS/Mag should work with all modules.
What are your thoughts on this ?

For your reference I wrote a list of combine modules from better known manufactures, and their orientation preset, with respect to the plug facing the user.
(Ignoring the arrow, for the very few that even include one. But for the ones that did. The arrow was consistent with their plug.)

AxisFlying - CW270FLIP
Beitian - CW270FLIP
Diatone - CW90FLIP
Flywoo - CW270FLIP
Foxeer - CW270FLIP and CW180FLIP
GEPRC - CW0FLIP
HGLRC - CW180FLIP
HAKRC - CW180FLIP
Matek - CW270FLIP
Speedybee - CW270FLIP
Walksnail - CW180FLIP

This is only a small portion of the modules on the market. But you get the idea of the non uniform mounting of the magnetometer chip. Which is why orientation preset has to be established first. With the align_mag PRY sliders being zero after its saved.

@sensei-hacker
Copy link
Collaborator

sensei-hacker commented Apr 29, 2024

So basically we should add correct 3d model for each combined GPS module on the market.

I have a working proof of concept which dispenses with all of this. That makes it so we don't care which model GPS/ mag, or how the sensor is oriented relative to the board.. It has the user point the aircraft roughly north, then roughly east. From those two readings we can compute the orientation.

Similarly for FC / accelerometer orientation. While the aircraft is roughly flat (and pointing north for compass, whichever direction reads about 1G is the side that's pointing down.

It all works and makes it easy for the user. The one challenge remaining is translating the new mag orientation based on what the new FC orientation will be. A little bit of quaternion math that I'm not particularly comfortable with.

@Jetrell
Copy link

Jetrell commented Apr 29, 2024

@sensei-hacker It would make it easier in theory.. Provided the magnetic bearing is not influenced in the slightest by weak magnetic fields emanating from something on the craft.. Otherwise that magnetic deviation would render the derived compass orientation erroneous.

The benefit of having an orientation preset that is based on physical parameters. Means its one less thing to guess about if the compass calibration is not correct. Or magnetic deviation does occur inflight from something on the copter.
e.g. high bank angles, causing the mag to temporarily intersect the motor magnetic fields. Or higher current drain emitting a magnetic field disturbance.

Arducopter uses something like this. And its proven not to be totally reliable.

@sensei-hacker
Copy link
Collaborator

sensei-hacker commented Apr 29, 2024

the compass calibration is not correct. Or magnetic deviation does occur inflight from something on the copter.
e.g. high bank angles

You still set the compass orientation once, on the bench, using one of the presets. Not continuously in flight. Nothing changes about in-flight behavior. I only changed the UI in Configurator. You choose the preset on the bench, not in flight.

In order to choose the right preset, you simply have the user point the aircraft north, then east, and round to the nearest 90°* to choose which preset matches . You don't ask the user which preset - they don't know. Instead you check the sensor reading and you can see which preset matches.

If it reads 3° while pointed north, and reads 267° while pointed east, we know it needs 180° rotation on the lateral axis.

I simply automated the exact procedure I've used dozens of times helping people on Discord. No changes to INAV itself. We don't look for markings on the board, we look at the sensor readings. It hasn't failed yet.

  • (Optionally, if both readings are a very good match for a 45° increment because it's a tiny whoop board, you can use that.)

@RomanLut
Copy link
Contributor Author

RomanLut commented May 1, 2024

Added magnetometer chips and some GNSS modules:

#2056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alignment tool problem? Or my problem?
5 participants