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
diplacam.cpp
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 diplacam.cpp
20 * @brief Command-line and worker-process entry point for Diplacam.
21 * @details
22 * Keep application policy here and numerical work in its owning modules. This
23 * entry point resolves settings, selects one planner, and chooses one lifetime:
24 * a single standalone observation/route, or a long-lived IPC service whose
25 * planner thread retains survey state across route chunks.
26 *
27 * Model settings are discovered relative to the executable, not the launcher's
28 * working directory. Explicit CLI model/metadata paths override their defaults,
29 * but do not turn off an existing INI's runtime, descriptor, or comparison policy.
30 * The distinction matters when launching from a service, a shell, or a package.
31 *
32 * @par Planner selection is not error recovery
33 * cmaes=true explicitly selects the native comparison planner. It bypasses ONNX
34 * initialization rather than trying diffusion first and quietly changing the
35 * experiment on failure. An invalid selected planner reports an error.
36 *
37 * @par Output contract
38 * Standalone stdout is one eight-point XY CSV, with diagnostics on stderr.
39 * Model-predicted Z is retained inside the sampler for numerical parity, but
40 * is not an altitude command. Both planner choices share flight-margin preparation.
41 * @see dipla_planner.hpp Survey, inference, and publication-preparation boundaries.
42 * @see dipla_worker.hpp Persistent IPC service and descriptor ownership.
43 */
44#include "dipla_planner.hpp"
45#include "dipla_worker.hpp"
46#include "aigenlib/compat.hpp"
50#include "../../src/version.h"
51#include <charconv>
52#include <cmath>
53#include <filesystem>
54#include <iomanip>
55#include <iostream>
56#include <limits>
57#include <optional>
58#include <random>
59#include <stdexcept>
60#include <string_view>
61
62namespace {
63/**
64 * @brief Parsed application settings before CLI overrides and mode dispatch.
65 * @details Optional values preserve the difference between absent and explicitly
66 * supplied settings. In particular, an explicitly false cmaes must still count
67 * as present when detecting duplicate keys; false is not a missing-value marker.
68 */
69struct ModelFiles {
70 /** @var ModelFiles::model
71 * @brief Graph path resolved by the shared inference-settings reader. */
72 /** @var ModelFiles::metadata
73 * @brief Diplacam deployment JSON path, rebased locally against the selected INI. */
74 /** Optional runtime directory resolved by the shared settings reader, not a library filename. */
75 std::string model, metadata, onnx_lib_path, conditioning_cache;
76 /** Shared backend, source, descriptor, thread, and deadline policy; not a second INI dialect. */
77 inference_settings inference{};
78 /** Optional explicit comparison-planner selector. */
79 std::optional<bool> cmaes;
80 /** Validated startup comparison policy; omitted keys retain its defaults. */
81 dipla::CmaesOptions comparison;
82 /** Startup-only experiment snapshot passed identically to standalone and worker modes. */
83 dipla::ExperimentOptions experiment;
84 /** Presence mask for application-specific keys, including explicitly false values. */
85 std::uint32_t seen = 0;
86};
87
88/**
89 * @brief Parse one bounded integer setting without accepting partial numbers.
90 * @details `from_chars` avoids locale-dependent parsing; checking the final
91 * pointer rejects suffixes such as `100ms`, while the closed interval protects
92 * downstream work and integer conversions from unreasonable configuration.
93 * @param[in,out] destination Field populated only after complete validation.
94 * @param[in] text NUL-terminated decimal integer from the bounded parser.
95 * @param[in] minimum Inclusive lower bound.
96 * @param[in] maximum Inclusive upper bound.
97 * @return True only when the value is fully parsed and in range.
98 * @post On failure, destination is unchanged; a malformed value cannot partially apply.
99 */
100bool integer_setting(int& destination, const char* text, int minimum, int maximum) {
101 const std::string value(text);
102 int parsed = 0;
103 const auto result = std::from_chars(value.data(), value.data() + value.size(), parsed);
104 if (result.ec != std::errc{} || result.ptr != value.data() + value.size() || parsed < minimum || parsed > maximum)
105 return false;
106 destination = parsed;
107 return true;
108}
109
110/**
111 * @brief Validate and store one key/value pair from the flat application INI.
112 * @details The shared inference-settings reader handles its common keys and
113 * delegates application-specific entries here. Keep descriptor/runtime/backend
114 * parsing there; copying it here would let two consumers disagree about one INI.
115 * Returning false rejects unknown or duplicate application settings rather than
116 * silently making behavior depend on file order.
117 * @param[in,out] context Pointer to the live ModelFiles being populated.
118 * @param[in] key Application setting name, NUL-terminated.
119 * @param[in] value Setting value, NUL-terminated and nonempty after common parsing.
120 * @return True when the key is recognized and its value is valid.
121 * @pre context points to ModelFiles for the duration of the synchronous read.
122 */
123bool model_setting(void* context, const char* key, const char* value) {
124 auto& files = *static_cast<ModelFiles*>(context);
125 static constexpr const char* keys[] = {
126 "cmaes", "metadata", "cmaes_budget_ms", "cmaes_maxfevals", "cmaes_seed",
127 "diffusion_seed", "sensor_noise_seed", "flight_margin_cells", "gp_prior_mean",
128 "gp_kernel_variance", "gp_lengthscale_m", "sensor_fov_deg", "sensor_noise_variance",
129 "cmaes_utility_threshold", "cmaes_confidence_beta", "cmaes_step_xy_m", "conditioning_cache"
130 };
131 static_assert(std::size(keys) <= std::numeric_limits<decltype(files.seen)>::digits);
132 std::size_t index = 0;
133 while (index < std::size(keys) && std::string_view(key) != keys[index]) ++index;
134 if (index == std::size(keys) || (files.seen & (1U << index))) return false;
135 files.seen |= 1U << index;
136 if (std::string(key) == "cmaes") {
137 // Accept one spelling for each boolean. A typo must not quietly select
138 // another planner, and an earlier explicit false still forbids a duplicate.
139 if (files.cmaes.has_value()) return false;
140 if (std::string(value) == "true") files.cmaes = true;
141 else if (std::string(value) == "false") files.cmaes = false;
142 else return false;
143 return true;
144 }
145 if (std::string_view(key) == "cmaes_budget_ms")
146 return integer_setting(files.comparison.budget_ms, value, 1, dipla::CmaesOptions::max_budget_ms);
147 if (std::string_view(key) == "cmaes_maxfevals")
148 return integer_setting(files.comparison.maxfevals, value, dipla::CmaesOptions::population_size,
150 if (std::string_view(key) == "cmaes_seed")
151 return integer_setting(files.comparison.seed, value, 1, std::numeric_limits<int>::max());
152 if (std::string_view(key) == "diffusion_seed") return ini_uint(value, &files.experiment.diffusion_seed);
153 if (std::string_view(key) == "sensor_noise_seed") return ini_uint(value, &files.experiment.sensor_noise_seed);
154 if (std::string_view(key) == "flight_margin_cells") {
155 uint64_t margin = 0;
156 if (!ini_uint(value, &margin) || margin >= (DIPLA_GRID_SIDE - 1U) / 2U) return false;
157 files.experiment.flight_margin_cells = static_cast<unsigned>(margin);
158 return true;
159 }
160 struct RealSetting { const char* name; double* destination; };
161 const RealSetting real_settings[] = {
162 {"gp_prior_mean", &files.experiment.gp_prior_mean},
163 {"gp_kernel_variance", &files.experiment.gp_kernel_variance},
164 {"gp_lengthscale_m", &files.experiment.gp_lengthscale_m},
165 {"sensor_fov_deg", &files.experiment.sensor_fov_deg},
166 {"sensor_noise_variance", &files.experiment.sensor_noise_variance},
167 {"cmaes_utility_threshold", &files.comparison.utility_threshold},
168 {"cmaes_confidence_beta", &files.comparison.confidence_beta},
169 {"cmaes_step_xy_m", &files.comparison.step_xy_m}
170 };
171 for (const auto& setting : real_settings)
172 if (std::string_view(key) == setting.name) return ini_real(value, setting.destination);
173 // Metadata belongs to Diplacam's DDIM adapter, not the generic inference
174 // schema. Store its raw path now; the owning reader resolves its INI base.
175 std::string* destination = nullptr;
176 if (std::string(key) == "metadata") destination = &files.metadata;
177 if (std::string(key) == "conditioning_cache") destination = &files.conditioning_cache;
178 if (!destination || !destination->empty()) return false;
179 *destination = value;
180 return true;
181}
182
183/**
184 * @brief Read, validate, and resolve application settings.
185 * @details Reads at most 8 KiB through the bounded INI parser.
186 * Model, metadata, and runtime-directory paths are resolved against the INI
187 * location so invocation from an unrelated working directory is reproducible.
188 * Comparison mode may omit model files because it does not construct ONNX.
189 * @param[in] filename Selected settings file.
190 * @param[in] require_model_files Whether missing CLI paths need diffusion defaults.
191 * @return Validated values, including empty fields for omitted optional settings.
192 * @throws std::runtime_error If the file is oversized, malformed, duplicated,
193 * contains an unknown key, or lacks required diffusion paths.
194 * @note Reading settings does not load the runtime or graph. Help/version and
195 * comparison-only execution must not acquire those resources as a side effect.
196 * @see model_setting Application-specific extension to the common INI grammar.
197 */
198ModelFiles read_model_settings(const std::filesystem::path& filename, bool require_model_files) {
199 ModelFiles files;
200 // Diplacam is a diffusion consumer unless comparison is explicitly selected.
201 // Do not let generic backend discovery invent a different experiment.
202 inference_settings_init(&files.inference, INFERENCE_ONNX);
203 std::array<char, 1024> error{};
204 if (!inference_settings_read(&files.inference, filename.c_str(), model_setting, &files,
205 error.data(), error.size()))
206 throw std::runtime_error("Invalid model settings: " + filename.string());
207 files.model = files.inference.model;
208 files.onnx_lib_path = files.inference.library_directory;
209 try {
210 files.experiment.validate();
211 files.comparison.validate();
212 } catch (const std::runtime_error& error) {
213 throw std::runtime_error("Invalid model settings: " + filename.string() + ": " + error.what());
214 }
215 // The native backend is meaningful here only for explicit CMA-ES. LIVE is
216 // the supported source selector; it does not turn the synthetic GP field
217 // into a physical camera driver or promise real-world observation accuracy.
218 if ((files.inference.backend != INFERENCE_ONNX &&
219 !(files.inference.backend == INFERENCE_NATIVE && files.cmaes.value_or(false))) ||
220 files.inference.source != INFERENCE_LIVE ||
221 (require_model_files && !files.cmaes.value_or(false) &&
222 (files.model.empty() || files.metadata.empty())))
223 throw std::runtime_error("Invalid model settings: " + filename.string());
224 // Common paths were already resolved by inference_settings_read. Rebase
225 // only the adapter-specific metadata path; rebasing a resolved path again
226 // would make launch-directory changes surprisingly educational.
227 const auto directory = std::filesystem::absolute(filename).parent_path();
228 if (!files.metadata.empty()) files.metadata = (directory / files.metadata).lexically_normal().string();
229 if (!files.conditioning_cache.empty()) files.conditioning_cache = (directory / files.conditioning_cache).lexically_normal().string();
230 return files;
231}
232}
233
234/**
235 * @brief Parse CLI options and run standalone planning or the IPC worker.
236 * @details Defaults are discovered relative to the executable rather than the
237 * process working directory. Explicit CLI paths override model settings, while
238 * an existing INI is still read for runtime lookup and comparison controls.
239 * Standalone mode emits the eight XY points as CSV and keeps diagnostics on
240 * stderr; the fixed 2 m survey footprint is separate from model-predicted Z.
241 * @param[in] argc Number of command-line arguments, including the executable name.
242 * @param[in] argv Process-owned, NUL-terminated argument strings.
243 * @retval 0 Standalone output, information request, or orderly IPC service completion.
244 * @retval 1 A standard exception was reported on stderr, or the IPC service failed.
245 * @note Information options return when encountered, before reading settings or
246 * initializing inference. Earlier malformed arguments can still report errors.
247 * @warning The standalone command produces one route, not a simulated flight
248 * or a live waypoint publisher. The persistent owner uses serve() instead.
249 */
250int main(int argc, char** argv) {
251 try {
252 // Resolve the real executable rather than argv[0], which may be a PATH
253 // lookup or symlink. An adjacent INI wins over the source-tree layout,
254 // then the installed share layout is the final default. A present but
255 // invalid selected INI is an error, not permission to try another one.
256 const auto executable = std::filesystem::canonical("/proc/self/exe");
257 const auto local = executable.parent_path() / "../modules/dipla_cam";
258 const auto directory = std::filesystem::exists(executable.parent_path() / "diplacam_settings.ini") ?
259 executable.parent_path() : std::filesystem::exists(local / "diplacam_settings.ini") ?
260 local : executable.parent_path() / "../share/diplacam";
261 std::string settings = (directory / "diplacam_settings.ini").string();
262 std::string model, metadata;
263 std::string field;
264 std::string configuration;
265 std::optional<std::string> conditioning_cache;
266 int descriptor = -1;
267 // Start inside the two-cell horizontal margin. Height stays at the
268 // declared 2 m experiment; model-predicted Z must not replace this input.
269 std::array<double, 3> position{{4, 4, DIPLA_DEMO_HEIGHT_MM / DIPLA_MM_PER_M}};
270 bool show_config = false;
271 for (int argument = 1; argument < argc; ++argument) {
272 const std::string option = argv[argument];
273 if (option == "--show-config") { show_config = true; continue; }
274 // Information requests are model-free so broken deployments can
275 // still identify their binary/backend and show usable diagnostics.
276 if (option == "--version" || option == "-V") {
277 std::cout << DIPLACAM_BUILD_VERSION << '\n';
278 return 0;
279 }
280 if (option == "--build-info") {
281 std::cout << aipp::math::build_info << '\n';
282 return 0;
283 }
284 if (option == "--help" || option == "-h") {
285 std::cout << DIPLACAM_BUILD_VERSION << '\n'
286 << "Usage: diplacam --field FIELD.csv [OPTIONS]\n"
287 " diplacam --config CONFIG.ini --ipc-fd FD [OPTIONS]\n\n"
288 "Standalone planning:\n"
289 " --field FILE Required field CSV; emits eight XY slots as CSV.\n"
290 " --east M Initial east coordinate in meters (default: 4).\n"
291 " --north M Initial north coordinate in meters (default: 4).\n"
292 " Demonstration altitude is fixed at 2 m.\n\n"
293 "IPC worker (normally started by USHER):\n"
294 " --config FILE Worker INI: field, cadence_ms, planning_pose_max_age_ms.\n"
295 " --ipc-fd FD Inherited IPC descriptor; requires --config, not --field.\n\n"
296 "Model selection (both modes):\n"
297 " --settings FILE Model-settings INI (default: executable-relative\n"
298 " diplacam_settings.ini in the app, module or share directory).\n"
299 " --model FILE Override the ONNX model from settings.\n"
300 " --metadata FILE Override the deployment JSON from settings.\n"
301 " --conditioning-cache DIR Opt-in verified encoder/denoiser bundle.\n"
302 " INI paths are relative to the INI; CLI paths use cwd.\n"
303 " Set onnx_lib_path in settings for a runtime directory.\n"
304 " cmaes=true selects comparison-only planning without ONNX.\n"
305 " Comparison settings: cmaes_budget_ms (1..4000),\n"
306 " cmaes_maxfevals (12..3000), cmaes_seed (positive int32).\n\n"
307 "Information (no model or runtime required):\n"
308 " --version, -V Show application version and build Git revision.\n"
309 " --build-info Show the compiled numerical backend.\n"
310 " --help, -h Show this help.\n";
311 std::cout << " --show-config Print effective settings without loading the model or field.\n";
312 return 0;
313 }
314 // Remaining options consume exactly one value. Check availability
315 // before advancing argv, and reject partially parsed numeric values.
316 if (argument + 1 == argc) throw std::runtime_error("Missing argument for " + option);
317 const std::string value = argv[++argument];
318 if (option == "--field") field = value;
319 else if (option == "--settings") settings = value;
320 else if (option == "--config") configuration = value;
321 else if (option == "--ipc-fd") {
322 std::size_t used = 0;
323 descriptor = std::stoi(value, &used);
324 if (used != value.size() || descriptor < 0) throw std::runtime_error("Invalid IPC descriptor");
325 }
326 else if (option == "--model") model = value;
327 else if (option == "--metadata") metadata = value;
328 else if (option == "--conditioning-cache") conditioning_cache = value;
329 else if (option == "--east" || option == "--north") {
330 std::size_t used = 0;
331 const double number = std::stod(value, &used);
332 if (used != value.size() || !std::isfinite(number)) throw std::runtime_error("Invalid coordinate");
333 // Finite parsing belongs here; the selected survey/planner owns
334 // field bounds. Keep east as X and north as Y at every boundary.
335 position[option == "--east" ? 0 : 1] = number;
336 } else throw std::runtime_error("Unknown option: " + option);
337 }
338 std::string onnx_lib_path;
339 bool cmaes = false;
340 dipla::CmaesOptions comparison;
341 dipla::ExperimentOptions experiment;
342 dipla::NetworkOptions network_options;
343 // Read an existing INI even with both CLI model paths: it still chooses
344 // runtime search, descriptor, resource limits, and comparison mode.
345 // Only two explicit paths AND an absent INI bypass settings altogether.
346 if (model.empty() || metadata.empty() || std::filesystem::exists(settings)) {
347 const auto files = read_model_settings(settings, !show_config && (model.empty() || metadata.empty()));
348 if (model.empty()) model = files.model;
349 if (metadata.empty()) metadata = files.metadata;
350 onnx_lib_path = files.onnx_lib_path;
351 // A CLI graph override does not disable the settings descriptor.
352 // If it names another export, the planner's integrity checks should
353 // reject that mismatch rather than silently weaken the model contract.
354 network_options.descriptor = files.inference.descriptor;
355 network_options.threads = files.inference.threads;
356 network_options.timeout_ms = files.inference.timeout_ms;
357 network_options.conditioning_cache = files.conditioning_cache;
358 cmaes = files.cmaes.value_or(false);
359 comparison = files.comparison;
360 experiment = files.experiment;
361 }
362 if (conditioning_cache) network_options.conditioning_cache = *conditioning_cache;
363 if (show_config) {
364 std::cout << std::setprecision(std::numeric_limits<double>::max_digits10)
365 << "model=" << model << '\n' << "metadata=" << metadata << '\n'
366 << "model_descriptor=" << network_options.descriptor << '\n'
367 << "onnx_lib_path=" << onnx_lib_path << '\n'
368 << "onnx_threads=" << network_options.threads << '\n'
369 << "inference_timeout_ms=" << network_options.timeout_ms << '\n'
370 << "conditioning_cache=" << network_options.conditioning_cache << '\n'
371 << "cmaes=" << (cmaes ? "true" : "false") << '\n'
372 << "cmaes_budget_ms=" << comparison.budget_ms << '\n'
373 << "cmaes_maxfevals=" << comparison.maxfevals << '\n'
374 << "cmaes_seed=" << comparison.seed << '\n'
375 << "cmaes_utility_threshold=" << comparison.utility_threshold << '\n'
376 << "cmaes_confidence_beta=" << comparison.confidence_beta << '\n'
377 << "cmaes_step_xy_m=" << comparison.step_xy_m << '\n'
378 << "diffusion_seed=" << experiment.diffusion_seed << '\n'
379 << "sensor_noise_seed=" << experiment.sensor_noise_seed << '\n'
380 << "flight_margin_cells=" << experiment.flight_margin_cells << '\n'
381 << "gp_prior_mean=" << experiment.gp_prior_mean << '\n'
382 << "gp_kernel_variance=" << experiment.gp_kernel_variance << '\n'
383 << "gp_lengthscale_m=" << experiment.gp_lengthscale_m << '\n'
384 << "sensor_fov_deg=" << experiment.sensor_fov_deg << '\n'
385 << "sensor_noise_variance=" << experiment.sensor_noise_variance << '\n';
386 return 0;
387 }
388 // The descriptor, not --config by itself, selects persistent IPC mode.
389 // Forbid a second field source so the worker's config has one clear owner.
390 // Runtime selection must precede creation of the planner's ONNX session.
391 if (descriptor >= 0) {
392 if (configuration.empty() || !field.empty()) throw std::runtime_error("IPC mode requires only --config");
393 if (!cmaes) dipla::initialize_runtime(onnx_lib_path);
394 return dipla::serve(descriptor, configuration, model, metadata, cmaes, comparison, network_options, experiment);
395 }
396 if (!configuration.empty()) throw std::runtime_error("--config requires --ipc-fd");
397 if (field.empty()) throw std::runtime_error("An explicit --field CSV is required");
398 if (!cmaes) dipla::initialize_runtime(onnx_lib_path);
399 // Standalone means a fresh experiment: one initial noisy observation,
400 // then one route from that posterior. Do not feed private full-field truth
401 // to the network or quietly plan from an entirely unobserved prior.
402 dipla::Survey survey(field, experiment);
403 survey.observe(position[0], position[1], 1);
404 dipla::Waypoints route{};
405 if (cmaes) {
406 const auto result = survey.compare(position, comparison);
407 // Never print half a route as a successful eight-point result.
408 if (!result) throw std::runtime_error("CMA-ES comparison budget expired before a complete route");
409 route = *result;
410 } else {
411 dipla::Network network(model, metadata, network_options);
412 dipla::Noise noise{};
413 // Repeatable diffusion noise, independent of Survey's sensor RNG.
414 // The sampler expects axis-major X/Y/Z blocks. Matching this seed
415 // alone does not reproduce NumPy's different random-number stream.
416 std::mt19937_64 generator(experiment.diffusion_seed);
417 std::normal_distribution<double> normal;
418 for (double& value : noise) value = normal(generator);
419 route = network.sample(survey.belief(), position, noise);
420 }
421 // Apply flight preparation once, regardless of which planner produced
422 // the route. Keeping padding outside sample() preserves raw model parity.
424 std::cerr << "diplacam planner=" << (cmaes ? "cmaes comparison_only=true onnx=false" : "diffusion onnx=true") << '\n';
425 std::cerr << "diplacam field_fnv1a=" << survey.field_digest() << " total_variance=" << survey.total_variance()
426 << " actual_agl_m=2 predicted_z_discarded=true\n";
427 // stdout is a machine-readable contract: no banners, diagnostics, or Z
428 // column mixed into a valid standalone result. Internal slots 0..7 map
429 // to P1..P8 at publication, not to eight automatic navigation commands.
430 std::cout << "slot,east_m,north_m\n" << std::setprecision(12);
431 for (std::size_t slot = 0; slot < route.size(); ++slot)
432 std::cout << slot << ',' << route[slot][0] << ',' << route[slot][1] << '\n';
433 return 0;
434 } catch (const std::exception& error) {
435 // One process-level error boundary keeps diagnostics on stderr and
436 // ensures invalid setup or planning is never reported as a successful CSV.
437 std::cerr << "diplacam: " << error.what() << '\n';
438 return 1;
439 }
440}
Allocation-free flat key=value mechanics; callers own schemas and storage.
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
static bool ini_real(const char *text, double *number)
Parse finite decimal/exponent notation, rejecting range errors and suffixes.
Definition bounded_ini.h:67
int descriptor
Definition chdk_pipe.c:142
Owns an ONNX session and samples eight metre-valued control points.
Maintains a synthetic field, GP posterior, and planning comparisons.
Belief belief() const
Copy the current GP marginal mean and variance into fixed-size storage.
double total_variance() const
Return the sum of posterior marginal variances.
std::uint64_t field_digest() const
Return the FNV-1a digest of the input CSV bytes.
bool observe(double east, double north, std::uint32_t number, double height=DIPLA_DEMO_HEIGHT_MM/DIPLA_MM_PER_M)
Assimilate one synthetic observation at a local pose.
std::optional< Waypoints > compare(const std::array< double, 3 > &position, const CmaesOptions &options={}, const std::function< bool()> &cancelled={}) const
Run the explicitly requested native CMA-ES comparison planner.
Eigen-style Aigen values and build-selected planner aliases.
#define DIPLA_MM_PER_M
#define DIPLA_DEMO_HEIGHT_MM
#define DIPLA_GRID_SIDE
Public planning, synthetic-survey, and comparison APIs for Diplacam.
Public entry point for Diplacam's bounded local IPC worker.
int main(int argc, char **argv)
Parse CLI options and run standalone planning or the IPC worker.
Definition diplacam.cpp:250
static bool model_setting(void *unused, const char *key, const char *value)
Keep class/threshold selection module-owned rather than assigning acoustic semantics to the common pa...
static struct inference_context network
Integrity-checked model contracts and independently owned tensor workspaces.
bool inference_settings_read(struct inference_settings *settings, const char *filename, ini_field_handler extra, void *context, char *error, size_t capacity)
Parse one flat INI, delegate application keys and resolve paths against the selected file.
void inference_settings_init(struct inference_settings *settings, enum inference_backend backend)
Reset storage and select conservative thread/timeout defaults.
Shared application_settings.ini discovery with module-owned extra keys.
@ INFERENCE_LIVE
@ INFERENCE_NATIVE
@ INFERENCE_ONNX
struct jpeg_error_mgr error
Definition lwir_image.c:60
constexpr const char * build_info
Definition compat.hpp:272
void apply_flight_margin(Waypoints &route, unsigned margin_cells)
Apply the configured horizontal flight margin.
int serve(int descriptor, const std::string &config_path, const std::string &model, const std::string &metadata, bool cmaes, const CmaesOptions &comparison, const NetworkOptions &network_options, const ExperimentOptions &experiment)
Serve a Diplacam session over an already-connected IPC descriptor.
void initialize_runtime(const std::string &onnx_lib_path)
Load the ONNX Runtime C API before constructing an inference session.
std::array< double, DIPLA_COORDINATE_COUNT *points > Noise
std::array< std::array< double, DIPLA_COORDINATE_COUNT >, points > Waypoints
Compile-time build identity strings for USHER executables.
#define DIPLACAM_BUILD_VERSION
Definition version.h:79
Bounded parameters for the comparison-only CMA-ES planner.
void validate() const
Validate the complete comparison policy before planning.
static constexpr int max_evaluations
static constexpr int max_budget_ms
static constexpr int population_size
Startup-only synthetic experiment settings shared by both planners.
void validate() const
Reject nonfinite values and incompatible margins before allocation.
std::uint64_t sensor_noise_seed
Model identity and execution limits for a diffusion network.
enum inference_backend backend
char model[INFERENCE_PATH_CAPACITY]
enum inference_source source
char descriptor[INFERENCE_PATH_CAPACITY]
char library_directory[INFERENCE_PATH_CAPACITY]
struct usher_control_result result
Definition usher.c:377