Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
optical-flow based hovering for Parrot AR.Drone 2.0 More...
#include "opticflow_module.h"
#include <stdio.h>
#include <pthread.h>
#include "state.h"
#include "subsystems/abi.h"
#include "lib/v4l/v4l2.h"
#include "lib/encoding/jpeg.h"
#include "lib/encoding/rtp.h"
#include "errno.h"
#include "cv.h"
#include "subsystems/datalink/telemetry.h"
Go to the source code of this file.
Macros | |
#define | OPTICFLOW_AGL_ID ABI_BROADCAST |
Default sonar/agl to use in opticflow visual_estimator. More... | |
#define | OPTICFLOW_SENDER_ID 1 |
Functions | |
struct image_t * | opticflow_module_calc (struct image_t *img) |
The main optical flow calculation thread. More... | |
static void | opticflow_agl_cb (uint8_t sender_id, float distance) |
Callback function of the ground altitude. More... | |
static void | opticflow_telem_send (struct transport_tx *trans, struct link_device *dev) |
Send optical flow telemetry information. More... | |
void | opticflow_module_init (void) |
Initialize the optical flow module for the bottom camera. More... | |
void | opticflow_module_run (void) |
Update the optical flow state for the calculation thread and update the stabilization loops with the newest result. More... | |
Variables | |
struct opticflow_t | opticflow |
Opticflow calculations. More... | |
static struct opticflow_result_t | opticflow_result |
The opticflow result. More... | |
static struct opticflow_state_t | opticflow_state |
State of the drone to communicate with the opticflow. More... | |
static abi_event | opticflow_agl_ev |
The altitude ABI event. More... | |
static bool | opticflow_got_result |
When we have an optical flow calculation. More... | |
static pthread_mutex_t | opticflow_mutex |
Mutex lock fo thread safety. More... | |
optical-flow based hovering for Parrot AR.Drone 2.0
Sensors from vertical camera and IMU of Parrot AR.Drone 2.0
Definition in file opticflow_module.c.
#define OPTICFLOW_AGL_ID ABI_BROADCAST |
Default sonar/agl to use in opticflow visual_estimator.
Definition at line 45 of file opticflow_module.c.
Referenced by opticflow_module_init().
#define OPTICFLOW_SENDER_ID 1 |
Definition at line 50 of file opticflow_module.c.
Referenced by opticflow_module_run().
|
static |
Callback function of the ground altitude.
Get the altitude above ground of the drone.
[in] | sender_id | The id that send the ABI message (unused) |
[in] | distance | The distance above ground level in meters |
Definition at line 185 of file opticflow_module.c.
References opticflow_state_t::agl, and opticflow_state.
Referenced by opticflow_module_init().
The main optical flow calculation thread.
The main optical flow calculation thread This thread passes the images trough the optical flow calculator.
[in] | *img | The image_t structure of the captured image |
Definition at line 150 of file opticflow_module.c.
References opticflow_state_t::agl, get_rotation_at_timestamp(), opticflow, opticflow_calc_frame(), opticflow_result, opticflow_state, image_t::pprz_ts, pose_t::rates, opticflow_state_t::rates, opticflow_result_t::vel_body_x, opticflow_result_t::vel_body_y, opticflow_result_t::vel_x, and opticflow_result_t::vel_y.
Referenced by opticflow_module_init().
void opticflow_module_init | ( | void | ) |
Initialize the optical flow module for the bottom camera.
Definition at line 91 of file opticflow_module.c.
References opticflow_state_t::agl, cv_add_to_device(), DefaultPeriodic, FLOAT_RATES_ZERO, opticflow_agl_cb(), OPTICFLOW_AGL_ID, opticflow_module_calc(), opticflow_state, opticflow_telem_send(), opticflow_state_t::rates, and register_periodic_telemetry().
void opticflow_module_run | ( | void | ) |
Update the optical flow state for the calculation thread and update the stabilization loops with the newest result.
Definition at line 115 of file opticflow_module.c.
References opticflow_state_t::agl, opticflow_result_t::div_size, opticflow_result_t::flow_der_x, opticflow_result_t::flow_der_y, opticflow_result_t::flow_x, opticflow_result_t::flow_y, get_sys_time_usec(), opticflow_result_t::noise_measurement, opticflow_result, OPTICFLOW_SENDER_ID, opticflow_state, opticflow_result_t::vel_body_x, and opticflow_result_t::vel_body_y.
|
static |
Send optical flow telemetry information.
[in] | *trans | The transport structure to send the information over |
[in] | *dev | The link to send the data over |
Definition at line 72 of file opticflow_module.c.
References opticflow_result_t::corner_cnt, opticflow_result_t::div_size, opticflow_result_t::divergence, opticflow_result_t::flow_der_x, opticflow_result_t::flow_der_y, opticflow_result_t::flow_x, opticflow_result_t::flow_y, opticflow_result_t::fps, opticflow_result_t::noise_measurement, opticflow_result, opticflow_result_t::surface_roughness, opticflow_result_t::tracked_cnt, opticflow_result_t::vel_x, and opticflow_result_t::vel_y.
Referenced by opticflow_module_init().
struct opticflow_t opticflow |
Opticflow calculations.
Definition at line 54 of file opticflow_module.c.
Referenced by opticflow_module_calc().
|
static |
The altitude ABI event.
Definition at line 57 of file opticflow_module.c.
|
static |
When we have an optical flow calculation.
Definition at line 58 of file opticflow_module.c.
|
static |
Mutex lock fo thread safety.
Definition at line 59 of file opticflow_module.c.
|
static |
The opticflow result.
Definition at line 55 of file opticflow_module.c.
Referenced by opticflow_module_calc(), opticflow_module_run(), and opticflow_telem_send().
|
static |
State of the drone to communicate with the opticflow.
Definition at line 56 of file opticflow_module.c.
Referenced by opticflow_agl_cb(), opticflow_module_calc(), opticflow_module_init(), and opticflow_module_run().