Give the Fly App every remaining GO 4 flight mode and the missing settings

Intelligent modes: Point of Interest (orbit on the map, live radius and
speed), Follow Me (follows the phone), QuickShots on a boxed subject,
Course Lock / Home Lock, Tripod and Cinematic, a Free hyperlapse, and
Waypoints 2.0 for V2-only aircraft. ActiveTrack gains Spotlight Pro and
Circle. Every mode has a first-use tutorial and stops from the rail.
Waypoints can resume an interrupted mission, change cruise speed in
flight and check terrain clearance (Open-Meteo, on tap).

Settings: units, C1/C2 actions, dual-operator master/slave, HDMI/SDI
output, a link spectrum chart, Wi-Fi name and password, aircraft name,
video cache, battery warning history and pairing, non-smart cell
voltages. Calibration: compass interference meter, per-IMU calibration,
lens infinity focus and a first-manual-focus prompt. Also an RTK chip,
gimbal movement presets and motor tuning, Precision Takeoff gated on the
flight controller, and the precise GEO database's server version.

Built and unit/widget-tested only; nothing has flown yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-20 23:06:16 +02:00
1 parent 91ca150a35
commit 636da1ac2c
57 files changed
+5363 -87

No files matched your search

+99 -9
View File
@@ -5,7 +5,7 @@ import '../product_profile.dart';
///
/// Which modes a product has comes from [ProductProfile.modes] (the product
/// matrix until runtime capture confirms it); which of those this app can fly
/// yet is [ModeInfo.built]. A mode that is supported but not built is listed
/// is [ModeInfo.built]. A mode that is supported but not built is listed
/// greyed out rather than hidden, so the pilot sees what is coming.
class ModeInfo {
const ModeInfo({
@@ -15,6 +15,7 @@ class ModeInfo {
required this.group,
required this.blurb,
required this.terms,
this.tutorial = const <String>[],
this.built = false,
});
@@ -33,6 +34,10 @@ class ModeInfo {
/// The first-use disclaimer: what the pilot stays responsible for.
final List<String> terms;
/// GO 4's first-use tutorial: how to fly the mode, step by step. Shown once
/// after the terms, and again from the mode's panel.
final List<String> tutorial;
/// This app can fly the mode.
final bool built;
}
@@ -43,6 +48,13 @@ abstract final class ModeCatalog {
'The aircraft flies itself in this mode. Push the remote\'s pause button, or tap Stop, to make it hover.',
];
static const List<String> _waypointTutorial = <String>[
'Tap the map to drop waypoints; tap a waypoint to edit its altitude, speed, heading, gimbal and camera action.',
'Long-press and drag a waypoint to move it. The + between two waypoints inserts one there.',
'ROUTE sets the cruise speed, the heading and what happens at the end; LIBRARY saves the route.',
'START checks the route against the aircraft, uploads it and flies it. PAUSE holds the aircraft where it is.',
];
static const List<ModeInfo> all = <ModeInfo>[
ModeInfo(
mode: IntelligentMode.waypoint,
@@ -56,6 +68,7 @@ abstract final class ModeCatalog {
'The route flies straight between waypoints at the altitudes you set. It does not avoid terrain, trees or buildings: check the route and its altitudes before you start.',
'If the remote loses signal the aircraft follows the route\'s signal-lost setting.',
],
tutorial: _waypointTutorial,
),
ModeInfo(
mode: IntelligentMode.waypointV2,
@@ -63,7 +76,12 @@ abstract final class ModeCatalog {
icon: 'route',
group: 'Map',
blurb: 'Enterprise waypoint missions.',
terms: _common,
built: true,
terms: <String>[
..._common,
'Waypoints 2.0 flies the route\'s positions, altitudes, speeds and headings. Camera actions are not sent to the aircraft yet: run the camera yourself.',
],
tutorial: _waypointTutorial,
),
ModeInfo(
mode: IntelligentMode.pointOfInterest,
@@ -71,7 +89,17 @@ abstract final class ModeCatalog {
icon: 'circle',
group: 'Map',
blurb: 'Circle a subject at a set radius.',
terms: _common,
built: true,
terms: <String>[
..._common,
'The aircraft circles at a fixed height and does not brake for obstacles on the circle: check the whole circle is clear.',
],
tutorial: <String>[
'Tap the map on the subject, or AIRCRAFT to use where the aircraft is now.',
'Set the radius, the altitude and the speed; pick the direction and which way the aircraft faces.',
'GO flies to the circle and starts circling. Radius and speed can change while it circles.',
'The remote\'s sticks nudge the orbit; PAUSE holds position, STOP ends it.',
],
),
ModeInfo(
mode: IntelligentMode.followMe,
@@ -79,7 +107,18 @@ abstract final class ModeCatalog {
icon: 'user',
group: 'Map',
blurb: 'The aircraft follows this phone.',
terms: _common,
built: true,
terms: <String>[
..._common,
'The aircraft follows the phone\'s GPS, which can be off by several metres, and it does not avoid obstacles while it follows.',
'Keep the phone with you and its screen on: if the app stops sending your position the aircraft stops following and hovers.',
],
tutorial: <String>[
'Take off and climb to at least 10 m with open space around you.',
'Set the height to follow at and whether the aircraft faces you or the remote steers its heading.',
'GO: the aircraft keeps its distance as you walk. Keep the app open.',
'STOP, or the remote\'s pause button, ends it.',
],
),
ModeInfo(
mode: IntelligentMode.activeTrack,
@@ -93,6 +132,12 @@ abstract final class ModeCatalog {
'ActiveTrack follows what the camera sees. It can lose the subject behind trees or in crowds, and it does not see obstacles to the sides or behind on every aircraft.',
'Do not use it to follow cars or boats at speed, or over water and roads you cannot see the end of.',
],
tutorial: <String>[
'Drag a box round the subject on the video (or tap a person-sized one), then GO.',
'Trace follows behind, Profile alongside, Spotlight keeps the camera on it while you fly.',
'A green box is locked on, amber is unsure; confirm with ✓ when the aircraft asks.',
'Gestures: with Gesture mode on (Settings → Vision), raise your arms to be tracked, frame your fingers for a photo.',
],
),
ModeInfo(
mode: IntelligentMode.tapFly,
@@ -105,6 +150,11 @@ abstract final class ModeCatalog {
..._common,
'TapFly keeps flying towards the point until you stop it. Obstacle avoidance only works in the direction the sensors face, and not at all in Free.',
],
tutorial: <String>[
'Tap where to fly on the video, then GO.',
'Forward flies towards the point; Backward away from it; Free lets you turn the aircraft while it flies.',
'Set the speed with − / +; tap a new point to change course.',
],
),
ModeInfo(
mode: IntelligentMode.quickShots,
@@ -112,7 +162,16 @@ abstract final class ModeCatalog {
icon: 'dronie',
group: 'Shots',
blurb: 'Dronie, Rocket, Circle, Helix…',
terms: _common,
built: true,
terms: <String>[
..._common,
'A QuickShot flies a set path around the subject, up to 120 m away and high: keep that space clear.',
],
tutorial: <String>[
'Pick the shot, draw a box round the subject on the video, then GO.',
'The aircraft records the video, flies the path and comes back to where it started.',
'STOP, the sticks or the remote\'s pause button end it early.',
],
),
ModeInfo(
mode: IntelligentMode.hyperlapse,
@@ -120,7 +179,16 @@ abstract final class ModeCatalog {
icon: 'hyperlapse',
group: 'Shots',
blurb: 'A moving timelapse.',
terms: _common,
built: true,
terms: <String>[
'You fly the aircraft during a Free hyperlapse; the camera only shoots the frames. Fly slowly and steadily.',
'Stop the sequence before landing or flying home.',
],
tutorial: <String>[
'Set the interval between frames and how long the finished video should be.',
'START shoots the frames; fly a slow, steady line meanwhile.',
'The frames are on the SD card; assemble them into the video on a computer.',
],
),
ModeInfo(
mode: IntelligentMode.courseLock,
@@ -128,7 +196,15 @@ abstract final class ModeCatalog {
icon: 'compass',
group: 'Orientation',
blurb: 'Forward stays the current heading.',
terms: _common,
built: true,
terms: <String>[
'Course Lock changes what the sticks do: forward is the locked course, whichever way the aircraft faces. Turn it off before flying normally again.',
],
tutorial: <String>[
'Point the aircraft where "forward" should be, then turn Course Lock on.',
'Turn the aircraft freely: the sticks keep flying the locked course.',
'LOCK HEADING takes the current heading as the new course.',
],
),
ModeInfo(
mode: IntelligentMode.homeLock,
@@ -136,7 +212,14 @@ abstract final class ModeCatalog {
icon: 'home',
group: 'Orientation',
blurb: 'Pulling back always flies home.',
terms: _common,
built: true,
terms: <String>[
'Home Lock changes what the sticks do: back is always towards home, whichever way the aircraft faces. Turn it off before flying normally again.',
],
tutorial: <String>[
'Fly at least 10 m from home, then turn Home Lock on.',
'Pull the stick back to come home, push it to fly away, whichever way the aircraft points.',
],
),
ModeInfo(
mode: IntelligentMode.tripod,
@@ -144,7 +227,14 @@ abstract final class ModeCatalog {
icon: 'gauge',
group: 'Orientation',
blurb: 'Slow, precise control for framing.',
terms: _common,
built: true,
terms: <String>[
'Tripod mode limits the speed to about 1 m/s and makes the sticks very gentle. Turn it off to fly away from danger quickly.',
],
tutorial: <String>[
'Tripod: about 1 m/s and gentle sticks, for framing and indoor-tight spaces.',
'Cinematic: smooth braking and slow turns for steady video; set how gently it brakes and turns.',
],
),
];
+283
View File
@@ -0,0 +1,283 @@
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:latlong2/latlong.dart' show LatLng;
import '../hud_geometry.dart';
/// The remaining Intelligent Flight Modes (plan P7) as pure data: Point of
/// Interest, Follow Me, QuickShots, Hyperlapse and the orientation /
/// Tripod / Cinematic switches. The SafetyGate checks them and the bridge
/// flies them; nothing here talks to the aircraft.
// ── Point of Interest ─────────────────────────────────────────────────────────
/// Which way the aircraft faces while circling (`HotpointHeading`).
enum PoiHeading {
toCenter('Towards POI', 'TOWARDS_HOT_POINT'),
away('Away from POI', 'AWAY_FROM_HOT_POINT'),
forward('Along the circle', 'ALONG_CIRCLE_LOOKING_FORWARDS'),
backward('Along, looking back', 'ALONG_CIRCLE_LOOKING_BACKWARDS'),
remote('Remote controls it', 'CONTROLLED_BY_REMOTE_CONTROLLER');
const PoiHeading(this.label, this.sdk);
final String label;
final String sdk;
}
/// Where on the circle the aircraft joins it (`HotpointStartPoint`).
enum PoiStart {
nearest('Nearest', 'NEAREST'),
north('North', 'NORTH'),
east('East', 'EAST'),
south('South', 'SOUTH'),
west('West', 'WEST');
const PoiStart(this.label, this.sdk);
final String label;
final String sdk;
}
/// A Point of Interest orbit as the pilot sets it up (GO 4's POI panel).
@immutable
class PoiSpec {
const PoiSpec({
this.center,
this.radius = 30,
this.altitude = 30,
this.speed = 3,
this.clockwise = true,
this.heading = PoiHeading.toCenter,
this.start = PoiStart.nearest,
});
// `HotpointMission` limits (MSDK 4.18 constants).
static const double minRadius = 5;
static const double maxRadius = 500;
static const double minAltitude = 5;
static const double maxAltitude = 500;
/// The operator's ceiling for the orbit, whatever the radius allows.
static const double maxSpeed = 10;
static const double minSpeed = 0.5;
/// Below this the pre-start check warns about trees and buildings.
static const double lowAltitude = 20;
final LatLng? center;
final double radius;
final double altitude;
/// Tangential speed, m/s; the bridge wants °/s ([angularVelocity]).
final double speed;
final bool clockwise;
final PoiHeading heading;
final PoiStart start;
static const Object _keep = Object();
PoiSpec copyWith({
Object? center = _keep,
double? radius,
double? altitude,
double? speed,
bool? clockwise,
PoiHeading? heading,
PoiStart? start,
}) =>
PoiSpec(
center: identical(center, _keep) ? this.center : center as LatLng?,
radius: radius ?? this.radius,
altitude: altitude ?? this.altitude,
speed: speed ?? this.speed,
clockwise: clockwise ?? this.clockwise,
heading: heading ?? this.heading,
start: start ?? this.start,
);
/// Degrees per second for a tangential [speed] on a circle of [radius].
static double angularFor(double speed, double radius) => speed / radius * 180 / math.pi;
/// The tangential speed of [deg] °/s on [radius].
static double speedFor(double deg, double radius) => deg * math.pi / 180 * radius;
double get angularVelocity => angularFor(speed, radius);
/// Seconds per lap.
int get lapSeconds => (2 * math.pi * radius / speed.clamp(minSpeed, maxSpeed)).round();
/// What would make the operator refuse the orbit (blocking) or what the
/// pilot should know (not).
List<(bool, String)> issues({double? maxAngular, LatLng? aircraft}) => <(bool, String)>[
if (center == null) (true, 'Set the point of interest: tap the map, or use the aircraft\'s position.'),
if (radius < minRadius || radius > maxRadius) (true, 'The radius must be between 5 and 500 m.'),
if (altitude < minAltitude || altitude > maxAltitude) (true, 'The altitude must be between 5 and 500 m.'),
if (maxAngular != null && maxAngular > 0 && angularVelocity > maxAngular)
(false, 'At ${radius.round()} m the aircraft circles at most ${speedFor(maxAngular, radius).toStringAsFixed(1)} m/s; it flies that speed.'),
if (altitude < lowAltitude) (false, 'The orbit is only ${altitude.round()} m up: check for trees and buildings on the circle.'),
if (center != null && aircraft != null && HudGeometry.distance(aircraft.latitude, aircraft.longitude, center!.latitude, center!.longitude) > 1000)
(false, 'The point of interest is more than 1 km from the aircraft.'),
];
/// `startHotpoint`'s arguments; [maxAngular] caps the speed the operator would refuse.
Map<String, Object?> toBridge({double? maxAngular}) {
double w = angularVelocity;
if (maxAngular != null && maxAngular > 0) w = math.min(w, maxAngular);
return <String, Object?>{
'lat': center!.latitude,
'lon': center!.longitude,
'altitude': altitude.clamp(minAltitude, maxAltitude),
'radius': radius.clamp(minRadius, maxRadius),
'angularVelocity': w,
'clockwise': clockwise,
'startPoint': start.sdk,
'heading': heading.sdk,
};
}
}
// ── Follow Me ─────────────────────────────────────────────────────────────────
enum FollowMeHeading {
toPilot('Face me', 'TOWARD_FOLLOW_POSITION'),
remote('Remote controls it', 'CONTROLLED_BY_REMOTE_CONTROLLER');
const FollowMeHeading(this.label, this.sdk);
final String label;
final String sdk;
}
@immutable
class FollowMeSpec {
const FollowMeSpec({this.altitude = 15, this.heading = FollowMeHeading.toPilot});
static const double minAltitude = 10;
static const double maxAltitude = 120;
/// How often the phone's fix is sent while following.
static const Duration updateEvery = Duration(milliseconds: 500);
/// A phone fix worse than this (m) is not worth following.
static const double maxAccuracy = 15;
final double altitude;
final FollowMeHeading heading;
FollowMeSpec copyWith({double? altitude, FollowMeHeading? heading}) =>
FollowMeSpec(altitude: altitude ?? this.altitude, heading: heading ?? this.heading);
}
// ── QuickShots ────────────────────────────────────────────────────────────────
/// GO 4's QuickShots (`QuickShotMode` names); which ones an aircraft flies is
/// its firmware's call — an unsupported one is refused by the operator.
enum QuickShot {
dronie('Dronie', 'DRONIE', 'Flies up and back, camera on the subject'),
rocket('Rocket', 'ROCKET', 'Climbs straight up, camera looking down'),
circle('Circle', 'CIRCLE', 'Circles the subject at its height'),
helix('Helix', 'HELIX', 'Spirals up and out around the subject'),
boomerang('Boomerang', 'BOOMERANG', 'Swings out and back in an oval'),
asteroid('Asteroid', 'ASTEROID', 'Flies up and back, then a spherical pano'),
dollyZoom('Dolly zoom', 'DOLLY_ZOOM', 'Backs away while zooming in (zoom cameras)');
const QuickShot(this.label, this.sdk, this.blurb);
final String label;
final String sdk;
final String blurb;
/// The shots GO 4 offers on this product: Boomerang and Asteroid came with
/// the omni-sensing aircraft, Dolly zoom needs a zoom lens.
static List<QuickShot> offered({required bool omni, required bool zoom}) => <QuickShot>[
dronie,
rocket,
circle,
helix,
if (omni) boomerang,
if (omni) asteroid,
if (zoom) dollyZoom,
];
}
// ── Hyperlapse ────────────────────────────────────────────────────────────────
/// A Free hyperlapse: the camera shoots an interval sequence while the pilot
/// flies, for a video of [videoSeconds] at [fps] (GO 4's Hyperlapse → Free).
/// MSDK V4 has no hyperlapse operator, so the flight is the pilot's and the
/// frames are assembled afterwards.
@immutable
class HyperlapseSpec {
const HyperlapseSpec({this.intervalSeconds = 2, this.videoSeconds = 10, this.fps = 25});
static const List<int> intervals = <int>[2, 3, 5, 10];
static const List<int> durations = <int>[5, 10, 15, 20, 30];
final int intervalSeconds;
final int videoSeconds;
final int fps;
int get frames => (videoSeconds * fps).clamp(2, 10000);
/// The camera's interval count: at most 254 frames, else 255 = "until
/// stopped", and the gate stops it after [shootingSeconds].
int get cameraCount => frames > 254 ? 255 : frames;
/// How long the shooting takes, s.
int get shootingSeconds => frames * intervalSeconds;
HyperlapseSpec copyWith({int? intervalSeconds, int? videoSeconds}) =>
HyperlapseSpec(intervalSeconds: intervalSeconds ?? this.intervalSeconds, videoSeconds: videoSeconds ?? this.videoSeconds, fps: fps);
}
// ── Orientation / Tripod / Cinematic ──────────────────────────────────────────
/// Intelligent Orientation Control (`FlightOrientationMode`).
enum OrientationMode {
normal('Normal', 'AIRCRAFT_HEADING'),
courseLock('Course Lock', 'COURSE_LOCK'),
homeLock('Home Lock', 'HOME_LOCK');
const OrientationMode(this.label, this.sdk);
final String label;
final String sdk;
static OrientationMode fromSdk(String? s) => switch (s) {
'COURSE_LOCK' => courseLock,
'HOME_LOCK' => homeLock,
_ => normal,
};
}
/// Home Lock refuses within this distance of home: "pull back" has no direction.
const double homeLockMinDistance = 10;
/// What the pilot has set up in the POI / Follow Me / Hyperlapse panels,
/// shared by the panel, the map layer and the flight screen.
class ModeSetup extends ChangeNotifier {
PoiSpec poi = const PoiSpec();
FollowMeSpec followMe = const FollowMeSpec();
HyperlapseSpec hyperlapse = const HyperlapseSpec();
/// The aircraft's fastest orbit at [poi]'s radius (°/s), once asked.
double? poiMaxAngular;
void setPoi(PoiSpec p) {
if (p.radius != poi.radius) poiMaxAngular = null;
poi = p;
notifyListeners();
}
void setPoiMaxAngular(double? v) {
poiMaxAngular = v;
notifyListeners();
}
void setFollowMe(FollowMeSpec f) {
followMe = f;
notifyListeners();
}
void setHyperlapse(HyperlapseSpec h) {
hyperlapse = h;
notifyListeners();
}
}
+139
View File
@@ -0,0 +1,139 @@
import 'dart:convert';
import 'dart:io';
import 'package:latlong2/latlong.dart' show LatLng;
import '../hud_geometry.dart';
import 'waypoint_mission.dart';
/// The route's clearance over the ground (plan P7's terrain check).
///
/// Waypoint altitudes are relative to the take-off point, so a route that
/// climbs a hillside can fly into it while every waypoint reads "50 m". This
/// samples the ground along every leg (an elevation service, [ElevationSource])
/// and compares it with the aircraft's planned height above sea level: take-off
/// elevation + the altitude interpolated along the leg.
///
/// Pure apart from the source, so the maths is unit-tested with a fake.
abstract class ElevationSource {
/// Ground elevation in metres above sea level for each point, in order.
Future<List<double>> elevations(List<LatLng> points);
}
/// One sample along the route that comes too close to the ground.
class TerrainIssue {
const TerrainIssue({required this.leg, required this.clearance, required this.at});
/// The leg it is on: from waypoint [leg] to [leg] + 1 (0-based).
final int leg;
/// Metres between the aircraft and the ground there (negative = underground).
final double clearance;
final LatLng at;
MissionIssue toIssue() => clearance < 0
? MissionIssue.error(
'Between waypoints ${leg + 1} and ${leg + 2} the ground rises ${(-clearance).round()} m above the route.',
point: leg + 1,
)
: MissionIssue.warning(
'Between waypoints ${leg + 1} and ${leg + 2} the route passes only ${clearance.round()} m over the ground.',
point: leg + 1,
);
}
class TerrainCheck {
const TerrainCheck(this.source, {this.spacing = 50, this.minClearance = 15, this.maxSamples = 100});
final ElevationSource source;
/// Metres between samples along a leg.
final double spacing;
/// Less clearance than this is reported.
final double minClearance;
/// The service takes at most this many points per request.
final int maxSamples;
/// Samples along the route: every waypoint, and points every [spacing] m
/// between them, each with its leg and planned altitude (relative to take-off).
List<(int leg, LatLng at, double altitude)> samples(WaypointMissionSpec spec) {
final List<(int, LatLng, double)> out = <(int, LatLng, double)>[];
final List<WaypointSpec> p = spec.points;
for (int i = 0; i + 1 < p.length; i++) {
final LatLng a = p[i].at, b = p[i + 1].at;
final double d = HudGeometry.distance(a.latitude, a.longitude, b.latitude, b.longitude);
final int n = (d / spacing).ceil().clamp(1, 1000);
for (int k = 0; k < n; k++) {
final double t = k / n;
out.add((
i,
LatLng(a.latitude + (b.latitude - a.latitude) * t, a.longitude + (b.longitude - a.longitude) * t),
p[i].altitude + (p[i + 1].altitude - p[i].altitude) * t,
));
}
}
if (p.isNotEmpty) out.add((p.length - 2 < 0 ? 0 : p.length - 2, p.last.at, p.last.altitude));
// Evenly thinned to the service's limit.
if (out.length > maxSamples) {
final double step = out.length / maxSamples;
return <(int, LatLng, double)>[for (int k = 0; k < maxSamples; k++) out[(k * step).floor()]];
}
return out;
}
/// The places the route comes within [minClearance] of the ground; [home]
/// is the take-off point the altitudes are measured from. The worst per leg.
Future<List<TerrainIssue>> run(WaypointMissionSpec spec, LatLng home) async {
final List<(int, LatLng, double)> s = samples(spec);
if (s.isEmpty) return const <TerrainIssue>[];
final List<double> ground = await source.elevations(<LatLng>[home, for (final (int, LatLng, double) x in s) x.$2]);
if (ground.length != s.length + 1) throw const FormatException('The elevation service answered for a different number of points');
final double base = ground.first;
final Map<int, TerrainIssue> worst = <int, TerrainIssue>{};
for (int k = 0; k < s.length; k++) {
final (int leg, LatLng at, double alt) = s[k];
final double clearance = base + alt - ground[k + 1];
if (clearance >= minClearance) continue;
final TerrainIssue? w = worst[leg];
if (w == null || clearance < w.clearance) worst[leg] = TerrainIssue(leg: leg, clearance: clearance, at: at);
}
final List<TerrainIssue> out = worst.values.toList()..sort((TerrainIssue a, TerrainIssue b) => a.leg.compareTo(b.leg));
return out;
}
}
/// Open-Meteo's free elevation API (Copernicus 90 m DEM, no key). Sends the
/// sampled coordinates to api.open-meteo.com, so the check only runs when the
/// pilot asks for it.
class OpenMeteoElevation implements ElevationSource {
const OpenMeteoElevation();
@override
Future<List<double>> elevations(List<LatLng> points) async {
final List<double> out = <double>[];
// 100 coordinates per request is the API's limit.
for (int i = 0; i < points.length; i += 100) {
final List<LatLng> chunk = points.sublist(i, (i + 100).clamp(0, points.length));
final Uri uri = Uri.https('api.open-meteo.com', '/v1/elevation', <String, String>{
'latitude': chunk.map((LatLng p) => p.latitude.toStringAsFixed(5)).join(','),
'longitude': chunk.map((LatLng p) => p.longitude.toStringAsFixed(5)).join(','),
});
final HttpClient client = HttpClient()..connectionTimeout = const Duration(seconds: 10);
try {
final HttpClientRequest req = await client.getUrl(uri);
final HttpClientResponse res = await req.close().timeout(const Duration(seconds: 15));
final String body = await res.transform(utf8.decoder).join();
if (res.statusCode != 200) throw HttpException('Elevation service answered ${res.statusCode}', uri: uri);
final Object? json = jsonDecode(body);
final Object? list = json is Map ? json['elevation'] : null;
if (list is! List) throw const FormatException('No elevation in the answer');
out.addAll(<double>[for (final Object? e in list) (e as num).toDouble()]);
} finally {
client.close();
}
}
return out;
}
}
+31 -1
View File
@@ -2,6 +2,8 @@ import 'dart:ui' show Offset, Rect, Size;
import 'package:flutter/foundation.dart';
import 'orbit_modes.dart' show QuickShot;
/// What the pilot has chosen in an ActiveTrack or TapFly session, before and
/// while the operator runs: shared by the video overlay and the mode panel.
class VisionSession extends ChangeNotifier {
@@ -9,6 +11,22 @@ class VisionSession extends ChangeNotifier {
TapFlyDirection direction = TapFlyDirection.forward;
double speed = 5;
/// ActiveTrack Circle's orbit, m/s; negative goes anticlockwise.
double circleSpeed = 3;
/// The QuickShot the next box flies.
QuickShot quickShot = QuickShot.dronie;
void setCircleSpeed(double v) {
circleSpeed = v;
notifyListeners();
}
void setQuickShot(QuickShot s) {
quickShot = s;
notifyListeners();
}
/// A box drawn (or tapped) on the video, 0..1, waiting for GO.
Rect? pendingBox;
@@ -77,12 +95,24 @@ enum TrackMode {
profile('Profile', 'PROFILE'),
/// Stays put and keeps the camera on it; the pilot flies.
spotlight('Spotlight', 'SPOTLIGHT');
spotlight('Spotlight', 'SPOTLIGHT'),
/// Spotlight that also turns the aircraft (the gimbal alone cannot keep
/// up): Mavic 2-class aircraft.
spotlightPro('Spotlight Pro', 'SPOTLIGHT_PRO'),
/// Orbits the subject at [VisionSession.circleSpeed].
circle('Circle', 'CIRCLE');
const TrackMode(this.label, this.sdk);
final String label;
final String sdk;
/// The follow styles GO 4 offers: Spotlight Pro and Circle came with the
/// omni-sensing aircraft (Mavic 2); everything else has the first three.
static List<TrackMode> offered({required bool omni}) =>
<TrackMode>[trace, profile, spotlight, if (omni) spotlightPro, if (omni) circle];
static TrackMode? fromSdk(String? s) {
for (final TrackMode m in values) {
if (m.sdk == s) return m;
@@ -365,6 +365,21 @@ class WaypointMissionSpec {
updatedAt: updatedAt ?? this.updatedAt,
);
/// The rest of the route from waypoint [index] on (0-based), to resume an
/// interrupted mission there. Keeps the route settings and POIs.
WaypointMissionSpec from(int index) => copyWith(points: points.sublist(index.clamp(0, points.length)));
/// Whether an interruption at [at] (waypoint [index]) belongs to this route:
/// the route has that waypoint and it lies within 50 m of where it stopped.
bool matchesInterruption(int index, LatLng at) {
if (index < 0 || index >= points.length) return false;
// Interrupted between index−1 and index: near either end of that leg counts.
final LatLng p = points[index].at;
final LatLng q = index > 0 ? points[index - 1].at : p;
final double leg = _dist2(q, p);
return _dist2(at, p) <= leg + 50 && _dist2(at, q) <= leg + 50;
}
// ── Geometry and estimates ────────────────────────────────────────────────
/// 3-D length of each leg, m: leg i runs from point i to point i+1.