sistemato movimento antenna tra north-up e heading up anche con heading aereo diverso da 0
This commit is contained in:
parent
14c0501451
commit
4fed8dc983
@ -360,21 +360,29 @@ class DebugPayloadRouter:
|
|||||||
|
|
||||||
# --- Propagate antenna azimuth to hub ---
|
# --- Propagate antenna azimuth to hub ---
|
||||||
if self._hub:
|
if self._hub:
|
||||||
# Get platform heading and relative antenna sweep
|
# FINAL UNDERSTANDING after testing:
|
||||||
heading_rad = scenario_dict.get(
|
# ant_nav_az appears to be in BODY coordinates (relative to platform)
|
||||||
"true_heading", scenario_dict.get("platform_azimuth")
|
# The PPI display handles the rotation based on North-Up vs Heading-Up mode
|
||||||
)
|
#
|
||||||
|
# In North-Up: antenna should stay within scan cone centered on heading
|
||||||
|
# In Heading-Up: antenna should stay within scan cone centered on nose
|
||||||
|
#
|
||||||
|
# Just pass ant_nav_az directly - let PPI handle the transformations
|
||||||
sweep_rad = scenario_dict.get("ant_nav_az")
|
sweep_rad = scenario_dict.get("ant_nav_az")
|
||||||
|
|
||||||
total_az_rad = None
|
|
||||||
if heading_rad is not None:
|
|
||||||
total_az_rad = float(heading_rad)
|
|
||||||
if sweep_rad is not None:
|
if sweep_rad is not None:
|
||||||
total_az_rad += float(sweep_rad)
|
try:
|
||||||
|
sweep_deg = math.degrees(float(sweep_rad))
|
||||||
|
|
||||||
if total_az_rad is not None:
|
# Normalize to [-180, 180]
|
||||||
az_deg = math.degrees(total_az_rad)
|
while sweep_deg > 180:
|
||||||
self._hub.set_antenna_azimuth(az_deg, timestamp=time.monotonic())
|
sweep_deg -= 360
|
||||||
|
while sweep_deg < -180:
|
||||||
|
sweep_deg += 360
|
||||||
|
|
||||||
|
self._hub.set_antenna_azimuth(sweep_deg, timestamp=time.monotonic())
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self._logger.exception("Failed to generate text/JSON for RIS debug view.")
|
self._logger.exception("Failed to generate text/JSON for RIS debug view.")
|
||||||
@ -415,42 +423,36 @@ class DebugPayloadRouter:
|
|||||||
return sc[key]
|
return sc[key]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Find platform heading and relative antenna sweep using multiple potential keys
|
# Just pass ant_nav_az directly - PPI handles transformations
|
||||||
heading_val = _find_val(
|
|
||||||
["true_heading", "platform_azimuth", "heading"], obj
|
|
||||||
)
|
|
||||||
sweep_val = _find_val(
|
sweep_val = _find_val(
|
||||||
["ant_nav_az", "antenna_azimuth", "sweep_azimuth"], obj
|
["ant_nav_az", "antenna_azimuth", "sweep_azimuth"], obj
|
||||||
)
|
)
|
||||||
|
|
||||||
total_az_val = None
|
|
||||||
if heading_val is not None:
|
|
||||||
try:
|
|
||||||
h_rad = float(heading_val)
|
|
||||||
# If heading is in degrees (> 2*pi), convert to radians
|
|
||||||
if abs(h_rad) > (2 * math.pi + 0.01):
|
|
||||||
h_rad = math.radians(h_rad)
|
|
||||||
|
|
||||||
total_az_rad = h_rad
|
|
||||||
if sweep_val is not None:
|
if sweep_val is not None:
|
||||||
|
try:
|
||||||
s_rad = float(sweep_val)
|
s_rad = float(sweep_val)
|
||||||
# If sweep is in degrees, convert
|
|
||||||
|
# If value is in degrees, convert
|
||||||
if abs(s_rad) > (2 * math.pi + 0.01):
|
if abs(s_rad) > (2 * math.pi + 0.01):
|
||||||
s_rad = math.radians(s_rad)
|
s_rad = math.radians(s_rad)
|
||||||
total_az_rad += s_rad
|
|
||||||
|
|
||||||
az_deg = math.degrees(total_az_rad)
|
sweep_deg = math.degrees(s_rad)
|
||||||
# LOGGARE IL SUCCESSO PER DEBUG
|
|
||||||
|
# Normalize to [-180, 180]
|
||||||
|
while sweep_deg > 180:
|
||||||
|
sweep_deg -= 360
|
||||||
|
while sweep_deg < -180:
|
||||||
|
sweep_deg += 360
|
||||||
|
|
||||||
self._logger.debug(
|
self._logger.debug(
|
||||||
f"Found azimuth info in JSON: heading={heading_val}, sweep={sweep_val} -> total_deg={az_deg}"
|
f"Found antenna azimuth in JSON: ant_nav_az={sweep_deg:.1f}°"
|
||||||
)
|
)
|
||||||
self._hub.set_antenna_azimuth(az_deg, timestamp=time.monotonic())
|
self._hub.set_antenna_azimuth(sweep_deg, timestamp=time.monotonic())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.debug(f"Error processing azimuth values: {e}")
|
self._logger.debug(f"Error processing antenna azimuth: {e}")
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
# self._logger.debug("No heading info found in JSON payload")
|
# self._logger.debug("No complete antenna azimuth info in JSON")
|
||||||
|
|
||||||
# Optionally capture elevation for future UI use
|
# Optionally capture elevation for future UI use
|
||||||
# plat_el = _find_val(["ant_nav_el", "platform_elevation"], obj)
|
# plat_el = _find_val(["ant_nav_el", "platform_elevation"], obj)
|
||||||
|
|||||||
@ -696,21 +696,32 @@ class PPIDisplay(ttk.Frame):
|
|||||||
else:
|
else:
|
||||||
az_float = float(az_deg)
|
az_float = float(az_deg)
|
||||||
|
|
||||||
final_az_for_plot = az_float
|
# WORKING SOLUTION confirmed by user:
|
||||||
if self.display_mode_var.get() == "Heading-Up":
|
# North-Up with heading=+10°:
|
||||||
# The incoming az_deg is absolute. To display it relative to the
|
# - Server sends ant_nav_az from +50° to -70°
|
||||||
# ownship (which is fixed at 0 deg), we subtract the ownship heading.
|
# - Add 2×heading: result is +70° to -50° ✓ CORRECT
|
||||||
final_az_for_plot -= self.ownship_heading_deg
|
#
|
||||||
|
# Heading-Up with heading=+10°:
|
||||||
|
# - Grid is rotated by -10° (via set_theta_offset)
|
||||||
|
# - Scan lines are drawn at heading ± limit
|
||||||
|
# - Antenna needs same transformation as scan lines
|
||||||
|
#
|
||||||
|
# Solution: use SAME formula for both modes
|
||||||
|
# - North-Up: add 2×heading
|
||||||
|
# - Heading-Up: add 2×heading (counter-rotates for the rotated grid)
|
||||||
|
|
||||||
|
final_az_for_plot = az_float + (2.0 * self.ownship_heading_deg)
|
||||||
|
|
||||||
|
# Normalize to [-180, 180] range
|
||||||
|
while final_az_for_plot > 180:
|
||||||
|
final_az_for_plot -= 360
|
||||||
|
while final_az_for_plot < -180:
|
||||||
|
final_az_for_plot += 360
|
||||||
|
|
||||||
# Convert final angle to theta for Matplotlib (0=N, positive=CCW)
|
# Convert final angle to theta for Matplotlib (0=N, positive=CCW)
|
||||||
theta = np.deg2rad(final_az_for_plot)
|
theta = np.deg2rad(final_az_for_plot)
|
||||||
max_r = self.ax.get_ylim()[1]
|
max_r = self.ax.get_ylim()[1]
|
||||||
|
|
||||||
# logger.debug(
|
|
||||||
# f"Rendering antenna: az_in={az_deg}, mode={self.display_mode_var.get()}, "
|
|
||||||
# f"own_hdg={self.ownship_heading_deg}, final_az={final_az_for_plot}, theta={theta}"
|
|
||||||
# )
|
|
||||||
|
|
||||||
self._antenna_line_artist.set_data([theta, theta], [0, max_r])
|
self._antenna_line_artist.set_data([theta, theta], [0, max_r])
|
||||||
self._antenna_line_artist.set_visible(True)
|
self._antenna_line_artist.set_visible(True)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user