Implement compass cal#2342
Conversation
b072b5b to
f5d9a0f
Compare
joaoantoniocardoso
left a comment
There was a problem hiding this comment.
Large vehicle calibration is working fine! :)
one annoying thing: the "Current Declination", which doesn't show the current declination, rather, it seems to be showing the last manual declination set.
It's weird to have to input the declination in a separate window if I can select the value. Maybe make it non-selectable, but also, make something like a transparent text that shows when the mouse hovers it saying "CLICK TO EDIT", to indicate the action.
Also about it, the edit box contains units, and the main "current declination" value does not.
Another thing is: why can't I manually enter the GPS coordinates?
Another UI thing: can we remove this bar? |
patrickelectric
left a comment
There was a problem hiding this comment.
I forgot to send my review 🤦
I have not finished yet, but should catch up later today.
| @@ -0,0 +1,186 @@ | |||
| export function degrees (radians: number): number { | |||
There was a problem hiding this comment.
Any problem with https://www.npmjs.com/package/ts-matrix ?
There was a problem hiding this comment.
I'll give it a go.
There was a problem hiding this comment.
well, after looking at it, I think I'd rather keep well-defined Vector3 and Matrix3 types. The constructors are also different, and I'm tired of looking at this code as a whole 😅
|
|
||
| export function mag_heading(RawImu: Vector3, attitude: Vector3, declination: number) { | ||
| // calculate heading from raw magnetometer | ||
| if (declination === undefined) { |
There was a problem hiding this comment.
How is that possible if the type of declination is not | undefined ?
There was a problem hiding this comment.
it is not. good catch
| const headY = magY * dcmMatrix.e(8) - magZ * dcmMatrix.e(7) | ||
| const headX = magX * cosPitchSqr - dcmMatrix.e(6) * (magY * dcmMatrix.e(7) + magZ * dcmMatrix.e(8)) | ||
| let heading = degrees(Math.atan2(-headY, headX)) + declination | ||
| if (heading < -180) { |
There was a problem hiding this comment.
I dont think atan2 can produce anything that far. but maybe if declinations is set wrongly...
updating it anyway.
| components: { | ||
| ParamSets, | ||
| ArdupilotMavlinkCompassSetup, | ||
| SpinningLogo, |
There was a problem hiding this comment.
yeah, it shows up while the parameters are not fully loaded
|
There's a relatively large refactor coming later today. So you might want
to wait.
…On Tue, Feb 6, 2024, 08:08 Patrick José Pereira ***@***.***> wrote:
***@***.**** requested changes on this pull request.
I forgot to send my review 🤦
I have not finished yet, but should catch up later today.
------------------------------
In core/frontend/src/utils/math.ts
<#2342 (comment)>:
> @@ -0,0 +1,186 @@
+export function degrees (radians: number): number {
Any problem with https://www.npmjs.com/package/ts-matrix ?
------------------------------
In core/frontend/src/utils/mavlink_math.ts
<#2342 (comment)>:
> @@ -0,0 +1,24 @@
+// ported from https://github.com/ArduPilot/pymavlink/blob/master/mavextra.py#L60
+
+import { Matrix3, Vector3, degrees } from "./math"
+
+export function mag_heading(RawImu: Vector3, attitude: Vector3, declination: number) {
+ // calculate heading from raw magnetometer
+ if (declination === undefined) {
How is that possible if the type of declination is not | undefined ?
------------------------------
In core/frontend/src/utils/mavlink_math.ts
<#2342 (comment)>:
> +export function mag_heading(RawImu: Vector3, attitude: Vector3, declination: number) {
+ // calculate heading from raw magnetometer
+ if (declination === undefined) {
+ throw new Error('declination is undefined')
+ }
+ let magX = RawImu.x
+ let magY = RawImu.y
+ let magZ = RawImu.z
+
+ // go via a DCM matrix to match the APM calculation
+ const dcmMatrix = (new Matrix3()).fromEuler(attitude.x, attitude.y, attitude.z)
+ const cosPitchSqr = 1.0 - (dcmMatrix.e(6) * dcmMatrix.e(6))
+ const headY = magY * dcmMatrix.e(8) - magZ * dcmMatrix.e(7)
+ const headX = magX * cosPitchSqr - dcmMatrix.e(6) * (magY * dcmMatrix.e(7) + magZ * dcmMatrix.e(8))
+ let heading = degrees(Math.atan2(-headY, headX)) + declination
+ if (heading < -180) {
while ?
------------------------------
In core/frontend/src/components/vehiclesetup/Configure.vue
<#2342 (comment)>:
> @@ -39,14 +41,16 @@ export default Vue.extend({
name: 'Configure',
components: {
ParamSets,
+ ArdupilotMavlinkCompassSetup,
+ SpinningLogo,
Are we using it ?
------------------------------
In core/frontend/src/components/common/StatusTextWatcher.vue
<#2342 (comment)>:
> + }
+ },
+ computed: {
+ all_messages(): string {
+ return this.messages.join('\n')
+ },
+ },
+ watch: {
+ filter(newFilter) {
+ this.filterRegex = new RegExp(newFilter)
+ },
+ },
+ mounted() {
+ this.listener = mavlink2rest.startListening('STATUSTEXT').setCallback((receivedMessage) => {
+ const text = receivedMessage.message.text.join('')
+ if (this.messages && this.messages[this.messages.length - 1] === text) {
⬇️ Suggested change
- if (this.messages && this.messages[this.messages.length - 1] === text) {
+ if (this.messages?.[this.messages.length - 1] === text) {
—
Reply to this email directly, view it on GitHub
<#2342 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6T53C5A4SPRBPEHBWJP33YSIFJHAVCNFSM6AAAAABCJIVNWOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNJZGY2DCNRXGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
db84243 to
1d6ccfc
Compare
c5c00e3 to
5791f6b
Compare
5791f6b to
925aefa
Compare


No description provided.