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

Bounded ground-source localization from a geotagged acoustic survey. More...

#include "earcam_core.h"
#include <math.h>
#include <pthread.h>
#include <string.h>
Include dependency graph for ear_fusion.c:

Go to the source code of this file.

Data Structures

struct  enu_sample
 Solver-local horizontal coordinates plus each window's own squared height. More...

Macros

#define EAR_MIN_SAMPLES   8U
#define EARTH_RADIUS_M   6378137.0
#define DEG_TO_RAD   0.017453292519943295
#define RAD_TO_DEG   57.29577951308232
#define EAR_POSE_LATITUDE_EPSILON_DEG   1e-6
#define EAR_MAD_TO_SIGMA   1.4826
#define EAR_MIN_LEVEL_SIGMA_DB   0.5
#define EAR_QUIET_OUTLIER_SIGMAS   4.0
#define EAR_PEAK_QUARTILE_DIVISOR   4
#define EAR_MIN_PEAK_WINDOWS   4
#define EAR_DB_LOG_BASE   10.0
#define EAR_POWER_DB_PER_DECADE   10.0
#define EAR_DISTANCE_DB_PER_DECADE   20.0
#define EAR_TREND_BONUS_LIMIT_DB   6.0
#define EAR_TREND_BONUS_SCALE_DB   12.0
#define EAR_HEIGHT_WINDOW_LIMIT   64
#define EAR_MIN_USABLE_HEIGHT_M   0.5
#define EAR_FALLBACK_HEIGHT_M   10.0
#define EAR_REFERENCE_DISTANCE_M   1.0
#define EAR_FIT_PARAMETER_COUNT   3
#define EAR_FIT_EAST   0
#define EAR_FIT_NORTH   1
#define EAR_FIT_SOURCE_LEVEL   2
#define EAR_FIT_ITERATION_LIMIT   8
#define EAR_FIT_RESIDUAL_LIMIT_DB   6.0
#define EAR_FIT_DAMPING   1e-3
#define EAR_FIT_DETERMINANT_EPSILON   1e-12
#define EAR_FIT_HORIZONTAL_STEP_LIMIT_M   25.0
#define EAR_FIT_LEVEL_STEP_LIMIT_DB   6.0
#define EAR_FIT_CONVERGENCE_M   0.05
#define EAR_FIT_CENTROID_DRIFT_LIMIT_M   60.0
#define EAR_CONFIDENCE_PROMINENCE_WEIGHT   0.5
#define EAR_CONFIDENCE_CONCENTRATION_WEIGHT   0.3
#define EAR_CONFIDENCE_SUPPORT_WEIGHT   0.2
#define EAR_CONFIDENCE_PROMINENCE_SCALE_DB   12.0
#define EAR_CONFIDENCE_SPREAD_SCALE_M   40.0
#define EAR_CONFIDENCE_SUPPORT_WINDOWS   100.0

Functions

static void sift_down (double *values, size_t root, size_t count)
 Restore a zero-based binary max heap without allocating scratch memory.
static void sort_double (double *values, size_t count)
 In-place heapsort keeps worst-case workspace bounded for a full survey.
static double median_of (double *values, size_t count)
 Median of nonempty scratch values; sorting intentionally destroys their order.
int calculated_loudestspot (const struct ear_sample *samples, size_t count, struct ear_loudest_spot *result)
 Estimate a ground source from relative loudness along a survey track.

Variables

static pthread_mutex_t solver_mutex = PTHREAD_MUTEX_INITIALIZER
static struct enu_sample solver_points [EAR_MAX_SAMPLES]
static double solver_levels [EAR_MAX_SAMPLES]

Detailed Description

Bounded ground-source localization from a geotagged acoustic survey.

Relative band power supplies a conservative starting centroid; inverse-distance fitting improves it when survey geometry supports a fit. Constants below preserve the existing estimator policy. They are documented heuristics, not universal field-calibration values or flight-safety limits.

Definition in file ear_fusion.c.

Macro Definition Documentation

◆ DEG_TO_RAD

#define DEG_TO_RAD   0.017453292519943295

Definition at line 34 of file ear_fusion.c.

◆ EAR_CONFIDENCE_CONCENTRATION_WEIGHT

#define EAR_CONFIDENCE_CONCENTRATION_WEIGHT   0.3

Definition at line 70 of file ear_fusion.c.

◆ EAR_CONFIDENCE_PROMINENCE_SCALE_DB

#define EAR_CONFIDENCE_PROMINENCE_SCALE_DB   12.0

Definition at line 72 of file ear_fusion.c.

◆ EAR_CONFIDENCE_PROMINENCE_WEIGHT

#define EAR_CONFIDENCE_PROMINENCE_WEIGHT   0.5

These three weights form a heuristic score, not calibrated detection odds.

Definition at line 69 of file ear_fusion.c.

◆ EAR_CONFIDENCE_SPREAD_SCALE_M

#define EAR_CONFIDENCE_SPREAD_SCALE_M   40.0

Definition at line 73 of file ear_fusion.c.

◆ EAR_CONFIDENCE_SUPPORT_WEIGHT

#define EAR_CONFIDENCE_SUPPORT_WEIGHT   0.2

Definition at line 71 of file ear_fusion.c.

◆ EAR_CONFIDENCE_SUPPORT_WINDOWS

#define EAR_CONFIDENCE_SUPPORT_WINDOWS   100.0

Definition at line 74 of file ear_fusion.c.

◆ EAR_DB_LOG_BASE

#define EAR_DB_LOG_BASE   10.0

Definition at line 45 of file ear_fusion.c.

◆ EAR_DISTANCE_DB_PER_DECADE

#define EAR_DISTANCE_DB_PER_DECADE   20.0

Definition at line 47 of file ear_fusion.c.

◆ EAR_FALLBACK_HEIGHT_M

#define EAR_FALLBACK_HEIGHT_M   10.0

Definition at line 53 of file ear_fusion.c.

◆ EAR_FIT_CENTROID_DRIFT_LIMIT_M

#define EAR_FIT_CENTROID_DRIFT_LIMIT_M   60.0

Definition at line 67 of file ear_fusion.c.

◆ EAR_FIT_CONVERGENCE_M

#define EAR_FIT_CONVERGENCE_M   0.05

Definition at line 66 of file ear_fusion.c.

◆ EAR_FIT_DAMPING

#define EAR_FIT_DAMPING   1e-3

Definition at line 62 of file ear_fusion.c.

◆ EAR_FIT_DETERMINANT_EPSILON

#define EAR_FIT_DETERMINANT_EPSILON   1e-12

Definition at line 63 of file ear_fusion.c.

◆ EAR_FIT_EAST

#define EAR_FIT_EAST   0

Definition at line 57 of file ear_fusion.c.

◆ EAR_FIT_HORIZONTAL_STEP_LIMIT_M

#define EAR_FIT_HORIZONTAL_STEP_LIMIT_M   25.0

Definition at line 64 of file ear_fusion.c.

◆ EAR_FIT_ITERATION_LIMIT

#define EAR_FIT_ITERATION_LIMIT   8

Definition at line 60 of file ear_fusion.c.

◆ EAR_FIT_LEVEL_STEP_LIMIT_DB

#define EAR_FIT_LEVEL_STEP_LIMIT_DB   6.0

Definition at line 65 of file ear_fusion.c.

◆ EAR_FIT_NORTH

#define EAR_FIT_NORTH   1

Definition at line 58 of file ear_fusion.c.

◆ EAR_FIT_PARAMETER_COUNT

#define EAR_FIT_PARAMETER_COUNT   3

Fit east, north and unknown source level; altitude is supplied per window.

Definition at line 56 of file ear_fusion.c.

◆ EAR_FIT_RESIDUAL_LIMIT_DB

#define EAR_FIT_RESIDUAL_LIMIT_DB   6.0

Definition at line 61 of file ear_fusion.c.

◆ EAR_FIT_SOURCE_LEVEL

#define EAR_FIT_SOURCE_LEVEL   2

Definition at line 59 of file ear_fusion.c.

◆ EAR_HEIGHT_WINDOW_LIMIT

#define EAR_HEIGHT_WINDOW_LIMIT   64

Bound representative-height scratch space independently of survey size.

Definition at line 51 of file ear_fusion.c.

◆ EAR_MAD_TO_SIGMA

#define EAR_MAD_TO_SIGMA   1.4826

Gaussian-consistent conversion from median absolute deviation to sigma.

Definition at line 40 of file ear_fusion.c.

◆ EAR_MIN_LEVEL_SIGMA_DB

#define EAR_MIN_LEVEL_SIGMA_DB   0.5

Definition at line 41 of file ear_fusion.c.

◆ EAR_MIN_PEAK_WINDOWS

#define EAR_MIN_PEAK_WINDOWS   4

Definition at line 44 of file ear_fusion.c.

◆ EAR_MIN_SAMPLES

#define EAR_MIN_SAMPLES   8U

Definition at line 32 of file ear_fusion.c.

◆ EAR_MIN_USABLE_HEIGHT_M

#define EAR_MIN_USABLE_HEIGHT_M   0.5

Definition at line 52 of file ear_fusion.c.

◆ EAR_PEAK_QUARTILE_DIVISOR

#define EAR_PEAK_QUARTILE_DIVISOR   4

Definition at line 43 of file ear_fusion.c.

◆ EAR_POSE_LATITUDE_EPSILON_DEG

#define EAR_POSE_LATITUDE_EPSILON_DEG   1e-6

Legacy near-zero-latitude placeholder gate; it also excludes equatorial tracks.

Definition at line 38 of file ear_fusion.c.

◆ EAR_POWER_DB_PER_DECADE

#define EAR_POWER_DB_PER_DECADE   10.0

Definition at line 46 of file ear_fusion.c.

◆ EAR_QUIET_OUTLIER_SIGMAS

#define EAR_QUIET_OUTLIER_SIGMAS   4.0

Definition at line 42 of file ear_fusion.c.

◆ EAR_REFERENCE_DISTANCE_M

#define EAR_REFERENCE_DISTANCE_M   1.0

Definition at line 54 of file ear_fusion.c.

◆ EAR_TREND_BONUS_LIMIT_DB

#define EAR_TREND_BONUS_LIMIT_DB   6.0

Definition at line 48 of file ear_fusion.c.

◆ EAR_TREND_BONUS_SCALE_DB

#define EAR_TREND_BONUS_SCALE_DB   12.0

Definition at line 49 of file ear_fusion.c.

◆ EARTH_RADIUS_M

#define EARTH_RADIUS_M   6378137.0

Definition at line 33 of file ear_fusion.c.

◆ RAD_TO_DEG

#define RAD_TO_DEG   57.29577951308232

Definition at line 35 of file ear_fusion.c.

Function Documentation

◆ calculated_loudestspot()

int calculated_loudestspot ( const struct ear_sample * samples,
size_t count,
struct ear_loudest_spot * result )

Estimate a ground source from relative loudness along a survey track.

Parameters
samplesCaller-owned immutable windows; never modified or retained.
countInput count, bounded by EAR_MAX_SAMPLES.
resultRequired destination; cleared before validation when non-NULL.
Returns
Zero for an estimate, -1 for invalid input or insufficient retained evidence.

A robust centroid seeds a damped inverse-distance fit; unstable fits fall back to that centroid. Shared bounded scratch storage is mutex-protected, so concurrent calls serialize without allocating another survey-sized buffer.

Warning
A valid result is not an absolute alarm gate. With too few alarm windows the solver deliberately uses other finite levels, even silent ones. Mission policy must consider level, quality, geometry and independent evidence. The legacy near-zero-latitude placeholder gate also excludes equatorial tracks.

Definition at line 129 of file ear_fusion.c.

◆ median_of()

double median_of ( double * values,
size_t count )
static

Median of nonempty scratch values; sorting intentionally destroys their order.

Definition at line 104 of file ear_fusion.c.

◆ sift_down()

void sift_down ( double * values,
size_t root,
size_t count )
static

Restore a zero-based binary max heap without allocating scratch memory.

Definition at line 77 of file ear_fusion.c.

◆ sort_double()

void sort_double ( double * values,
size_t count )
static

In-place heapsort keeps worst-case workspace bounded for a full survey.

Definition at line 92 of file ear_fusion.c.

Variable Documentation

◆ solver_levels

double solver_levels[EAR_MAX_SAMPLES]
static

Definition at line 127 of file ear_fusion.c.

◆ solver_mutex

pthread_mutex_t solver_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 123 of file ear_fusion.c.

◆ solver_points

struct enu_sample solver_points[EAR_MAX_SAMPLES]
static

Definition at line 126 of file ear_fusion.c.