35 #include "generated/airframe.h"
38 #include "pprzlink/messages.h"
51 #ifndef CLOUD_SENSOR_LOG_FILE
52 #define CLOUD_SENSOR_LOG_FILE flightrecorder_sdlog
56 #ifndef CLOUD_SENSOR_RAW_MAX
57 #define CLOUD_SENSOR_RAW_MAX 16
61 #ifndef CLOUD_SENSOR_NB
62 #define CLOUD_SENSOR_NB 4
66 #ifndef CLOUD_SENSOR_OFFSET
67 #define CLOUD_SENSOR_OFFSET 4
71 #ifndef CLOUD_SENSOR_BORDER_THRESHOLD
72 #define CLOUD_SENSOR_BORDER_THRESHOLD 0.05
76 #ifndef CLOUD_SENSOR_BORDER_HYSTERESIS
77 #define CLOUD_SENSOR_BORDER_HYSTERESIS 0.01
81 #ifndef CLOUD_SENSOR_SINGLE_CHANNEL
82 #define CLOUD_SENSOR_SINGLE_CHANNEL 1
86 #ifndef CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF
87 #define CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF 2.f
91 #ifndef CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF
92 #define CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF 0.5f
95 #ifndef CLOUD_SENSOR_CALIB_ALPHA
96 #define CLOUD_SENSOR_CALIB_ALPHA 1.f
99 #ifndef CLOUD_SENSOR_CALIB_BETA
100 #define CLOUD_SENSOR_CALIB_BETA 1.f
103 #ifndef CLOUD_SENSOR_CHANNEL_SCALE
104 #define CLOUD_SENSOR_CHANNEL_SCALE 1.f
107 #ifndef CLOUD_SENSOR_TAU
108 #define CLOUD_SENSOR_TAU 0.f
113 #define CLOUD_BORDER 1
116 #ifndef CLOUD_SENSOR_REPORT_BORDER_CROSSING
117 #define CLOUD_SENSOR_REPORT_BORDER_CROSSING FALSE
122 #ifndef CLOUD_SENSOR_LAMBDA
123 #define CLOUD_SENSOR_LAMBDA { 505.f, 590.f, 840.f, 840.f }
128 #ifndef CLOUD_SENSOR_ANGSTROM_COEF
129 #define CLOUD_SENSOR_ANGSTROM_COEF { 1.f, 1.f, 1.f, 1.f }
134 #ifndef CLOUD_SENSOR_ANGSTROM_OFFSET
135 #define CLOUD_SENSOR_ANGSTROM_OFFSET { 1.f, 1.f, 1.f, 1.f }
151 #ifndef CLOUD_SENSOR_BACKGROUND_NB
152 #define CLOUD_SENSOR_BACKGROUND_NB 30
210 for (
int i = 0; i < DL_PAYLOAD_COMMAND_command_length(buf); i++) {
211 res = res * 10 + DL_PAYLOAD_COMMAND_command(buf)[i];
213 float lwc = (float) res;
225 pprz_msg_send_CLOUD_SENSOR(trans,
dev, AC_ID,
234 #if CLOUD_SENSOR_REPORT_BORDER_CROSSING
236 static void border_send_shot_position(
void)
238 static int16_t border_point_nr = 0;
269 #if CLOUD_SENSOR_REPORT_BORDER_CROSSING
270 border_send_shot_position();
274 #if CLOUD_SENSOR_REPORT_BORDER_CROSSING
275 border_send_shot_position();
399 uint8_t nb = pprzlink_get_PAYLOAD_FLOAT_values_length(buf);
407 memcpy(values, pprzlink_get_DL_PAYLOAD_FLOAT_values(buf), nb*
sizeof(
float));
506 #if (defined CLOUD_SENSOR_LOG_FILE) && !(defined SITL)
534 if (DL_PAYLOAD_COMMAND_ac_id(
dl_buffer) == AC_ID) {
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
float cloud_sensor_channel_scale
void LWC_callback(uint8_t *buf)
float cloud_sensor_hysteresis
#define CLOUD_SENSOR_ANGSTROM_OFFSET
static struct MedianFilter medianFilter0
float cloud_sensor_threshold
struct Background background
structure for background parameters
static void send_data(uint32_t stamp)
static void check_border(void)
float values[CLOUD_SENSOR_NB]
preprocessed cloud sensor values
float median_filter_update(float new_sample, struct MedianFilter *filter)
Median filter function.
struct LinReg reg
linear regression parameters
uint8_t cloud_sensor_compute_background
#define CLOUD_SENSOR_CHANNEL_SCALE
#define CLOUD_SENSOR_ANGSTROM_COEF
#define CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF
void cloud_sensor_init(void)
Init function.
static void send_cloud_sensor_data(struct transport_tx *trans, struct link_device *dev)
float cloud_sensor_filtering(float new_sample, struct MedianFilter *medianFilter, struct FirstOrderLowPass *lowPassFilter)
uint8_t cloud_sensor_compute_coef
Extern variables.
#define CLOUD_SENSOR_OFFSET
float cloud_sensor_background
#define CLOUD_SENSOR_BORDER_HYSTERESIS
void cloud_sensor_callback(uint8_t *buf)
End median filter function.
#define CLOUD_SENSOR_SINGLE_CHANNEL
void cloud_sensor_update_tau(float tau)
#define CLOUD_SENSOR_BACKGROUND_NB
float mean[CLOUD_SENSOR_NB]
mean of the lists
#define CLOUD_SENSOR_BORDER_THRESHOLD
#define CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF
#define CLOUD_SENSOR_CALIB_ALPHA
static float angstrom_coef[]
float raw[CLOUD_SENSOR_RAW_MAX]
raw cloud sensor values
#define CLOUD_SENSOR_RAW_MAX
float var_lambda
variance of lambda
#define CLOUD_SENSOR_LOG_FILE
float raw[CLOUD_SENSOR_NB][CLOUD_SENSOR_BACKGROUND_NB]
lists of raw values
float lambda[CLOUD_SENSOR_NB]
list of sensor LED frequencies
static struct CloudSensor cloud_sensor
Local variables.
float coef
scalar coeff related to cloud parameter (LWC, angstrom, extinction,...)
static float angstrom_offset[]
static float lwc_from_buffer(uint8_t *buf)
float cloud_sensor_calib_beta
#define CLOUD_SENSOR_LAMBDA
float std[CLOUD_SENSOR_NB]
std of the lists
uint8_t nb_raw
number of raw data in array
static struct FirstOrderLowPass lowPassFilter0
void cloud_sensor_report(void)
Report function.
bool inside_cloud
in/out status flag
float cloud_sensor_calib_alpha
#define CLOUD_SENSOR_CALIB_BETA
Structure used to compute the background and the threshold which is a list of raw data,...
Structure used to compute the linear regression that provides the angstrom coefficient.
Get data from Cloud Sensor.
#define CLOUD_SENSOR_COEF_ANGSTROM
#define CLOUD_SENSOR_COEF_SINGLE
Common code for AP and FBW telemetry.
struct GpsState gps
global GPS state
Device independent GPS code (interface)
uint32_t tow
GPS time of week in ms.
int32_t hmsl
height above mean sea level (MSL) in mm
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
static struct LlaCoor_i * stateGetPositionLla_i(void)
Get position in LLA coordinates (int).
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
Simple first order low pass filter with bilinear transform.
static void update_first_order_low_pass_tau(struct FirstOrderLowPass *filter, float tau, float sample_time)
Update time constant (tau parameter) for first order low pass filter.
static float update_first_order_low_pass(struct FirstOrderLowPass *filter, float value)
Update first order low pass filter state with a new value.
static void init_first_order_low_pass(struct FirstOrderLowPass *filter, float tau, float sample_time, float value)
Init first order low pass filter.
First order low pass filter structure.
uint8_t dl_buffer[MSG_SIZE]
Paparazzi floating point math for geodetic calculations.
uint8_t zone
UTM zone number.
position in UTM coordinates Units: meters
float covariance_f(float *arr1, float *arr2, uint32_t n_elements)
Compute the covariance of two arrays V(X) = E[(X-E[X])(Y-E[Y])] = E[XY] - E[X]E[Y] where E[X] is the ...
float mean_f(float *array, uint32_t n_elements)
Compute the mean value of an array (float)
float variance_f(float *array, uint32_t n_elements)
Compute the variance of an array of values (float).
struct pprzlog_transport pprzlog_tp
PPRZLOG transport structure.
Initialize pprzlog transport.
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.