Commit 2317230a authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

erp5_officejs_drone_simulator: fix loiter

See merge request !1817
Fix loitering trajectory when the drone is closer to the center than the required radius.
parent ae7f0809
Pipeline #29634 failed with stage
in 0 seconds
......@@ -198,6 +198,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
distance,
distanceCos,
distanceSin,
distanceToTarget,
currentSinLat,
currentLonRad,
groundSpeed,
......@@ -209,12 +210,19 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed,
yawToDirection;
if (this._loiter_mode
&& Math.sqrt(
Math.pow(drone._targetCoordinates.x - drone.position.x, 2)
+ Math.pow(drone._targetCoordinates.y - drone.position.y, 2)
) <= this._loiter_radius) {
newYaw = bearing - 90;
if (this._loiter_mode) {
distanceToTarget = Math.sqrt(
Math.pow(drone._targetCoordinates.x - drone.position.x, 2)
+ Math.pow(drone._targetCoordinates.y - drone.position.y, 2)
);
if (Math.abs(distanceToTarget - this._loiter_radius) <= 1) {
newYaw = bearing - 90;
} else if (distanceToTarget < this._loiter_radius) {
newYaw = bearing - 135;
} else {
newYaw = this._getNewYaw(drone, bearing, delta_time);
}
} else {
newYaw = this._getNewYaw(drone, bearing, delta_time);
}
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.22099.47894.60006</string> </value>
<value> <string>1010.43751.23980.5597</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1691588633.42</float>
<float>1692888030.77</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment