44 #ifndef OPTICFLOW_AGL_ID
45 #define OPTICFLOW_AGL_ID ABI_BROADCAST
49 #ifndef OPTICFLOW_IMU_ID
50 #define OPTICFLOW_IMU_ID ABI_BROADCAST
54 #ifndef OPTICFLOW_BODY_TO_IMU_ID
55 #define OPTICFLOW_BODY_TO_IMU_ID ABI_BROADCAST
59 #ifndef OPTICFLOW_SEND_ABI_ID
60 #define OPTICFLOW_SEND_ABI_ID 1
65 #define OPTICFLOW_FPS 0
88 #if PERIODIC_TELEMETRY
97 pthread_mutex_lock(&opticflow_mutex);
98 if (opticflow_result.noise_measurement < 0.8) {
99 pprz_msg_send_OPTIC_FLOW_EST(trans, dev, AC_ID,
100 &opticflow_result.fps, &opticflow_result.corner_cnt,
101 &opticflow_result.tracked_cnt, &opticflow_result.flow_x,
102 &opticflow_result.flow_y, &opticflow_result.flow_der_x,
103 &opticflow_result.flow_der_y, &opticflow_result.vel_x,
104 &opticflow_result.vel_y, &opticflow_result.div_size,
105 &opticflow_result.surface_roughness, &opticflow_result.divergence);
107 pthread_mutex_unlock(&opticflow_mutex);
127 opticflow_state.agl = 0;
130 opticflow_got_result =
false;
135 #if PERIODIC_TELEMETRY
147 pthread_mutex_lock(&opticflow_mutex);
149 if (opticflow_got_result) {
152 opticflow_result.flow_x,
153 opticflow_result.flow_y,
154 opticflow_result.flow_der_x,
155 opticflow_result.flow_der_y,
156 opticflow_result.noise_measurement,
157 opticflow_result.div_size,
158 opticflow_state.agl);
160 if (opticflow_result.noise_measurement < 0.8) {
162 opticflow_result.vel_body_x,
163 opticflow_result.vel_body_y,
165 opticflow_result.noise_measurement
168 opticflow_got_result =
false;
170 pthread_mutex_unlock(&opticflow_mutex);
194 pthread_mutex_lock(&opticflow_mutex);
195 opticflow_result = temp_result;
196 opticflow_got_result =
true;
200 pthread_mutex_unlock(&opticflow_mutex);
213 opticflow_state.agl = distance;
225 opticflow_state.accel_imu_meas = *accel;
238 opticflow_state.imu_to_body_quat = imu_to_body_quat_temp;
Event structure to store callbacks in a linked list.
#define OPTICFLOW_BODY_TO_IMU_ID
Default body to IMU to use in opticflow visual_estimator.
struct opticflow_t opticflow
Opticflow calculations.
Periodic telemetry system header (includes downlink utility and generated code).
struct FloatRates rates
Body rates.
static bool opticflow_got_result
When we have an optical flow calculation.
static struct opticflow_state_t opticflow_state
State of the drone to communicate with the opticflow.
optical-flow calculation for Parrot Drones
static abi_event opticflow_imu_accel_ev
The altitude ABI event.
static abi_event opticflow_agl_ev
The accelerometers ABI event.
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
Capture images from a V4L2 device (Video for Linux 2)
Main include for ABI (AirBorneInterface).
struct pose_t get_rotation_at_timestamp(uint32_t timestamp)
Given a pprz timestamp in used (obtained with get_sys_time_usec) we return the pose in FloatEulers cl...
#define FLOAT_RATES_ZERO(_r)
uint32_t pprz_ts
The timestamp in us since system startup.
static void opticflow_body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
Callback function of imu to body.
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps)
void opticflow_module_init(void)
Initialize the optical flow module for the bottom camera.
struct image_t * opticflow_module_calc(struct image_t *img)
The main optical flow calculation thread.
static pthread_mutex_t opticflow_mutex
Mutex lock fo thread safety.
void opticflow_calc_init(struct opticflow_t *opticflow)
Initialize the opticflow calculator.
#define OPTICFLOW_IMU_ID
Default IMU (accelerometers) to use in opticflow visual_estimator.
static void opticflow_imu_accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
Callback function of the IMU's accelerometers.
Computer vision framework for onboard processing.
#define DefaultPeriodic
Set default periodic telemetry.
static struct opticflow_result_t opticflow_result
The opticflow result.
static abi_event opticflow_body_to_imu_ev
The body-to-imu ABI event.
static void float_quat_invert(struct FloatQuat *qo, struct FloatQuat *qi)
Encode images with the use of the JPEG encoding.
#define OPTICFLOW_FPS
Default FPS (zero means run at camera fps)
static const struct usb_device_descriptor dev
#define INT_VECT3_ZERO(_v)
API to get/set the generic vehicle states.
void opticflow_module_run(void)
Update the optical flow state for the calculation thread and update the stabilization loops with the ...
void opticflow_calc_frame(struct opticflow_t *opticflow, struct opticflow_state_t *cam_state, struct image_t *img, struct opticflow_result_t *result)
Run the optical flow on a new image frame.
Encodes a vide stream with RTP (JPEG)
#define OPTICFLOW_AGL_ID
Default sonar/agl to use in opticflow visual_estimator.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define OPTICFLOW_SEND_ABI_ID
Default ID to send abi messages.
static void opticflow_agl_cb(uint8_t sender_id, float distance)
Callback function of the ground altitude.
static void opticflow_telem_send(struct transport_tx *trans, struct link_device *dev)
Send optical flow telemetry information.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.