3 # Written by Curtis L. Olson, started January 2003
5 # This file is in the Public Domain and comes with no warranty.
8 # ----------------------------------------------------------------------------
15 my( $server ) = "localhost";
20 $Route{0} = "OAK:116.80:020";
21 $Route{1} = "OAK:116.80:019:27";
22 $Route{2} = "SAC:115.20:020";
23 $Route{3} = "SAC:115.20:080:43";
24 $Route{4} = "ECA:116.0:209";
28 foreach $i ( keys(%Route) ) {
29 &fly_to( $Route{$i} );
34 my( $waypoint ) = shift;
37 my( $id, $freq, $radial, $dist ) = split( /:/, $waypoint );
39 print "Next way point is $id - $freq\n";
40 print " Target radial is $radial\n";
42 print " Flying outbound for $dist nm\n";
44 print " Flying inbound to station\n";
47 # tune radio and set autopilot
49 if ( !( $fgfs = &connect($server, $port, $timeout) ) ) {
50 print "Error: can't open socket\n";
53 &send( $fgfs, "data" ); # switch to raw data mode
54 set_prop( $fgfs, "/radios/nav[0]/frequencies/selected-mhz", $freq );
55 set_prop( $fgfs, "/radios/nav[0]/radials/selected-deg", $radial );
56 set_prop( $fgfs, "/radios/dme/switch-position", "1" );
57 set_prop( $fgfs, "/autopilot/locks/nav", "true" );
59 # monitor progress until goal is achieved
61 my( $last_range ) = 9999.0;
63 my( $inrange ) = get_prop( $fgfs, "/radios/nav[0]/in-range" );
64 if ( $inrange eq "false" ) {
65 print "Warning, VOR not in range, we are lost!\n";
67 my( $cur_range ) = get_prop( $fgfs, "/radios/dme/distance-nm" );
68 print " range = $cur_range\n";
70 # a target dist is specified so assume we are flying outbound
71 if ( $cur_range > $dist ) {
75 # no target dist is specified, assume we are flying
76 # inbound to the station
77 if ( $cur_range < 0.25 && $cur_range > 0.0 ) {
79 } elsif ( $last_range < $cur_range ) {
83 $last_range = $cur_range;
85 # loop once per second
89 &send( $fgfs, "quit");