Skip to content

Commit 118b631

Browse files
committed
Adjust altitude calculation in geo_util.py to align with AirSim's origin settings
1 parent 140e79a commit 118b631

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎backend/PythonClient/multirotor/util/geo/geo_util.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def geo_to_cartesian_coordinates(lat, long, alt, cesium_origin):
8484
ratio = GeoUtil.geo_to_cartesian_ratio(lat)
8585
y = lat * ratio - cesium_origin[0] * ratio
8686
x = long * EQUATORIAL_RATIO - cesium_origin[1] * EQUATORIAL_RATIO
87-
# z is negative because in unreal, -z is up
88-
z = -alt
87+
# Altitude is relative to the Cesium origin in AirSim settings.
88+
# Preserve the configured-minus-origin sign convention used by the
89+
# frontend and AirSim's Unreal Z axis.
90+
z = alt - cesium_origin[2]
8991
return x, y, z
9092

9193
@staticmethod
@@ -101,7 +103,8 @@ def geo_to_cartesian_coordinates_spawn(lat, long, alt, cesium_origin):
101103
ratio = GeoUtil.geo_to_cartesian_ratio(lat)
102104
y = lat * ratio - cesium_origin[0] * ratio
103105
x = long * EQUATORIAL_RATIO - cesium_origin[1] * EQUATORIAL_RATIO
104-
z = -alt
106+
# AirSim settings use the configured altitude relative to the origin.
107+
z = alt - cesium_origin[2]
105108
return x, y, z
106109

107110
@staticmethod

0 commit comments

Comments
 (0)