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
...@@ -198,6 +198,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -198,6 +198,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
distance, distance,
distanceCos, distanceCos,
distanceSin, distanceSin,
distanceToTarget,
currentSinLat, currentSinLat,
currentLonRad, currentLonRad,
groundSpeed, groundSpeed,
...@@ -209,12 +210,19 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -209,12 +210,19 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed, verticalSpeed,
yawToDirection; yawToDirection;
if (this._loiter_mode if (this._loiter_mode) {
&& Math.sqrt( distanceToTarget = Math.sqrt(
Math.pow(drone._targetCoordinates.x - drone.position.x, 2) Math.pow(drone._targetCoordinates.x - drone.position.x, 2)
+ Math.pow(drone._targetCoordinates.y - drone.position.y, 2) + Math.pow(drone._targetCoordinates.y - drone.position.y, 2)
) <= this._loiter_radius) { );
newYaw = bearing - 90;
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 { } else {
newYaw = this._getNewYaw(drone, bearing, delta_time); newYaw = this._getNewYaw(drone, bearing, delta_time);
} }
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.22099.47894.60006</string> </value> <value> <string>1010.43751.23980.5597</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1691588633.42</float> <float>1692888030.77</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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