Show the drone's locked home point on the fly-mode map

Adds MSP_WP (118) support to query the flightcontroller's stored home
point (WP#0 is a special case for this in iNAV's getWaypoint(), per
navigation.c) - the FC reports (0,0,0) rather than an error before one
is set, so parseMspHomePoint() treats that pair as "unset". Rendered
with a small pentagon house icon (design/homepoint-pentagon.svg,
ported to a CustomPainter like the other map icons).

Deliberately not polled continuously: a new home_point_provider.dart
refreshes it only at the three moments the FC's home point can
actually change - connect/reconnect, GPS fix acquired, and arming
(iNAV's default reset_home_type=FIRST_ARM only freezes it at the first
arm; before that it continuously follows the aircraft while disarmed).

Mock's implementation offsets the point 25m from the anchor so it
doesn't sit exactly under the drone marker during UI testing.
This commit is contained in:
Constantin Leue
2026-08-09 21:10:00 +02:00
parent c9f16b13f8
commit 5fd5d0117a
12 changed files with 594 additions and 0 deletions
@@ -144,6 +144,24 @@ class TelemetryFrame {
final int? activeWaypointIndex;
}
/// Vom Flightcontroller gemeldeter Homepoint (Doku: "den auf der Drohne
/// gelockten Homepoint abfragen") - anders als [TelemetryFrame] NICHT Teil
/// des kontinuierlichen Telemetrie-Stroms, sondern gezielt per
/// [FlightControllerLink.readHomePoint] abgefragt (siehe dortige Doku und
/// ui/providers/home_point_provider.dart fuer die drei Momente, zu denen
/// das tatsaechlich noetig ist).
class HomePoint {
const HomePoint({required this.lat, required this.lon, required this.altitudeM});
final double lat;
final double lon;
/// Referenzhoehe des Homepoints in Metern (bei MSP: `GPS_home.alt` in cm,
/// bereits umgerechnet) - relativ zum selben Nullpunkt wie
/// TelemetryFrame.altitudeM, keine absolute Hoehe ueber Meeresspiegel.
final double altitudeM;
}
/// Zentrale Abstraktion fuer alle Flightcontroller-Interaktionen (Doku 3.1).
/// Implementierungen: MspFlightControllerLink (iNAV), MavlinkFlightControllerLink
/// (ArduPilot, Post-MVP), MockFlightControllerLink (Tests ohne Hardware).
@@ -171,4 +189,13 @@ abstract class FlightControllerLink {
Stream<TelemetryFrame> subscribeTelemetry();
Future<int?> readActiveWaypointIndex();
/// Fragt den aktuell auf dem Flightcontroller gespeicherten Homepoint ab,
/// oder `null`, wenn dort noch keiner gesetzt ist (bei MSP: FC meldet vor
/// dem ersten Fix (0,0,0) statt eines Fehlers, siehe
/// `MspFlightControllerLink.readHomePoint`-Doku). Bewusst ein einzelner
/// gezielter Abruf statt eines Streams/Poll-Feldes - der Homepoint
/// aendert sich ausserhalb weniger Trigger-Momente ohnehin nicht (siehe
/// ui/providers/home_point_provider.dart).
Future<HomePoint?> readHomePoint();
}