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
coverage_scheduler.c File Reference

Bounded geometric decisions without pixel decoding or camera dependencies. More...

#include "coverage_scheduler.h"
#include <math.h>
#include <string.h>
Include dependency graph for coverage_scheduler.c:

Go to the source code of this file.

Data Structures

struct  coverage_bounds
 Validated inclusive grid bounds and polygon winding for half-plane tests. More...

Functions

static void rotate (double vector[3], double roll_deg, double pitch_deg, double yaw_deg)
 Apply Rz*Ry*Rx in place, matching the mount/body order used by PANGEA.
bool coverage_project (const struct coverage_camera *camera, const struct coverage_pose *pose, double origin_latitude_deg, double origin_longitude_deg, struct coverage_footprint *footprint)
 Project delivered-image corners onto a local flat ground plane.
bool coverage_project_pixel (const struct coverage_camera *camera, const struct coverage_pose *pose, double column, double row, struct coverage_point *offset)
 Project an image pixel onto the same ground plane as the coverage footprint.
bool coverage_init (struct coverage_state *state, double east, double north, double cell_m)
 Clear the ledger and set its fixed spatial domain.
static bool bounds (const struct coverage_state *state, const struct coverage_candidate *candidate, struct coverage_bounds *box)
 Reject unusable polygons before converting coordinates or scanning cells.
static bool contains_cell (const struct coverage_state *state, const struct coverage_candidate *candidate, const struct coverage_bounds *box, int column, int row)
 Require the whole cell, not merely its centre, inside every polygon edge.
static double gain_after (const struct coverage_state *state, const struct coverage_candidate *candidate, const struct coverage_candidate *previous)
 Score a second view against a hypothetical first, without committing either.
double coverage_gain (const struct coverage_state *state, const struct coverage_candidate *candidate)
 Score additional detail in conservatively contained cells without mutation.
bool coverage_commit (struct coverage_state *state, const struct coverage_candidate *candidate)
 Credit a successfully saved observation, retaining the best detail per cell.
int coverage_choose (const struct coverage_state *state, const struct coverage_candidate *candidates, size_t count, uint64_t now_us, uint64_t service_us)
 Choose the first observation of the best feasible one- or two-shot plan.
bool coverage_wholly_saved (const struct coverage_state *state, const struct coverage_candidate *candidate)
 Check whether skipping this observation is geometrically conservative.
double coverage_overlap (const struct coverage_state *state, const struct coverage_candidate *first, const struct coverage_candidate *second)
 Estimate conservative overlap for deciding whether a delay is acceptable.

Detailed Description

Bounded geometric decisions without pixel decoding or camera dependencies.

Two different margins are intentional: shrink footprints when granting credit, but expand them before deciding a new photograph is redundant. Using the same test for both would turn uncertainty into falsely claimed coverage.

Definition in file coverage_scheduler.c.

Function Documentation

◆ bounds()

bool bounds ( const struct coverage_state * state,
const struct coverage_candidate * candidate,
struct coverage_bounds * box )
static

Reject unusable polygons before converting coordinates or scanning cells.

Convexity and work limits belong here so every scoring/credit path shares the same conservative definition of a computable footprint.

Definition at line 120 of file coverage_scheduler.c.

◆ contains_cell()

bool contains_cell ( const struct coverage_state * state,
const struct coverage_candidate * candidate,
const struct coverage_bounds * box,
int column,
int row )
static

Require the whole cell, not merely its centre, inside every polygon edge.

Definition at line 156 of file coverage_scheduler.c.

◆ coverage_choose()

int coverage_choose ( const struct coverage_state * state,
const struct coverage_candidate * candidates,
size_t count,
uint64_t now_us,
uint64_t service_us )

Choose the first observation of the best feasible one- or two-shot plan.

Parameters
stateCommitted coverage, left unchanged.
candidatesAt most COVERAGE_CANDIDATES opportunities.
countNumber of opportunities.
now_usEarliest permissible start, monotonic microseconds.
service_usPositive serialized acquisition interval used between choices.
Returns
First candidate index, or -1 when no positive feasible gain is known.

Union scoring avoids double-counting repeated ground in the second view. Ties favor an earlier start, then greater first-shot gain. The caller still enforces overlap, uncertainty and delay limits; this is not a global flight planner.

Definition at line 218 of file coverage_scheduler.c.

◆ coverage_commit()

bool coverage_commit ( struct coverage_state * state,
const struct coverage_candidate * candidate )

Credit a successfully saved observation, retaining the best detail per cell.

Parameters
[in,out]stateInitialized committed ledger.
candidateSaved image footprint with trusted pose and detail score.
Returns
True for a valid bounded update, even if no cells improve; false for unknown geometry.
Precondition
The caller has verified publication. Never call this for a mere capture request.

Definition at line 204 of file coverage_scheduler.c.

◆ coverage_gain()

double coverage_gain ( const struct coverage_state * state,
const struct coverage_candidate * candidate )

Score additional detail in conservatively contained cells without mutation.

Parameters
stateInitialized committed ledger.
candidateObservation to evaluate.
Returns
Quality-weighted square metres, zero for no credited gain, or -1 for unknown geometry. Zero alone is not permission to skip; use coverage_wholly_saved().

Definition at line 199 of file coverage_scheduler.c.

◆ coverage_init()

bool coverage_init ( struct coverage_state * state,
double east,
double north,
double cell_m )

Clear the ledger and set its fixed spatial domain.

Parameters
[out]stateCaller-owned ledger; allocate off small embedded thread stacks.
eastLower grid edge in local east metres.
northLower grid edge in local north metres.
cell_mCell edge in metres, within 0.25..100.
Returns
True on initialization; false leaves state unchanged.

Definition at line 105 of file coverage_scheduler.c.

◆ coverage_overlap()

double coverage_overlap ( const struct coverage_state * state,
const struct coverage_candidate * first,
const struct coverage_candidate * second )

Estimate conservative overlap for deciding whether a delay is acceptable.

Parameters
stateGrid geometry used to discretize the comparison; saved values are not read.
firstCandidate whose bounding-cell count is the denominator.
secondSame-camera footprint to overlap with.
Returns
Conservative fraction in 0..1, or -1 if the comparison is unknown.
Note
This is asymmetric and deliberately stricter than exact polygon overlap.

Definition at line 269 of file coverage_scheduler.c.

◆ coverage_project()

bool coverage_project ( const struct coverage_camera * camera,
const struct coverage_pose * pose,
double origin_latitude_deg,
double origin_longitude_deg,
struct coverage_footprint * footprint )

Project delivered-image corners onto a local flat ground plane.

Parameters
cameraMeasured intrinsics and camera-to-body mount.
poseObservation pose with AGL and uncertainty.
origin_latitude_degLocal projection reference latitude, degrees.
origin_longitude_degLocal projection reference longitude, degrees.
[out]footprintResult, written only on success.
Returns
False for invalid, near-horizon or excessively distant geometry.
Warning
A plausible footprint does not establish terrain visibility, focus or exposure synchronization. Zero mount means image-up forward and optical-axis down.

Definition at line 46 of file coverage_scheduler.c.

◆ coverage_project_pixel()

bool coverage_project_pixel ( const struct coverage_camera * camera,
const struct coverage_pose * pose,
double column,
double row,
struct coverage_point * offset )

Project an image pixel onto the same ground plane as the coverage footprint.

Parameters
cameraDelivered-image calibration and mount.
poseObservation attitude and camera-to-ground height.
columnPixel column within the delivered image.
rowPixel row within the delivered image.
[out]offsetMetres east/north relative to the observation position.
Returns
False for invalid pixels or geometry, leaving offset unchanged.

Reuses whole-footprint qualification and the existing mount/body rotation order.

Definition at line 88 of file coverage_scheduler.c.

◆ coverage_wholly_saved()

bool coverage_wholly_saved ( const struct coverage_state * state,
const struct coverage_candidate * candidate )

Check whether skipping this observation is geometrically conservative.

Parameters
stateInitialized committed ledger.
candidateProposed observation.
Returns
True only when the uncertainty-expanded bounding region already has at least the requested detail. Outside the grid or work budget, return false.

Definition at line 252 of file coverage_scheduler.c.

◆ gain_after()

double gain_after ( const struct coverage_state * state,
const struct coverage_candidate * candidate,
const struct coverage_candidate * previous )
static

Score a second view against a hypothetical first, without committing either.

The overlay is local to this calculation. A predicted image must never leak into the saved ledger, even if it scores well or is next in the queue.

Definition at line 179 of file coverage_scheduler.c.

◆ rotate()

void rotate ( double vector[3],
double roll_deg,
double pitch_deg,
double yaw_deg )
static

Apply Rz*Ry*Rx in place, matching the mount/body order used by PANGEA.

Definition at line 34 of file coverage_scheduler.c.