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