1 /******************************************************************************
2 * AIFlightPlanCreate.cxx
3 * Written by Durk Talsma, started May, 2004.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
20 #include "AIFlightPlan.hxx"
21 #include <simgear/math/sg_geodesy.hxx>
22 #include <Airports/runways.hxx>
24 #include <Environment/environment_mgr.hxx>
25 #include <Environment/environment.hxx>
28 /* FGAIFlightPlan::create()
29 * dynamically create a flight plan for AI traffic, based on data provided by the
30 * Traffic Manager, when reading a filed flightplan failes. (DT, 2004/07/10)
32 * This is the top-level function, and the only one that is publicly available.
37 // Check lat/lon values during initialization;
38 void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr,
39 double alt, double speed, double latitude,
40 double longitude, bool firstFlight,double radius,
41 const string& fltType, const string& aircraftType,
42 const string& airline)
44 int currWpt = wpt_iterator - waypoints.begin();
48 createPushBack(firstFlight,dep, latitude, longitude,
49 radius, fltType, aircraftType, airline);
52 createTaxi(firstFlight, 1, dep, latitude, longitude,
53 radius, fltType, aircraftType, airline);
56 createTakeOff(firstFlight, dep, speed);
59 createClimb(firstFlight, dep, speed, alt);
62 createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt);
71 createTaxi(false, 2, arr, latitude, longitude, radius,
72 fltType, aircraftType, airline);
75 createParking(arr, radius);
79 SG_LOG(SG_INPUT, SG_ALERT, "AIFlightPlan::create() attempting to create unknown leg"
80 " this is probably an internal program error");
82 wpt_iterator = waypoints.begin()+currWpt;
86 /*******************************************************************
88 * initialize the Aircraft at the parking location
89 ******************************************************************/
90 void FGAIFlightPlan::createPushBack(bool firstFlight, FGAirport *dep,
94 const string& fltType,
95 const string& aircraftType,
96 const string& airline)
105 //int currWpt = wpt_iterator - waypoints.begin();
106 // Erase all existing waypoints.
109 // We only need to get a valid parking if this is the first leg.
110 // Otherwise use the current aircraft position.
113 if (!(dep->getDynamics()->getAvailableParking(&lat, &lon,
116 aircraftType, airline)))
118 SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
120 " of flight type " << fltType <<
121 " of airline " << airline <<
122 " at airport " << dep->getId());
127 dep->getDynamics()->getParking(gateId, &lat, &lon, &heading);
132 waypoint *wpt = new waypoint;
135 wpt->longitude = lon;
136 wpt->altitude = dep->getElevation();
138 wpt->crossat = -10000;
139 wpt->gear_down = true;
140 wpt->flaps_down= true;
141 wpt->finished = false;
142 wpt->on_ground = true;
143 waypoints.push_back(wpt);
145 // Add park twice, because it uses park once for initialization and once
146 // to trigger the departure ATC message
147 geo_direct_wgs_84 ( 0, lat, lon, heading,
149 &lat2, &lon2, &az2 );
152 wpt->latitude = lat2;
153 wpt->longitude = lon2;
154 wpt->altitude = dep->getElevation();
156 wpt->crossat = -10000;
157 wpt->gear_down = true;
158 wpt->flaps_down= true;
159 wpt->finished = false;
160 wpt->on_ground = true;
161 waypoints.push_back(wpt);
162 geo_direct_wgs_84 ( 0, lat, lon, heading,
164 &lat2, &lon2, &az2 );
166 wpt->name = "taxiStart";
167 wpt->latitude = lat2;
168 wpt->longitude = lon2;
169 wpt->altitude = dep->getElevation();
171 wpt->crossat = -10000;
172 wpt->gear_down = true;
173 wpt->flaps_down= true;
174 wpt->finished = false;
175 wpt->on_ground = true;
176 waypoints.push_back(wpt);
179 /*******************************************************************
181 * initialize the Aircraft at the parking location
182 ******************************************************************/
183 void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
184 FGAirport *apt, double latitude, double longitude,
185 double radius, const string& fltType,
186 const string& acType, const string& airline)
192 double lat2, lon2, az2;
197 // If this function is called during initialization,
198 // make sure we obtain a valid gate ID first
199 // and place the model at the location of the gate.
202 if (!(apt->getDynamics()->getAvailableParking(&lat, &lon,
207 SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
209 " of flight type " << fltType <<
210 " of airline " << airline <<
211 " at airport " << apt->getId());
213 //waypoint *wpt = new waypoint;
214 //wpt->name = "park";
215 //wpt->latitude = lat;
216 //wpt->longitude = lon;
217 //wpt->altitude = apt->getElevation();
219 //wpt->crossat = -10000;
220 //wpt->gear_down = true;
221 //wpt->flaps_down= true;
222 //wpt->finished = false;
223 //wpt->on_ground = true;
224 //waypoints.push_back(wpt);
226 // "NOTE: this is currently fixed to "com" for commercial traffic
227 // Should be changed to be used dynamically to allow "gen" and "mil"
229 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
230 if (!(globals->get_runways()->search(apt->getId(),
234 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
236 " at airport " << apt->getId());
240 // Determine the beginning of he runway
241 heading = rwy._heading;
242 double azimuth = heading + 180.0;
243 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
244 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
245 rwy._length * SG_FEET_TO_METER * 0.5 - 5.0,
246 &lat2, &lon2, &az2 );
248 if (apt->getDynamics()->getGroundNetwork()->exists())
251 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat2,
255 // A negative gateId indicates an overflow parking, use a
256 // fallback mechanism for this.
257 // Starting from gate 0 in this case is a bit of a hack
258 // which requires a more proper solution later on.
261 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(gateId,
264 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(0, runwayId);
268 //Add the runway startpoint;
270 wpt->name = "Airport Center";
271 wpt->latitude = latitude;
272 wpt->longitude = longitude;
273 wpt->altitude = apt->getElevation();
275 wpt->crossat = -10000;
276 wpt->gear_down = true;
277 wpt->flaps_down= true;
278 wpt->finished = false;
279 wpt->on_ground = true;
280 waypoints.push_back(wpt);
282 //Add the runway startpoint;
284 wpt->name = "Runway Takeoff";
285 wpt->latitude = lat2;
286 wpt->longitude = lon2;
287 wpt->altitude = apt->getElevation();
289 wpt->crossat = -10000;
290 wpt->gear_down = true;
291 wpt->flaps_down= true;
292 wpt->finished = false;
293 wpt->on_ground = true;
294 waypoints.push_back(wpt);
298 bool isPushBackPoint = false;
300 // If this is called during initialization, randomly
301 // skip a number of waypoints to get a more realistic
303 isPushBackPoint = true;
304 int nrWaypoints = route.size();
305 int nrWaypointsToSkip = rand() % nrWaypoints;
306 // but make sure we always keep two active waypoints
307 // to prevent a segmentation fault
308 for (int i = 0; i < nrWaypointsToSkip-2; i++) {
309 isPushBackPoint = false;
314 //chop off the first two waypoints, because
315 // those have already been created
316 // by create pushback
317 int size = route.size();
323 while(route.next(&node))
325 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
328 wpt->name = "taxiway"; // fixme: should be the name of the taxiway
329 wpt->latitude = tn->getLatitude();
330 wpt->longitude = tn->getLongitude();
331 // Elevation is currently disregarded when on_ground is true
332 // because the AIModel obtains a periodic ground elevation estimate.
333 wpt->altitude = apt->getElevation();
334 if (isPushBackPoint) {
336 isPushBackPoint = false;
341 wpt->crossat = -10000;
342 wpt->gear_down = true;
343 wpt->flaps_down= true;
344 wpt->finished = false;
345 wpt->on_ground = true;
346 waypoints.push_back(wpt);
353 // This is the fallback mechanism, in case no ground network is available
354 //Add the runway startpoint;
356 wpt->name = "Airport Center";
357 wpt->latitude = apt->getLatitude();
358 wpt->longitude = apt->getLongitude();
359 wpt->altitude = apt->getElevation();
361 wpt->crossat = -10000;
362 wpt->gear_down = true;
363 wpt->flaps_down= true;
364 wpt->finished = false;
365 wpt->on_ground = true;
366 waypoints.push_back(wpt);
368 //Add the runway startpoint;
370 wpt->name = "Runway Takeoff";
371 wpt->latitude = lat2;
372 wpt->longitude = lon2;
373 wpt->altitude = apt->getElevation();
375 wpt->crossat = -10000;
376 wpt->gear_down = true;
377 wpt->flaps_down= true;
378 wpt->finished = false;
379 wpt->on_ground = true;
380 waypoints.push_back(wpt);
385 apt->getDynamics()->getAvailableParking(&lat, &lon, &heading,
386 &gateId, radius, fltType,
389 double lat3 = (*(waypoints.end()-1))->latitude;
390 double lon3 = (*(waypoints.end()-1))->longitude;
391 //cerr << (*(waypoints.end()-1))->name << endl;
393 // Find a route from runway end to parking/gate.
394 if (apt->getDynamics()->getGroundNetwork()->exists())
397 int runwayId = apt->getDynamics()->getGroundNetwork()->findNearestNode(lat3,
399 // A negative gateId indicates an overflow parking, use a
400 // fallback mechanism for this.
401 // Starting from gate 0 is a bit of a hack...
404 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId,
407 route = apt->getDynamics()->getGroundNetwork()->findShortestRoute(runwayId, 0);
410 // No route found: go from gate directly to runway
412 //Add the runway startpoint;
414 wpt->name = "Airport Center";
415 wpt->latitude = latitude;
416 wpt->longitude = longitude;
417 wpt->altitude = apt->getElevation();
419 wpt->crossat = -10000;
420 wpt->gear_down = true;
421 wpt->flaps_down= true;
422 wpt->finished = false;
423 wpt->on_ground = true;
424 waypoints.push_back(wpt);
426 //Add the runway startpoint;
428 wpt->name = "Runway Takeoff";
429 wpt->latitude = lat2;
430 wpt->longitude = lon2;
431 wpt->altitude = apt->getElevation();
433 wpt->crossat = -10000;
434 wpt->gear_down = true;
435 wpt->flaps_down= true;
436 wpt->finished = false;
437 wpt->on_ground = true;
438 waypoints.push_back(wpt);
442 int size = route.size();
443 // Omit the last two waypoints, as
444 // those are created by createParking()
445 for (int i = 0; i < size-2; i++)
448 FGTaxiNode *tn = apt->getDynamics()->getGroundNetwork()->findNode(node);
450 wpt->name = "taxiway"; // fixme: should be the name of the taxiway
451 wpt->latitude = tn->getLatitude();
452 wpt->longitude = tn->getLongitude();
453 wpt->altitude = apt->getElevation();
455 wpt->crossat = -10000;
456 wpt->gear_down = true;
457 wpt->flaps_down= true;
458 wpt->finished = false;
459 wpt->on_ground = true;
460 waypoints.push_back(wpt);
466 // Use a fallback mechanism in case no ground network is available
467 // obtain the location of the gate entrance point
471 geo_direct_wgs_84 ( 0, lat, lon, heading,
473 &lat2, &lon2, &az2 );
475 wpt->name = "Airport Center";
476 wpt->latitude = apt->getLatitude();
477 wpt->longitude = apt->getLongitude();
478 wpt->altitude = apt->getElevation();
480 wpt->crossat = -10000;
481 wpt->gear_down = true;
482 wpt->flaps_down= true;
483 wpt->finished = false;
484 wpt->on_ground = true;
485 waypoints.push_back(wpt);
488 wpt->name = "Begin Parking"; //apt->getId(); //wpt_node->getStringValue("name", "END");
489 wpt->latitude = lat2;
490 wpt->longitude = lon2;
491 wpt->altitude = apt->getElevation();
493 wpt->crossat = -10000;
494 wpt->gear_down = true;
495 wpt->flaps_down= true;
496 wpt->finished = false;
497 wpt->on_ground = true;
498 waypoints.push_back(wpt);
504 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
510 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
512 wpt->longitude = lon;
515 wpt->crossat = -10000;
516 wpt->gear_down = true;
517 wpt->flaps_down= true;
518 wpt->finished = false;
519 wpt->on_ground = true;
520 waypoints.push_back(wpt);
526 /*******************************************************************
528 * initialize the Aircraft at the parking location
529 ******************************************************************/
530 void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed)
536 double lat2, lon2, az2;
539 // Get the current active runway, based on code from David Luff
540 // This should actually be unified and extended to include
541 // Preferential runway use schema's
545 // "NOTE: this is currently fixed to "com" for commercial traffic
546 // Should be changed to be used dynamically to allow "gen" and "mil"
548 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
549 if (!(globals->get_runways()->search(apt->getId(),
553 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
555 " at airport " << apt->getId());
559 heading = rwy._heading;
560 double azimuth = heading + 180.0;
561 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
562 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
563 rwy._length * SG_FEET_TO_METER * 0.5 - 105.0,
564 &lat2, &lon2, &az2 );
567 wpt->latitude = lat2;
568 wpt->longitude = lon2;
569 wpt->altitude = apt->getElevation();
571 wpt->crossat = -10000;
572 wpt->gear_down = true;
573 wpt->flaps_down= true;
574 wpt->finished = false;
575 wpt->on_ground = true;
576 waypoints.push_back(wpt);
582 //Next: the Start of Climb
583 geo_direct_wgs_84 ( 0, lat, lon, heading,
584 2560 * SG_FEET_TO_METER,
585 &lat2, &lon2, &az2 );
589 wpt->latitude = lat2;
590 wpt->longitude = lon2;
591 wpt->altitude = apt->getElevation()+3000;
593 wpt->crossat = -10000;
594 wpt->gear_down = true;
595 wpt->flaps_down= true;
596 wpt->finished = false;
597 wpt->on_ground = false;
598 waypoints.push_back(wpt);
601 /*******************************************************************
603 * initialize the Aircraft at the parking location
604 ******************************************************************/
605 void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt)
612 double lat2, lon2, az2;
620 // "NOTE: this is currently fixed to "com" for commercial traffic
621 // Should be changed to be used dynamically to allow "gen" and "mil"
623 apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
624 if (!(globals->get_runways()->search(apt->getId(),
628 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
630 " at airport " << apt->getId());
636 heading = rwy._heading;
637 double azimuth = heading + 180.0;
638 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
639 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
641 &lat2, &lon2, &az2 );
643 wpt->name = "10000ft climb";
644 wpt->latitude = lat2;
645 wpt->longitude = lon2;
646 wpt->altitude = 10000;
648 wpt->crossat = -10000;
649 wpt->gear_down = true;
650 wpt->flaps_down= true;
651 wpt->finished = false;
652 wpt->on_ground = false;
653 waypoints.push_back(wpt);
656 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
658 &lat2, &lon2, &az2 );
660 wpt->name = "18000ft climb";
661 wpt->latitude = lat2;
662 wpt->longitude = lon2;
663 wpt->altitude = 18000;
665 wpt->crossat = -10000;
666 wpt->gear_down = true;
667 wpt->flaps_down= true;
668 wpt->finished = false;
669 wpt->on_ground = false;
670 waypoints.push_back(wpt);
674 /*******************************************************************
676 * initialize the Aircraft at the parking location
677 ******************************************************************/
678 void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
679 FGAirport *arr, double latitude,
680 double longitude, double speed,
687 double lat2, lon2, az2;
692 wpt->name = "Cruise"; //wpt_node->getStringValue("name", "END");
693 wpt->latitude = latitude;
694 wpt->longitude = longitude;
697 wpt->crossat = -10000;
698 wpt->gear_down = false;
699 wpt->flaps_down= false;
700 wpt->finished = false;
701 wpt->on_ground = false;
702 waypoints.push_back(wpt);
705 // should be changed dynamically to allow "gen" and "mil"
706 arr->getDynamics()->getActiveRunway("com", 2, activeRunway);
707 if (!(globals->get_runways()->search(arr->getId(),
711 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
713 " at airport " << arr->getId());
716 heading = rwy._heading;
717 azimuth = heading + 180.0;
718 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
721 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
723 &lat2, &lon2, &az2 );
726 wpt->latitude = lat2;
727 wpt->longitude = lon2;
731 wpt->gear_down = false;
732 wpt->flaps_down= false;
733 wpt->finished = false;
734 wpt->on_ground = false;
735 waypoints.push_back(wpt);
738 /*******************************************************************
740 * initialize the Aircraft at the parking location
741 ******************************************************************/
742 void FGAIFlightPlan::createDecent(FGAirport *apt)
745 // Ten thousand ft. Slowing down to 240 kts
751 double lat2, lon2, az2;
756 //Beginning of Decent
758 // allow "mil" and "gen" as well
759 apt->getDynamics()->getActiveRunway("com", 2, activeRunway);
760 if (!(globals->get_runways()->search(apt->getId(),
764 SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
766 " at airport " << apt->getId());
770 heading = rwy._heading;
771 azimuth = heading + 180.0;
772 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
773 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
775 &lat2, &lon2, &az2 );
778 wpt->name = "Dec 10000ft"; //wpt_node->getStringValue("name", "END");
779 wpt->latitude = lat2;
780 wpt->longitude = lon2;
781 wpt->altitude = apt->getElevation();
783 wpt->crossat = 10000;
784 wpt->gear_down = false;
785 wpt->flaps_down= false;
786 wpt->finished = false;
787 wpt->on_ground = false;
788 waypoints.push_back(wpt);
790 // Three thousand ft. Slowing down to 160 kts
791 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
793 &lat2, &lon2, &az2 );
795 wpt->name = "DEC 3000ft"; //wpt_node->getStringValue("name", "END");
796 wpt->latitude = lat2;
797 wpt->longitude = lon2;
798 wpt->altitude = apt->getElevation();
801 wpt->gear_down = true;
802 wpt->flaps_down= true;
803 wpt->finished = false;
804 wpt->on_ground = false;
805 waypoints.push_back(wpt);
807 /*******************************************************************
809 * initialize the Aircraft at the parking location
810 ******************************************************************/
811 void FGAIFlightPlan::createLanding(FGAirport *apt)
813 // Ten thousand ft. Slowing down to 150 kts
819 double lat2, lon2, az2;
825 heading = rwy._heading;
826 azimuth = heading + 180.0;
827 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
830 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
831 rwy._length*0.45 * SG_FEET_TO_METER,
832 &lat2, &lon2, &az2 );
834 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
835 wpt->latitude = lat2;
836 wpt->longitude = lon2;
837 wpt->altitude = apt->getElevation();
839 wpt->crossat = apt->getElevation();
840 wpt->gear_down = true;
841 wpt->flaps_down= true;
842 wpt->finished = false;
843 wpt->on_ground = true;
844 waypoints.push_back(wpt);
846 //Full stop at the runway centerpoint
847 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, azimuth,
849 &lat2, &lon2, &az2 );
851 wpt->name = "Center"; //wpt_node->getStringValue("name", "END");
852 wpt->latitude = rwy._lat;
853 wpt->longitude = rwy._lon;
854 wpt->altitude = apt->getElevation();
856 wpt->crossat = -10000;
857 wpt->gear_down = true;
858 wpt->flaps_down= true;
859 wpt->finished = false;
860 wpt->on_ground = true;
861 waypoints.push_back(wpt);
863 geo_direct_wgs_84 ( 0, rwy._lat, rwy._lon, heading,
864 rwy._length*0.45 * SG_FEET_TO_METER,
865 &lat2, &lon2, &az2 );
867 wpt->name = "Threshold"; //wpt_node->getStringValue("name", "END");
868 wpt->latitude = lat2;
869 wpt->longitude = lon2;
870 wpt->altitude = apt->getElevation();
872 wpt->crossat = apt->getElevation();
873 wpt->gear_down = true;
874 wpt->flaps_down= true;
875 wpt->finished = false;
876 wpt->on_ground = true;
877 waypoints.push_back(wpt);
880 /*******************************************************************
882 * initialize the Aircraft at the parking location
883 ******************************************************************/
884 void FGAIFlightPlan::createParking(FGAirport *apt, double radius)
891 apt->getDynamics()->getParking(gateId, &lat, &lon, &heading);
895 geo_direct_wgs_84 ( 0, lat, lon, heading,
897 &lat2, &lon2, &az2 );
899 wpt->name = "taxiStart";
900 wpt->latitude = lat2;
901 wpt->longitude = lon2;
902 wpt->altitude = apt->getElevation();
904 wpt->crossat = -10000;
905 wpt->gear_down = true;
906 wpt->flaps_down= true;
907 wpt->finished = false;
908 wpt->on_ground = true;
909 waypoints.push_back(wpt);
910 geo_direct_wgs_84 ( 0, lat, lon, heading,
912 &lat2, &lon2, &az2 );
914 wpt->name = "taxiStart";
915 wpt->latitude = lat2;
916 wpt->longitude = lon2;
917 wpt->altitude = apt->getElevation();
919 wpt->crossat = -10000;
920 wpt->gear_down = true;
921 wpt->flaps_down= true;
922 wpt->finished = false;
923 wpt->on_ground = true;
924 waypoints.push_back(wpt);
927 wpt->name = "END"; //wpt_node->getStringValue("name", "END");
929 wpt->longitude = lon;
930 wpt->altitude = apt->getElevation();
932 wpt->crossat = -10000;
933 wpt->gear_down = true;
934 wpt->flaps_down= true;
935 wpt->finished = false;
936 wpt->on_ground = true;
937 waypoints.push_back(wpt);