|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
46 #include "generated/airframe.h"
64 #define OFL_AGL_ID ABI_BROADCAST
69 #ifndef OFL_OPTICAL_FLOW_ID
70 #define OFL_OPTICAL_FLOW_ID ABI_BROADCAST
76 #define OFL_PGAIN 0.40
80 #define OFL_IGAIN 0.01
87 #ifndef OFL_VISION_METHOD
88 #define OFL_VISION_METHOD 1
91 #ifndef OFL_CONTROL_METHOD
92 #define OFL_CONTROL_METHOD 0
95 #ifndef OFL_COV_METHOD
96 #define OFL_COV_METHOD 0
100 #ifndef OFL_COV_WINDOW_SIZE
101 #define OFL_COV_WINDOW_SIZE 30
104 #ifndef OFL_COV_LANDING_LIMIT
105 #define OFL_COV_LANDING_LIMIT 2.2
108 #ifndef OFL_COV_SETPOINT
109 #define OFL_COV_SETPOINT -0.0075
113 #define OFL_LP_CONST 0.02
116 #ifndef OFL_P_LAND_THRESHOLD
117 #define OFL_P_LAND_THRESHOLD 0.15
120 #ifndef OFL_ELC_OSCILLATE
121 #define OFL_ELC_OSCILLATE true
127 #define MINIMUM_GAIN 0.1
130 #define INCREASE_GAIN_PER_SECOND 0.02
162 pprz_msg_send_DIVERGENCE(trans,
dev, AC_ID,
301 Bound(lp_factor, 0.
f, 1.
f);
341 static const float max_div_dt = 0.20f;
396 static const float phase_0_set_point = 0.0f;
446 if (t_interval < 0) { t_interval = 0.0f; }
463 if (t_interval < 0) { t_interval = 0.0f; }
506 uint32_t thrust = 0.85 * nominal_throttle;
507 Bound(thrust, 0.6 * nominal_throttle, 0.9 *
MAX_PPRZ);
586 Bound(lp_factor, 0.
f, 1.
f);
static abi_event optical_flow_ev
void vertical_ctrl_module_init(void)
Initialize the optical flow landing module.
#define OFL_OPTICAL_FLOW_ID
uint32_t window_size
number of time steps in "window" used for getting the covariance
static void set_cov_div(int32_t thrust)
Set the covariance of the divergence and the thrust / past divergence This funciton should only be ca...
static void send_divergence(struct transport_tx *trans, struct link_device *dev)
static int32_t PID_divergence_control(float divergence_setpoint, float P, float I, float D, float dt)
Determine and set the thrust for constant divergence control.
uint32_t VISION_METHOD
whether to use vision (1) or Optitrack / sonar (0)
#define INCREASE_GAIN_PER_SECOND
#define OFL_COV_WINDOW_SIZE
float t_transition
how many seconds the drone has to be oscillating in order to transition to the hover phase with reduc...
void guidance_v_module_init(void)
static float get_sys_time_float(void)
Get the time in seconds since startup.
float divergence_vision_dt
float lp_cov_div_factor
low-pass factor for the covariance of divergence in order to trigger the second landing phase in the ...
static void update_errors(float error, float dt)
Updates the integral and differential errors for PID control and sets the previous error.
float divergence_history[OFL_COV_WINDOW_SIZE]
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Event structure to store callbacks in a linked list.
float nominal_thrust
nominal thrust around which the PID-control operates
float reduction_factor_elc
reduction factor - after oscillation, how much to reduce the gain...
void vertical_ctrl_agl_cb(uint8_t sender_id, uint32_t stamp, float distance)
Function definitions Callback function of the ground altitude.
#define OFL_ELC_OSCILLATE
float agl_lp
low-pass version of agl
uint32_t COV_METHOD
method to calculate the covariance: between thrust and div (0) or div and div past (1)
float lp_const
low-pass filter constant
float divergence_setpoint
setpoint for constant divergence approach
float pgain_adaptive
P-gain for adaptive gain control.
void vertical_ctrl_module_run(bool in_flight)
Run the optical flow landing module.
void vertical_ctrl_optical_flow_cb(uint8_t sender_id, uint32_t stamp, int32_t flow_x, int32_t flow_y, int32_t flow_der_x, int32_t flow_der_y, float quality, float size_divergence)
uint32_t CONTROL_METHOD
type of divergence control: 0 = fixed gain, 1 = adaptive gain
float divergence
Divergence estimate.
float past_divergence_history[OFL_COV_WINDOW_SIZE]
static const struct usb_device_descriptor dev
bool elc_oscillate
Whether or not to oscillate at beginning of elc to find optimum gain.
float igain
I-gain for constant divergence control.
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
float igain_adaptive
I-gain for adaptive gain control.
static abi_event agl_ev
The altitude ABI event.
float previous_err
Previous divergence tracking error.
struct OpticalFlowLanding of_landing_ctrl
float d_err
difference of error for the D-gain
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 ...
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
float thrust_history[OFL_COV_WINDOW_SIZE]
#define OFL_COV_LANDING_LIMIT
float divergence_setpoint
float guidance_v_nominal_throttle
nominal throttle for hover.
void guidance_v_module_run(bool in_flight)
This module implements optical flow landings in which the divergence is kept constant....
static uint32_t final_landing_procedure(void)
Execute a final landing procedure.
float dgain
D-gain for constant divergence control.
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
void guidance_v_module_enter(void)
Entering the module (user switched to module)
#define OFL_P_LAND_THRESHOLD
float sum_err
integration of the error for I-gain
#define OFL_VISION_METHOD
float p_land_threshold
if during the exponential landing the gain reaches this value, the final landing procedure is trigger...
float cov_set_point
for adaptive gain control, setpoint of the covariance (oscillations)
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
float cov_limit
for fixed gain control, what is the cov limit triggering the landing
uint32_t delay_steps
number of delay steps for div past
float pgain
P-gain for constant divergence control (from divergence error to thrust)
#define OFL_CONTROL_METHOD
float agl
agl = height from sonar (only used when using "fake" divergence)
float vel
vertical velocity as determined with sonar (only used when using "fake" divergence)
static void reset_all_vars(void)
Reset all variables:
#define DefaultPeriodic
Set default periodic telemetry.
float dgain_adaptive
D-gain for adaptive gain control.