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