aggiunta la preview dei movimenti di tipo duration
This commit is contained in:
parent
8449e36c1c
commit
638e4a648f
@ -122,8 +122,10 @@ class Target:
|
|||||||
total_duration = sum(wp.duration_s or 0.0 for wp in self.trajectory if wp.duration_s)
|
total_duration = sum(wp.duration_s or 0.0 for wp in self.trajectory if wp.duration_s)
|
||||||
|
|
||||||
# Create a time mapping for each point in the spline path
|
# Create a time mapping for each point in the spline path
|
||||||
|
if self._spline_path is not None and len(self._spline_path) > 1:
|
||||||
self._spline_point_times = [i * (total_duration / (len(self._spline_path) - 1)) for i in range(len(self._spline_path))]
|
self._spline_point_times = [i * (total_duration / (len(self._spline_path) - 1)) for i in range(len(self._spline_path))]
|
||||||
if not self._spline_point_times: self._spline_point_times = [0.0]
|
else:
|
||||||
|
self._spline_point_times = [0.0]
|
||||||
|
|
||||||
self._update_current_polar_coords()
|
self._update_current_polar_coords()
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import numpy as np
|
|||||||
import copy
|
import copy
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
||||||
|
from target_simulator.core.models import NM_TO_FT
|
||||||
|
|
||||||
# Use absolute imports
|
# Use absolute imports
|
||||||
from target_simulator.core.models import Target, Waypoint, ManeuverType
|
from target_simulator.core.models import Target, Waypoint, ManeuverType
|
||||||
@ -192,8 +193,35 @@ class PPIDisplay(ttk.Frame):
|
|||||||
return
|
return
|
||||||
# Classic preview (polyline) SOLO se spline non attiva
|
# Classic preview (polyline) SOLO se spline non attiva
|
||||||
# (la preview spline cancella la classica)
|
# (la preview spline cancella la classica)
|
||||||
thetas = [math.radians(getattr(wp, 'target_azimuth_deg', 0)) for wp in waypoints]
|
# Costruisci la lista dei punti da visualizzare
|
||||||
rs = [getattr(wp, 'target_range_nm', 0) for wp in waypoints]
|
points = []
|
||||||
|
for i, wp in enumerate(waypoints):
|
||||||
|
if getattr(wp, 'maneuver_type', None) == ManeuverType.FLY_TO_POINT:
|
||||||
|
# Usa range/azimuth
|
||||||
|
r = getattr(wp, 'target_range_nm', 0)
|
||||||
|
theta = math.radians(getattr(wp, 'target_azimuth_deg', 0))
|
||||||
|
points.append((theta, r, wp))
|
||||||
|
elif getattr(wp, 'maneuver_type', None) == ManeuverType.FLY_FOR_DURATION:
|
||||||
|
# Calcola punto terminale
|
||||||
|
# Serve punto di partenza
|
||||||
|
if i == 0:
|
||||||
|
# Se non c'è punto iniziale, ignora
|
||||||
|
continue
|
||||||
|
prev_wp = waypoints[i-1]
|
||||||
|
r0 = getattr(prev_wp, 'target_range_nm', 0)
|
||||||
|
theta0 = math.radians(getattr(prev_wp, 'target_azimuth_deg', 0))
|
||||||
|
vel_fps = getattr(wp, 'target_velocity_fps', 0)
|
||||||
|
vel_nmps = vel_fps / NM_TO_FT if vel_fps else 0
|
||||||
|
duration = getattr(wp, 'duration_s', 0)
|
||||||
|
heading_deg = getattr(wp, 'target_heading_deg', 0)
|
||||||
|
heading_rad = math.radians(heading_deg)
|
||||||
|
# Calcola delta x/y in coordinate polari
|
||||||
|
dr = vel_nmps * duration
|
||||||
|
theta1 = theta0 + heading_rad
|
||||||
|
r1 = r0 + dr
|
||||||
|
points.append((theta1, r1, wp))
|
||||||
|
thetas = [p[0] for p in points]
|
||||||
|
rs = [p[1] for p in points]
|
||||||
if len(thetas) == 1:
|
if len(thetas) == 1:
|
||||||
# Mostra solo il punto iniziale con stile simulazione
|
# Mostra solo il punto iniziale con stile simulazione
|
||||||
self._preview_artist.set_data([], [])
|
self._preview_artist.set_data([], [])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user