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
spotter_targets.c
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/** @file spotter_targets.c
19 * @brief Stable five-slot confidence ranking without heap, threads or flight-plan decisions. */
20#include "spotter_targets.h"
21
22#include <stddef.h>
23
25{
26 if (!targets) return;
27 for (unsigned slot = 0; slot < SPOTTER_TARGET_COUNT; ++slot)
28 targets->slots[slot] = (struct spotter_target){0};
29}
30
31int spotter_targets_offer(struct spotter_targets *targets, const struct spotter_target *observation,
32 bool (*apply)(void *, unsigned, const struct spotter_target *), void *context)
33{
34 if (!targets || !observation || !observation->valid || observation->score > 1000 ||
35 observation->latitude < -900000000 || observation->latitude > 900000000 ||
36 observation->longitude < -1800000000 || observation->longitude > 1800000000) return -1;
37 unsigned selected = SPOTTER_TARGET_COUNT;
38 for (unsigned slot = 0; slot < SPOTTER_TARGET_COUNT; ++slot) {
39 const struct spotter_target *stored = &targets->slots[slot];
40 if (stored->valid && stored->latitude == observation->latitude &&
41 stored->longitude == observation->longitude) {
42 if (observation->score <= stored->score) return -1;
43 selected = slot;
44 break;
45 }
46 if (!stored->valid && selected == SPOTTER_TARGET_COUNT) selected = slot;
47 }
48 if (selected == SPOTTER_TARGET_COUNT) {
49 selected = 0;
50 for (unsigned slot = 1; slot < SPOTTER_TARGET_COUNT; ++slot)
51 if (targets->slots[slot].score < targets->slots[selected].score) selected = slot;
52 if (observation->score <= targets->slots[selected].score) return -1;
53 }
54 if (apply && !apply(context, selected, observation)) return -1;
55 targets->slots[selected] = *observation;
56 return (int)selected;
57}
void spotter_targets_reset(struct spotter_targets *targets)
Forget all prior assignments without manufacturing target coordinates.
int spotter_targets_offer(struct spotter_targets *targets, const struct spotter_target *observation, bool(*apply)(void *, unsigned, const struct spotter_target *), void *context)
Admit a target only after its owner's coordinate application succeeds.
Five ranked geographic targets, independent of navigation and camera transport.
#define SPOTTER_TARGET_COUNT
Geographic observation in the shared USHER point units.
Caller-owned fixed storage; slot indices stay stable while scores improve.
struct spotter_target slots[SPOTTER_TARGET_COUNT]