Skip to content

Commit

Permalink
Plane: QRTL: add interactive return altitude graph
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 committed Jan 26, 2023
1 parent a2eb0d8 commit ef3aa66
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions plane/source/docs/qrtl-mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,132 @@ Notes
feature for flying at airfields.
- If you get lock for the first time while flying, your home will be
set at the location of lock.


Return Altitude
===============

If in a VTOL motors are active when QRTL is entered the vehicle will first climb vertically before returning home. The altitude to which the vehicle climbs depends on the distance from home as shown below.
Altitude will be above terrain if terrain following is enabled, if not altitude will be above home.

.. raw:: html
<embed>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>QRTL Altitude Interactive</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
</head>
<body onload="update();">
<canvas id="QRTL_Altitude" style="width:100%;max-width:1200px"></canvas>
<p>
<label for="Q_RTL_ALT">Q_RTL_ALT</label>
<input id="Q_RTL_ALT" name="Q_RTL_ALT" type="number" step="0.1" value="15" onchange="update();"/>
</p>
<p>
<label for="Q_RTL_ALT_MIN">Q_RTL_ALT_MIN</label>
<input id="Q_RTL_ALT_MIN" name="Q_RTL_ALT_MIN" type="number" step="0.1" value="10.0" onchange="update();"/>
</p>
<p>
<label for="RTL_RADIUS">RTL_RADIUS</label>
<input id="RTL_RADIUS" name="RTL_RADIUS" type="number" step="1" value="0" onchange="update();"/>
</p>
<p>
<label for="WP_LOITER_RAD">WP_LOITER_RAD</label>
<input id="WP_LOITER_RAD" name="WP_LOITER_RAD" type="number" step="1" value="60" onchange="update();"/>
</p>
<p>
<label for="Q_LAND_FINAL">Q_LAND_FINAL</label>
<input id="Q_LAND_FINAL" name="Q_LAND_FINAL" type="number" step="0.1" value="6" onchange="update();"/>
</p>

<script>
var chart;
function update() {
var Q_RTL_ALT = parseFloat(document.getElementById("Q_RTL_ALT").value)
var Q_RTL_ALT_MIN = parseFloat(document.getElementById("Q_RTL_ALT_MIN").value)
var RTL_RADIUS = parseFloat(document.getElementById("RTL_RADIUS").value)
var WP_LOITER_RAD = parseFloat(document.getElementById("WP_LOITER_RAD").value)
var Q_LAND_FINAL = parseFloat(document.getElementById("Q_LAND_FINAL").value)
if (Q_RTL_ALT_MIN < Q_LAND_FINAL) {
Q_RTL_ALT_MIN = Q_LAND_FINAL
document.getElementById("Q_RTL_ALT_MIN").value = Q_LAND_FINAL
} else if (Q_RTL_ALT_MIN > Q_RTL_ALT) {
Q_RTL_ALT_MIN = Q_RTL_ALT
document.getElementById("Q_RTL_ALT_MIN").value = Q_RTL_ALT
}
var radius = Math.max(Math.abs(RTL_RADIUS), Math.abs(WP_LOITER_RAD)) * 1.5
var min_alt_radius = (Q_RTL_ALT_MIN/Q_RTL_ALT) * radius;
var max_disp_rad = Math.ceil((radius * 1.2) / 10) * 10
var max_disp_alt = Math.ceil((Q_RTL_ALT+5.0) / 10) * 10
var alt = [{x:-5, y:Q_RTL_ALT_MIN},
{x:min_alt_radius, y:Q_RTL_ALT_MIN},
{x:radius, y:Q_RTL_ALT},
{x:max_disp_rad+5, y:Q_RTL_ALT}]
var land_final = [{x:-5, y:Q_LAND_FINAL},
{x:max_disp_rad+5, y:Q_LAND_FINAL}]
if (chart == null) {
chart = new Chart("QRTL_Altitude", {
type : "scatter",
data: {
datasets: [
{
label: 'Return Altitude',
borderColor: "rgba(0,0,255,1.0)",
pointBackgroundColor: "rgba(0,0,255,1.0)",
data: alt,
fill: false,
showLine: true,
lineTension: 0,
},
{
label: 'Q_LAND_FINAL',
borderColor: "rgba(0,255,0,0.25)",
pointBackgroundColor: "rgba(0,255,0,0.25)",
data: land_final,
fill: false,
showLine: true,
lineTension: 0,
}
]
},
options: {
aspectRatio: 3,
scales: {
yAxes: [
{
scaleLabel: { display: true, labelString: "Altitude (m)" },
ticks: {min:0.0, max:max_disp_alt}
},
],
xAxes: [
{
scaleLabel: { display: true, labelString: "Distance from home (m)" },
ticks: { min:0.0, max:max_disp_rad}
}
],
}
}
});
} else {
chart.data.datasets[0].data = alt;
chart.data.datasets[1].data = land_final;
chart.options.scales.xAxes[0].ticks.max = max_disp_rad;
chart.options.scales.yAxes[0].ticks.max = max_disp_alt;
chart.update();
}
}
</script>

</body>
</html>

</embed>

0 comments on commit ef3aa66

Please sign in to comment.