Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Get data from Cloud Sensor. More...
#include "modules/meteo/cloud_sensor.h"
#include "generated/airframe.h"
#include "state.h"
#include "modules/core/abi.h"
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "math/pprz_geodetic_float.h"
#include "math/pprz_stat.h"
#include "modules/gps/gps.h"
#include "filters/low_pass_filter.h"
#include "modules/loggers/sdlog_chibios.h"
#include "modules/loggers/pprzlog_tp.h"
Go to the source code of this file.
Data Structures | |
struct | LinReg |
Structure used to compute the linear regression that provides the angstrom coefficient. More... | |
struct | Background |
Structure used to compute the background and the threshold which is a list of raw data, the mean and the standard deviation. More... | |
struct | CloudSensor |
Cloud sensor structure. More... | |
struct | MedianFilter |
Median Filter structure. More... | |
Macros | |
#define | CLOUD_SENSOR_LOG_FILE flightrecorder_sdlog |
#define | CLOUD_SENSOR_RAW_MAX 16 |
#define | CLOUD_SENSOR_NB 4 |
#define | CLOUD_SENSOR_OFFSET 4 |
#define | CLOUD_SENSOR_BORDER_THRESHOLD 0.05 |
#define | CLOUD_SENSOR_BORDER_HYSTERESIS 0.01 |
#define | CLOUD_SENSOR_SINGLE_CHANNEL 1 |
#define | CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF 2.f |
#define | CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF 0.5f |
#define | CLOUD_SENSOR_CALIB_ALPHA 1.f |
#define | CLOUD_SENSOR_CALIB_BETA 1.f |
#define | CLOUD_SENSOR_CHANNEL_SCALE 1.f |
#define | CLOUD_SENSOR_TAU 0.f |
#define | CLOUD_RAW 0 |
#define | CLOUD_BORDER 1 |
#define | CLOUD_SENSOR_REPORT_BORDER_CROSSING FALSE |
#define | CLOUD_SENSOR_LAMBDA { 505.f, 590.f, 840.f, 840.f } |
#define | CLOUD_SENSOR_ANGSTROM_COEF { 1.f, 1.f, 1.f, 1.f } |
#define | CLOUD_SENSOR_ANGSTROM_OFFSET { 1.f, 1.f, 1.f, 1.f } |
#define | CLOUD_SENSOR_BACKGROUND_NB 30 |
Functions | |
static float | lwc_from_buffer (uint8_t *buf) |
static void | send_cloud_sensor_data (struct transport_tx *trans, struct link_device *dev) |
static void | check_border (void) |
static void | send_data (uint32_t stamp) |
void | cloud_sensor_init (void) |
Init function. More... | |
void | cloud_sensor_update_tau (float tau) |
float | median_filter_update (float new_sample, struct MedianFilter *filter) |
Median filter function. More... | |
float | cloud_sensor_filtering (float new_sample, struct MedianFilter *medianFilter, struct FirstOrderLowPass *lowPassFilter) |
void | cloud_sensor_callback (uint8_t *buf) |
End median filter function. More... | |
void | LWC_callback (uint8_t *buf) |
void | cloud_sensor_report (void) |
Report function. More... | |
Variables | |
static float | lambdas [] = CLOUD_SENSOR_LAMBDA |
static float | angstrom_coef [] = CLOUD_SENSOR_ANGSTROM_COEF |
static float | angstrom_offset [] = CLOUD_SENSOR_ANGSTROM_OFFSET |
static struct CloudSensor | cloud_sensor |
Local variables. More... | |
static bool | log_tagged |
static struct MedianFilter | medianFilter0 |
static struct FirstOrderLowPass | lowPassFilter0 |
uint8_t | cloud_sensor_compute_coef |
Extern variables. More... | |
uint8_t | cloud_sensor_compute_background |
float | cloud_sensor_threshold |
float | cloud_sensor_hysteresis |
float | cloud_sensor_background |
float | cloud_sensor_calib_alpha |
float | cloud_sensor_calib_beta |
float | cloud_sensor_channel_scale |
float | cloud_sensor_tau |
Get data from Cloud Sensor.
Definition in file cloud_sensor.c.
struct LinReg |
Structure used to compute the linear regression that provides the angstrom coefficient.
The slope of the linear regression is computed as cov(X,Y)/var(X). var(X) can be precomputed as LED frequencies are not changing.
Definition at line 145 of file cloud_sensor.c.
Data Fields | ||
---|---|---|
float | lambda[CLOUD_SENSOR_NB] | list of sensor LED frequencies |
float | var_lambda | variance of lambda |
struct Background |
Structure used to compute the background and the threshold which is a list of raw data, the mean and the standard deviation.
Definition at line 159 of file cloud_sensor.c.
Data Fields | ||
---|---|---|
uint8_t | idx | current index |
float | mean[CLOUD_SENSOR_NB] | mean of the lists |
float | raw[CLOUD_SENSOR_NB][CLOUD_SENSOR_BACKGROUND_NB] | lists of raw values |
float | std[CLOUD_SENSOR_NB] | std of the lists |
struct CloudSensor |
Cloud sensor structure.
Definition at line 168 of file cloud_sensor.c.
Data Fields | ||
---|---|---|
struct Background | background | structure for background parameters |
float | coef | scalar coeff related to cloud parameter (LWC, angstrom, extinction,...) |
bool | inside_cloud | in/out status flag |
uint8_t | nb_raw | number of raw data in array |
float | raw[CLOUD_SENSOR_RAW_MAX] | raw cloud sensor values |
struct LinReg | reg | linear regression parameters |
float | values[CLOUD_SENSOR_NB] | preprocessed cloud sensor values |
struct MedianFilter |
Median Filter structure.
Definition at line 181 of file cloud_sensor.c.
Data Fields | ||
---|---|---|
int | current | |
int | length | |
float | values[3] |
#define CLOUD_BORDER 1 |
Definition at line 113 of file cloud_sensor.c.
#define CLOUD_RAW 0 |
Definition at line 112 of file cloud_sensor.c.
Definition at line 129 of file cloud_sensor.c.
Definition at line 135 of file cloud_sensor.c.
#define CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF 0.5f |
Definition at line 92 of file cloud_sensor.c.
#define CLOUD_SENSOR_BACKGROUND_NB 30 |
Definition at line 152 of file cloud_sensor.c.
#define CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF 2.f |
Definition at line 87 of file cloud_sensor.c.
#define CLOUD_SENSOR_BORDER_HYSTERESIS 0.01 |
Definition at line 77 of file cloud_sensor.c.
#define CLOUD_SENSOR_BORDER_THRESHOLD 0.05 |
Definition at line 72 of file cloud_sensor.c.
#define CLOUD_SENSOR_CALIB_ALPHA 1.f |
Definition at line 96 of file cloud_sensor.c.
#define CLOUD_SENSOR_CALIB_BETA 1.f |
Definition at line 100 of file cloud_sensor.c.
#define CLOUD_SENSOR_CHANNEL_SCALE 1.f |
Definition at line 104 of file cloud_sensor.c.
Definition at line 123 of file cloud_sensor.c.
#define CLOUD_SENSOR_LOG_FILE flightrecorder_sdlog |
Definition at line 52 of file cloud_sensor.c.
#define CLOUD_SENSOR_NB 4 |
Definition at line 62 of file cloud_sensor.c.
#define CLOUD_SENSOR_OFFSET 4 |
Definition at line 67 of file cloud_sensor.c.
#define CLOUD_SENSOR_RAW_MAX 16 |
Definition at line 57 of file cloud_sensor.c.
#define CLOUD_SENSOR_REPORT_BORDER_CROSSING FALSE |
Definition at line 117 of file cloud_sensor.c.
#define CLOUD_SENSOR_SINGLE_CHANNEL 1 |
Definition at line 82 of file cloud_sensor.c.
#define CLOUD_SENSOR_TAU 0.f |
Definition at line 108 of file cloud_sensor.c.
|
static |
Definition at line 266 of file cloud_sensor.c.
References cloud_sensor, cloud_sensor_hysteresis, cloud_sensor_threshold, CloudSensor::coef, and CloudSensor::inside_cloud.
Referenced by cloud_sensor_callback(), and LWC_callback().
void cloud_sensor_callback | ( | uint8_t * | buf | ) |
End median filter function.
New message/data callback.
Definition at line 397 of file cloud_sensor.c.
References angstrom_coef, angstrom_offset, CloudSensor::background, check_border(), cloud_sensor, cloud_sensor_background, CLOUD_SENSOR_BACKGROUND_HYSTERESIS_COEF, CLOUD_SENSOR_BACKGROUND_NB, CLOUD_SENSOR_BACKGROUND_THRESHOLD_COEF, CLOUD_SENSOR_COEF_ANGSTROM, CLOUD_SENSOR_COEF_SINGLE, cloud_sensor_compute_background, cloud_sensor_compute_coef, cloud_sensor_filtering(), cloud_sensor_hysteresis, CLOUD_SENSOR_LOG_FILE, CLOUD_SENSOR_NB, CLOUD_SENSOR_OFFSET, CLOUD_SENSOR_RAW_MAX, CLOUD_SENSOR_SINGLE_CHANNEL, cloud_sensor_threshold, CloudSensor::coef, covariance_f(), UtmCoor_f::east, GpsState::fix, get_sys_time_usec(), gps, GpsFixValid, GpsState::hmsl, Background::idx, idx, LinReg::lambda, log_tagged, lowPassFilter0, Background::mean, mean_f(), medianFilter0, Min, CloudSensor::nb_raw, UtmCoor_f::north, pprzlog_tp, Background::raw, CloudSensor::raw, CloudSensor::reg, send_cloud_sensor_data(), send_data(), stateGetPositionUtm_f(), Background::std, GpsState::tow, CloudSensor::values, LinReg::var_lambda, variance_f(), GpsState::week, and UtmCoor_f::zone.
float cloud_sensor_filtering | ( | float | new_sample, |
struct MedianFilter * | medianFilter, | ||
struct FirstOrderLowPass * | lowPassFilter | ||
) |
Definition at line 382 of file cloud_sensor.c.
References cloud_sensor_calib_alpha, cloud_sensor_calib_beta, cloud_sensor_channel_scale, median_filter_update(), PowerVoltage, and update_first_order_low_pass().
Referenced by cloud_sensor_callback().
void cloud_sensor_init | ( | void | ) |
Init function.
Definition at line 290 of file cloud_sensor.c.
References CloudSensor::background, cloud_sensor, cloud_sensor_background, CLOUD_SENSOR_BORDER_HYSTERESIS, CLOUD_SENSOR_BORDER_THRESHOLD, CLOUD_SENSOR_CALIB_ALPHA, cloud_sensor_calib_alpha, CLOUD_SENSOR_CALIB_BETA, cloud_sensor_calib_beta, CLOUD_SENSOR_CHANNEL_SCALE, cloud_sensor_channel_scale, CLOUD_SENSOR_COEF_SINGLE, cloud_sensor_compute_coef, cloud_sensor_hysteresis, CLOUD_SENSOR_NB, CLOUD_SENSOR_TAU, cloud_sensor_tau, cloud_sensor_threshold, CloudSensor::coef, MedianFilter::current, Background::idx, init_first_order_low_pass(), CloudSensor::inside_cloud, LinReg::lambda, lambdas, MedianFilter::length, log_tagged, lowPassFilter0, Background::mean, medianFilter0, CloudSensor::nb_raw, CloudSensor::reg, Background::std, CloudSensor::values, LinReg::var_lambda, and variance_f().
void cloud_sensor_report | ( | void | ) |
Report function.
Definition at line 547 of file cloud_sensor.c.
References DefaultChannel, DefaultDevice, and send_cloud_sensor_data().
void cloud_sensor_update_tau | ( | float | tau | ) |
Definition at line 324 of file cloud_sensor.c.
References cloud_sensor_tau, lowPassFilter0, and update_first_order_low_pass_tau().
void LWC_callback | ( | uint8_t * | buf | ) |
Definition at line 532 of file cloud_sensor.c.
References check_border(), cloud_sensor, CloudSensor::coef, dl_buffer, get_sys_time_usec(), lwc_from_buffer(), and send_data().
|
static |
Definition at line 207 of file cloud_sensor.c.
Referenced by LWC_callback().
float median_filter_update | ( | float | new_sample, |
struct MedianFilter * | filter | ||
) |
Median filter function.
Definition at line 332 of file cloud_sensor.c.
References MedianFilter::current, MedianFilter::length, and MedianFilter::values.
Referenced by cloud_sensor_filtering().
|
static |
Definition at line 218 of file cloud_sensor.c.
References cloud_sensor, CloudSensor::coef, dev, gps, GpsState::hmsl, CloudSensor::nb_raw, CloudSensor::raw, stateGetPositionLla_i(), GpsState::tow, and val.
Referenced by cloud_sensor_callback(), and cloud_sensor_report().
|
static |
Definition at line 282 of file cloud_sensor.c.
References CLOUD_BORDER, CLOUD_RAW, cloud_sensor, CLOUD_SENSOR_ID, CloudSensor::coef, and CloudSensor::inside_cloud.
Referenced by cloud_sensor_callback(), encodeHighBytes(), and LWC_callback().
|
static |
Definition at line 131 of file cloud_sensor.c.
Referenced by cloud_sensor_callback().
|
static |
Definition at line 137 of file cloud_sensor.c.
Referenced by cloud_sensor_callback().
|
static |
Local variables.
Definition at line 137 of file cloud_sensor.c.
Referenced by check_border(), cloud_sensor_callback(), cloud_sensor_init(), LWC_callback(), send_cloud_sensor_data(), and send_data().
float cloud_sensor_background |
Definition at line 200 of file cloud_sensor.c.
Referenced by cloud_sensor_callback(), and cloud_sensor_init().
float cloud_sensor_calib_alpha |
Definition at line 201 of file cloud_sensor.c.
Referenced by cloud_sensor_filtering(), and cloud_sensor_init().
float cloud_sensor_calib_beta |
Definition at line 202 of file cloud_sensor.c.
Referenced by cloud_sensor_filtering(), and cloud_sensor_init().
float cloud_sensor_channel_scale |
Definition at line 203 of file cloud_sensor.c.
Referenced by cloud_sensor_filtering(), and cloud_sensor_init().
uint8_t cloud_sensor_compute_background |
Definition at line 197 of file cloud_sensor.c.
Referenced by cloud_sensor_callback().
uint8_t cloud_sensor_compute_coef |
Extern variables.
variables for settings
Definition at line 196 of file cloud_sensor.c.
Referenced by cloud_sensor_callback(), and cloud_sensor_init().
float cloud_sensor_hysteresis |
Definition at line 199 of file cloud_sensor.c.
Referenced by check_border(), cloud_sensor_callback(), and cloud_sensor_init().
float cloud_sensor_tau |
Definition at line 204 of file cloud_sensor.c.
Referenced by cloud_sensor_init(), and cloud_sensor_update_tau().
float cloud_sensor_threshold |
Definition at line 198 of file cloud_sensor.c.
Referenced by check_border(), cloud_sensor_callback(), and cloud_sensor_init().
|
static |
Definition at line 125 of file cloud_sensor.c.
Referenced by cloud_sensor_init().
|
static |
Definition at line 190 of file cloud_sensor.c.
Referenced by cloud_sensor_callback(), cloud_sensor_init(), and meteo_stick_init().
|
static |
Definition at line 190 of file cloud_sensor.c.
Referenced by cloud_sensor_callback(), cloud_sensor_init(), and cloud_sensor_update_tau().
|
static |
Definition at line 190 of file cloud_sensor.c.
Referenced by cloud_sensor_callback(), and cloud_sensor_init().