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
dipla_planner.hpp
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/* Additional author attribution: Copyright 2026 Akshat Jain */
19
32#pragma once
33
34#include "dipla_contract.h"
35#include <array>
36#include <cstdint>
37#include <functional>
38#include <memory>
39#include <optional>
40#include <string>
41
42namespace dipla {
44constexpr std::size_t cells = DIPLA_GRID_SIDE * DIPLA_GRID_SIDE;
46constexpr std::size_t points = DIPLA_WAYPOINT_COUNT;
48using Noise = std::array<double, DIPLA_COORDINATE_COUNT * points>;
50using Waypoints = std::array<std::array<double, DIPLA_COORDINATE_COUNT>, points>;
51
55 std::uint64_t diffusion_seed = 123;
57 std::uint64_t sensor_noise_seed = 149;
59 static constexpr unsigned default_margin_cells = 2;
63 double gp_prior_mean = 0.2;
65 double gp_kernel_variance = 0.0079;
67 double gp_lengthscale_m = 4.78;
69 double sensor_fov_deg = 60.0;
71 double sensor_noise_variance = 0.01;
73 void validate() const;
74};
75
86
98void initialize_runtime(const std::string& onnx_lib_path = {});
99
105struct Belief {
107 std::array<double, cells> mean{};
109 std::array<double, cells> variance{};
110};
111
119 static constexpr int population_size = 12;
121 static constexpr int max_budget_ms = 4000;
123 static constexpr int max_evaluations = 3000;
125 int budget_ms = 1000;
127 int maxfevals = 300;
129 int seed = 55;
131 double utility_threshold = 0.3;
133 double confidence_beta = 1.0;
135 double step_xy_m = 20.0;
137 void validate() const;
138};
139
146 std::string descriptor;
148 unsigned threads = 1;
150 unsigned timeout_ms = 0;
153};
154
159class Network {
160public:
170 Network(const std::string& model, const std::string& metadata,
171 const NetworkOptions& options = {});
177
192 Waypoints sample(const Belief& belief, const std::array<double, 3>& position,
193 const Noise& noise);
194private:
196 struct State;
198 std::unique_ptr<State> state_;
199};
200
207class Survey {
208public:
217 explicit Survey(const std::string& field, const ExperimentOptions& options = {});
223
243 bool observe(double east, double north, std::uint32_t number,
244 double height = DIPLA_DEMO_HEIGHT_MM / DIPLA_MM_PER_M);
245
257 std::optional<Waypoints> compare(const std::array<double, 3>& position,
258 const CmaesOptions& options = {},
259 const std::function<bool()>& cancelled = {}) const;
260
266 Belief belief() const;
272 double total_variance() const;
278 std::uint64_t field_digest() const;
279private:
281 struct State;
283 std::unique_ptr<State> state_;
284};
285}
~Network()
Releases the owned ONNX session and inference buffers.
Network(const std::string &model, const std::string &metadata, const NetworkOptions &options={})
Load and validate a deployment model.
Definition dipla_planner.cpp:465
std::unique_ptr< State > state_
Exclusive ownership keeps the runtime session lifetime tied to this object.
Definition dipla_planner.hpp:198
Waypoints sample(const Belief &belief, const std::array< double, 3 > &position, const Noise &noise)
Run the complete deterministic DDIM sampler for a supplied noise vector.
Definition dipla_planner.cpp:486
Belief belief() const
Copy the current GP marginal mean and variance into fixed-size storage.
Definition dipla_planner.cpp:808
double total_variance() const
Return the sum of posterior marginal variances.
Definition dipla_planner.cpp:825
std::uint64_t field_digest() const
Return the FNV-1a digest of the input CSV bytes.
Definition dipla_planner.cpp:832
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.
Definition dipla_planner.cpp:715
std::unique_ptr< State > state_
Exclusive ownership keeps private truth and dense GP state out of the API.
Definition dipla_planner.hpp:283
Survey(const std::string &field, const ExperimentOptions &options={})
Load the complete finite-grid synthetic field.
Definition dipla_planner.cpp:699
~Survey()
Releases field and covariance storage.
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.
Definition dipla_planner.cpp:758
Fixed model geometry and C/C++ local transport units, not runtime settings.
#define DIPLA_WAYPOINT_COUNT
Ordered route slots; changing this requires a new model and transport contract.
Definition dipla_contract.h:31
#define DIPLA_MM_PER_M
Millimetres per metre.
Definition dipla_contract.h:49
#define DIPLA_DEMO_HEIGHT_MM
Fixed mission experiment height; not the model altitude normalization.
Definition dipla_contract.h:43
#define DIPLA_GRID_SIDE
Supported model grid side; generic numerical grids remain independent.
Definition dipla_contract.h:25
Definition aigenlib.cpp:42
void apply_flight_margin(Waypoints &route, unsigned margin_cells)
Apply the configured horizontal flight margin.
Definition dipla_planner.cpp:599
void initialize_runtime(const std::string &onnx_lib_path)
Load the ONNX Runtime C API before constructing an inference session.
Definition dipla_planner.cpp:75
std::array< double, DIPLA_COORDINATE_COUNT *points > Noise
Flattened XYZ diffusion noise, grouped by coordinate axis.
Definition dipla_planner.hpp:48
constexpr std::size_t cells
Number of cells in the supported 51-by-51 world grid.
Definition dipla_planner.hpp:44
std::array< std::array< double, DIPLA_COORDINATE_COUNT >, points > Waypoints
Eight ordered XYZ waypoints in local east/north/metre coordinates.
Definition dipla_planner.hpp:50
constexpr std::size_t points
Number of ordered control points returned by either planner.
Definition dipla_planner.hpp:46
Fixed-shape posterior summary consumed by the diffusion model.
Definition dipla_planner.hpp:105
std::array< double, cells > variance
Posterior marginal variance at each grid cell.
Definition dipla_planner.hpp:109
std::array< double, cells > mean
Posterior mean at each grid cell.
Definition dipla_planner.hpp:107
Bounded parameters for the comparison-only CMA-ES planner.
Definition dipla_planner.hpp:117
int maxfevals
Maximum objective evaluations, inclusive range 12..3000.
Definition dipla_planner.hpp:127
double step_xy_m
Positive initial horizontal optimizer standard deviation in metres.
Definition dipla_planner.hpp:135
void validate() const
Validate the complete comparison policy before planning.
Definition dipla_planner.cpp:585
static constexpr int max_evaluations
Largest accepted evaluation allowance.
Definition dipla_planner.hpp:123
int seed
Positive deterministic seed used by the native optimizer.
Definition dipla_planner.hpp:129
double utility_threshold
Confidence-bound field importance threshold.
Definition dipla_planner.hpp:131
static constexpr int max_budget_ms
Largest accepted cooperative budget in milliseconds.
Definition dipla_planner.hpp:121
double confidence_beta
Nonnegative confidence multiplier.
Definition dipla_planner.hpp:133
static constexpr int population_size
Smallest complete comparison population.
Definition dipla_planner.hpp:119
int budget_ms
Cooperative wall-clock budget in milliseconds, inclusive range 1..4000.
Definition dipla_planner.hpp:125
Startup-only synthetic experiment settings shared by both planners.
Definition dipla_planner.hpp:53
unsigned flight_margin_cells
Horizontal inset for both comparison controls and published targets.
Definition dipla_planner.hpp:61
double gp_kernel_variance
Positive Matern marginal variance in squared field units.
Definition dipla_planner.hpp:65
static constexpr unsigned default_margin_cells
Reference horizontal inset, in grid cells.
Definition dipla_planner.hpp:59
double sensor_fov_deg
Full synthetic sensor field of view in degrees, strictly between 0 and 180.
Definition dipla_planner.hpp:69
void validate() const
Reject nonfinite values and incompatible margins before allocation.
Definition dipla_planner.cpp:576
double gp_lengthscale_m
Positive Matern spatial length scale in metres.
Definition dipla_planner.hpp:67
std::uint64_t sensor_noise_seed
Independent sensor stream seed; reset only for a new survey.
Definition dipla_planner.hpp:57
std::uint64_t diffusion_seed
Independent diffusion stream seed; retained across worker survey resets.
Definition dipla_planner.hpp:55
double gp_prior_mean
Initial scalar field estimate, independent of the comparison threshold.
Definition dipla_planner.hpp:63
double sensor_noise_variance
Positive independent measurement variance used for noise and likelihood.
Definition dipla_planner.hpp:71
Model identity and execution limits for a diffusion network.
Definition dipla_planner.hpp:144
std::string conditioning_cache
Optional verified encoder/denoiser bundle; empty retains the original graph.
Definition dipla_planner.hpp:152
std::string descriptor
Optional integrity-checked model descriptor path.
Definition dipla_planner.hpp:146
unsigned timeout_ms
Whole-plan cooperative deadline in milliseconds; zero leaves supervision to the caller.
Definition dipla_planner.hpp:150
unsigned threads
CPU inference threads, bounded to 1..32; one avoids competing with other MORA workers by default.
Definition dipla_planner.hpp:148
Runtime-owned ONNX session and reusable input/output storage.
Definition dipla_planner.cpp:197