Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
scout_detector.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Fabien-B <fabien-B@github.com>
3 * Gautier Hattenberger <gautier.hattenberger@enac.fr>
4 *
5 * This file is part of paparazzi
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
28#include "string.h"
29#include "uavcan/uavcan.h"
30#include "uavcan.protocol.debug.KeyValue.h"
32#ifdef SITL
33#include "generated/flight_plan.h"
34#endif
35
37
40
43
45 return;
46 }
47
48 if (msg.key.len != 3) {
49 return;
50 }
51
52 if (strncmp("snr", (const char*)msg.key.data, 3) == 0) {
53 // first receive signal to noise value
54 scout_data.snr = msg.value;
55 } else if (strncmp("lit", (const char*)msg.key.data, 3) == 0) {
56 // lit (value in [0,1]) always received after snr
57 scout_data.lit = msg.value;
58 // FIXME better sync of data or single message !!!
59 float data = scout_data.snr * (1.f + scout_data.lit);
60 // update map
62 }
63}
64
66{
67 // Init map at dummy waypoint (0, 0)
68 // proper initialization according to the mission should be done in the flight plan
70
72}
73
80
82#if (defined SITL) && (defined WP_SCOUT)
84 struct EnuCoor_f pos = *stateGetPositionEnu_f();
85 struct FloatVect3 dp;
86 VECT3_DIFF(dp, pos, scout);
87 float dist = float_vect3_norm(&dp);
88 // scout at 3 m ~ 95 dB
89 // sound level: L(d) = L(d0) - 20 * log10(d/d0)
90 // snr = 20 db at 3 m with propellers -> L(d0) = 20
91 float snr = 20. - 20.f*log10f(dist/3.f);
92 if (snr > 5.f) { // avoid to detect at too long range
93 scout_data.snr = snr;
94 } else {
95 scout_data.snr = 0.f;
96 }
98#endif
99}
100
static float float_vect3_norm(const struct FloatVect3 *v)
#define VECT3_DIFF(_c, _a, _b)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition state.h:848
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
Definition state.h:839
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
uint16_t foo
Definition main_demo5.c:58
struct EnuCoor_f * waypoint_get_enu_f(uint8_t wp_id)
Get ENU coordinates (float)
Definition waypoints.c:392
vector in East North Up coordinates Units: meters
static uavcan_event scout_detector_uavcan_ev
scoutector_t scout_data
void scout_detector_sim(void)
void scout_detector_report(void)
void scout_detector_init(void)
struct search_map_t scout_map
static void scout_detector_uavcan_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
Scoutector driver Initially made for IMAV 2026 !
void search_map_init_from_wp(struct search_map_t *map, uint8_t wp_id, float res)
init map from waypoint
Definition search_map.c:50
bool search_map_update(struct search_map_t *map, float data, struct NedCoor_f pos)
update map with new data
Definition search_map.c:67
map for detection
Definition search_map.h:38
void uavcan_bind(uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
Bind to a receiving message from uavcan.
Definition uavcan.c:240
Main uavcan event structure for registering/calling callbacks.
Definition uavcan.h:74
uavcan interface structure
Definition uavcan.h:44
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
Definition wedgebug.c:204
int transfer(const Mat *from, const image_t *to)