Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
route.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 * @file route.h
20 * @brief Parse capture-route settings and evaluate the simulated flight path.
21 * @details Route interpolation is deliberately simple and deterministic: the
22 * capture generator needs repeatable positions and altitude policy, not a
23 * navigation controller. Terrain-relative and start-locked altitude are kept
24 * separate because changing the reference mid-session would corrupt map scale.
25 */
26#ifndef PANGEA_ROUTE_H
27#define PANGEA_ROUTE_H
28
29#include "utc_time.h"
30#include "image_framing.h"
31#include "camera_optics.h"
32
33#include <algorithm>
34#include <cmath>
35#include <filesystem>
36#include <fstream>
37#include <map>
38#include <optional>
39#include <sstream>
40#include <stdexcept>
41#include <string>
42
43namespace pangea_survey {
44constexpr double pi = 3.14159265358979323846;
45constexpr double earthRadius = 6371008.8;
46
47/** @brief Geographic route point; latitude/longitude are degrees and AGL is metres. */
48struct Point {
49 double lat = 0;
50 double lon = 0;
51 double agl = 120;
52};
53
54/**
55 * @brief Validated camera, route, simulator-startup, and output settings.
56 * @details `fov` is vertical degrees; positions are WGS-84 and altitudes are
57 * metres. Startup weather/time readback and capture timing remain provenance,
58 * not a sensor exposure clock.
59 */
60struct Config {
63 double speed = 20;
64 double interval = 4;
65 double settle = 10;
66 double fov = 60;
67 std::string lensProfile = "simconnect";
70 int grab = 2;
71 double tileSettle = 0.05, tileOverlap = 0.15;
72 bool captureMargin = false;
73 double mapCameraAgl = 0;
74 int captureInset = 0;
75 unsigned long quality = 92;
76 int jpegWidth = 2028, jpegHeight = 1520;
77 bool lockStartAltitude = true;
78 bool ivyEnabled = false;
79 std::string ivyAddress = "127.255.255.255:2010";
80 int ivyAircraftId = -1;
81 std::filesystem::path output;
82 std::string startupFlight = "auto";
83 std::string startupAirport = "EHRD";
84 bool autoEnterFlight = true;
86 double startupTimeout = 0;
87 std::optional<UtcDateTime> startupUtc;
88 std::string weatherPreset = "unchanged";
89 std::filesystem::path weatherReadback;
90 std::filesystem::path iniDirectory;
91
92 /** @brief Check whether an enabled timed capture has reached its deadline.
93 * @param elapsed Seconds elapsed in the session.
94 * @param nextPhoto Scheduled time in the same elapsed-time domain.
95 * @return True when timed capture is enabled and due. */
96 bool timedPhotoDue(double elapsed, double nextPhoto) const {
97 return interval > 0 && elapsed >= nextPhoto;
98 }
99 /** @brief Compute field of view at the selected map-camera height.
100 * @return Field of view in degrees.
101 * @details Preserve the starting ground footprint by scaling the tangent
102 * of the half-angle, not the angle itself. */
103 double cameraFov() const {
104 return mapCameraAgl == 0 ? fov :
105 360 / pi * std::atan(start.agl / mapCameraAgl * std::tan(fov * pi / 360));
106 }
107 /** @brief Resolve the camera's height above ground.
108 * @param nominalAgl Route height in metres.
109 * @return Configured map-camera height, or @p nominalAgl if unset. */
110 double cameraAgl(double nominalAgl) const {
111 return mapCameraAgl == 0 ? nominalAgl : mapCameraAgl;
112 }
113 /** @brief Check for the calibrated Raspberry Pi AI camera optics path.
114 * @return True when the route selects that profile. */
115 bool piCamera() const { return lensProfile == "raspberry_pi_ai"; }
116 /** @brief Choose the simulator viewport field of view.
117 * @param width Viewport columns in pixels.
118 * @param height Viewport rows in pixels.
119 * @return Field of view in degrees.
120 * @details The Pi optics path accounts for viewport shape and capture inset;
121 * the generic path uses the height-adjusted configuration. */
122 double viewportFov(int width, int height) const {
123 return piCamera() ? PiAiOptics::viewportFov(width, height, captureInset) : cameraFov();
124 }
125};
126
127/** @brief Strip the ASCII whitespace allowed around route INI tokens.
128 * @param text Original field or line.
129 * @return Trimmed text, empty for an all-whitespace input. */
130inline std::string trim(const std::string& text) {
131 const auto first = text.find_first_not_of(" \t\r\n");
132 if (first == std::string::npos) return {};
133 return text.substr(first, text.find_last_not_of(" \t\r\n") - first + 1);
134}
135
136/** @brief Read a complete finite numeric route field.
137 * @param text Already trimmed value.
138 * @param name Setting name for diagnostics.
139 * @return Converted value.
140 * @throws std::runtime_error If malformed, nonfinite, or only partly consumed. */
141inline double number(const std::string& text, const std::string& name) {
142 std::size_t used = 0;
143 double value;
144 try {
145 value = std::stod(text, &used);
146 } catch (const std::exception&) {
147 throw std::runtime_error("Invalid number for " + name + ": " + text);
148 }
149 if (used != text.size() || !std::isfinite(value))
150 throw std::runtime_error("Invalid number for " + name + ": " + text);
151 return value;
152}
153
154/** @brief Enforce the inclusive policy bounds for a parsed setting.
155 * @param value Already validated finite value.
156 * @param minimum Inclusive lower bound.
157 * @param maximum Inclusive upper bound.
158 * @param name Setting name for diagnostics.
159 * @throws std::runtime_error If outside the bounds. */
160inline void range(double value, double minimum, double maximum, const std::string& name) {
161 if (value < minimum || value > maximum)
162 throw std::runtime_error(name + " must be between " + std::to_string(minimum) +
163 " and " + std::to_string(maximum));
164}
165
166/** @brief Validate the syntax of an Ivy IPv4 bus endpoint.
167 * @param address Numeric dotted quad followed by a port.
168 * @throws std::runtime_error For malformed octets, port or delimiters.
169 * @details Checks syntax, not whether the endpoint is reachable or broadcast-capable. */
170inline void validateIvyAddress(const std::string& address) {
171 std::istringstream input(address);
172 int octet[4]{}, port = 0;
173 char separator[4]{};
174 if (!(input >> octet[0] >> separator[0] >> octet[1] >> separator[1] >>
175 octet[2] >> separator[2] >> octet[3] >> separator[3] >> port) ||
176 separator[0] != '.' || separator[1] != '.' || separator[2] != '.' ||
177 separator[3] != ':' || input.peek() != std::char_traits<char>::eof() ||
178 address.find_first_not_of("0123456789.:") != std::string::npos ||
179 port < 1 || port > 65535 ||
180 std::any_of(std::begin(octet), std::end(octet), [](int value) { return value < 0 || value > 255; }))
181 throw std::runtime_error("ivy.bus_address must be a full IPv4 broadcast/multicast address:port (1-65535)");
182}
183
184/** @brief Compute the shortest signed longitude change across the antimeridian.
185 * @param start Starting longitude in degrees.
186 * @param end Ending longitude in degrees.
187 * @return Wrapped delta in [-180, 180] degrees. */
188inline double longitudeDelta(double start, double end) {
189 return std::remainder(end - start, 360.0);
190}
191
192/** @brief Estimate surface distance between two route points.
193 * @param a First geographic position.
194 * @param b Second geographic position.
195 * @return Spherical great-circle distance in metres, ignoring altitude.
196 * @details Use haversine with a wrapped longitude delta. Clamp its argument
197 * so roundoff near antipodal points cannot invalidate the inverse sine. */
198inline double distance(const Point& a, const Point& b) {
199 const double lat1 = a.lat * pi / 180;
200 const double lat2 = b.lat * pi / 180;
201 const double dlat = lat2 - lat1;
202 const double dlon = longitudeDelta(a.lon, b.lon) * pi / 180;
203 const double h = std::pow(std::sin(dlat / 2), 2) +
204 std::cos(lat1) * std::cos(lat2) * std::pow(std::sin(dlon / 2), 2);
205 return 2 * earthRadius * std::asin(std::sqrt(std::clamp(h, 0.0, 1.0)));
206}
207
208/**
209 * @brief Parse and validate a route INI stream relative to a base directory.
210 * @param[in] input Readable INI stream.
211 * @param[in] base Directory used to resolve the output path.
212 * @return Validated route and camera configuration.
213 * @throws std::runtime_error If keys, units, bounds, or option combinations are invalid.
214 */
215inline Config parseConfig(std::istream& input, const std::filesystem::path& base) {
216 std::map<std::string, std::string> values;
217 std::string section, line;
218 std::size_t lineNumber = 0;
219 while (std::getline(input, line)) {
220 ++lineNumber;
221 line = trim(line.substr(0, line.find_first_of(";#")));
222 if (line.empty()) continue;
223 if (line.front() == '[' && line.back() == ']') {
224 section = trim(line.substr(1, line.size() - 2));
225 if (section != "start" && section != "end" && section != "camera" &&
226 section != "ivy" && section != "simulation")
227 throw std::runtime_error("Unknown INI section on line " + std::to_string(lineNumber));
228 continue;
229 }
230 const auto equal = line.find('=');
231 if (section.empty() || equal == std::string::npos)
232 throw std::runtime_error("Expected section/key=value on INI line " +
233 std::to_string(lineNumber));
234 const std::string key = section + "." + trim(line.substr(0, equal));
235 const std::string value = trim(line.substr(equal + 1));
236 if (value.empty() || !values.emplace(key, value).second)
237 throw std::runtime_error("Empty or duplicate INI key: " + key);
238 }
239 if (input.bad()) throw std::runtime_error("Failed while reading INI file");
240 const auto required = [&](const std::string& key) {
241 const auto found = values.find(key);
242 if (found == values.end()) throw std::runtime_error("Missing INI key: " + key);
243 return number(found->second, key);
244 };
245 const auto optional = [&](const std::string& key, double fallback) {
246 const auto found = values.find(key);
247 return found == values.end() ? fallback : number(found->second, key);
248 };
249 const auto boolean = [&](const std::string& key, bool fallback) {
250 const double value = optional(key, fallback ? 1 : 0);
251 if (value != 0 && value != 1) throw std::runtime_error(key + " must be 0 or 1");
252 return value == 1;
253 };
254 const std::string allowed[] = {
255 "start.lat", "start.lon", "start.agl", "end.lat", "end.lon", "end.agl",
256 "camera.speed_mps", "camera.photo_interval_seconds", "camera.settle_seconds",
257 "camera.fov_degrees", "camera.jpeg_quality", "camera.output_directory", "camera.startup_flight",
258 "camera.lock_start_altitude", "camera.jpeg_width", "camera.jpeg_height",
259 "camera.grab", "camera.tile_settle_seconds", "camera.tile_overlap", "camera.map_camera_agl_m",
260 "camera.capture_inset_pixels", "camera.lens_profile",
261 "camera.shutter_speed_seconds", "camera.iso", "camera.hardware_identifier",
262 "camera.capture_margin",
263 "camera.lens_k1", "camera.lens_k2", "camera.lens_blue_scale", "camera.lens_red_scale",
264 "camera.auto_enter_flight", "camera.startup_timeout_seconds", "camera.startup_airport",
265 "camera.startup_maximize_minimized",
266 "ivy.enabled", "ivy.bus_address", "ivy.aircraft_id", "simulation.utc_datetime",
267 "simulation.weather_preset"
268 };
269 for (const auto& entry : values)
270 if (std::find(std::begin(allowed), std::end(allowed), entry.first) == std::end(allowed))
271 throw std::runtime_error("Unknown INI key: " + entry.first);
272
273 Config config;
274 config.start = {required("start.lat"), required("start.lon"), required("start.agl")};
275 config.end = {required("end.lat"), required("end.lon"), required("end.agl")};
276 for (const auto& point : {config.start, config.end}) {
277 range(point.lat, -85, 85, "latitude");
278 range(point.lon, -180, 180, "longitude");
279 range(point.agl, 1, 1000, "AGL in meters");
280 }
281 config.speed = optional("camera.speed_mps", config.speed);
282 config.interval = optional("camera.photo_interval_seconds", config.interval);
283 config.settle = optional("camera.settle_seconds", config.settle);
284 config.fov = optional("camera.fov_degrees", config.fov);
285 const auto lens = values.find("camera.lens_profile");
286 if (lens != values.end()) config.lensProfile = lens->second;
287 if (config.lensProfile != "simconnect" && !config.piCamera())
288 throw std::runtime_error("camera.lens_profile must be simconnect or raspberry_pi_ai");
289 if (config.piCamera() && values.count("camera.fov_degrees"))
290 throw std::runtime_error("Pi AI lens fixes the optical FOV; omit camera.fov_degrees");
291 config.exifSettings.shutterSeconds = optional("camera.shutter_speed_seconds",
293 const double iso = optional("camera.iso", config.exifSettings.iso);
294 range(iso, 1, 65535, "camera.iso");
295 if (std::floor(iso) != iso)
296 throw std::runtime_error("camera.iso must be an integer");
297 config.exifSettings.iso = static_cast<std::uint16_t>(iso);
298 const auto hardware = values.find("camera.hardware_identifier");
299 if (hardware != values.end()) config.exifSettings.hardwareIdentifier = hardware->second;
300 config.exifSettings.validate();
301 config.lens.k1 = optional("camera.lens_k1", config.lens.k1);
302 config.lens.k2 = optional("camera.lens_k2", config.lens.k2);
303 config.lens.blueScale = optional("camera.lens_blue_scale", config.lens.blueScale);
304 config.lens.redScale = optional("camera.lens_red_scale", config.lens.redScale);
305 range(config.lens.k1, -.05, 0, "camera.lens_k1");
306 range(config.lens.k2, 0, .01, "camera.lens_k2");
307 range(config.lens.blueScale, .999, 1.001, "camera.lens_blue_scale");
308 range(config.lens.redScale, .999, 1.001, "camera.lens_red_scale");
309 if (!config.piCamera() && (values.count("camera.lens_k1") || values.count("camera.lens_k2") ||
310 values.count("camera.lens_blue_scale") || values.count("camera.lens_red_scale")))
311 throw std::runtime_error("Lens effect overrides require lens_profile=raspberry_pi_ai");
312 const double grab = optional("camera.grab", config.grab);
313 if (grab != 2 && grab != 3) throw std::runtime_error("camera.grab must be 2 (line flight) or 3 (box tiles)");
314 config.grab = static_cast<int>(grab);
315 config.tileSettle = optional("camera.tile_settle_seconds", config.tileSettle);
316 config.tileOverlap = optional("camera.tile_overlap", config.tileOverlap);
317 config.captureMargin = boolean("camera.capture_margin", false);
318 config.mapCameraAgl = optional("camera.map_camera_agl_m", 0);
319 const double inset = optional("camera.capture_inset_pixels", 0);
320 range(inset, 0, 256, "camera.capture_inset_pixels");
321 if (std::floor(inset) != inset)
322 throw std::runtime_error("camera.capture_inset_pixels must be an integer");
323 config.captureInset = static_cast<int>(inset);
324 if (config.mapCameraAgl != 0)
325 range(config.mapCameraAgl, 1000, 100000, "camera.map_camera_agl_m");
326 range(config.tileSettle, 0.05, 60, "camera.tile_settle_seconds");
327 range(config.tileOverlap, 0, 0.9, "camera.tile_overlap");
328 config.lockStartAltitude = boolean("camera.lock_start_altitude", config.lockStartAltitude);
329 if (config.mapCameraAgl != 0 && (config.grab != 3 || !config.lockStartAltitude))
330 throw std::runtime_error("map_camera_agl_m requires grab=3 and lock_start_altitude=1");
331 config.autoEnterFlight = boolean("camera.auto_enter_flight", config.autoEnterFlight);
332 config.startupMaximizeMinimized = boolean("camera.startup_maximize_minimized",
334 config.startupTimeout = optional("camera.startup_timeout_seconds", config.startupTimeout);
335 range(config.startupTimeout, 0, 86400, "camera.startup_timeout_seconds");
336 const auto airport = values.find("camera.startup_airport");
337 if (airport != values.end()) config.startupAirport = airport->second;
338 if (config.startupAirport.size() != 4 ||
339 !std::all_of(config.startupAirport.begin(), config.startupAirport.end(), [](unsigned char value) {
340 return (value >= 'A' && value <= 'Z') || (value >= '0' && value <= '9');
341 }))
342 throw std::runtime_error("camera.startup_airport must be a four-character uppercase ICAO airport code");
343 config.ivyEnabled = boolean("ivy.enabled", config.ivyEnabled);
344 const auto ivyAddress = values.find("ivy.bus_address");
345 if (ivyAddress != values.end()) config.ivyAddress = ivyAddress->second;
347 const double aircraftId = optional("ivy.aircraft_id", config.ivyAircraftId);
348 range(aircraftId, -1, 255, "ivy.aircraft_id");
349 if (std::floor(aircraftId) != aircraftId)
350 throw std::runtime_error("ivy.aircraft_id must be an integer (-1 = any)");
351 config.ivyAircraftId = static_cast<int>(aircraftId);
352 const auto utc = values.find("simulation.utc_datetime");
353 if (utc != values.end() && utc->second != "unchanged") {
354 try {
355 config.startupUtc = parseUtcDateTime(utc->second);
356 } catch (const std::invalid_argument& error) {
357 throw std::runtime_error(std::string("simulation.utc_datetime: ") + error.what());
358 }
359 }
360 const auto weather = values.find("simulation.weather_preset");
361 if (weather != values.end()) config.weatherPreset = weather->second;
362 if (config.weatherPreset != "unchanged" && config.weatherPreset != "clear_sky")
363 throw std::runtime_error("simulation.weather_preset must be unchanged or clear_sky");
364 const double quality = optional("camera.jpeg_quality", config.quality);
365 const double jpegWidth = optional("camera.jpeg_width", config.jpegWidth);
366 const double jpegHeight = optional("camera.jpeg_height", config.jpegHeight);
367 range(jpegWidth, 1, 16384, "camera.jpeg_width");
368 range(jpegHeight, 1, 16384, "camera.jpeg_height");
369 if (std::floor(jpegWidth) != jpegWidth || std::floor(jpegHeight) != jpegHeight)
370 throw std::runtime_error("camera.jpeg_width and camera.jpeg_height must be integer pixel counts");
371 config.jpegWidth = static_cast<int>(jpegWidth);
372 config.jpegHeight = static_cast<int>(jpegHeight);
373 validateJpegSize(config.jpegWidth, config.jpegHeight);
374 if (config.piCamera() && (config.grab != 3 || config.mapCameraAgl != 0 ||
376 throw std::runtime_error("Pi AI lens requires grab=3, ordinary camera height and 2028x1520 JPEGs");
377 range(config.speed, 0.1, 200, "speed_mps");
378 if (config.interval != -1 && config.interval <= 0)
379 throw std::runtime_error("photo_interval_seconds must be -1 (disabled) or a positive number of seconds");
380 range(config.settle, 1, 300, "settle_seconds");
381 range(config.fov, 10, 120, "fov_degrees");
382 if (config.mapCameraAgl != 0 && config.cameraFov() < 1.05)
383 throw std::runtime_error("Mapping camera needs at least 1.05 degrees FOV; reduce map_camera_agl_m "
384 "or increase start AGL/fov_degrees (MSFS clamps narrower lenses)");
385 range(quality, 1, 100, "jpeg_quality");
386 if (std::floor(quality) != quality) throw std::runtime_error("jpeg_quality must be an integer");
387 config.quality = static_cast<unsigned long>(quality);
388 const auto output = values.find("camera.output_directory");
389 config.iniDirectory = base;
390 const auto startup = values.find("camera.startup_flight");
391 if (startup != values.end()) config.startupFlight = startup->second;
392 config.output = base / (output == values.end() ? std::filesystem::path(config.piCamera() ? L"pictures" : L"mytiles") :
393 std::filesystem::u8path(output->second));
394 const double length = distance(config.start, config.end);
395 range(length, 1, 100000, "route length in meters");
396 if (config.grab == 3 && (config.start.lat == config.end.lat ||
397 longitudeDelta(config.start.lon, config.end.lon) == 0))
398 throw std::runtime_error("grab=3 needs opposite corners of a nonzero-width, nonzero-height bounding box");
399 return config;
400}
401
402/**
403 * @brief Open and parse a route configuration file.
404 * @param[in] path INI file; output paths are resolved relative to its directory.
405 * @return Validated capture configuration.
406 * @throws std::runtime_error If the file cannot be read or its settings are invalid.
407 */
408inline Config loadConfig(const std::filesystem::path& path) {
409 std::ifstream input(path);
410 if (!input) throw std::runtime_error("Cannot open INI file: " + path.u8string());
411 return parseConfig(input, std::filesystem::absolute(path).parent_path());
412}
413
414/**
415 * @brief Apply the route's chosen terrain-following or fixed-start altitude policy.
416 * @details A fixed altitude is latched only after the initial camera has settled;
417 * before then the provisional value follows current terrain plus configured AGL.
418 */
421 double startAgl_;
422 std::optional<double> lockedMsl_;
423public:
424 /** @brief Initialize altitude policy from a validated route configuration. */
425 explicit CameraAltitude(const Config& config)
426 : lockStart_(config.lockStartAltitude), startAgl_(config.cameraAgl(config.start.agl)) {}
427
428 /**
429 * @brief Compute camera AMSL altitude for one terrain sample.
430 * @param[in] ground Ground elevation AMSL in metres.
431 * @param[in] routeAgl Requested route height above ground in metres.
432 * @param[in] settled Whether the initial settled position may be latched.
433 * @return Camera altitude AMSL in metres.
434 * @throws std::runtime_error If either input height is nonfinite.
435 */
436 double at(double ground, double routeAgl, bool settled) {
437 if (!std::isfinite(ground) || !std::isfinite(routeAgl))
438 throw std::runtime_error("Nonfinite camera terrain/AGL height");
439 if (!lockStart_) return ground + routeAgl;
440 if (!lockedMsl_ && settled) lockedMsl_ = ground + startAgl_;
441 return lockedMsl_.value_or(ground + startAgl_);
442 }
443 /** @brief Report whether fixed-start AMSL has been latched. */
444 bool locked() const { return lockedMsl_.has_value(); }
445};
446
447/**
448 * @brief Evaluate a back-and-forth route at elapsed time.
449 * @details Geographic interpolation uses the shortest longitude delta; it does
450 * not model aircraft dynamics or establish that a real aircraft flew the path.
451 */
452class Route {
454 double length_;
455public:
456 /** @brief Construct a route and cache its great-circle endpoint distance. */
457 explicit Route(const Config& config) : config_(config), length_(distance(config.start, config.end)) {}
458 /** @brief Return route length in metres. */
459 double length() const { return length_; }
460 /** @brief Return one-way travel duration at the configured speed. */
461 double legSeconds() const { return length_ / config_.speed; }
462 /**
463 * @brief Return the interpolated endpoint-to-endpoint route position.
464 * @param[in] seconds Nonnegative elapsed seconds; every second leg reverses direction.
465 * @return Geographic position and interpolated AGL.
466 * @throws std::runtime_error If elapsed time is negative or nonfinite.
467 */
468 Point at(double seconds) const {
469 if (!std::isfinite(seconds) || seconds < 0)
470 throw std::runtime_error("Route time must be finite and nonnegative");
471 const double phase = std::fmod(seconds / legSeconds(), 2.0);
472 const double t = phase <= 1 ? phase : 2 - phase;
473 return {
474 config_.start.lat + t * (config_.end.lat - config_.start.lat),
475 std::remainder(config_.start.lon + t * longitudeDelta(config_.start.lon, config_.end.lon), 360.0),
476 config_.start.agl + t * (config_.end.agl - config_.start.agl)
477 };
478 }
479 /** @brief Interpolate route AGL from distance along the endpoint segment. */
480 double aglAt(const Point& point) const {
481 const double t = std::clamp(distance(config_.start, point) / length_, 0.0, 1.0);
482 return config_.start.agl + t * (config_.end.agl - config_.start.agl);
483 }
484};
485}
486#endif
Optical profiles and EXIF settings for simulated survey cameras.
double at(double ground, double routeAgl, bool settled)
Compute camera AMSL altitude for one terrain sample.
Definition route.h:436
bool locked() const
Report whether fixed-start AMSL has been latched.
Definition route.h:444
std::optional< double > lockedMsl_
Definition route.h:422
CameraAltitude(const Config &config)
Initialize altitude policy from a validated route configuration.
Definition route.h:425
double legSeconds() const
Return one-way travel duration at the configured speed.
Definition route.h:461
double aglAt(const Point &point) const
Interpolate route AGL from distance along the endpoint segment.
Definition route.h:480
Point at(double seconds) const
Return the interpolated endpoint-to-endpoint route position.
Definition route.h:468
Route(const Config &config)
Construct a route and cache its great-circle endpoint distance.
Definition route.h:457
double length() const
Return route length in metres.
Definition route.h:459
static bool start(uint32_t session)
Admit a nonzero session and discard correlation from the previous one.
Crop, resample, and rotate BGRA images into the requested camera frame.
struct jpeg_error_mgr error
Definition lwir_image.c:60
Config parseConfig(std::istream &input, const std::filesystem::path &base)
Parse and validate a route INI stream relative to a base directory.
Definition route.h:215
std::string trim(const std::string &text)
Strip the ASCII whitespace allowed around route INI tokens.
Definition route.h:130
Config loadConfig(const std::filesystem::path &path)
Open and parse a route configuration file.
Definition route.h:408
double distance(const Point &a, const Point &b)
Estimate surface distance between two route points.
Definition route.h:198
void validateJpegSize(int width, int height)
Validate encoded-image dimensions before allocating pixel buffers.
void range(double value, double minimum, double maximum, const std::string &name)
Enforce the inclusive policy bounds for a parsed setting.
Definition route.h:160
constexpr double pi
Definition route.h:44
UtcDateTime parseUtcDateTime(std::string_view text)
Parse a strict Gregorian UTC minute in YYYY-MM-DDTHH:MMZ form.
Definition utc_time.h:115
constexpr double earthRadius
Definition route.h:45
void validateIvyAddress(const std::string &address)
Validate the syntax of an Ivy IPv4 bus endpoint.
Definition route.h:170
double number(const std::string &text, const std::string &name)
Read a complete finite numeric route field.
Definition route.h:141
double longitudeDelta(double start, double end)
Compute the shortest signed longitude change across the antimeridian.
Definition route.h:188
static FILE * output
Definition pose_log.c:77
User-supplied exposure labels written to simulated-photo EXIF.
void validate() const
Reject values that cannot be represented as bounded EXIF metadata.
Validated camera, route, simulator-startup, and output settings.
Definition route.h:60
double startupTimeout
Definition route.h:86
bool startupMaximizeMinimized
Definition route.h:85
std::string lensProfile
Definition route.h:67
unsigned long quality
Definition route.h:75
std::string startupFlight
Definition route.h:82
CameraExifSettings exifSettings
Definition route.h:69
std::string startupAirport
Definition route.h:83
double mapCameraAgl
Definition route.h:73
double cameraFov() const
Compute field of view at the selected map-camera height.
Definition route.h:103
std::string weatherPreset
Definition route.h:88
double viewportFov(int width, int height) const
Choose the simulator viewport field of view.
Definition route.h:122
double cameraAgl(double nominalAgl) const
Resolve the camera's height above ground.
Definition route.h:110
bool piCamera() const
Check for the calibrated Raspberry Pi AI camera optics path.
Definition route.h:115
std::filesystem::path weatherReadback
Definition route.h:89
std::filesystem::path iniDirectory
Definition route.h:90
LensEffects lens
Definition route.h:68
std::optional< UtcDateTime > startupUtc
Definition route.h:87
bool timedPhotoDue(double elapsed, double nextPhoto) const
Check whether an enabled timed capture has reached its deadline.
Definition route.h:96
std::string ivyAddress
Definition route.h:79
std::filesystem::path output
Definition route.h:81
Engineering lens-distortion and lateral colour-scale parameters.
static double viewportFov(int sourceWidth, int sourceHeight, int inset)
Find the simulator vertical FOV that yields this captured viewport.
static constexpr double clearDayShutterSeconds
static constexpr int height
static constexpr int width
Geographic route point; latitude/longitude are degrees and AGL is metres.
Definition route.h:48
One timestamped geographic position for a replay annotation.
static double seconds(Clock::duration duration)
Convert a monotonic interval without truncating fractional seconds.
Definition survey.cpp:100
Validate Gregorian UTC targets and qualify simulator time samples.