garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/notes/rtk-receiver.md

raw


topic: rtk-receiver triggers: [gnss_receiver, cartopolis_gnss, UsbSerial.java, RTK, NTRIP, UM980, RTCM, NMEA, ttyUSB, "external receiver", "serial port", FT230X, crates/gnss] updated: 2026-11-22

An external RTK receiver as the position

A GNSS receiver on a cable — first the UM980 RTK Handheld Surveyor Kit — is the client's first location provider when switched on in Settings ▸ General ▸ GNSS receiver. platform::gnss_receiver runs it; LocationWatch asks it before the platform's own provider, so the locate button, driver mode, location sharing and the high-precision anchor take its fix without knowing it exists. The parsing, the caster client and the receiver loop are the Bevy-free cartopolis_gnss. The crate reads any byte port; the client supplies one per platform — a tty through the crate's serial feature on the desktop (off by default, and never turned on for Android, which gets no tty for a USB adapter) and UsbSerial.java on Android.

The receiver does the RTK

The client never solves anything. It asks the receiver for GGA/RMC/GST (receiver::configure_commands), writes the caster's RTCM into the same port, and reads back a position whose GGA quality says single, DGPS, RTK float or RTK fixed. The accuracy is the receiver's own GST (√(σlat² + σlng²), ≈ the 68 % radius Android reports) and only estimated from quality and HDOP when no GST arrives — so a fixed solution reads ±1–2 cm and the phone's ±4 m beside it compare like for like.

Its height stands the avatar on a roof

The GGA height is the antenna above the receiver's mean sea level. With an RTK float or fixed solution it is good to centimetres; on the Forum's roof on 2026-11-05 it read 53.60 m against 3DBAG's 52.15 m NAP for the roof terrace — the roof plus a phone held at the chest. Until then the app dropped the height and stood the avatar in the street under the person.

Every height travels with its error (GpsFix::height, a GpsHeight: metres above sea level and a 1σ, from GST when the receiver sends one, else by fix quality — Solution::height_sigma_m; a code solution's vertical is taken as twice its horizontal). Android's own getMslAltitudeMeters (API 34, with its accuracy) is passed the same way; the browser's ellipsoid height is not. Until 2026-11-22 only carrier-phase heights were passed at all, and on the Forum's roof without an RTK fix (a single solution, ±4 m) the avatar stood in the street inside the building's shell.

locate turns it into metres above the ground there (minus PHONE_HEIGHT_M, against the terrain's datum_m) as AvatarState::measured_level, and Footing::step takes the floor from it instead of the step rule, as far as the error allows:

AvatarState::floor_measured says whether the floor came from the measurement this frame; while it did the offline eject backstop stands down, and track_indoors does not count a level over the top storey as inside. Online the lift is the client's alone: the sim is flat, so other people still see the avatar at street level.

The kit as found (2026-10-13)

Nothing may change the receiver for good

A Unicore receiver takes text commands on the port it reports on, including FRESET (factory reset), SAVECONFIG, baud and mode changes, and it is the same port the corrections go into. So every write passes one of two gates in receiver.rs, which check each byte they are handed:

a_hostile_caster_cannot_type_at_the_receiver and nothing_is_sent_to_a_receiver_that_has_not_been_heard pin the first three.

NTRIP

Getting a report off a phone

The receiver keeps its own event history (Status::events, the last 80: opened, heard at this baud, configured, each reply, every change of fix kind, the delivered rate, the station chosen and why, stream open, failures). A phone's log is a ring this client rolls over in minutes, so the history is what survives to be reported. Settings ▸ GNSS receiver ▸ Copy receiver report puts settings (never the password), live state and the history on the clipboard; Share diagnostics… carries the same section.

Android: the USB host API, not a tty

A phone gives apps no tty for a USB serial adapter, so UsbSerial.java speaks the adapter's protocol over UsbDeviceConnection: FTDI, Silicon Labs CP210x and CDC-ACM. WCH CH34x is refused by name — its line setup is undocumented register writes, and guessing them blind was not worth it. USB access is asked per device at runtime (a broadcast; Context.RECEIVER_NOT_EXPORTED works because the PendingIntent is ours). A refusal is remembered until the device is unplugged, so the dialog is not re-raised every second.

Rejected

Not verified