Skip to content

Commit

Permalink
Plane: QRTL: add interactive return path
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 committed Jan 27, 2023
1 parent 779001b commit d5bb769
Showing 1 changed file with 49 additions and 17 deletions.
66 changes: 49 additions & 17 deletions plane/source/docs/qrtl-mode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ 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.
Altitude will be above terrain if terrain following is enabled, if not altitude will be above home. If the vehicle is within one and a half times :ref:`RTL_RADIUS<RTL_RADIUS>` or :ref:`WP_LOITER_RAD<WP_LOITER_RAD>`
the vehicle we return in VTOL flight without transitioning into forward flight.

.. raw:: html

Expand All @@ -95,10 +96,12 @@ Altitude will be above terrain if terrain following is enabled, if not altitude
<input id="Q_LAND_FINAL" name="Q_LAND_FINAL" type="number" step="0.5" value="6" min="0" onchange="update()"/>
</p>

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script>
var chart
var vehicle_dist = 80
var vehicle_alt = 7
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)
Expand Down Expand Up @@ -133,6 +136,20 @@ Altitude will be above terrain if terrain following is enabled, if not altitude
var land_final = [{x:-5, y:Q_LAND_FINAL},
{x:max_disp_rad+5, y:Q_LAND_FINAL}]
var threshold_alt = Math.max(Q_RTL_ALT * (vehicle_dist / Math.max(radius, vehicle_dist)), Q_RTL_ALT_MIN)
var return_path = []
return_path.push({x:vehicle_dist, y:vehicle_alt})
if (vehicle_alt < threshold_alt) {
return_path.push({x:vehicle_dist, y:threshold_alt})
return_path.push({x:0, y:threshold_alt})
} else {
return_path.push({x:vehicle_dist, y:vehicle_alt})
return_path.push({x:0, y:vehicle_alt})
}
return_path.push({x:0, y:0})
if (chart == null) {
chart = new Chart("QRTL_Altitude", {
type : "scatter",
Expand All @@ -155,31 +172,46 @@ Altitude will be above terrain if terrain following is enabled, if not altitude
fill: false,
showLine: true,
lineTension: 0,
},
{
label: 'Return Path',
borderColor: "rgba(0,0,0,1)",
pointBackgroundColor: "rgba(0,0,0,1)",
data: return_path,
fill: false,
showLine: true,
lineTension: 0,
}
]
},
options: {
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}
}
],
}
y: {
scaleLabel: { display: true, labelString: "Altitude (m)" },
min: 0.0,
max: max_disp_alt
},
x: {
scaleLabel: { display: true, labelString: "Distance from home (m)" },
min: 0.0,
max: max_disp_rad
}
},
onClick: (e) => {
var canvasPosition = Chart.helpers.getRelativePosition(e, chart)
const {scales: {x, y}} = chart
vehicle_dist = x.getValueForPixel(canvasPosition.x)
vehicle_alt = y.getValueForPixel(canvasPosition.y)
update()
}
}
});
} 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.data.datasets[2].data = return_path
chart.options.scales.x.max = max_disp_rad
chart.options.scales.y.max = max_disp_alt
chart.update()
}
}
Expand Down

0 comments on commit d5bb769

Please sign in to comment.