Skip to content

Add Realistic Altimeter Simulation#868

Open
Jud6969 wants to merge 27 commits into
mmp:masterfrom
Jud6969:add-altimeter-sim
Open

Add Realistic Altimeter Simulation#868
Jud6969 wants to merge 27 commits into
mmp:masterfrom
Jud6969:add-altimeter-sim

Conversation

@Jud6969
Copy link
Copy Markdown
Contributor

@Jud6969 Jud6969 commented Apr 20, 2026

Closes #852 , & #781

  • Adds a SimulatePilotAltimeter scenario toggle that gives each aircraft its own PilotAltim (inHg). When enabled, the aircraft flies to its indicated altitude rather than its true altitude — if the pilot's setting differs from the local actual, the aircraft's true altitude drifts proportionally (1 inHg ~= 1000 ft).
  • Initial altimeter is chosen on spawn: departures use the departure field's METAR; arrivals / IFR overflights / VFR with flight-following use the nearest METAR; VFR overflights without flight-following have a 30% chance of using a random METAR within 100 NM (the "I set the wrong airport" case). Bias only applies airborne and below FL180.
  • Controllers can issue ALT 3002 (or spoken equivalents) to update the pilot's setting, producing an altimeter readback. "Altimeter three zero zero two" is also extracted mid-sentence so it can ride along with other instructions.
  • Also adds a small debug aid: when paused, hovering an aircraft shows its current pilot altimeter and indicated altitude alongside the existing nav summary.
  • Added stop altitude squawk phraseology IAW 5-2-15 of the 7110.65
  • Added "report reaching" functionality

@Jud6969 Jud6969 closed this Apr 20, 2026
@Jud6969 Jud6969 changed the title sim: simulate pilot altimeter setting and resulting altitude bias Added Realistic Altimeter Simulation Apr 20, 2026
@Jud6969 Jud6969 reopened this Apr 20, 2026
@Jud6969 Jud6969 changed the title Added Realistic Altimeter Simulation Add Realistic Altimeter Simulation Apr 20, 2026
@Jud6969 Jud6969 force-pushed the add-altimeter-sim branch from 34a8a24 to 13e7253 Compare April 20, 2026 15:36
@Jud6969 Jud6969 marked this pull request as draft April 20, 2026 16:31
@Jud6969 Jud6969 marked this pull request as ready for review April 20, 2026 16:57
Jud6969 and others added 23 commits May 18, 2026 09:03
Sentinel-based: PilotAltim==0 means feature inactive for that aircraft.
FacilityAdaptation.SimulatePilotAltimeter gates everything else, default off.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
altimBiasFeet computes (actual - pilot) * 1000 with sentinel for zero pilot.
nearestActualAltim picks closest METAR-reporting station, 0 on empty map.
Unit tests cover sign correctness, sentinel, magnitude, and empty METAR.
Adds altimBiasFeet float32 to Nav.Update and Nav.UpdateWithWeather; applied
unconditionally to targetAltitude before updateAltitude. All existing call
sites pass 0, so no behavior changes yet.
Bias is gated on SimulatePilotAltimeter, IsAirborne, and Altitude < 18000.
Below toggle is off and no aircraft have PilotAltim set, so all biases are
0 — behavior unchanged until spawn-init wires PilotAltim.
Hybrid rule: departures use field METAR; arrivals/IFR/VFR-with-FF use
nearest METAR; fresh VFR overflights get a 30% chance of a random
station-within-100NM altimeter (simulating stale upstream setting).
PendingTransmissionAltimeterReadback carries hundredths-of-inHg in
PendingContact.AltimeterHundredths. Render-switch mutates ac.PilotAltim
at audible-event time, matching the TrafficInSight pattern.
Enqueues a PendingTransmissionAltimeterReadback when the toggle is on and
the aircraft is on a controller frequency. Silent no-op when toggle off.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace stripAltimeterSuffix with extractAltimeterSuffix that returns the
parsed hundredths-of-inHg. Range-gated 2500-3200 to reject implausible
numbers (e.g., headings). Caller captures the value but does not yet
dispatch it (next commit).
Controller transmissions ending in 'altimeter X.XX' now produce an ALT/<hundredths>
synthetic command, which the sim dispatches to handleAltimeterSetting on the
addressed aircraft.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Spawns aircraft near KJFK with PilotAltim=30.05, teleports near KABE
(altim 29.95), verifies altitude drifts to ~4900, issues 'altimeter 29.95',
verifies aircraft drifts back to ~5000.
…ntent

- Scan whole token stream for altimeter keyword (not just suffix), splice
  matched tokens out so the rest of the transmission still parses.
- Fuzzy-match the altimeter keyword (Jaro-Winkler 0.85) so "altometer",
  "altimeters", etc. still trigger extraction.
- Accept "N point NN" form alongside "NNNN" and "N NN".
- Dispatch <CALLSIGN> ALT/<hundredths> when altimeter is the only content
  in the transmission, instead of returning empty.
- Update test JSON expected commands to include the now-extracted ALT
  tokens.
Turn the toggle on for the N90 facility so the altimeter setting feature
gets exercised in the default scenario.
The pilot reads off their altimeter, which is offset from true altitude
when the pilot's setting differs from the local actual. Subtract the
bias so the verbal "say altitude" response matches what the pilot
actually sees, even when the scope shows the (corrected) true altitude.

Factor altimBiasFor() out of the per-tick loop so SayAltitude and the
update loop compute the bias the same way.
Altimeter setting was dispatched as a separate PendingContact, so when
combined with other commands ("descend 5000, altimeter 30.05") the
pilot read it back as a second transmission. Return it as a
CommandIntent like AssignHeading / AssignAltitude so it merges into
the single readback string.

Also fix the spoken form to read the setting as four individual digits
("altimeter three zero zero five") instead of two grouped numbers
("altimeter thirty five").
Telling an aircraft "information alpha" implies the pilot just listened
to that ATIS and now has the current altimeter. Set PilotAltim to the
ATIS airport's METAR so subsequent altitude assignments use the correct
bias.
Remove the SimulatePilotAltimeter FacilityAdaptation toggle so the
feature runs unconditionally in all scenarios.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When the sim is paused, hovering an aircraft now shows the pilot's set
altimeter (inHg) and their indicated altitude alongside the existing
nav summary — useful for debugging altimeter bias behavior.
Add Aircraft.setPilotAltim(simTime, inHg) and route the six existing
call sites through it. Also split initPilotAltim's value selection into
initialPilotAltimValue so the write happens exactly once instead of in
every branch.
Adds a SimulateIncorrectAltimeters flag to NewSimRequest / Sim,
defaulted to true, with a checkbox in the Simulation Settings panel
below the readback error interval. When disabled, initPilotAltim is
skipped at spawn and altimBiasFor returns 0.
…nsponders

Replaces the on/off altimeter checkbox with a probability slider and
drops the hardcoded 30% VFR-overflight-no-FF carve-out. All non-
departure spawns now roll once against IncorrectAltimeterChance; on a
hit, they get a nearby-but-wrong station's altimeter.

Also adds a second slider for faulty-transponder simulation. Aircraft
that roll a hit get a persistent Mode C encoder offset (signed random
magnitude 1-1000 ft) that's fixed for the aircraft's life. The offset
is added to TransponderAltitude at GetRadarTrack, so scope display,
CA, and MSAW all read the corrupted number — TrueAltitude (used for
3D airspace and visibility checks) stays correct.
Match the probability gate on incorrect altimeters, which defaults to
30%. At 0 there's no simulation at all, so pick a small but non-zero
default so new sims exercise the Mode C offset path without being
overwhelming.
"Stop altitude squawk" gives controllers the proper phraseology for
responding to a Mode C altitude mismatch: the aircraft switches from
Mode C to Mode A and the readback uses the specific phrase rather
than the generic "squawk on" readback. An optional "altitude differs
NNN feet" tail is accepted and ignored.

"Report reaching {altitude}" installs a pending target on the nav
state. A new altitude assignment or a new report-reaching request
supersedes any pending target. When the aircraft levels off within
100 ft of the target (AltitudeRate clamped to 0), the sim enqueues
an unsolicited "reaching {alt}" pilot transmission and clears the
target.
The RR dispatch was mistakenly placed inside case 'S', so "RR50"
(command[0]=='R') fell through to the turn-right heading parser,
which either errored or produced a spurious heading. Move it under
case 'R' with the same 100-ft scaling as the altitude assignments,
so "report reaching 5000" correctly targets 5000 ft instead of 50 ft.
Jud6969 and others added 4 commits May 18, 2026 09:18
The pilot's "reaching NNNN" call is fulfilling a controller-requested
report, not an out-of-turn urgent transmission, so it shouldn't
render in the unexpected/red style. Leave it at the default
RadioTransmissionContact type that MakeContactTransmission sets.
Using MakeContactTransmission tags it as a first-contact call, which
the formatter prefixes with "{controller}, {full callsign}, ...". A
report-reaching report is a brief advisory on an already-established
frequency, so switch to MakeReadbackTransmission, which just appends
the abbreviated callsign at the end.
"say altitude" was being misrouted to "stop altitude squawk" because
"say" and "stop" both start with 's' and Jaro-Winkler's prefix bonus
was enough to fuzzy-match them — particularly since the stop-squawk
template has higher priority. Add both directions to the fuzzy-match
blocklist so the say-altitude command isn't captured.
The hold_test.go file was added on upstream/master after this branch
diverged, so the altimeter-rebase didn't sweep its UpdateWithWeather
call sites. Pass 0 to match the new signature.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jud6969 Jud6969 force-pushed the add-altimeter-sim branch from 3caf4fa to a015c2f Compare May 18, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(rare) aircraft with incorrect altitudes due to wrong altimeter

1 participant