aggiunto il calcolo dei waypoint dinamici sulla tipologia duration

This commit is contained in:
VALLONGOL 2025-10-14 14:11:16 +02:00
parent 638e4a648f
commit 77a1d87366
3 changed files with 155 additions and 121 deletions

View File

@ -1,100 +1,101 @@
x_nm,y_nm
1.7364817766693033,9.84807753012208
1.8196915585801245,9.997286852043835
1.909698355298528,10.164705993254746
2.006314644389864,10.349354914685591
2.1093529034194827,10.550253577267155
2.218625609952734,10.766421941930222
2.3339452415549684,10.99687996960557
2.4551242757915364,11.240647621223985
2.581975190227787,11.496744857716246
2.714310462429072,11.764191640013136
2.851942569960741,12.04200792904544
2.9946839903881437,12.329213685743936
3.14234720127663,12.624828871039403
3.2947446801915516,12.927873445862636
3.4516889046982575,13.237367371144403
3.612992352362098,13.552330607815493
3.7784675007484245,13.871783116806688
3.947926827422586,14.19474485904877
4.121182809949932,14.520235795472518
4.298047925895815,14.847275887008719
4.478334652825583,15.17488509458815
4.661855468304586,15.502083379141595
4.848422849898178,15.827890701599843
5.037849275171705,16.151327022893664
5.2299472216905185,16.471412303953848
5.424529167019969,16.787166505711173
5.621407588725407,17.09760958909643
5.8203949643721815,17.401761515040384
6.021303771525644,17.698642244473834
6.223946487751144,17.987271738327554
6.4281355906140325,18.26666995753233
6.6336835576796584,18.535856863018942
6.840402866513372,18.79385241571817
6.840402866513374,18.79385241571817
7.064412663195302,19.043619595904882
7.319986102939524,19.28896147814137
7.604166677012322,19.530158164789555
7.913997876679983,19.767489758211376
8.246523193208787,20.001236360768743
8.598786117865023,20.231678074823588
8.96783014191497,20.459095002737843
9.350698756624908,20.683767246873423
9.744435453261131,20.90597490959226
10.146083723089918,21.12599809325628
10.552687057377549,21.3441169002274
10.961288947390312,21.560611432867567
11.368932884394491,21.775761793538678
11.772662359656369,21.989848084602684
12.169520864442228,22.203150408421493
12.556551890018351,22.41594886735704
12.930798927651024,22.62852356377125
13.289305468606532,22.84115460002604
13.629115004151155,23.054122078483353
13.947271025551181,23.267706101505095
14.24081702407289,23.482186771453204
14.506796490982568,23.6978441906896
14.742252917546494,23.91495846157622
14.944229795030958,24.133809686474972
15.109770614702246,24.354677967747794
15.23591886782663,24.57784340775661
15.319718045670406,24.80358610886334
15.358211639499848,25.032186173429917
15.348443140581244,25.26392370381826
15.28745604018088,25.499078802390304
15.172293829565035,25.737931571507964
15.0,25.980762113533167
14.999999999999998,25.98076211353316
14.76007873005941,26.230939963143115
14.447076186168827,26.491050501357915
14.065598841372388,26.760197600053854
13.62025316871424,27.037485131107207
13.11564564123853,27.322016966394273
12.556382731989396,27.612896977791323
11.947070914010986,27.909229037174644
11.292316660347446,28.210117016420522
10.596726444042913,28.514664787405238
9.86490673814154,28.82197622200508
9.101464015687464,29.13115519209633
8.311004749724834,29.441305569555276
7.498135413297791,29.751531226258194
6.66746247945048,30.060936034081376
5.823592421227048,30.368623864901103
4.971131711671633,30.67369859059366
4.114686823828384,30.97526408303533
3.2588642307414455,31.272424214102394
2.4082704054549575,31.564282855671145
1.5675118210130687,31.84994387961786
0.7411949504599216,32.12851115781883
-0.06607373316034426,32.39908856215034
-0.8496877568035757,32.660779964488654
-1.6050406474256338,32.91268923671007
-2.3275259319823753,33.15392025069089
-3.0125371374296517,33.38357687830738
-3.6554677907233284,33.600762991435815
-4.2517114188192515,33.80458246195249
-4.796661548673278,33.99413916173369
-5.285711707241269,34.1685369626557
-5.714255421479081,34.326879736594805
-6.077686218342556,34.46827135542728
0.17452406437283513,9.998476951563912
0.2859422147817867,10.279638104623308
0.4421393353133215,10.609933583832394
0.636432547474389,10.985187585712282
0.8621389727719386,11.401224306784082
1.1125757327129193,11.853867943568899
1.3810599488042814,12.338942692587844
1.6609087425529734,12.852272750362022
1.9454392354659444,13.389682313412546
2.227968549050145,13.946995578260525
2.5018138048125236,14.520036741427065
2.7602921242600305,15.104629999433275
2.996720628899614,15.696599548800267
3.2044164402382243,16.291769586049142
3.3766966797828104,16.885964307701016
3.5068784690403216,17.475007910277
3.588278929517707,18.054724590298196
3.6142151827219164,18.620938544285714
3.578004350159902,19.169473968760666
3.472963553338606,19.696155060244156
3.4729635533386065,19.69615506024416
3.272762644392875,20.217383756990923
2.964843068011936,20.750866222507394
2.5631793345343286,21.294382991192247
2.081745954298589,21.845714597444157
1.5345174376432555,22.402641575661793
0.9354682949068648,22.962944460243826
0.2985730364279542,23.52440378558893
-0.36219382745493856,24.084800086095772
-1.032857786403277,24.641913896163032
-1.699444330078522,25.193525750189377
-2.347978948142139,25.737416182573483
-2.964487130255587,26.271365727714013
-3.5349943660803307,26.793154920009652
-4.045526145277833,27.30056429385906
-4.482107957509558,27.79137438366092
-4.830765292436963,28.263365723813894
-5.077523639721516,28.714318848716662
-5.208408489024677,29.14201429276789
-5.2094453300079095,29.544232590366253
-5.2094453300079095,29.544232590366242
-5.087215806911271,29.93160758132983
-4.8634013589893685,30.31504050771131
-4.54667716842549,30.69271300726126
-4.145718417402923,31.062806717730222
-3.6692002881049564,31.42350327686877
-3.1257979627148766,31.772984322427458
-2.5241866234159707,32.10943149215684
-1.873041452391528,32.43102642380748
-1.1810376318248348,32.735950755129934
-0.4568503438991798,33.02238612387475
0.29084522920215017,33.28851416779252
1.0533739052958677,33.53251652463377
1.822060502198683,33.75257483214907
2.5882298377273103,33.94687072808898
3.343206729698462,34.113585850204075
4.078315995928851,34.25090183624488
4.784882454235189,34.35700032396197
5.454230922434187,34.430062951105924
6.077686218342558,34.46827135542727
6.077686218342562,34.468271355427284
6.6950615437258465,34.47971290071672
7.3476044195818755,34.472832854810775
8.028791142575807,34.44634971152879
8.732098009372796,34.3989819646901
9.451001316637997,34.32944810811404
10.178977361036566,34.23646663561996
10.909502439233654,34.11875604102719
11.636052847894423,33.97503481815507
12.352104883684024,33.80402146082294
13.051134843267612,33.60443446285013
13.726619023310347,33.37499231805599
14.372033720477376,33.114413520259845
14.98085523143386,32.82141656328105
15.546559852844958,32.49471994093893
16.062623881375814,32.13304214705283
16.522523613691593,31.735101675442085
16.919735346457447,31.29961701992603
17.247735376338525,30.825306674324008
17.499999999999996,30.310889132455358
17.499999999999996,30.310889132455355
17.667951456825268,29.722378176057024
17.752649951768674,29.034858901953363
17.76202872985173,28.26065677659477
17.704021036095945,27.412097266431687
17.586560115522854,26.501505837914515
17.417579213153953,25.541207957493693
17.205011574010783,24.54352909161962
16.956790443114837,23.52079470674273
16.68084906548765,22.485330269313444
16.385120686150735,21.449461245782175
16.0775385501256,20.425513102599343
15.766035902433776,19.42581130621538
15.45854598809677,18.462681323080695
15.1630020521361,17.5484486196457
14.88733733957329,16.69543866236083
14.639485095429851,15.9159769176765
14.427378564727302,15.222388852043133
14.258950992487165,14.626999931911136
14.142135623730947,14.142135623730947

1 x_nm y_nm
2 1.7364817766693033 0.17452406437283513 9.84807753012208 9.998476951563912
3 1.8196915585801245 0.2859422147817867 9.997286852043835 10.279638104623308
4 1.909698355298528 0.4421393353133215 10.164705993254746 10.609933583832394
5 2.006314644389864 0.636432547474389 10.349354914685591 10.985187585712282
6 2.1093529034194827 0.8621389727719386 10.550253577267155 11.401224306784082
7 2.218625609952734 1.1125757327129193 10.766421941930222 11.853867943568899
8 2.3339452415549684 1.3810599488042814 10.99687996960557 12.338942692587844
9 2.4551242757915364 1.6609087425529734 11.240647621223985 12.852272750362022
10 2.581975190227787 1.9454392354659444 11.496744857716246 13.389682313412546
11 2.714310462429072 2.227968549050145 11.764191640013136 13.946995578260525
12 2.851942569960741 2.5018138048125236 12.04200792904544 14.520036741427065
13 2.9946839903881437 2.7602921242600305 12.329213685743936 15.104629999433275
14 3.14234720127663 2.996720628899614 12.624828871039403 15.696599548800267
15 3.2947446801915516 3.2044164402382243 12.927873445862636 16.291769586049142
16 3.4516889046982575 3.3766966797828104 13.237367371144403 16.885964307701016
17 3.612992352362098 3.5068784690403216 13.552330607815493 17.475007910277
18 3.7784675007484245 3.588278929517707 13.871783116806688 18.054724590298196
19 3.947926827422586 3.6142151827219164 14.19474485904877 18.620938544285714
20 4.121182809949932 3.578004350159902 14.520235795472518 19.169473968760666
21 4.298047925895815 3.472963553338606 14.847275887008719 19.696155060244156
22 4.478334652825583 3.4729635533386065 15.17488509458815 19.69615506024416
23 4.661855468304586 3.272762644392875 15.502083379141595 20.217383756990923
24 4.848422849898178 2.964843068011936 15.827890701599843 20.750866222507394
25 5.037849275171705 2.5631793345343286 16.151327022893664 21.294382991192247
26 5.2299472216905185 2.081745954298589 16.471412303953848 21.845714597444157
27 5.424529167019969 1.5345174376432555 16.787166505711173 22.402641575661793
28 5.621407588725407 0.9354682949068648 17.09760958909643 22.962944460243826
29 5.8203949643721815 0.2985730364279542 17.401761515040384 23.52440378558893
30 6.021303771525644 -0.36219382745493856 17.698642244473834 24.084800086095772
31 6.223946487751144 -1.032857786403277 17.987271738327554 24.641913896163032
32 6.4281355906140325 -1.699444330078522 18.26666995753233 25.193525750189377
33 6.6336835576796584 -2.347978948142139 18.535856863018942 25.737416182573483
34 6.840402866513372 -2.964487130255587 18.79385241571817 26.271365727714013
35 6.840402866513374 -3.5349943660803307 18.79385241571817 26.793154920009652
36 7.064412663195302 -4.045526145277833 19.043619595904882 27.30056429385906
37 7.319986102939524 -4.482107957509558 19.28896147814137 27.79137438366092
38 7.604166677012322 -4.830765292436963 19.530158164789555 28.263365723813894
39 7.913997876679983 -5.077523639721516 19.767489758211376 28.714318848716662
40 8.246523193208787 -5.208408489024677 20.001236360768743 29.14201429276789
41 8.598786117865023 -5.2094453300079095 20.231678074823588 29.544232590366253
42 8.96783014191497 -5.2094453300079095 20.459095002737843 29.544232590366242
43 9.350698756624908 -5.087215806911271 20.683767246873423 29.93160758132983
44 9.744435453261131 -4.8634013589893685 20.90597490959226 30.31504050771131
45 10.146083723089918 -4.54667716842549 21.12599809325628 30.69271300726126
46 10.552687057377549 -4.145718417402923 21.3441169002274 31.062806717730222
47 10.961288947390312 -3.6692002881049564 21.560611432867567 31.42350327686877
48 11.368932884394491 -3.1257979627148766 21.775761793538678 31.772984322427458
49 11.772662359656369 -2.5241866234159707 21.989848084602684 32.10943149215684
50 12.169520864442228 -1.873041452391528 22.203150408421493 32.43102642380748
51 12.556551890018351 -1.1810376318248348 22.41594886735704 32.735950755129934
52 12.930798927651024 -0.4568503438991798 22.62852356377125 33.02238612387475
53 13.289305468606532 0.29084522920215017 22.84115460002604 33.28851416779252
54 13.629115004151155 1.0533739052958677 23.054122078483353 33.53251652463377
55 13.947271025551181 1.822060502198683 23.267706101505095 33.75257483214907
56 14.24081702407289 2.5882298377273103 23.482186771453204 33.94687072808898
57 14.506796490982568 3.343206729698462 23.6978441906896 34.113585850204075
58 14.742252917546494 4.078315995928851 23.91495846157622 34.25090183624488
59 14.944229795030958 4.784882454235189 24.133809686474972 34.35700032396197
60 15.109770614702246 5.454230922434187 24.354677967747794 34.430062951105924
61 15.23591886782663 6.077686218342558 24.57784340775661 34.46827135542727
62 15.319718045670406 6.077686218342562 24.80358610886334 34.468271355427284
63 15.358211639499848 6.6950615437258465 25.032186173429917 34.47971290071672
64 15.348443140581244 7.3476044195818755 25.26392370381826 34.472832854810775
65 15.28745604018088 8.028791142575807 25.499078802390304 34.44634971152879
66 15.172293829565035 8.732098009372796 25.737931571507964 34.3989819646901
67 15.0 9.451001316637997 25.980762113533167 34.32944810811404
68 14.999999999999998 10.178977361036566 25.98076211353316 34.23646663561996
69 14.76007873005941 10.909502439233654 26.230939963143115 34.11875604102719
70 14.447076186168827 11.636052847894423 26.491050501357915 33.97503481815507
71 14.065598841372388 12.352104883684024 26.760197600053854 33.80402146082294
72 13.62025316871424 13.051134843267612 27.037485131107207 33.60443446285013
73 13.11564564123853 13.726619023310347 27.322016966394273 33.37499231805599
74 12.556382731989396 14.372033720477376 27.612896977791323 33.114413520259845
75 11.947070914010986 14.98085523143386 27.909229037174644 32.82141656328105
76 11.292316660347446 15.546559852844958 28.210117016420522 32.49471994093893
77 10.596726444042913 16.062623881375814 28.514664787405238 32.13304214705283
78 9.86490673814154 16.522523613691593 28.82197622200508 31.735101675442085
79 9.101464015687464 16.919735346457447 29.13115519209633 31.29961701992603
80 8.311004749724834 17.247735376338525 29.441305569555276 30.825306674324008
81 7.498135413297791 17.499999999999996 29.751531226258194 30.310889132455358
82 6.66746247945048 17.499999999999996 30.060936034081376 30.310889132455355
83 5.823592421227048 17.667951456825268 30.368623864901103 29.722378176057024
84 4.971131711671633 17.752649951768674 30.67369859059366 29.034858901953363
85 4.114686823828384 17.76202872985173 30.97526408303533 28.26065677659477
86 3.2588642307414455 17.704021036095945 31.272424214102394 27.412097266431687
87 2.4082704054549575 17.586560115522854 31.564282855671145 26.501505837914515
88 1.5675118210130687 17.417579213153953 31.84994387961786 25.541207957493693
89 0.7411949504599216 17.205011574010783 32.12851115781883 24.54352909161962
90 -0.06607373316034426 16.956790443114837 32.39908856215034 23.52079470674273
91 -0.8496877568035757 16.68084906548765 32.660779964488654 22.485330269313444
92 -1.6050406474256338 16.385120686150735 32.91268923671007 21.449461245782175
93 -2.3275259319823753 16.0775385501256 33.15392025069089 20.425513102599343
94 -3.0125371374296517 15.766035902433776 33.38357687830738 19.42581130621538
95 -3.6554677907233284 15.45854598809677 33.600762991435815 18.462681323080695
96 -4.2517114188192515 15.1630020521361 33.80458246195249 17.5484486196457
97 -4.796661548673278 14.88733733957329 33.99413916173369 16.69543866236083
98 -5.285711707241269 14.639485095429851 34.1685369626557 15.9159769176765
99 -5.714255421479081 14.427378564727302 34.326879736594805 15.222388852043133
100 -6.077686218342556 14.258950992487165 34.46827135542728 14.626999931911136
101 14.142135623730947 14.142135623730947

View File

@ -114,7 +114,7 @@
"target_azimuth_deg": 45.0
}
],
"use_spline": true
"use_spline": false
},
{
"target_id": 1,
@ -170,6 +170,20 @@
"target_altitude_ft": 10000.0,
"target_range_nm": 20.0,
"target_azimuth_deg": 0.0
},
{
"maneuver_type": "Fly for Duration",
"target_velocity_fps": 506.343,
"target_heading_deg": 90.0,
"duration_s": 20.0,
"target_altitude_ft": 10000.0
},
{
"maneuver_type": "Fly for Duration",
"target_velocity_fps": 506.343,
"target_heading_deg": 180.0,
"duration_s": 10.0,
"target_altitude_ft": 10000.0
}
],
"use_spline": false

View File

@ -195,21 +195,18 @@ class PPIDisplay(ttk.Frame):
# (la preview spline cancella la classica)
# Costruisci la lista dei punti da visualizzare
points = []
# Stato corrente: range/azimuth
curr_r = None
curr_theta = None
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))
curr_r = getattr(wp, 'target_range_nm', 0)
curr_theta = math.radians(getattr(wp, 'target_azimuth_deg', 0))
points.append((curr_theta, curr_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
# Se non c'è punto iniziale, ignora
if curr_r is None or curr_theta is None:
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)
@ -217,9 +214,11 @@ class PPIDisplay(ttk.Frame):
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))
theta1 = curr_theta + heading_rad
r1 = curr_r + dr
curr_r = r1
curr_theta = theta1
points.append((curr_theta, curr_r, wp))
thetas = [p[0] for p in points]
rs = [p[1] for p in points]
if len(thetas) == 1:
@ -259,13 +258,33 @@ class PPIDisplay(ttk.Frame):
start_theta = thetas[0]
start_r = rs[0]
self._start_plot.set_data([start_theta], [start_r])
heading_len = 3
heading_theta = start_theta
heading_r2 = start_r + heading_len
# Cancella eventuali frecce precedenti
if hasattr(self, '_heading_artist'):
self._heading_artist.remove()
self._heading_artist, = self.ax.plot([start_theta, heading_theta], [start_r, heading_r2], color='red', linewidth=1, alpha=0.8)
# Heading dal primo waypoint
wp0 = points[0][2]
heading_deg = getattr(wp0, 'target_heading_deg', None)
if heading_deg is not None:
h_rad = math.radians(heading_deg)
vector_len = self.max_range / 25
x1, y1 = start_r * math.sin(start_theta), start_r * math.cos(start_theta)
dx, dy = vector_len * math.sin(h_rad), vector_len * math.cos(h_rad)
x2, y2 = x1 + dx, y1 + dy
r2, th2 = math.sqrt(x2**2 + y2**2), math.atan2(x2, y2)
if hasattr(self, '_heading_artist'):
self._heading_artist.remove()
self._heading_artist, = self.ax.plot([start_theta, th2], [start_r, r2], color='red', linewidth=1.2)
# Heading per ogni punto finale FLY_FOR_DURATION
for i, (theta, r, wp) in enumerate(points):
if i == 0:
continue
if getattr(wp, 'maneuver_type', None) == ManeuverType.FLY_FOR_DURATION:
heading_deg = getattr(wp, 'target_heading_deg', None)
if heading_deg is not None:
h_rad = math.radians(heading_deg)
vector_len = self.max_range / 25
x1, y1 = r * math.sin(theta), r * math.cos(theta)
dx, dy = vector_len * math.sin(h_rad), vector_len * math.cos(h_rad)
x2, y2 = x1 + dx, y1 + dy
r2, th2 = math.sqrt(x2**2 + y2**2), math.atan2(x2, y2)
self.ax.plot([theta, th2], [r, r2], color='red', linewidth=1.2)
else:
# Assume Target object with trajectory and use_spline
waypoints = getattr(trajectory, "trajectory", [])