Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
optical_flow_landing.c File Reference

This module implements optical flow landings in which the divergence is kept constant. More...

+ Include dependency graph for optical_flow_landing.c:

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
 

Detailed Description

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.

Macro Definition Documentation

#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().

Function Documentation

float get_cov ( float *  a,
float *  b,
int  n_elements 
)

Get the covariance of two arrays.

Parameters
[out]covThe covariance
[in]*aThe first array
[in]*bThe second array
[in]nNumber 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float get_mean_array ( float *  a,
int  n_elements 
)

Get the mean value of an array.

Parameters
[out]meanThe mean value
[in]*aThe array
[in]nNumber of elements in the array

Definition at line 440 of file optical_flow_landing.c.

Referenced by get_cov().

+ Here is the caller graph for this function:

void guidance_v_module_init ( void  )

Definition at line 493 of file optical_flow_landing.c.

References vertical_ctrl_module_init().

+ Here is the call graph for this function:

void guidance_v_module_run ( bool  in_flight)

Definition at line 526 of file optical_flow_landing.c.

static void send_divergence ( struct transport_tx *  trans,
struct link_device *  dev 
)
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().

+ Here is the caller graph for this function:

static void vertical_ctrl_agl_cb ( uint8_t  sender_id,
float  distance 
)
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().

+ Here is the caller graph for this function:

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)
static

Definition at line 483 of file optical_flow_landing.c.

References divergence_vision, and vision_message_nr.

Referenced by vertical_ctrl_module_init().

+ Here is the caller graph for this function:

Variable Documentation

abi_event agl_ev
static

The altitude ABI event.

Definition at line 115 of file optical_flow_landing.c.

float divergence_vision
float divergence_vision_dt
abi_event optical_flow_ev
static

Definition at line 116 of file optical_flow_landing.c.

float previous_cov_err
float previous_err
int previous_message_nr
float pstate
float pused