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

Secondary method to calibrate the Compass for use with large vehicles #2096

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions locale/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@
"initialSetupMagCalibStarted": {
"message": "Magnetometer calibration started"
},
"initialSetupMagFixedCalibStarted": {
"message": "Large vehicle Magnetometer calibration started"
},
"initialSetupMagCalibEnded": {
"message": "Magnetometer calibration <span style=\"color: #37a8db\">finished</span>"
},
Expand Down Expand Up @@ -2877,9 +2880,6 @@
"calibrationHead2": {
"message": "Accelerometer Values"
},
"calibrationHead3": {
"message": "Level Calibration"
},
"calibrationHead4": {
"message": "Compass Calibration"
},
Expand Down Expand Up @@ -2926,6 +2926,9 @@
"MagXText": {
"message": "Zero X"
},
"MagFixedText": {
"message": "True Heading in Degrees (0 - 359)"
},
"MagYText": {
"message": "Zero Y"
},
Expand All @@ -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 'Large Vehicles Compass Calibration' 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"
Expand Down
4 changes: 0 additions & 4 deletions src/css/tabs/calibration.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@
margin-top: 10px;
}

.tab-calibration #level_btn {
margin-top: 10px;
}

.tab-calibration .acc tr td {
width: 25%;
}
Expand Down
158 changes: 87 additions & 71 deletions tabs/calibration.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<div class="third_right">
<div class="default_btn">
<div id="calib_btn">
<a id="calibrate-start-button" class="calibrate" href="#" data-i18n="AccBtn"></a>
<a id="calibrate-start-button" class="calibrate" href="#"
data-i18n="AccBtn"></a>
</div>
</div>
</div>
Expand Down Expand Up @@ -54,15 +55,21 @@
<table class="cf_table acc">
<tr>
<td data-i18n="accZero"></td>
<td><label for="accZeroX"><span>X</span></label><input readonly disabled type="number" name="accZeroX" min="-32768" max="32767"></td>
<td><label for="accZeroY"><span>Y</span></label><input readonly disabled type="number" name="accZeroY" min="-32768" max="32767"></td>
<td><label for="accZeroZ"><span>Z</span></label><input readonly disabled type="number" name="accZeroZ" min="-32768" max="32767"></td>
<td><label for="accZeroX"><span>X</span></label><input readonly disabled
type="number" name="accZeroX" min="-32768" max="32767"></td>
<td><label for="accZeroY"><span>Y</span></label><input readonly disabled
type="number" name="accZeroY" min="-32768" max="32767"></td>
<td><label for="accZeroZ"><span>Z</span></label><input readonly disabled
type="number" name="accZeroZ" min="-32768" max="32767"></td>
</tr>
<tr>
<td data-i18n="accGain"></td>
<td><label for="accGainX"><span>X</span></label><input readonly disabled type="number" name="accGainX" min="1" max="8192"></td>
<td><label for="accGainY"><span>Y</span></label><input readonly disabled type="number" name="accGainY" min="1" max="8192"></td>
<td><label for="accGainZ"><span>Z</span></label><input readonly disabled type="number" name="accGainZ" min="1" max="8192"></td>
<td><label for="accGainX"><span>X</span></label><input readonly disabled
type="number" name="accGainX" min="1" max="8192"></td>
<td><label for="accGainY"><span>Y</span></label><input readonly disabled
type="number" name="accGainY" min="1" max="8192"></td>
<td><label for="accGainZ"><span>Z</span></label><input readonly disabled
type="number" name="accGainZ" min="1" max="8192"></td>
</tr>
</table>
</div>
Expand All @@ -71,76 +78,85 @@
</div>
</div>
</div>
<div class="cf_column fourth">
<!-- div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="calibrationHead3"></div>
</div>
<div class="spacer_box">
<span data-i18n="LevCalText">text</span>
<div class="default_btn">
<div id="level_btn">
<a class="level" href="#" data-i18n="LevBtn"></a>
</div>
<div class="spacer_right">
<div class="cf_column threefourth_left">
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="calibrationHead4"></div>
</div>
</div>
</div -->
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="calibrationHead4"></div>
</div>
<div class="spacer_box">
<span data-i18n="MagCalText">text</span>
<div class="default_btn">
<div id="mag_btn">
<a class="calibratemag" href="#" data-i18n="MagBtn"></a>
<div class="spacer_box">
<span data-i18n="MagCalText">text</span>
<div class="default_btn">
<div id="mag_btn">
<a class="calibratemag" href="#" data-i18n="MagBtn"></a>
</div>
</div>
<div></div>
<span data-i18n="MagFixedCalText">text</span>
<br><br>
<table id="mag-fixed-calibrated-data" class="cf_table">
<tr>
<td><label for="YawFixedDegrees"><span data-i18n="MagFixedText"></span></label></td>
<td><input type="number" name="YawFixedDegrees" min="0" max="32767"></td>
</tr>
</table>
<div class="default_btn">
<div id="magfixed_btn">
<a class="calibratemag" href="#" data-i18n="FixedMagBtn"></a>
</div>
</div>
<table id="mag-calibrated-data" class="cf_table">
<tr>
<td><label for="MagX" data-i18n="MagXText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagX" min="-32768" max="32767">
</td>
</tr>
<tr>
<td><label for="MagY" data-i18n="MagYText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagY" min="-32768" max="32767">
</td>
</tr>
<tr>
<td><label for="MagZ" data-i18n="MagZText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagZ" min="-32768" max="32767">
</td>
</tr>
<tr>
<td><label for="MagGainX" data-i18n="MagGainXText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainX" min="-32768" max="32767">
</td>
</tr>
<tr>
<td><label for="MagGainY" data-i18n="MagGainYText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainY" min="-32768" max="32767">
</td>
</tr>
<tr>
<td><label for="MagGainZ" data-i18n="MagGainZText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainZ" min="-32768" max="32767">
</td>
</tr>
</table>
</div>
<table id="mag-calibrated-data" class="cf_table">
<tr>
<td><label for="MagX" data-i18n="MagXText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagX" min="-32768" max="32767"></td>
</tr>
<tr>
<td><label for="MagY" data-i18n="MagYText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagY" min="-32768" max="32767"></td>
</tr>
<tr>
<td><label for="MagZ" data-i18n="MagZText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagZ" min="-32768" max="32767"></td>
</tr>
<tr>
<td><label for="MagGainX" data-i18n="MagGainXText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainX" min="-32768" max="32767"></td>
</tr>
<tr>
<td><label for="MagGainY" data-i18n="MagGainYText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainY" min="-32768" max="32767"></td>
</tr>
<tr>
<td><label for="MagGainZ" data-i18n="MagGainZText"><span></span></label></td>
<td><input readonly disabled type="number" name="MagGainZ" min="-32768" max="32767"></td>
</tr>
</table>
</div>
</div>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="calibrationHead5"></div>
</div>
<div class="spacer_box">
<span data-i18n="OpflowCalText">text</span>
<div class="default_btn">
<div id="opflow_btn">
<a class="calibrateopflow" href="#" data-i18n="OpflowCalBtn"></a>
<div class="gui_box grey">
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="calibrationHead5"></div>
</div>
<div class="spacer_box">
<span data-i18n="OpflowCalText">text</span>
<div class="default_btn">
<div id="opflow_btn">
<a class="calibrateopflow" href="#" data-i18n="OpflowCalBtn"></a>
</div>
</div>
<table id="opflow-calibrated-data" class="cf_table">
<tr>
<td><label for="OpflowScale"><span data-i18n="OpflowScaleText"></span></label></td>
<td><input type="number" name="OpflowScale" min="0" max="10000"></td>
</tr>
</table>
</div>
<table id="opflow-calibrated-data" class="cf_table">
<tr>
<td><label for="OpflowScale"><span data-i18n="OpflowScaleText"></span></label></td>
<td><input type="number" name="OpflowScale" min="0" max="10000"></td>
</tr>
</table>
</div>
</div>
</div>
Expand Down
75 changes: 73 additions & 2 deletions tabs/calibration.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,87 @@ 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');
}

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 () {

const yawBoxIsEmpty = $('[name=YawFixedDegrees]').val().length === 0;

if (yawBoxIsEmpty) {
GUI.log("Heading box value is empty!");
return;
}

if (!(FC.GPS_DATA.fix >= 2)) {
GUI.log("GPS without 3D Fix!");
return;
}

const yawBoxValue = parseInt($('[name=YawFixedDegrees]').val());

if (yawBoxValue > 360) {
GUI.log("Heading box value Min = 0 and Max = 360");
return;
}

var buffer = [];

var button = $(this);

$(button).addClass('disabled');

buffer.push(0x00FF & yawBoxValue);
buffer.push(yawBoxValue >> 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 = 1;
interval.add('compass_calibration_interval', function () {
countdown--;
if (countdown === 0) {
setTimeout(function () {
$(button).removeClass('disabled');

modalProcessing.close();
GUI.log(i18n.getMessage('initialSetupMagCalibEnded'));

MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
interval.remove('compass_calibration_interval');

//Cleanup
//delete modalProcessing;
$('.jBox-wrapper').remove();
}, 1000);
}

}, 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'));
});

Expand Down
Loading