GPS internals: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 25: Line 25:
===Commands and the scratch===
===Commands and the scratch===


The GPS has a simple command system - it expects the properties under <tt>gps/scratch</tt> to be populated with some parameters, and then a command property to be set. Information is also returned via the <tt>gps/scratch</tt> properties. For example, to go direct to a waypoint, it must be loaded into the scratch, and a 'direct' command executed. To find the nearest VOR, set scratch/type to 'vor' and execute a 'nearest' command. The scratch will be updated with information about the result (if one was found) - and then a 'direct' or 'obs' command can be executed to use the waypoint.
The GPS has a simple command system - it expects the properties under <tt>gps/scratch</tt> to be populated with some parameters, and then a command property to be set. Information is also returned via the <tt>gps/scratch</tt> properties. For example, to go direct to a waypoint, it must be loaded into the scratch, and a 'direct' command executed. To find the nearest VOR, set <tt>scratch/type</tt> to <tt>vor</tt> and execute a <tt>nearest</tt> command. The scratch will be updated with information about the result (if one was found) - and then a 'direct' or 'obs' command can be executed to use the waypoint.





Revision as of 13:24, 5 October 2009

GPS internals

Introduction

Although the code is named 'GPS', it is intended to be used to support a wide range of related devices, such as INS or FMS systems. A generic name such as 'navigation computer' might be better, but renaming the properties and code at this point would be awkward.

The core GPS code attempts to provide simple, building block functions that can be easily composed in Nasal or XML to model the behaviour of particular real world instruments.

It is assumed the reader is familiar with using the GPS in flight, as detailed in the GPS.

The GPS is a work in progress - if you have problems with a feature, or think functionality is missing, don't work around the problem yourself, get in touch. It's far better to support a feature used by 50% of real-world devices, in the core code, than to duplicate it many times over. (Of course, if the feature is only found in one real world device, it may not be added to the core code)

Concepts

The code computes basic positional information, derived from FG's knowledge of the aircraft position (i.e the /position properties). There is no attempt made to accurately simulate GPS position calculation - in the future an error function will be used (optionally) to reduce the accuracy of the GPS indicated position.

From the indicated position, many other values are derived - ground track, speed, vertical speed, odometer and so on. All these values can be seen in the basic /gps property tree, and are hopefully self-explanatory.

Active waypoints

The active waypoint is available as gps/wp/wp[1], for historical reasons. Various interesting values are computed for the active waypoint, such as distance, bearing and so on.

gps/wp/wp[0] contains another waypoint, which varies depending on mode. For DTO and OBS modes, it is the position at the point the mode was entered; for LEG mode it is the previous waypoint in the route. Again this exists for compatibility reasons, and SHOULD NOT be used by aircraft or instruments.

Commands and the scratch

The GPS has a simple command system - it expects the properties under gps/scratch to be populated with some parameters, and then a command property to be set. Information is also returned via the gps/scratch properties. For example, to go direct to a waypoint, it must be loaded into the scratch, and a 'direct' command executed. To find the nearest VOR, set scratch/type to vor and execute a nearest command. The scratch will be updated with information about the result (if one was found) - and then a 'direct' or 'obs' command can be executed to use the waypoint.


Command List

More commands can be added! Let James know what you want (and why) and it can probably be done.

leg
Enter leg mode. Only possible if the route-manager route is active. The active waypoint becomes the current route manager waypoint
obs
Enter OBS mode. The active waypoint is loaded from the scratch
direct
Enter DTO mode. The active waypoint is loaded from the scratch, and a course calculated.
nearest
load the nearest waypoint (of a type) into the scratch. The following parameters are supported:
;max-results
: maximum number of nearby waypoints to load. Default is 1.
; type
: a type string. 'any', 'all' or an empty value mean all types
search
load waypoints by matching ident or name. The following parameters are supported:
;type
: as for 'nearest'
;ident
: the string to search on
; order-by-range
: a flag indicating if matches should be returned sorted by distance (the default) or alphabetically
;exact
: a flag indicated if matches must be exact (true) or partial (false). In
next
load the next result (for nearest/search/load-route-wpt)
previous
load the previous search result
define-user-waypoint
create a user waypoint based on the current scratch.

Configuration

Various properties exist under gps/config</tt< to control behaviour. They can be adjusted at any time, and depend partly on the real-world insturment being modelled, and partly on installed aircraft performance (eg, turn rate). The default values are generally acceptable.

linear-deflection-nm
If positive, the cross-track error (in nm) that corresponds to full-scale CDI deflection output. Internally, this value is used to scale the cdi-deflection property, so that at is maximum value (+/- 10), it corresponds to this deviation in nm.
If this value is negative, the GPS reports angular CDI deflection (like a VOR receiver), in degrees, directly.
min-runway-length-ft
If positive, the minimum runway length (in feet) suitable for this aircraft. This is used to filters (and airports) from search / nearest results, so that 'nearest airport' does not list close, but unusable, airports.
hard-surface-runways-only
Flag to indicate if the GPS should consider hard-surfaced or all types of runway. Set this flag for aircraft which cannot land on soft surfaces such as grass or gravel. As above, this is used to filter search results.
turn-rate-deg-sec
turn rate in degrees per second. Default value is 3, meaning a 180 degree turn takes one minute, which is usually called a 'standard rate turn'. This value is needed to perform accurate turn anticipation.