]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.cxx
Boris Koenig:
[flightgear.git] / src / AIModel / AIFlightPlan.cxx
1 // FGAIFlightPlan - class for loading and storing  AI flight plans
2 // Written by David Culp, started May 2004
3 // - davidculp2@comcast.net
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19
20
21 #include <simgear/misc/sg_path.hxx>
22 #include <simgear/debug/logstream.hxx>
23 #include <simgear/route/waypoint.hxx>
24 #include <simgear/math/sg_geodesy.hxx>
25 #include <simgear/structure/exception.hxx>
26 #include <simgear/constants.h>
27 #ifdef __BORLANDC__
28 #  define exception c_exception
29 #endif
30 #include <simgear/props/props.hxx>
31 #include <Main/globals.hxx>
32 #include <Main/fg_props.hxx>
33 #include <Main/fg_init.hxx>
34 #include <Airports/simple.hxx>
35 #include <Airports/runways.hxx>
36
37
38 #include <Environment/environment_mgr.hxx>
39 #include <Environment/environment.hxx>
40
41 #include "AIFlightPlan.hxx"
42
43
44 FGAIFlightPlan::FGAIFlightPlan(string filename)
45 {
46   int i;
47   SGPath path( globals->get_fg_root() );
48   path.append( ("/Data/AI/FlightPlans/" + filename).c_str() );
49   SGPropertyNode root;
50
51   try {
52       readProperties(path.str(), &root);
53   } catch (const sg_exception &e) {
54       SG_LOG(SG_GENERAL, SG_ALERT,
55        "Error reading AI flight plan: ");
56        cout << path.str() << endl;
57       return;
58   }
59
60   SGPropertyNode * node = root.getNode("flightplan");
61   for (i = 0; i < node->nChildren(); i++) { 
62      //cout << "Reading waypoint " << i << endl;        
63      waypoint* wpt = new waypoint;
64      SGPropertyNode * wpt_node = node->getChild(i);
65      wpt->name      = wpt_node->getStringValue("name", "END");
66      wpt->latitude  = wpt_node->getDoubleValue("lat", 0);
67      wpt->longitude = wpt_node->getDoubleValue("lon", 0);
68      wpt->altitude  = wpt_node->getDoubleValue("alt", 0);
69      wpt->speed     = wpt_node->getDoubleValue("ktas", 0);
70      wpt->crossat   = wpt_node->getDoubleValue("crossat", -10000);
71      wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
72      wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
73      wpt->on_ground = wpt_node->getBoolValue("on-ground", false);
74
75      if (wpt->name == "END") wpt->finished = true;
76      else wpt->finished = false;
77
78      waypoints.push_back( wpt );
79    }
80
81   wpt_iterator = waypoints.begin();
82   //cout << waypoints.size() << " waypoints read." << endl;
83 }
84
85
86 // This is a modified version of the constructor,
87 // Which not only reads the waypoints from a 
88 // Flight plan file, but also adds the current
89 // Position computed by the traffic manager, as well
90 // as setting speeds and altitude computed by the
91 // traffic manager. 
92 FGAIFlightPlan::FGAIFlightPlan(FGAIModelEntity *entity,
93                                double course, 
94                                FGAirport *dep,
95                                FGAirport *arr)
96 {
97   bool useInitialWayPoint = true;
98   bool useCurrentWayPoint = false;
99   SGPath path( globals->get_fg_root() );
100   path.append( "/Data/AI/FlightPlans" );
101   path.append( entity->path );
102   SGPropertyNode root;
103
104   try {
105     readProperties(path.str(), &root);
106     
107     SGPropertyNode * node = root.getNode("flightplan");
108   
109     //waypoints.push_back( init_waypoint );
110     for (int i = 0; i < node->nChildren(); i++) { 
111       //cout << "Reading waypoint " << i << endl;
112       waypoint* wpt = new waypoint;
113       SGPropertyNode * wpt_node = node->getChild(i);
114       wpt->name      = wpt_node->getStringValue("name", "END");
115       wpt->latitude  = wpt_node->getDoubleValue("lat", 0);
116       wpt->longitude = wpt_node->getDoubleValue("lon", 0);
117       wpt->altitude  = wpt_node->getDoubleValue("alt", 0);
118       wpt->speed     = wpt_node->getDoubleValue("ktas", 0);
119       //wpt->speed     = speed;
120       wpt->crossat   = wpt_node->getDoubleValue("crossat", -10000);
121       wpt->gear_down = wpt_node->getBoolValue("gear-down", false);
122       wpt->flaps_down= wpt_node->getBoolValue("flaps-down", false);
123       
124       if (wpt->name == "END") wpt->finished = true;
125       else wpt->finished = false;
126       waypoints.push_back(wpt);
127     }
128   }
129   catch (const sg_exception &e) {
130     //SG_LOG(SG_GENERAL, SG_ALERT,
131     // "Error reading AI flight plan: ");
132     // cout << path.str() << endl;
133     // cout << "Trying to create this plan dynamically" << endl;
134     // cout << "Route from " << dep->id << " to " << arr->id << endl;
135        create(dep,arr, entity->altitude, entity->speed);
136        // Now that we have dynamically created a flight plan,
137        // we need to add some code that pops any waypoints already past.
138        //return;
139   }
140   waypoint* init_waypoint   = new waypoint;
141   init_waypoint->name       = string("initial position");
142   init_waypoint->latitude   = entity->latitude;
143   init_waypoint->longitude  = entity->longitude;
144   init_waypoint->altitude   = entity->altitude;
145   init_waypoint->speed      = entity->speed;
146   init_waypoint->crossat    = - 10000;
147   init_waypoint->gear_down  = false;
148   init_waypoint->flaps_down = false;
149   init_waypoint->finished   = false;
150
151   wpt_vector_iterator i = waypoints.begin();
152   while (i != waypoints.end())
153     {
154       //cerr << "Checking status of each waypoint: " << (*i)->name << endl;
155        SGWayPoint first(init_waypoint->longitude, 
156                        init_waypoint->latitude, 
157                        init_waypoint->altitude);
158       SGWayPoint curr ((*i)->longitude, 
159                        (*i)->latitude, 
160                        (*i)->altitude);
161       double crse, crsDiff;
162       double dist;
163       first.CourseAndDistance(curr, &crse, &dist);
164       
165       dist *= SG_METER_TO_NM;
166       
167       // We're only interested in the absolute value of crsDiff
168       // wich should fall in the 0-180 deg range.
169       crsDiff = fabs(crse-course);
170       if (crsDiff > 180)
171         crsDiff = 360-crsDiff;
172       // These are the three conditions that we consider including
173       // in our flight plan:
174       // 1) current waypoint is less then 100 miles away OR
175       // 2) curren waypoint is ahead of us, at any distance
176      
177       if ((dist > 20.0) && (crsDiff > 90.0) && ((*i)->name != string ("EOF")))
178         {
179           //useWpt = false;
180           // Once we start including waypoints, we have to continue, even though
181           // one of the following way point would suffice. 
182           // so once is the useWpt flag is set to true, we cannot reset it to false.
183           //cerr << "Discarding waypoint: " << (*i)->name 
184           //   << ": Course difference = " << crsDiff
185           //   << "Course = " << course
186           //   << "crse   = " << crse << endl;
187         }
188       else
189         useCurrentWayPoint = true;
190       
191       if (useCurrentWayPoint)
192         {
193           if ((dist > 100.0) && (useInitialWayPoint))
194             {
195               //waypoints.push_back(init_waypoint);
196               waypoints.insert(i, init_waypoint);
197               //cerr << "Using waypoint : " << init_waypoint->name <<  endl;
198             }
199           //waypoints.push_back( wpt );
200           //cerr << "Using waypoint : " << (*i)->name 
201           //  << ": course diff : " << crsDiff 
202           //   << "Course = " << course
203           //   << "crse   = " << crse << endl
204           //    << "distance      : " << dist << endl;
205           useInitialWayPoint = false;
206           i++;
207         }
208       else 
209         {
210           //delete wpt;
211           delete *(i);
212           i = waypoints.erase(i);
213         }
214     }
215   //for (i = waypoints.begin(); i != waypoints.end(); i++)
216   //  cerr << "Using waypoint : " << (*i)->name << endl;
217   wpt_iterator = waypoints.begin();
218   //cout << waypoints.size() << " waypoints read." << endl;
219 }
220
221
222
223
224 FGAIFlightPlan::~FGAIFlightPlan()
225 {
226   waypoints.clear();
227 }
228
229
230 FGAIFlightPlan::waypoint*
231 FGAIFlightPlan::getPreviousWaypoint( void )
232 {
233   if (wpt_iterator == waypoints.begin()) {
234     return 0;
235   } else {
236     wpt_vector_iterator prev = wpt_iterator;
237     return *(--prev);
238   }
239 }
240
241 FGAIFlightPlan::waypoint*
242 FGAIFlightPlan::getCurrentWaypoint( void )
243 {
244   return *wpt_iterator;
245 }
246
247 FGAIFlightPlan::waypoint*
248 FGAIFlightPlan::getNextWaypoint( void )
249 {
250   if (wpt_iterator == waypoints.end()) {
251     return 0;
252   } else {
253     wpt_vector_iterator next = wpt_iterator;
254     return *(++next);
255   }
256 }
257
258 void FGAIFlightPlan::IncrementWaypoint( void )
259 {
260   wpt_iterator++;
261 }
262
263 // gives distance in feet from a position to a waypoint
264 double FGAIFlightPlan::getDistanceToGo(double lat, double lon, waypoint* wp){
265    // get size of a degree at the present latitude
266    // this won't work over large distances
267    double ft_per_deg_lat = 366468.96 - 3717.12 * cos(lat / SG_RADIANS_TO_DEGREES);
268    double ft_per_deg_lon = 365228.16 * cos(lat / SG_RADIANS_TO_DEGREES);
269    double lat_diff_ft = fabs(wp->latitude - lat) * ft_per_deg_lat;
270    double lon_diff_ft = fabs(wp->longitude - lon) * ft_per_deg_lon;
271    return sqrt((lat_diff_ft * lat_diff_ft) + (lon_diff_ft * lon_diff_ft));
272 }
273
274 // sets distance in feet from a lead point to the current waypoint
275 void FGAIFlightPlan::setLeadDistance(double speed, double bearing, 
276                                      waypoint* current, waypoint* next){
277   double turn_radius = 0.1911 * speed * speed; // an estimate for 25 degrees bank
278   double inbound = bearing;
279   double outbound = getBearing(current, next);
280   double diff = fabs(inbound - outbound);
281   if (diff > 180.0) diff = 360.0 - diff;
282   lead_distance = turn_radius * sin(diff * SG_DEGREES_TO_RADIANS); 
283 }
284
285 void FGAIFlightPlan::setLeadDistance(double distance_ft){
286   lead_distance = distance_ft;
287 }
288
289
290 double FGAIFlightPlan::getBearing(waypoint* first, waypoint* second){
291   return getBearing(first->latitude, first->longitude, second);
292 }
293
294
295 double FGAIFlightPlan::getBearing(double lat, double lon, waypoint* wp){
296   double course, distance;
297  //  double latd = lat;
298 //   double lond = lon;
299 //   double latt = wp->latitude;
300 //   double lont = wp->longitude;
301 //   double ft_per_deg_lat = 366468.96 - 3717.12 * cos(lat/SG_RADIANS_TO_DEGREES);
302 //   double ft_per_deg_lon = 365228.16 * cos(lat/SG_RADIANS_TO_DEGREES);
303
304 //   if (lond < 0.0) {
305 //     lond+=360.0;
306 //     lont+=360;
307 //   }
308 //   if (lont < 0.0) {
309 //     lond+=360.0;
310 //     lont+=360.0;
311 //   }
312 //   latd+=90.0;
313 //   latt+=90.0;
314
315 //   double lat_diff = (latt - latd) * ft_per_deg_lat;
316 //   double lon_diff = (lont - lond) * ft_per_deg_lon;
317 //   double angle = atan(fabs(lat_diff / lon_diff)) * SG_RADIANS_TO_DEGREES;
318
319 //   bool southerly = true;
320 //   if (latt > latd) southerly = false;
321 //   bool easterly = false;
322 //   if (lont > lond) easterly = true;
323 //   if (southerly && easterly) return 90.0 + angle;
324 //   if (!southerly && easterly) return 90.0 - angle;
325 //   if (southerly && !easterly) return 270.0 - angle;
326 //   if (!southerly && !easterly) return 270.0 + angle; 
327   SGWayPoint sgWp(wp->longitude,wp->latitude, wp->altitude, SGWayPoint::WGS84, string("temp"));
328   sgWp.CourseAndDistance(lon, lat, wp->altitude, &course, &distance);
329   return course;
330   // Omit a compiler warning.
331  
332 }
333
334 /* FGAIFlightPlan::create()
335  * dynamically create a flight plan for AI traffic, based on data provided by the
336  * Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10) 
337  *
338  * Probably need to split this into separate functions for different parts of the flight
339
340  * once the code matures a bit more.
341  *
342  */ 
343 void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, double alt, double speed)
344 {
345   double wind_speed;
346   double wind_heading;
347   FGRunway rwy;
348   
349   //waypoints.push_back(wpt);
350   // Create the outbound taxi leg, for now simplified as a 
351   // Direct route from the airport center point to the start
352   // of the runway.
353   ///////////////////////////////////////////////////////////
354       //cerr << "Cruise Alt << " << alt << endl;
355   waypoint *wpt = new waypoint;
356   wpt->name      = dep->id; //wpt_node->getStringValue("name", "END");
357   wpt->latitude  = dep->latitude;
358   wpt->longitude = dep->longitude;
359   wpt->altitude  = dep->elevation + 19; // probably need to add some model height to it
360   wpt->speed     = 15; 
361   wpt->crossat   = -10000;
362   wpt->gear_down = true;
363   wpt->flaps_down= true;
364   wpt->finished  = false;
365   waypoints.push_back(wpt);
366   
367   // Get the current active runway, based on code from David Luff
368   FGEnvironment 
369     stationweather = ((FGEnvironmentMgr *) globals->get_subsystem("environment"))
370     ->getEnvironment(dep->latitude, dep->longitude, dep->elevation);
371   
372   wind_speed = stationweather.get_wind_speed_kt();
373   wind_heading = stationweather.get_wind_from_heading_deg();
374   if (wind_speed == 0) {
375     wind_heading = 270; // This forces West-facing rwys to be used in no-wind situations
376                         // which is consistent with Flightgear's initial setup.
377   }
378   
379   string rwy_no = globals->get_runways()->search(dep->id, int(wind_heading));
380   if (!(globals->get_runways()->search(dep->id, (int) wind_heading, &rwy )))
381     {
382       cout << "Failed to find runway for " << dep->id << endl;
383       // Hmm, how do we handle a potential error like this?
384       exit(1);
385     }
386
387   double lat, lon, az;
388   double lat2, lon2, az2;
389   double heading = rwy.heading;
390   double azimuth = heading + 180.0;
391   while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
392   geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
393                       rwy.length * SG_FEET_TO_METER * 0.5 - 5.0,
394                       &lat2, &lon2, &az2 );
395   
396   //Add the runway startpoint;
397   wpt = new waypoint;
398   wpt->name      = rwy.id;
399   wpt->latitude  = lat2;
400   wpt->longitude = lon2;
401   wpt->altitude  = dep->elevation + 19;
402   wpt->speed     = 15; 
403   wpt->crossat   = -10000;
404   wpt->gear_down = true;
405   wpt->flaps_down= true;
406   wpt->finished  = false;
407   wpt->on_ground = true;
408   waypoints.push_back(wpt);
409
410   //Next: The point on the runway where we begin to accelerate to take-off speed
411   //100 meters down the runway seems to work. Shorter distances cause problems with
412   // the turn with larger aircraft
413   geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
414                       rwy.length * SG_FEET_TO_METER * 0.5 - 105.0,
415                       &lat2, &lon2, &az2 );
416   wpt = new waypoint;
417   wpt->name      = "accel";
418   wpt->latitude  = lat2;
419   wpt->longitude = lon2;
420   wpt->altitude  = dep->elevation + 19;
421   wpt->speed     = speed; 
422   wpt->crossat   = -10000;
423   wpt->gear_down = true;
424   wpt->flaps_down= true;
425   wpt->finished  = false;
426   wpt->on_ground = true;
427   waypoints.push_back(wpt); 
428   
429   lat = lat2;
430   lon = lon2;
431   az  = az2;
432
433  //Next: the Start of Climb
434   geo_direct_wgs_84 ( 0, lat, lon, heading, 
435                       2560 * SG_FEET_TO_METER,
436                       &lat2, &lon2, &az2 );
437
438   wpt = new waypoint;
439   wpt->name      = "SOC";
440   wpt->latitude  = lat2;
441   wpt->longitude = lon2;
442   wpt->altitude  = alt + 19;
443   wpt->speed     = speed; 
444   wpt->crossat   = -10000;
445   wpt->gear_down = true;
446   wpt->flaps_down= true;
447   wpt->finished  = false;
448   wpt->on_ground = false;
449   waypoints.push_back(wpt); 
450
451 //Next: the Top of Climb
452   geo_direct_wgs_84 ( 0, lat, lon, heading, 
453                       20*SG_NM_TO_METER,
454                       &lat2, &lon2, &az2 );
455   wpt = new waypoint;
456   wpt->name      = "10000ft climb";
457   wpt->latitude  = lat2;
458   wpt->longitude = lon2;
459   wpt->altitude  = 10000;
460   wpt->speed     = speed; 
461   wpt->crossat   = -10000;
462   wpt->gear_down = true;
463   wpt->flaps_down= true;
464   wpt->finished  = false;
465   wpt->on_ground = false;
466   waypoints.push_back(wpt); 
467
468
469
470   //Beginning of Decent
471   stationweather = ((FGEnvironmentMgr *)globals->get_subsystem("environment"))
472     ->getEnvironment(arr->latitude, arr->longitude, arr->elevation);
473
474   wind_speed = stationweather.get_wind_speed_kt();
475   wind_heading = stationweather.get_wind_from_heading_deg();
476
477   if (wind_speed == 0) {
478     wind_heading = 270; // This forces West-facing rwys to be used in no-wind situations
479                         // which is consistent with Flightgear's initial setup.
480   }
481
482   rwy_no = globals->get_runways()->search(arr->id, int(wind_heading));
483   //cout << "Using runway # " << rwy_no << " for departure at " << dep->id << endl;
484   
485    if (!(globals->get_runways()->search(arr->id, (int) wind_heading, &rwy )))
486     {
487       cout << "Failed to find runway for " << arr->id << endl;
488       // Hmm, how do we handle a potential error like this?
489       exit(1);
490     }
491   //cerr << "Done" << endl;
492  heading = rwy.heading;
493  azimuth = heading + 180.0;
494  while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
495
496  
497
498  geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
499                      100000,
500                      &lat2, &lon2, &az2 );
501   wpt = new waypoint;
502   wpt->name      = "BOD"; //wpt_node->getStringValue("name", "END");
503   wpt->latitude  = lat2;
504   wpt->longitude = lon2;
505   wpt->altitude  = 10000;
506   wpt->speed     = speed; 
507   wpt->crossat   = alt +19;
508   wpt->gear_down = false;
509   wpt->flaps_down= false;
510   wpt->finished  = false;
511   wpt->on_ground = false;
512   waypoints.push_back(wpt); 
513
514   // Ten thousand ft. Slowing down to 240 kts
515   geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
516                      20*SG_NM_TO_METER,
517                      &lat2, &lon2, &az2 );
518   wpt = new waypoint;
519   wpt->name      = "Dec 10000ft"; //wpt_node->getStringValue("name", "END");
520   wpt->latitude  = lat2;
521   wpt->longitude = lon2;
522   wpt->altitude  = arr->elevation + 19;
523   wpt->speed     = 240; 
524   wpt->crossat   = 10000;
525   wpt->gear_down = false;
526   wpt->flaps_down= false;
527   wpt->finished  = false;
528   wpt->on_ground = false;
529   waypoints.push_back(wpt);  
530
531   // Three thousand ft. Slowing down to 160 kts
532   geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
533                      8*SG_NM_TO_METER,
534                      &lat2, &lon2, &az2 );
535   wpt = new waypoint;
536   wpt->name      = "DEC 3000ft"; //wpt_node->getStringValue("name", "END");
537   wpt->latitude  = lat2;
538   wpt->longitude = lon2;
539   wpt->altitude  = arr->elevation + 19;
540   wpt->speed     = 160; 
541   wpt->crossat   = 3000;
542   wpt->gear_down = true;
543   wpt->flaps_down= true;
544   wpt->finished  = false;
545   wpt->on_ground = false;
546   waypoints.push_back(wpt); 
547   //Runway Threshold
548  geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
549                      rwy.length*0.45,
550                      &lat2, &lon2, &az2 );
551   wpt = new waypoint;
552   wpt->name      = "Threshold"; //wpt_node->getStringValue("name", "END");
553   wpt->latitude  = lat2;
554   wpt->longitude = lon2;
555   wpt->altitude  = arr->elevation + 19;
556   wpt->speed     = 15; 
557   wpt->crossat   = arr->elevation + 19;
558   wpt->gear_down = true;
559   wpt->flaps_down= true;
560   wpt->finished  = false;
561   wpt->on_ground = true;
562   waypoints.push_back(wpt); 
563
564  //Full stop at the runway centerpoint
565  geo_direct_wgs_84 ( 0, rwy.lat, rwy.lon, azimuth, 
566                      rwy.length*0.45,
567                      &lat2, &lon2, &az2 );
568   wpt = new waypoint;
569   wpt->name      = "Center"; //wpt_node->getStringValue("name", "END");
570   wpt->latitude  = rwy.lat;
571   wpt->longitude = rwy.lon;
572   wpt->altitude  = arr->elevation + 19;
573   wpt->speed     = 15; 
574   wpt->crossat   = -10000;
575   wpt->gear_down = true;
576   wpt->flaps_down= true;
577   wpt->finished  = false;
578   wpt->on_ground = false;
579   waypoints.push_back(wpt); 
580
581   // Add the final destination waypoint
582   wpt = new waypoint;
583   wpt->name      = arr->id; //wpt_node->getStringValue("name", "END");
584   wpt->latitude  = arr->latitude;
585   wpt->longitude = arr->longitude;
586   wpt->altitude  = arr->elevation+19;
587   wpt->speed     = 15; 
588   wpt->crossat   = -10000;
589   wpt->gear_down = true;
590   wpt->flaps_down= true;
591   wpt->finished  = false;
592   wpt->on_ground = false;
593   waypoints.push_back(wpt); 
594
595   // And finally one more named "END"
596   wpt = new waypoint;
597   wpt->name      = "END"; //wpt_node->getStringValue("name", "END");
598   wpt->latitude  = arr->latitude;
599   wpt->longitude = arr->longitude;
600   wpt->altitude  = 19;
601   wpt->speed     = 15; 
602   wpt->crossat   = -10000;
603   wpt->gear_down = true;
604   wpt->flaps_down= true;
605   wpt->finished  = true;
606   wpt->on_ground = true;
607   waypoints.push_back(wpt);
608
609  // And finally one more named "EOF"
610   wpt = new waypoint;
611   wpt->name      = "EOF"; //wpt_node->getStringValue("name", "END");
612   wpt->latitude  = arr->latitude;
613   wpt->longitude = arr->longitude;
614   wpt->altitude  = 19;
615   wpt->speed     = 15; 
616   wpt->crossat   = -10000;
617   wpt->gear_down = true;
618   wpt->flaps_down= true;
619   wpt->finished  = true;
620   wpt->finished  = true;
621   waypoints.push_back(wpt);
622 }