Paparazzi UAS
v5.8.2_stable-0-g6260b7c
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"
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 |
#define | OPTICFLOW_DEVICE /dev/video2 |
The video device. More... | |
#define | OPTICFLOW_DEVICE_SIZE 320,240 |
The video device size (width, height) More... | |
#define | __SIZE_HELPER(x, y) #x", "#y |
#define | _SIZE_HELPER(x) __SIZE_HELPER(x) |
#define | OPTICFLOW_DEVICE_BUFFERS 15 |
The video device buffers (the amount of V4L2 buffers) More... | |
Functions | |
static void * | opticflow_module_calc (void *data) |
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... | |
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... | |
void | opticflow_module_start (void) |
Start the optical flow calculation. More... | |
void | opticflow_module_stop (void) |
Stop the optical flow calculation. 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 struct v4l2_device * | opticflow_dev |
The opticflow camera V4L2 device. More... | |
static abi_event | opticflow_agl_ev |
The altitude ABI event. More... | |
static pthread_t | opticflow_calc_thread |
The optical flow calculation thread. More... | |
static bool_t | 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 __SIZE_HELPER | ( | x, | |
y | |||
) | #x", "#y |
Definition at line 60 of file opticflow_module.c.
#define _SIZE_HELPER | ( | x | ) | __SIZE_HELPER(x) |
Definition at line 61 of file opticflow_module.c.
#define OPTICFLOW_AGL_ID ABI_BROADCAST |
Default sonar/agl to use in opticflow visual_estimator.
Definition at line 42 of file opticflow_module.c.
Referenced by opticflow_module_init().
#define OPTICFLOW_DEVICE /dev/video2 |
The video device.
Definition at line 52 of file opticflow_module.c.
Referenced by opticflow_module_init().
#define OPTICFLOW_DEVICE_BUFFERS 15 |
The video device buffers (the amount of V4L2 buffers)
Definition at line 66 of file opticflow_module.c.
Referenced by opticflow_module_init().
#define OPTICFLOW_DEVICE_SIZE 320,240 |
The video device size (width, height)
Definition at line 58 of file opticflow_module.c.
Referenced by opticflow_module_init().
#define OPTICFLOW_SENDER_ID 1 |
Definition at line 47 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 278 of file opticflow_module.c.
Referenced by opticflow_module_init().
|
static |
The main optical flow calculation thread.
The main optical flow calculation thread This thread passes the images trough the optical flow calculator based on Lucas Kanade.
Definition at line 216 of file opticflow_module.c.
References FALSE, image_create(), image_free(), IMAGE_JPEG, jpeg_encode_image(), opticflow_calc_frame(), rtp_frame_send(), TRUE, v4l2_image_free(), v4l2_image_get(), v4l2_start_capture(), and image_t::w.
Referenced by opticflow_module_start().
void opticflow_module_init | ( | void | ) |
Initialize the optical flow module for the bottom camera.
Definition at line 108 of file opticflow_module.c.
References DefaultPeriodic, FALSE, opticflow_agl_cb(), OPTICFLOW_AGL_ID, opticflow_calc_init(), OPTICFLOW_DEVICE, OPTICFLOW_DEVICE_BUFFERS, OPTICFLOW_DEVICE_SIZE, PRINT_CONFIG_MSG(), register_periodic_telemetry(), v4l2_init(), and v4l2_init_subdev().
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 149 of file opticflow_module.c.
References FALSE, get_sys_time_usec(), OPTICFLOW_SENDER_ID, FloatEulers::phi, stateGetNedToBodyEulers_f(), and FloatEulers::theta.
void opticflow_module_start | ( | void | ) |
Start the optical flow calculation.
Definition at line 184 of file opticflow_module.c.
References opticflow_module_calc().
void opticflow_module_stop | ( | void | ) |
Stop the optical flow calculation.
Definition at line 202 of file opticflow_module.c.
References v4l2_stop_capture().
struct opticflow_t opticflow |
Opticflow calculations.
Definition at line 71 of file opticflow_module.c.
|
static |
The altitude ABI event.
Definition at line 75 of file opticflow_module.c.
|
static |
The optical flow calculation thread.
Definition at line 76 of file opticflow_module.c.
|
static |
The opticflow camera V4L2 device.
Definition at line 74 of file opticflow_module.c.
|
static |
When we have an optical flow calculation.
Definition at line 77 of file opticflow_module.c.
|
static |
Mutex lock fo thread safety.
Definition at line 78 of file opticflow_module.c.
|
static |
The opticflow result.
Definition at line 72 of file opticflow_module.c.
|
static |
State of the drone to communicate with the opticflow.
Definition at line 73 of file opticflow_module.c.