Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
opticflow_module.c File Reference

Optical-flow estimation module. More...

#include "opticflow_module.h"
#include <stdio.h>
#include <pthread.h>
#include "state.h"
#include "modules/core/abi.h"
#include "modules/pose_history/pose_history.h"
#include "lib/v4l/v4l2.h"
#include "lib/encoding/jpeg.h"
#include "lib/encoding/rtp.h"
#include "errno.h"
#include "cv.h"
#include "generated/airframe.h"
#include "modules/datalink/telemetry.h"
Include dependency graph for opticflow_module.c:

Go to the source code of this file.

Macros

#define OPTICFLOW_AGL_ID   ABI_BROADCAST
 Default sonar/agl to use in opticflow visual_estimator.
#define OPTICFLOW_FPS   0
 Default FPS (zero means run at camera fps).
#define OPTICFLOW_FPS_CAMERA2   0
 Default FPS (zero means run at camera fps).
#define ACTIVE_CAMERAS   1

Functions

struct image_t * opticflow_module_calc (struct image_t *img, uint8_t camera_id)
 The main optical flow calculation thread.
static void opticflow_telem_send (struct transport_tx *trans, struct link_device *dev)
 Send optical flow telemetry information.
void opticflow_module_init (void)
 Initialize the optical flow module for the bottom camera.
void opticflow_module_run (void)
 Update the optical flow state for the calculation thread and update the stabilization loops with the newest result.

Variables

uint16_t fps_OF
struct opticflow_t opticflow [ACTIVE_CAMERAS]
 Opticflow calculations.
static struct opticflow_result_t opticflow_result [ACTIVE_CAMERAS]
 The opticflow result.
static bool opticflow_got_result [ACTIVE_CAMERAS]
 When we have an optical flow calculation.
static pthread_mutex_t opticflow_mutex
 Mutex lock fo thread safety.

Detailed Description

Optical-flow estimation module.

Definition in file opticflow_module.c.

Macro Definition Documentation

◆ ACTIVE_CAMERAS

#define ACTIVE_CAMERAS   1

◆ OPTICFLOW_AGL_ID

#define OPTICFLOW_AGL_ID   ABI_BROADCAST

Default sonar/agl to use in opticflow visual_estimator.

Definition at line 48 of file opticflow_module.c.

◆ OPTICFLOW_FPS

#define OPTICFLOW_FPS   0

Default FPS (zero means run at camera fps).

Definition at line 53 of file opticflow_module.c.

Referenced by opticflow_module_init().

◆ OPTICFLOW_FPS_CAMERA2

#define OPTICFLOW_FPS_CAMERA2   0

Default FPS (zero means run at camera fps).

Definition at line 57 of file opticflow_module.c.

Referenced by opticflow_module_init().

Function Documentation

◆ opticflow_module_calc()

struct image_t * opticflow_module_calc ( struct image_t * img,
uint8_t camera_id )

The main optical flow calculation thread.

The main optical flow calculation thread This thread passes the images trough the optical flow calculator.

Parameters
[in]*imgThe image_t structure of the captured image
[in]camera_idThe camera index id
Returns
*img The processed image structure

Definition at line 176 of file opticflow_module.c.

References ACTIVE_CAMERAS, opticflow_result_t::camera_id, image_t::eulers, pose_t::eulers, get_rotation_at_timestamp(), opticflow, opticflow_calc_frame(), opticflow_got_result, opticflow_mutex, opticflow_result, and image_t::pprz_ts.

Referenced by opticflow_module_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ opticflow_module_init()

void opticflow_module_init ( void )

Initialize the optical flow module for the bottom camera.

Definition at line 114 of file opticflow_module.c.

References ACTIVE_CAMERAS, cv_add_to_device(), DefaultPeriodic, opticflow, opticflow_calc_init(), OPTICFLOW_FPS, OPTICFLOW_FPS_CAMERA2, opticflow_got_result, opticflow_module_calc(), opticflow_telem_send(), and register_periodic_telemetry().

Here is the call graph for this function:

◆ opticflow_module_run()

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 137 of file opticflow_module.c.

References ACTIVE_CAMERAS, FLOW_OPTICFLOW_ID, get_sys_time_usec(), opticflow_got_result, opticflow_mutex, opticflow_result, and VEL_OPTICFLOW_ID.

Here is the call graph for this function:

◆ opticflow_telem_send()

void opticflow_telem_send ( struct transport_tx * trans,
struct link_device * dev )
static

Send optical flow telemetry information.

Parameters
[in]*transThe transport structure to send the information over
[in]*devThe link to send the data over

Definition at line 86 of file opticflow_module.c.

References ACTIVE_CAMERAS, dev, opticflow_mutex, and opticflow_result.

Referenced by opticflow_module_init().

Here is the caller graph for this function:

Variable Documentation

◆ fps_OF

uint16_t fps_OF

Definition at line 44 of file opticflow_module.c.

◆ opticflow

◆ opticflow_got_result

bool opticflow_got_result[ACTIVE_CAMERAS]
static

When we have an optical flow calculation.

Definition at line 72 of file opticflow_module.c.

Referenced by opticflow_module_calc(), opticflow_module_init(), and opticflow_module_run().

◆ opticflow_mutex

pthread_mutex_t opticflow_mutex
static

Mutex lock fo thread safety.

Definition at line 73 of file opticflow_module.c.

Referenced by opticflow_module_calc(), opticflow_module_run(), and opticflow_telem_send().

◆ opticflow_result

struct opticflow_result_t opticflow_result[ACTIVE_CAMERAS]
static

The opticflow result.

Definition at line 70 of file opticflow_module.c.

Referenced by opticflow_module_calc(), opticflow_module_run(), and opticflow_telem_send().