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

Mag cal values #3603

Closed
wants to merge 5 commits into from
Closed

Mag cal values #3603

wants to merge 5 commits into from

Conversation

ctzsnooze
Copy link
Member

@ctzsnooze ctzsnooze commented Oct 10, 2023

For testing only!

This PR makes two changes to the Sensors Tab display of Mag data.

  • Uses 'raw' Mag units in the display of Mag sensor data, using PR 3593

  • For each axis, shows, to the right of the instantaneous Mag sensor value, the average of the min and max values received on that axis since the Sensors Tab was opened. This value is preceded by 'C' for 'Cal`.

If the user goes set mag_calibration = 0,0,0 and clears their existing cal values, they can move the quad around so that, sequentially, one Mag axis, and then its opposite end, is pointed North into the local magnetic field vector. When a max and min have been defined, the value after C is the cal value to use for the axis.

Also a previous calibration can be checked. A good calibration will return within 1% of zero on each axis. This can be used to validate the 'hard iron' or 'zero point' calibration that Betaflight uses.

I also calculate the root (sum of squares of x,y,x) value, into magSumSqR which can be thought of as the 'radius' of the 'sphere' of mag readings. The value should equal the local value of the earths field, after correction for the internal gain of the sensor. Furthermore, if there are no soft iron effects, the value should remain constant regardless of the angle of the quad. If the 'sphere' appears deformed, the 'radius' will not be consistent, and the value will decrease, or increase, consistently, at certain angles. BUT... I can't figure out how to display this magSumSqR value; if anyone could help me with that, I'd be grateful.

I made a small video temporarily here...

MagUnscaledCal.mov

@github-actions

This comment has been minimized.

@blckmn
Copy link
Member

blckmn commented Oct 10, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> FAIL
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> FAIL
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> FAIL
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

samples_mag_i = addSampleToData(mag_data, samples_mag_i, FC.SENSOR_DATA.magnetometer);
drawGraph(magHelpers, mag_data, samples_mag_i);

// raw_data_text_ements.x[2].text(FC.SENSOR_DATA.magnetometer[0].toFixed(2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these comments here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not really, they can go away. Just kept them to remember the original code.
I'll remove them when the consensus is to merge or not merge.
What we really need is a dedicated 'Mag' tab, similar in concept to the dedicated 'GPS' tab, where we can perform calibrations, check raw values, etc.

@ctzsnooze
Copy link
Member Author

@chmelevskij @nerdCopter @haslinghuis

How could I display the 'root sum of squares' values? I would be grateful for a code suggestion.

I would be happy to display it, and indeed the min, max and cal values, in a separate html element underneath the mag trace, rather than messing around with the raw sensor values, something like this:

field strength: <root sum of squares>
X axis : <min> <max> <cal>
Y axis : <min> <max> <cal>
Z axis : <min> <max> <cal>

My problem is that I'm not a js coder. I know how to insert a div element into the html under the waveform, but I don't know how to 'load' such an element with values like the above. The values already exist in the .js code, I just don't know how to add them to the UI. I would be very grateful if someone could explain how to do this, with clear instructions.

@sonarcloud
Copy link

sonarcloud bot commented Oct 14, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
3.5% 3.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@github-actions
Copy link
Contributor

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

@chmelevskij
Copy link
Member

@ctzsnooze where about do you want to show those?

Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

Copy link
Contributor

Pull request closed automatically as inactive.

@github-actions github-actions bot closed this Nov 24, 2023
@ctzsnooze
Copy link
Member Author

Closing since the basics have been done in a different PR.

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

Successfully merging this pull request may close these issues.

3 participants