Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
This module implements optical flow landings in which the divergence is kept constant. More...
#include "firmwares/rotorcraft/autopilot.h"
#include "subsystems/navigation/common_flight_plan.h"
#include "subsystems/datalink/telemetry.h"
#include <time.h>
#include "modules/ctrl/optical_flow_landing.h"
#include "generated/airframe.h"
#include "paparazzi.h"
#include "subsystems/abi.h"
#include "firmwares/rotorcraft/stabilization.h"
Go to the source code of this file.
Macros | |
#define | MINIMUM_GAIN 0.1 |
#define | OPTICAL_FLOW_LANDING_AGL_ID ABI_BROADCAST |
#define | OPTICAL_FLOW_LANDING_OPTICAL_FLOW_ID ABI_BROADCAST |
#define | OPTICAL_FLOW_LANDING_PGAIN 1.0 |
#define | OPTICAL_FLOW_LANDING_IGAIN 0.0 |
#define | OPTICAL_FLOW_LANDING_DGAIN 0.0 |
#define | OPTICAL_FLOW_LANDING_VISION_METHOD 1 |
#define | OPTICAL_FLOW_LANDING_CONTROL_METHOD 0 |
#define | OPTICAL_FLOW_LANDING_COV_METHOD 0 |
Functions | |
static void | send_divergence (struct transport_tx *trans, struct link_device *dev) |
static void | vertical_ctrl_agl_cb (uint8_t sender_id, float distance) |
Callback function of the ground altitude. More... | |
static void | vertical_ctrl_optical_flow_cb (uint8_t sender_id, uint32_t stamp, int16_t flow_x, int16_t flow_y, int16_t flow_der_x, int16_t flow_der_y, uint8_t quality, float size_divergence, float dist) |
void | vertical_ctrl_module_init (void) |
Initialize the optical flow landing module. More... | |
void | vertical_ctrl_module_run (bool in_flight) |
Run the optical flow landing module. More... | |
void | reset_all_vars () |
Reset all variables: More... | |
float | get_mean_array (float *a, int n_elements) |
Get the mean value of an array. More... | |
float | get_cov (float *a, float *b, int n_elements) |
Get the covariance of two arrays. More... | |
void | guidance_v_module_init (void) |
void | guidance_v_module_enter (void) |
Entering the module (user switched to module) More... | |
void | guidance_v_module_run (bool in_flight) |
Variables | |
float | divergence |
float | divergence_vision |
float | divergence_vision_dt |
float | normalized_thrust |
float | cov_div |
float | pstate |
float | pused |
float | dt |
int | vision_message_nr |
int | previous_message_nr |
int | landing |
float | previous_err |
float | previous_cov_err |
long | previous_time |
static abi_event | agl_ev |
The altitude ABI event. More... | |
static abi_event | optical_flow_ev |
struct OpticalFlowLanding | of_landing_ctrl |
This module implements optical flow landings in which the divergence is kept constant.
When using a fixed gain for control, the covariance between thrust and divergence is tracked, so that the drone knows when it has arrived close to the landing surface. Then, a final landing procedure is triggered. It can also be set to adaptive gain control, where the goal is to continuously gauge the distance to the landing surface. In this mode, the drone will oscillate all the way down to the surface.
de Croon, G.C.H.E. (2016). Monocular distance estimation with optical flow maneuvers and efference copies: a stability-based strategy. Bioinspiration & biomimetics, 11(1), 016004. http://iopscience.iop.org/article/10.1088/1748-3190/11/1/016004
Definition in file optical_flow_landing.c.
#define MINIMUM_GAIN 0.1 |
Definition at line 53 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_run().
#define OPTICAL_FLOW_LANDING_AGL_ID ABI_BROADCAST |
Definition at line 80 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_CONTROL_METHOD 0 |
Definition at line 108 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_COV_METHOD 0 |
Definition at line 112 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_DGAIN 0.0 |
Definition at line 100 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_IGAIN 0.0 |
Definition at line 96 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_OPTICAL_FLOW_ID ABI_BROADCAST |
Definition at line 86 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_PGAIN 1.0 |
Definition at line 92 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
#define OPTICAL_FLOW_LANDING_VISION_METHOD 1 |
Definition at line 104 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init().
float get_cov | ( | float * | a, |
float * | b, | ||
int | n_elements | ||
) |
Get the covariance of two arrays.
[out] | cov | The covariance |
[in] | *a | The first array |
[in] | *b | The second array |
[in] | n | Number of elements in the arrays |
Definition at line 459 of file optical_flow_landing.c.
References get_mean_array().
Referenced by vertical_ctrl_module_run().
float get_mean_array | ( | float * | a, |
int | n_elements | ||
) |
Get the mean value of an array.
[out] | mean | The mean value |
[in] | *a | The array |
[in] | n | Number of elements in the array |
Definition at line 440 of file optical_flow_landing.c.
Referenced by get_cov().
void guidance_v_module_enter | ( | void | ) |
Entering the module (user switched to module)
Definition at line 501 of file optical_flow_landing.c.
References OpticalFlowLanding::agl_lp, cov_div, OpticalFlowLanding::cov_set_point, COV_WINDOW_SIZE, divergence, divergence_history, OpticalFlowLanding::divergence_setpoint, dt, ind_hist, landing, normalized_thrust, of_landing_ctrl, previous_cov_err, previous_err, previous_message_nr, previous_time, OpticalFlowLanding::sum_err, thrust_history, and vision_message_nr.
void guidance_v_module_init | ( | void | ) |
Definition at line 493 of file optical_flow_landing.c.
References vertical_ctrl_module_init().
void guidance_v_module_run | ( | bool | in_flight | ) |
Definition at line 526 of file optical_flow_landing.c.
void reset_all_vars | ( | void | ) |
Reset all variables:
Definition at line 194 of file optical_flow_landing.c.
References OpticalFlowLanding::agl_lp, cov_div, OpticalFlowLanding::cov_set_point, COV_WINDOW_SIZE, divergence, divergence_history, OpticalFlowLanding::divergence_setpoint, dt, ind_hist, landing, normalized_thrust, of_landing_ctrl, previous_cov_err, previous_err, previous_message_nr, previous_time, stabilization_cmd, OpticalFlowLanding::sum_err, thrust_history, and vision_message_nr.
Referenced by vertical_ctrl_module_run().
|
static |
Definition at line 65 of file optical_flow_landing.c.
References OpticalFlowLanding::agl, cov_div, divergence, divergence_vision_dt, normalized_thrust, of_landing_ctrl, pstate, and pused.
Referenced by vertical_ctrl_module_init().
|
static |
Callback function of the ground altitude.
Definition at line 479 of file optical_flow_landing.c.
References OpticalFlowLanding::agl, and of_landing_ctrl.
Referenced by vertical_ctrl_module_init().
void vertical_ctrl_module_init | ( | void | ) |
Initialize the optical flow landing module.
Definition at line 131 of file optical_flow_landing.c.
References OpticalFlowLanding::agl, OpticalFlowLanding::agl_lp, OpticalFlowLanding::CONTROL_METHOD, cov_div, OpticalFlowLanding::cov_limit, OpticalFlowLanding::COV_METHOD, OpticalFlowLanding::cov_set_point, COV_WINDOW_SIZE, DefaultPeriodic, OpticalFlowLanding::delay_steps, OpticalFlowLanding::dgain, OpticalFlowLanding::dgain_adaptive, divergence, divergence_history, OpticalFlowLanding::divergence_setpoint, divergence_vision, divergence_vision_dt, dt, OpticalFlowLanding::igain, OpticalFlowLanding::igain_adaptive, ind_hist, landing, OpticalFlowLanding::lp_factor, OpticalFlowLanding::nominal_thrust, normalized_thrust, of_landing_ctrl, OPTICAL_FLOW_LANDING_AGL_ID, OPTICAL_FLOW_LANDING_CONTROL_METHOD, OPTICAL_FLOW_LANDING_COV_METHOD, OPTICAL_FLOW_LANDING_DGAIN, OPTICAL_FLOW_LANDING_IGAIN, OPTICAL_FLOW_LANDING_OPTICAL_FLOW_ID, OPTICAL_FLOW_LANDING_PGAIN, OPTICAL_FLOW_LANDING_VISION_METHOD, OpticalFlowLanding::pgain, OpticalFlowLanding::pgain_adaptive, previous_cov_err, previous_err, previous_message_nr, previous_time, pstate, pused, register_periodic_telemetry(), send_divergence(), OpticalFlowLanding::sum_err, thrust_history, OpticalFlowLanding::vel, vertical_ctrl_agl_cb(), vertical_ctrl_optical_flow_cb(), vision_message_nr, and OpticalFlowLanding::VISION_METHOD.
Referenced by guidance_v_module_init().
void vertical_ctrl_module_run | ( | bool | in_flight | ) |
Run the optical flow landing module.
Definition at line 224 of file optical_flow_landing.c.
References OpticalFlowLanding::agl, OpticalFlowLanding::agl_lp, LlaCoor_i::alt, OpticalFlowLanding::CONTROL_METHOD, cov_div, OpticalFlowLanding::cov_limit, OpticalFlowLanding::COV_METHOD, OpticalFlowLanding::cov_set_point, COV_WINDOW_SIZE, OpticalFlowLanding::delay_steps, divergence, divergence_history, OpticalFlowLanding::divergence_setpoint, divergence_vision, divergence_vision_dt, dt, E, get_cov(), gps, if(), OpticalFlowLanding::igain, OpticalFlowLanding::igain_adaptive, ind_hist, landing, GpsState::lla_pos, OpticalFlowLanding::lp_factor, MAX_PPRZ, MINIMUM_GAIN, OpticalFlowLanding::nominal_thrust, normalized_thrust, of_landing_ctrl, past_divergence_history, OpticalFlowLanding::pgain, OpticalFlowLanding::pgain_adaptive, previous_message_nr, previous_time, pstate, pused, reset_all_vars(), stabilization_cmd, OpticalFlowLanding::sum_err, thrust_history, OpticalFlowLanding::vel, vision_message_nr, and OpticalFlowLanding::VISION_METHOD.
Referenced by guidance_v_module_run().
|
static |
Definition at line 483 of file optical_flow_landing.c.
References divergence_vision, and vision_message_nr.
Referenced by vertical_ctrl_module_init().
|
static |
The altitude ABI event.
Definition at line 115 of file optical_flow_landing.c.
float cov_div |
Definition at line 41 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float divergence |
Definition at line 37 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float divergence_vision |
Definition at line 38 of file optical_flow_landing.c.
Referenced by vertical_ctrl_module_init(), vertical_ctrl_module_run(), and vertical_ctrl_optical_flow_cb().
float divergence_vision_dt |
Definition at line 39 of file optical_flow_landing.c.
Referenced by send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float dt |
Definition at line 44 of file optical_flow_landing.c.
Referenced by accel_cb(), ahrs_icq_update_mag(), alt_kalman(), float_quat_integrate(), float_rates_integrate_fi(), float_vect3_integrate_fi(), gps_cb(), guidance_v_module_enter(), gyro_cb(), ins_alt_float_update_baro(), ins_alt_float_update_gps(), mag_cb(), ms2100_reset_cb(), ms5607_calc(), ms5611_calc(), nps_atmosphere_update(), nps_fdm_init(), propagate_state(), reset_all_vars(), stabilization_attitude_read_rc_setpoint_eulers(), stabilization_attitude_read_rc_setpoint_eulers_f(), stabilization_attitude_run(), tcas_periodic_task_1Hz(), vel_est_cb(), vertical_ctrl_module_init(), vertical_ctrl_module_run(), and vff_propagate().
int landing |
Definition at line 47 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float normalized_thrust |
Definition at line 40 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
struct OpticalFlowLanding of_landing_ctrl |
Definition at line 123 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), send_divergence(), vertical_ctrl_agl_cb(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
|
static |
Definition at line 116 of file optical_flow_landing.c.
float previous_cov_err |
Definition at line 49 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), and vertical_ctrl_module_init().
float previous_err |
Definition at line 48 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), and vertical_ctrl_module_init().
int previous_message_nr |
Definition at line 46 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
long previous_time |
Definition at line 62 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float pstate |
Definition at line 42 of file optical_flow_landing.c.
Referenced by send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
float pused |
Definition at line 43 of file optical_flow_landing.c.
Referenced by send_divergence(), vertical_ctrl_module_init(), and vertical_ctrl_module_run().
int vision_message_nr |
Definition at line 45 of file optical_flow_landing.c.
Referenced by guidance_v_module_enter(), reset_all_vars(), vertical_ctrl_module_init(), vertical_ctrl_module_run(), and vertical_ctrl_optical_flow_cb().