Documentation
¶
Index ¶
- Constants
- Variables
- func InitNavLog(enabled bool, categories string, callsign string)
- func LogRoute(callsign string, simTime time.Time, waypoints av.WaypointArray)
- func NavLog(callsign string, simTime time.Time, category string, format string, ...)
- func NavLogEnabled(category string) bool
- func TurnAngle(from, to float32, turn TurnMethod) float32
- type DeferredNavHeading
- type DepartureHeadingState
- type FlightState
- type FlyHold
- type FlyRacetrackPT
- type FlyStandard45PT
- type HoldState
- type HoldStateFunc
- type InterceptState
- type Nav
- func (nav *Nav) AltitudeOurDiscretion() av.CommandIntent
- func (nav *Nav) ApproachHeading(wxs wx.Sample) (heading float32, turn TurnMethod)
- func (nav *Nav) AssignAltitude(alt float32, afterSpeed bool) av.CommandIntent
- func (nav *Nav) AssignHeading(hdg float32, turn TurnMethod) av.CommandIntent
- func (nav *Nav) AssignSpeed(speed float32, afterAltitude bool) av.CommandIntent
- func (nav *Nav) AssignSpeedUntil(speed float32, until *av.SpeedUntil) av.CommandIntent
- func (nav *Nav) AssignedHeading() (float32, bool)
- func (nav *Nav) AssignedWaypoints() []av.Waypoint
- func (nav *Nav) AtFixCleared(fix, id string) av.CommandIntent
- func (nav *Nav) AtFixIntercept(fix, airport string, lg *log.Logger) av.CommandIntent
- func (nav *Nav) CancelApproachClearance() av.CommandIntent
- func (nav *Nav) Check(lg *log.Logger)
- func (nav *Nav) ClearedApproach(airport string, id string, straightIn bool) (av.CommandIntent, bool)
- func (nav *Nav) ClimbViaSID() av.CommandIntent
- func (nav *Nav) ContactMessage(reportingPoints []av.ReportingPoint, star string, reportHeading bool, ...) *av.RadioTransmission
- func (nav *Nav) CrossFixAt(fix string, ar *av.AltitudeRestriction, speed int) av.CommandIntent
- func (nav *Nav) DepartFixDirect(fixa string, fixb string) av.CommandIntent
- func (nav *Nav) DepartFixHeading(fix string, hdg float32) av.CommandIntent
- func (nav *Nav) DepartOnCourse(alt float32, exit string)
- func (nav *Nav) DepartureHeading() (int, DepartureHeadingState)
- func (nav *Nav) DepartureMessage(reportHeading bool) *av.RadioTransmission
- func (nav *Nav) DescendViaSTAR() av.CommandIntent
- func (nav *Nav) DirectFix(fix string) av.CommandIntent
- func (nav *Nav) DistanceAlongRoute(fix string) (float32, error)
- func (nav *Nav) DistanceToEndOfApproach() (float32, error)
- func (nav *Nav) DivertToAirport(airport string)
- func (nav *Nav) ETA(p math.Point2LL) float32
- func (nav *Nav) EnqueueDirectFix(wps []av.Waypoint)
- func (nav *Nav) EnqueueHeading(hdg float32, turn TurnMethod)
- func (nav *Nav) EnqueueOnCourse()
- func (nav *Nav) ExpectApproach(airport *av.Airport, id string, runwayWaypoints map[string]av.WaypointArray, ...) av.CommandIntent
- func (nav *Nav) ExpediteClimb() av.CommandIntent
- func (nav *Nav) ExpediteDescent() av.CommandIntent
- func (nav *Nav) FlyPresentHeading() av.CommandIntent
- func (nav *Nav) GoAround()
- func (nav *Nav) HoldAtFix(callsign string, fix string, hold *av.Hold) av.CommandIntent
- func (nav *Nav) InterceptApproach(airport string, lg *log.Logger) av.CommandIntent
- func (nav *Nav) InterceptedButNotCleared() bool
- func (nav *Nav) IsAirborne() bool
- func (nav *Nav) MaintainMaximumForward() av.CommandIntent
- func (nav *Nav) MaintainPresentSpeed() av.CommandIntent
- func (nav *Nav) MaintainSlowestPractical() av.CommandIntent
- func (nav *Nav) OnApproach(checkAltitude bool) bool
- func (nav *Nav) OnExtendedCenterline(maxNmDeviation float32) bool
- func (nav *Nav) RestoreSnapshot(snap NavSnapshot)
- func (nav *Nav) ResumeOwnNavigation() av.CommandIntent
- func (nav *Nav) SayAltitude() av.CommandIntent
- func (nav *Nav) SayHeading() av.CommandIntent
- func (nav *Nav) SaySpeed() av.CommandIntent
- func (nav *Nav) Summary(fp av.FlightPlan, model *wx.Model, simTime time.Time, lg *log.Logger) string
- func (nav *Nav) TAS() float32
- func (nav *Nav) TakeSnapshot() NavSnapshot
- func (nav *Nav) TargetAltitude() (float32, float32)
- func (nav *Nav) TargetHeading(callsign string, wxs wx.Sample, simTime time.Time) (heading float32, turn TurnMethod, rate float32)
- func (nav *Nav) TargetSpeed(targetAltitude float32, fp *av.FlightPlan, wxs wx.Sample, ...) (float32, float32)
- func (nav *Nav) Update(callsign string, model *wx.Model, fp *av.FlightPlan, simTime time.Time, ...) *av.Waypoint
- func (nav *Nav) UpdateWithWeather(callsign string, wxs wx.Sample, fp *av.FlightPlan, simTime time.Time, ...) *av.Waypoint
- type NavAirwork
- type NavAltitude
- type NavApproach
- type NavFixAssignment
- type NavHeading
- type NavSnapshot
- type NavSpeed
- type TurnMethod
- type WaypointCrossingConstraint
Constants ¶
const ( )
Available logging categories
const ( PTStateApproaching = iota PTStateTurningOutbound PTStateFlyingOutbound PTStateTurningInbound PTStateFlyingInbound // parallel entry only )
const ( PT45StateApproaching = iota PT45StateTurningOutbound PT45StateFlyingOutbound PT45StateTurningAway PT45StateFlyingAway PT45StateTurningIn PT45StateFlyingIn PT45StateTurningToIntercept )
const MaxIAS = 290
const MaximumRate = 100000
const StandardTurnRate = 3
Variables ¶
var ( ErrClearedForUnexpectedApproach = errors.New("Cleared for unexpected approach") ErrFixIsTooFarAway = errors.New("Fix is too far away") ErrFixNotInRoute = errors.New("Fix not in aircraft's route") ErrInvalidApproach = errors.New("Invalid approach") ErrInvalidFix = errors.New("Invalid fix") ErrNotClearedForApproach = errors.New("Aircraft has not been cleared for an approach") ErrNotFlyingRoute = errors.New("Aircraft is not currently flying its assigned route") ErrUnableCommand = errors.New("Unable") ErrUnknownApproach = errors.New("Unknown approach") )
Errors used by the nav package
Functions ¶
func InitNavLog ¶
InitNavLog is a no-op in release builds
func LogRoute ¶
func LogRoute(callsign string, simTime time.Time, waypoints av.WaypointArray)
LogRoute is a no-op in release builds
func NavLogEnabled ¶
NavLogEnabled always returns false in release builds
func TurnAngle ¶
func TurnAngle(from, to float32, turn TurnMethod) float32
Types ¶
type DeferredNavHeading ¶
type DeferredNavHeading struct {
// Time is just plain old wallclock time; it should be sim time, but a
// lot of replumbing would be required to have that available where
// needed. The downsides are minor: 1. On quit and resume, any pending
// assignments will generally be followed immediately, and 2. if the
// sim rate is increased, the delay will end up being longer than
// intended.
Waypoints []av.Waypoint
}
DeferredNavHeading stores a heading assignment from the controller and the time at which to start executing it; this time is set to be a few seconds after the controller issues it in order to model the delay before pilots start to follow assignments.
type DepartureHeadingState ¶ added in v0.14.0
type DepartureHeadingState int
DepartureHeadingState describes the state of a departure's heading assignment.
const ( // NoHeading indicates no heading is assigned or upcoming NoHeading DepartureHeadingState = iota // OnHeading indicates the aircraft is currently flying an assigned heading OnHeading // TurningToHeading indicates the aircraft is about to turn to a heading TurningToHeading )
type FlightState ¶
type FlightState struct {
InitialDepartureClimb bool
DepartureAirportLocation math.Point2LL
DepartureAirportElevation float32
ArrivalAirport av.Waypoint
ArrivalAirportLocation math.Point2LL
ArrivalAirportElevation float32
MagneticVariation float32
NmPerLongitude float32
Position math.Point2LL
Heading float32
Altitude float32
PrevAltitude float32
IAS, GS float32 // speeds...
BankAngle float32 // degrees
AltitudeRate float32 // + -> climb, - -> descent
}
func (FlightState) LogValue ¶
func (fs FlightState) LogValue() slog.Value
func (*FlightState) Summary ¶
func (fs *FlightState) Summary() string
type FlyHold ¶
type FlyRacetrackPT ¶
type FlyRacetrackPT struct {
ProcedureTurn *av.ProcedureTurn
Fix string
FixLocation math.Point2LL
Entry av.RacetrackPTEntry
InboundHeading float32
OutboundHeading float32
OutboundTurnRate float32
OutboundTurnMethod TurnMethod
OutboundLegLength float32
State int
}
func MakeFlyRacetrackPT ¶
func MakeFlyRacetrackPT(nav *Nav, wp []av.Waypoint) *FlyRacetrackPT
func (*FlyRacetrackPT) GetAltitude ¶
func (fp *FlyRacetrackPT) GetAltitude(nav *Nav) (float32, bool)
func (*FlyRacetrackPT) GetHeading ¶
func (fp *FlyRacetrackPT) GetHeading(nav *Nav, wxs wx.Sample) (float32, TurnMethod, float32)
type FlyStandard45PT ¶
type FlyStandard45PT struct {
ProcedureTurn *av.ProcedureTurn
Fix string
FixLocation math.Point2LL
InboundHeading float32 // fix->airport
AwayHeading float32 // outbound + 45 offset
State int
SecondsRemaining int
}
func MakeFlyStandard45PT ¶
func MakeFlyStandard45PT(nav *Nav, wp []av.Waypoint) *FlyStandard45PT
func (*FlyStandard45PT) GetHeading ¶
func (fp *FlyStandard45PT) GetHeading(nav *Nav, wxs wx.Sample) (float32, TurnMethod, float32)
type HoldState ¶
type HoldState int
const ( // Everyone starts here and then transitions to one of the next three groups depending on their entry method. HoldStateApproaching HoldState = iota HoldStateDirectTurningInitialOutbound HoldStateTurningForParallelEntry HoldStateFlyingParallelOutbound HoldStateTurningParallelInbound HoldStateFlyingTeardropOutbound HoldStateTurningForTeardropEntry // All holds cycle through these once after entry. HoldStateTurningOutbound HoldStateFlyingOutbound HoldStateTurningInbound HoldStateFlyingInbound )
type HoldStateFunc ¶
type HoldStateFunc func(nav *Nav, fh *FlyHold, wxs wx.Sample, simTime time.Time) (float32, TurnMethod, HoldState)
Holds are implemented using a simple state machine where each state is handled by a function with this signature. Return values: heading to fly, which direction to turn, and which state to be in for the next step.
type InterceptState ¶
type InterceptState int
const ( NotIntercepting InterceptState = iota InitialHeading TurningToJoin OnApproachCourse )
type Nav ¶
type Nav struct {
// controller that the pilot has not yet started to follow. Note that
// only a single such assignment is stored; for example, if the
// controller issues a first heading and then a second shortly
// afterward, before the first has been followed, it's fine for the
// second to override it.
DeferredNavHeading *DeferredNavHeading
}
State related to navigation. Pointers are used for optional values; nil -> unset/unspecified.
func MakeArrivalNav ¶
func MakeDepartureNav ¶
func MakeOverflightNav ¶
func MakeOverflightNav(callsign av.ADSBCallsign, of *av.Overflight, fp av.FlightPlan, perf av.AircraftPerformance, nmPerLongitude float32, magneticVariation float32, model *wx.Model, simTime time.Time, lg *log.Logger) *Nav
func (*Nav) AltitudeOurDiscretion ¶
func (nav *Nav) AltitudeOurDiscretion() av.CommandIntent
func (*Nav) ApproachHeading ¶
func (nav *Nav) ApproachHeading(wxs wx.Sample) (heading float32, turn TurnMethod)
Placeholder - will be filled from source
func (*Nav) AssignAltitude ¶
func (nav *Nav) AssignAltitude(alt float32, afterSpeed bool) av.CommandIntent
func (*Nav) AssignHeading ¶
func (nav *Nav) AssignHeading(hdg float32, turn TurnMethod) av.CommandIntent
func (*Nav) AssignSpeed ¶
func (nav *Nav) AssignSpeed(speed float32, afterAltitude bool) av.CommandIntent
func (*Nav) AssignSpeedUntil ¶ added in v0.14.0
func (nav *Nav) AssignSpeedUntil(speed float32, until *av.SpeedUntil) av.CommandIntent
func (*Nav) AssignedHeading ¶
AssignedHeading returns the aircraft's current heading assignment, if any, regardless of whether the pilot has yet started following it.
func (*Nav) AssignedWaypoints ¶
AssignedWaypoints returns the route that should be flown following a controller instruction. If an instruction has been issued but the delay hasn't passed, these are different than the waypoints currently being used for navigation.
func (*Nav) AtFixCleared ¶
func (nav *Nav) AtFixCleared(fix, id string) av.CommandIntent
func (*Nav) AtFixIntercept ¶ added in v0.14.0
func (*Nav) CancelApproachClearance ¶
func (nav *Nav) CancelApproachClearance() av.CommandIntent
func (*Nav) ClearedApproach ¶
func (*Nav) ClimbViaSID ¶
func (nav *Nav) ClimbViaSID() av.CommandIntent
func (*Nav) ContactMessage ¶
func (nav *Nav) ContactMessage(reportingPoints []av.ReportingPoint, star string, reportHeading bool, isDeparture bool) *av.RadioTransmission
func (*Nav) CrossFixAt ¶
func (nav *Nav) CrossFixAt(fix string, ar *av.AltitudeRestriction, speed int) av.CommandIntent
func (*Nav) DepartFixDirect ¶
func (nav *Nav) DepartFixDirect(fixa string, fixb string) av.CommandIntent
func (*Nav) DepartFixHeading ¶
func (nav *Nav) DepartFixHeading(fix string, hdg float32) av.CommandIntent
func (*Nav) DepartOnCourse ¶
func (*Nav) DepartureHeading ¶ added in v0.14.0
func (nav *Nav) DepartureHeading() (int, DepartureHeadingState)
DepartureHeading returns the heading a departure will fly and its state. Returns the heading and state based on: - OnHeading: aircraft has an assigned heading - TurningToHeading: first waypoint has a heading (about to turn) - NoHeading: no assigned heading and first waypoint has no heading
func (*Nav) DepartureMessage ¶
func (nav *Nav) DepartureMessage(reportHeading bool) *av.RadioTransmission
func (*Nav) DescendViaSTAR ¶
func (nav *Nav) DescendViaSTAR() av.CommandIntent
func (*Nav) DistanceToEndOfApproach ¶
distanceToEndOfApproach returns the remaining distance to the last waypoint (usually runway threshold) of the currently assigned approach.
func (*Nav) DivertToAirport ¶
func (*Nav) ETA ¶
ETA returns the estimated time in seconds until the aircraft will arrive at `p`, assuming it is flying direct.
func (*Nav) EnqueueDirectFix ¶
func (*Nav) EnqueueHeading ¶
func (nav *Nav) EnqueueHeading(hdg float32, turn TurnMethod)
EnqueueHeading enqueues the given heading assignment to be followed a few seconds in the future. It should only be called for heading changes due to controller instructions to the pilot and never in cases where the autopilot is changing the heading assignment.
func (*Nav) EnqueueOnCourse ¶
func (nav *Nav) EnqueueOnCourse()
func (*Nav) ExpectApproach ¶
func (*Nav) ExpediteClimb ¶
func (nav *Nav) ExpediteClimb() av.CommandIntent
func (*Nav) ExpediteDescent ¶
func (nav *Nav) ExpediteDescent() av.CommandIntent
func (*Nav) FlyPresentHeading ¶
func (nav *Nav) FlyPresentHeading() av.CommandIntent
func (*Nav) InterceptApproach ¶
func (*Nav) InterceptedButNotCleared ¶
func (*Nav) IsAirborne ¶
func (*Nav) MaintainMaximumForward ¶
func (nav *Nav) MaintainMaximumForward() av.CommandIntent
func (*Nav) MaintainPresentSpeed ¶ added in v0.14.0
func (nav *Nav) MaintainPresentSpeed() av.CommandIntent
func (*Nav) MaintainSlowestPractical ¶
func (nav *Nav) MaintainSlowestPractical() av.CommandIntent
func (*Nav) OnApproach ¶
func (*Nav) OnExtendedCenterline ¶
OnExtendedCenterline checks if the flight position is less than maxNmDeviation from the infinite line defined by the assigned approach localizer
func (*Nav) RestoreSnapshot ¶ added in v0.14.0
func (nav *Nav) RestoreSnapshot(snap NavSnapshot)
RestoreSnapshot restores nav state from a previously captured snapshot. The aircraft's physical state (FlightState) is NOT restored - only control assignments.
func (*Nav) ResumeOwnNavigation ¶
func (nav *Nav) ResumeOwnNavigation() av.CommandIntent
func (*Nav) SayAltitude ¶
func (nav *Nav) SayAltitude() av.CommandIntent
func (*Nav) SayHeading ¶
func (nav *Nav) SayHeading() av.CommandIntent
func (*Nav) SaySpeed ¶
func (nav *Nav) SaySpeed() av.CommandIntent
func (*Nav) Summary ¶
func (nav *Nav) Summary(fp av.FlightPlan, model *wx.Model, simTime time.Time, lg *log.Logger) string
Full human-readable summary of nav state for use when paused and mouse hover on the scope
func (*Nav) TakeSnapshot ¶ added in v0.14.0
func (nav *Nav) TakeSnapshot() NavSnapshot
TakeSnapshot captures the current controller-modifiable nav state for later rollback.
func (*Nav) TargetAltitude ¶
func (*Nav) TargetHeading ¶
func (*Nav) TargetSpeed ¶
func (nav *Nav) TargetSpeed(targetAltitude float32, fp *av.FlightPlan, wxs wx.Sample, bravo *av.AirspaceGrid) (float32, float32)
func (*Nav) Update ¶
func (nav *Nav) Update(callsign string, model *wx.Model, fp *av.FlightPlan, simTime time.Time, bravo *av.AirspaceGrid) *av.Waypoint
returns passed waypoint if any
func (*Nav) UpdateWithWeather ¶
func (nav *Nav) UpdateWithWeather(callsign string, wxs wx.Sample, fp *av.FlightPlan, simTime time.Time, bravo *av.AirspaceGrid) *av.Waypoint
UpdateWithWeather is a helper for simulations that use pre-fetched weather
type NavAirwork ¶
type NavAirwork struct {
}
func StartAirwork ¶
func StartAirwork(wp av.Waypoint, nav Nav) *NavAirwork
func (*NavAirwork) Start360 ¶
func (aw *NavAirwork) Start360(nav Nav)
func (*NavAirwork) TargetAltitude ¶
func (aw *NavAirwork) TargetAltitude() (float32, float32)
func (*NavAirwork) TargetHeading ¶
func (aw *NavAirwork) TargetHeading() (heading float32, turn TurnMethod, rate float32)
func (*NavAirwork) TargetSpeed ¶
func (aw *NavAirwork) TargetSpeed() (float32, float32, bool)
func (*NavAirwork) Update ¶
func (aw *NavAirwork) Update(nav *Nav) bool
type NavAltitude ¶
type NavAltitude struct {
// restriction at the way point; we keep trying until we get there (or
// are given another instruction..)
Restriction *av.AltitudeRestriction
}
type NavApproach ¶
type NavApproach struct {
}
type NavFixAssignment ¶
type NavHeading ¶
type NavHeading struct {
}
type NavSnapshot ¶ added in v0.14.0
type NavSnapshot struct {
}
NavSnapshot captures all controller-modifiable state in Nav for rollback purposes. It does NOT include FlightState (aircraft physical position/heading/altitude) - only control assignments that can be rolled back.
type TurnMethod ¶
type TurnMethod int
const ( TurnClosest TurnMethod = iota // default TurnLeft TurnRight )
func (TurnMethod) String ¶
func (t TurnMethod) String() string