From b3dfe29f2107cc22378e23b035de5a38d2fd4379 Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Sun, 19 May 2024 19:53:48 -0300 Subject: [PATCH 1/6] new secondary method to calibrate the compass for use with large vehicles --- js/fc.js | 3 + locale/en/messages.json | 21 +++-- src/css/tabs/calibration.css | 4 - tabs/calibration.html | 158 +++++++++++++++++++---------------- tabs/calibration.js | 62 +++++++++++++- 5 files changed, 162 insertions(+), 86 deletions(-) diff --git a/js/fc.js b/js/fc.js index 0d5d4861b..83e266e50 100644 --- a/js/fc.js +++ b/js/fc.js @@ -442,6 +442,9 @@ var FC = { X: null, Y: null, Z: null + }, + magFixedYaw: { + yawDegrees: null } }; diff --git a/locale/en/messages.json b/locale/en/messages.json index c5e53172e..9f90b5e9c 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -735,6 +735,9 @@ "initialSetupMagCalibStarted": { "message": "Magnetometer calibration started" }, + "initialSetupMagFixedCalibStarted": { + "message": "Large vehicle Magnetometer calibration started" + }, "initialSetupMagCalibEnded": { "message": "Magnetometer calibration finished" }, @@ -2877,9 +2880,6 @@ "calibrationHead2": { "message": "Accelerometer Values" }, - "calibrationHead3": { - "message": "Level Calibration" - }, "calibrationHead4": { "message": "Compass Calibration" }, @@ -2926,6 +2926,9 @@ "MagXText": { "message": "Zero X" }, + "MagFixedText": { + "message": "True Heading in Degrees (0 - 359)" + }, "MagYText": { "message": "Zero Y" }, @@ -2948,16 +2951,16 @@ "message": "Reset Accelerometer Calibration" }, "MagCalText": { - "message": "After pressing the button you have 30 seconds to hold the model in the air and rotate it so that each side (front, back, left, right, top and bottom) points down towards the earth. Be sure that your compass is not near magnets or electromagnets when installed in the craft or performing the calibration." + "message": "After pressing the button 'Calibrate Compass' you have 30 seconds to hold the model in the air and rotate it so that each side (front, back, left, right, top and bottom) points down towards the earth. Be sure that your compass is not near magnets or electromagnets when installed in the craft or performing the calibration." + }, + "MagFixedCalText": { + "message": "Large or heavy vehicles are impractical to use the primary method and manually rotate all axles. This feature allows for very accurate calibration if the GPS has 3D Fix status and the vehicles actual heading is known. First make sure you have aligned (CLI Param 'align_mag') your Compass correctly. With the help of a compass (for example, the one on your smartphone) you must enter your vehicle heading. The heading entered should be TRUE, not MAGNETIC. Finally, click on the 'Compass Calibration for Large Vehicles' button and wait for the calibration result." }, "MagBtn": { "message": "Calibrate Compass" }, - "LevCalText": { - "message": "Please put some Text hereā€¦" - }, - "LevBtn": { - "message": "Level calibration" + "FixedMagBtn": { + "message": "Large Vehicle Compass Calibration" }, "tabMixer": { "message": "Mixer" diff --git a/src/css/tabs/calibration.css b/src/css/tabs/calibration.css index 9f575d08d..144ef7293 100755 --- a/src/css/tabs/calibration.css +++ b/src/css/tabs/calibration.css @@ -178,10 +178,6 @@ margin-top: 10px; } -.tab-calibration #level_btn { - margin-top: 10px; - } - .tab-calibration .acc tr td { width: 25%; } diff --git a/tabs/calibration.html b/tabs/calibration.html index b0414cbaa..8d75a6a01 100755 --- a/tabs/calibration.html +++ b/tabs/calibration.html @@ -17,7 +17,8 @@
- +
@@ -54,15 +55,21 @@ - - - + + + - - - + + +
@@ -71,76 +78,85 @@ -
- -
-
-
-
-
- text -
-
- +
+ text +
+
+ +
+
+ text +

+ + + + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
- text -
-
- +
+
+
+
+
+ text +
+
+ +
+ + + + + +
- - - - - -
diff --git a/tabs/calibration.js b/tabs/calibration.js index 4566fc416..97d49a56e 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -117,6 +117,7 @@ TABS.calibration.initialize = function (callback) { $('[name=MagGain' + item + ']').val(FC.CALIBRATION_DATA.magGain[item]); }); $('[name=OpflowScale]').val(FC.CALIBRATION_DATA.opflow.Scale); + $('[name=YawFixedDegrees]').val(FC.CALIBRATION_DATA.magFixedYaw.yawDegrees); updateCalibrationSteps(); } @@ -230,16 +231,73 @@ TABS.calibration.initialize = function (callback) { if (FC.SENSOR_CONFIG.magnetometer === 0) { //Comment for test - $('#mag_btn, #mag-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); + $('#mag_btn, #mag-calibrated-data, #magfixed_btn, #mag-fixed-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); + } else { + if (!(FC.GPS_DATA.fix >= 2)) { + $('#magfixed_btn, #mag-fixed-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); + } } if (FC.SENSOR_CONFIG.opflow === 0) { //Comment for test $('#opflow_btn, #opflow-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); } + + $('#magfixed_btn').on('click', function () { + var buffer = []; + + var button = $(this); + + $(button).addClass('disabled'); + + buffer.push(0x00FF & parseInt($('[name=YawFixedDegrees]').val())); + buffer.push(parseInt($('[name=YawFixedDegrees]').val()) >> 8); + + MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, buffer, false, function () { + GUI.log(i18n.getMessage('initialSetupMagFixedCalibStarted')); + }); + + let modalProcessing = new jBox('Modal', { + width: 400, + height: 120, + animation: false, + closeOnClick: false, + closeOnEsc: false, + content: $('#modal-compass-processing').clone() + }).open(); + + var countdown = 3; + interval.add('compass_calibration_interval', function () { + countdown--; + if (countdown === 0) { + setTimeout(function () { + $(button).removeClass('disabled'); + + modalProcessing.close(); + GUI.log(i18n.getMessage('initialSetupMagFixedCalibEnded')); + + MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData); + interval.remove('compass_calibration_interval'); + + //Cleanup + //delete modalProcessing; + $('.jBox-wrapper').remove(); + }, 1000); + } else { + modalProcessing.content.find('.modal-compass-countdown').text(countdown); + } + + }, 1000); + }); $('#mag_btn').on('click', function () { - MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, false, false, function () { + var buffer = []; + + // 32767 = Indicates to INAV that sample calibration will be used + buffer.push(0x00FF & 32767); + buffer.push(32767 >> 8); + + MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, buffer, false, function () { GUI.log(i18n.getMessage('initialSetupMagCalibStarted')); }); From b798ce5e4791374dbfb7f8ce87448853aeed2d65 Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Sun, 19 May 2024 21:49:55 -0300 Subject: [PATCH 2/6] add gui alert --- locale/en/messages.json | 2 +- tabs/calibration.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/locale/en/messages.json b/locale/en/messages.json index 9f90b5e9c..e6fb10a66 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -2954,7 +2954,7 @@ "message": "After pressing the button 'Calibrate Compass' you have 30 seconds to hold the model in the air and rotate it so that each side (front, back, left, right, top and bottom) points down towards the earth. Be sure that your compass is not near magnets or electromagnets when installed in the craft or performing the calibration." }, "MagFixedCalText": { - "message": "Large or heavy vehicles are impractical to use the primary method and manually rotate all axles. This feature allows for very accurate calibration if the GPS has 3D Fix status and the vehicles actual heading is known. First make sure you have aligned (CLI Param 'align_mag') your Compass correctly. With the help of a compass (for example, the one on your smartphone) you must enter your vehicle heading. The heading entered should be TRUE, not MAGNETIC. Finally, click on the 'Compass Calibration for Large Vehicles' button and wait for the calibration result." + "message": "Large or heavy vehicles are impractical to use the primary method and manually rotate all axles. This feature allows for very accurate calibration if the GPS has 3D Fix status and the vehicles actual heading is known. First make sure you have aligned (CLI Param 'align_mag') your Compass correctly. With the help of a compass (for example, the one on your smartphone) you must enter your vehicle heading. The heading entered should be TRUE, not MAGNETIC. Finally, click on the 'Large Vehicles Compass Calibration' button and wait for the calibration result." }, "MagBtn": { "message": "Calibrate Compass" diff --git a/tabs/calibration.js b/tabs/calibration.js index 97d49a56e..bfb4b5548 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -232,10 +232,6 @@ TABS.calibration.initialize = function (callback) { if (FC.SENSOR_CONFIG.magnetometer === 0) { //Comment for test $('#mag_btn, #mag-calibrated-data, #magfixed_btn, #mag-fixed-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); - } else { - if (!(FC.GPS_DATA.fix >= 2)) { - $('#magfixed_btn, #mag-fixed-calibrated-data').css('pointer-events', 'none').css('opacity', '0.4'); - } } if (FC.SENSOR_CONFIG.opflow === 0) { @@ -244,6 +240,19 @@ TABS.calibration.initialize = function (callback) { } $('#magfixed_btn').on('click', function () { + + const yawBoxIsEmpty = $('[name=YawFixedDegrees]').val().length === 0; + + if (yawBoxIsEmpty) { + GUI.alert("Heading box value is empty!"); + return; + } + + if (!(FC.GPS_DATA.fix >= 2)) { + GUI.alert("GPS without 3D Fix!"); + return; + } + var buffer = []; var button = $(this); From 44222f61a78a007f4920ccaa0007289b52375dce Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Sun, 19 May 2024 21:54:59 -0300 Subject: [PATCH 3/6] remove not necessary variable --- js/fc.js | 3 --- tabs/calibration.js | 1 - 2 files changed, 4 deletions(-) diff --git a/js/fc.js b/js/fc.js index 83e266e50..0d5d4861b 100644 --- a/js/fc.js +++ b/js/fc.js @@ -442,9 +442,6 @@ var FC = { X: null, Y: null, Z: null - }, - magFixedYaw: { - yawDegrees: null } }; diff --git a/tabs/calibration.js b/tabs/calibration.js index bfb4b5548..da33957a9 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -117,7 +117,6 @@ TABS.calibration.initialize = function (callback) { $('[name=MagGain' + item + ']').val(FC.CALIBRATION_DATA.magGain[item]); }); $('[name=OpflowScale]').val(FC.CALIBRATION_DATA.opflow.Scale); - $('[name=YawFixedDegrees]').val(FC.CALIBRATION_DATA.magFixedYaw.yawDegrees); updateCalibrationSteps(); } From f49acee4bc1de81b81c918e2723afb92d78e6279 Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Sun, 19 May 2024 22:56:44 -0300 Subject: [PATCH 4/6] Avoid calibration starting with values greater than 360 degrees --- tabs/calibration.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tabs/calibration.js b/tabs/calibration.js index da33957a9..8a641d9c0 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -252,14 +252,21 @@ TABS.calibration.initialize = function (callback) { return; } + const yawBoxValue = parseInt($('[name=YawFixedDegrees]').val()); + + if (yawBoxValue > 360) { + GUI.alert("Value Min = 0 and Max = 360"); + return; + } + var buffer = []; var button = $(this); $(button).addClass('disabled'); - buffer.push(0x00FF & parseInt($('[name=YawFixedDegrees]').val())); - buffer.push(parseInt($('[name=YawFixedDegrees]').val()) >> 8); + buffer.push(0x00FF & yawBoxValue); + buffer.push(yawBoxValue >> 8); MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, buffer, false, function () { GUI.log(i18n.getMessage('initialSetupMagFixedCalibStarted')); From c6202b1ef6a3de56fcf62a1bdeaf83a8d21df3db Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Thu, 23 May 2024 21:24:56 -0300 Subject: [PATCH 5/6] push some corrections --- tabs/calibration.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tabs/calibration.js b/tabs/calibration.js index 8a641d9c0..1498feffd 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -248,8 +248,8 @@ TABS.calibration.initialize = function (callback) { } if (!(FC.GPS_DATA.fix >= 2)) { - GUI.alert("GPS without 3D Fix!"); - return; + //GUI.alert("GPS without 3D Fix!"); + //return; } const yawBoxValue = parseInt($('[name=YawFixedDegrees]').val()); @@ -281,7 +281,7 @@ TABS.calibration.initialize = function (callback) { content: $('#modal-compass-processing').clone() }).open(); - var countdown = 3; + var countdown = 1; interval.add('compass_calibration_interval', function () { countdown--; if (countdown === 0) { @@ -289,7 +289,7 @@ TABS.calibration.initialize = function (callback) { $(button).removeClass('disabled'); modalProcessing.close(); - GUI.log(i18n.getMessage('initialSetupMagFixedCalibEnded')); + GUI.log(i18n.getMessage('initialSetupMagCalibEnded')); MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData); interval.remove('compass_calibration_interval'); @@ -298,8 +298,6 @@ TABS.calibration.initialize = function (callback) { //delete modalProcessing; $('.jBox-wrapper').remove(); }, 1000); - } else { - modalProcessing.content.find('.modal-compass-countdown').text(countdown); } }, 1000); From c904801c9d6d42d1682efdb2434593c05e8a4f35 Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Thu, 23 May 2024 21:36:49 -0300 Subject: [PATCH 6/6] change gui alert by gui log --- tabs/calibration.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tabs/calibration.js b/tabs/calibration.js index 1498feffd..a905d13da 100755 --- a/tabs/calibration.js +++ b/tabs/calibration.js @@ -243,19 +243,19 @@ TABS.calibration.initialize = function (callback) { const yawBoxIsEmpty = $('[name=YawFixedDegrees]').val().length === 0; if (yawBoxIsEmpty) { - GUI.alert("Heading box value is empty!"); + GUI.log("Heading box value is empty!"); return; } if (!(FC.GPS_DATA.fix >= 2)) { - //GUI.alert("GPS without 3D Fix!"); - //return; + GUI.log("GPS without 3D Fix!"); + return; } const yawBoxValue = parseInt($('[name=YawFixedDegrees]').val()); if (yawBoxValue > 360) { - GUI.alert("Value Min = 0 and Max = 360"); + GUI.log("Heading box value Min = 0 and Max = 360"); return; }