1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

Merge pull request #272 from StewLG/MinimumFailsafeDistance

Minimum failsafe distance
This commit is contained in:
Konstantin Sharlaimov 2017-10-11 23:39:44 +10:00 committed by GitHub
commit 12cf9fe2e5
6 changed files with 148 additions and 1 deletions

View file

@ -1675,6 +1675,24 @@
"failsafeKillSwitchHelp": {
"message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. <strong>Note:</strong> Arming is blocked with the failsafe kill switch in the ON position"
},
"failsafeUseMinimumDistanceItem": {
"message": "Use alternate Minimum Distance Failsafe Procedure when close to Home"
},
"failsafeUseMinimumDistanceHelp": {
"message": "Set this option if you need an alternate failsafe behavior when the craft is close to Home. For example the author of the feature has a plane that failsafes when the wings detach on landing, when the RTH failsafe behavior normally desired in flight is no longer wanted or needed."
},
"failsafeMinDistanceItem": {
"message": "Failsafe Minimum Distance in centimeters"
},
"failsafeMinDistanceHelp": {
"message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in centimeters away from Home. For example if set to 2000 centimeters (20 meters), and the craft is at 13 meters, the Failsafe Minimum Distance Procedure will be followed. When the craft is at 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. "
},
"failsafeMinDistanceProcedureItem": {
"message": "Failsafe Minimum Distance Procedure"
},
"failsafeMinDistanceProcedureHelp": {
"message": "This is the failsafe procedure that will be followed when the craft is closer than the Failsafe Minimum Distance from Home."
},
"mainHelpArmed": {
"message": "Motor Arming"
},

View file

@ -376,7 +376,14 @@ var FC = {
failsafe_throttle: 0,
failsafe_kill_switch: 0,
failsafe_throttle_low_delay: 0,
failsafe_procedure: 0
failsafe_procedure: 0,
failsafe_recovery_delay: 0,
failsafe_fw_roll_angle: 0,
failsafe_fw_pitch_angle: 0,
failsafe_fw_yaw_rate: 0,
failsafe_stick_motion_threshold: 0,
failsafe_min_distance: 0,
failsafe_min_distance_procedure: 0
};
FW_CONFIG = {
@ -880,6 +887,14 @@ var FC = {
getRthAltControlMode: function () {
return ["Current", "Extra", "Fixed", "Max", "At Least"];
},
getFailsafeProcedure: function () {
return {
0: "Land",
1: "Drop",
2: "RTH",
3: "Do Nothing",
}
},
getRcMapLetters: function () {
return ['A', 'E', 'R', 'T', '5', '6', '7', '8'];
}

View file

@ -637,6 +637,24 @@ var mspHelper = (function (gui) {
offset += 2;
FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset);
offset++;
if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) {
FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset);
offset++;
FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true);
offset += 2;
FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true);
offset += 2;
FAILSAFE_CONFIG.failsafe_fw_yaw_rate = data.getUint16(offset, true);
offset += 2;
FAILSAFE_CONFIG.failsafe_stick_motion_threshold = data.getUint16(offset, true);
offset += 2;
}
if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) {
FAILSAFE_CONFIG.failsafe_min_distance = data.getUint16(offset, true);
offset += 2;
FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset);
offset++;
}
break;
case MSPCodes.MSP_RXFAIL_CONFIG:
@ -1214,6 +1232,22 @@ var mspHelper = (function (gui) {
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay));
buffer.push(FAILSAFE_CONFIG.failsafe_procedure);
if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) {
buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay);
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle));
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle));
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate));
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold));
}
if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) {
buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance));
buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance));
buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure);
}
break;
case MSPCodes.MSP_SET_TRANSPONDER_CONFIG:

View file

@ -253,6 +253,12 @@
height: 90px;
}
.tab-failsafe .minimumDistance {
width: 100px !important;
padding-left: 3px;
margin-right: 11px;
}
@media only screen and (max-width: 1055px) , only screen and (max-device-width: 1055px) {
}

View file

@ -109,6 +109,30 @@
<label for="nothing" data-i18n="failsafeProcedureItemSelect4"></label>
</div>
</div>
<!-- Minimum Failsafe Distance controls -->
<div class="requires-v1_7_4">
<div class="checkbox stage2">
<div class="numberspacer" >
<input type="checkbox" name="failsafe_use_minimum_distance" class="toggle" id="failsafe_use_minimum_distance" />
</div>
<label for="failsafe_use_minimum_distance"><span data-i18n="failsafeUseMinimumDistanceItem"></span>
</label>
<div class="helpicon cf_tip" data-i18n_title="failsafeUseMinimumDistanceHelp"></div>
</div>
<div class="number" id="failsafe_min_distance_elements">
<label> <input class="minimumDistance" type="number" name="failsafe_min_distance" id="failsafe_min_distance" min="0" max="65000" /> <span
data-i18n="failsafeMinDistanceItem"></span>
</label>
<div class="helpicon cf_tip" data-i18n_title="failsafeMinDistanceHelp"></div>
</div>
<div class="select" id="failsafe_min_distance_procedure_elements">
<select class="minimumDistance" id="failsafe_min_distance_procedure"></select>
<label for="failsafe_min_distance_procedure"> <span data-i18n="failsafeMinDistanceProcedureItem"></span></label>
<div class="helpicon cf_tip" data-i18n_title="failsafeMinDistanceProcedureHelp"></div>
</div>
</div>
</div>
</div>
</div>

View file

@ -75,6 +75,12 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
// translate to user-selected language
localize();
var $failsafeUseMinimumDistanceCheckbox = $('#failsafe_use_minimum_distance');
var $failsafeMinDistanceElements = $('#failsafe_min_distance_elements')
var $failsafeMinDistance = $('#failsafe_min_distance')
var $failsafeMinDistanceProcedureElements = $('#failsafe_min_distance_procedure_elements')
var $failsafeMinDistanceProcedure = $('#failsafe_min_distance_procedure');
// generate labels for assigned aux modes
var auxAssignment = [],
i,
@ -225,6 +231,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
$('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay);
$('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay);
$('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay);
if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) {
$('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance);
}
// set stage 2 failsafe procedure
$('input[type="radio"].procedure').change(function () {
@ -275,6 +284,44 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
// set stage 2 kill switch option
$('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch);
if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) {
// Adjust Minimum Distance values when checkbox is checked/unchecked
$failsafeUseMinimumDistanceCheckbox.change(function() {
if ($(this).is(':checked')) {
// 20 meters seems like a reasonable default for a minimum distance
$failsafeMinDistance.val(2000);
$failsafeMinDistanceElements.show();
$failsafeMinDistanceProcedureElements.show();
} else {
// If they uncheck it, clear the distance to 0, which disables this feature
$failsafeMinDistance.val(0);
$failsafeMinDistanceElements.hide();
$failsafeMinDistanceProcedureElements.hide();
}
});
// Set initial state of controls according to data
if (FAILSAFE_CONFIG.failsafe_min_distance > 0) {
$failsafeUseMinimumDistanceCheckbox.prop('checked', true);
$failsafeMinDistanceElements.show();
$failsafeMinDistanceProcedureElements.show();
} else {
$failsafeUseMinimumDistanceCheckbox.prop('checked', false);
$failsafeMinDistanceElements.hide();
$failsafeMinDistanceProcedureElements.hide();
}
// Alternate, minimum distance failsafe procedure
GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure);
$failsafeMinDistanceProcedure.val(FAILSAFE_CONFIG.failsafe_min_distance_procedure);
$failsafeMinDistanceProcedure.change(function () {
FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val();
});
$('.requires-v1_7_4').show();
} else {
$('.requires-v1_7_4').hide();
}
$('a.save').click(function () {
// gather data that doesn't have automatic change event bound
RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val());
@ -292,6 +339,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val());
FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val());
FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val());
if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) {
FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val());
}
if ($('input[id="land"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 0;