Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
px4flow.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Gautier Hattenberger
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
31 #include "subsystems/abi.h"
32 
35 
36 // message ID in Mavlink (v1.0)
37 #define MAVLINK_OPTICAL_FLOW_MSG_ID 100
38 // size of the structure
39 #define MAVLINK_OPTICAL_FLOW_LEN 26
40 
41 #ifndef PX4FLOW_NOISE
42 #define PX4FLOW_NOISE 0.5
43 #endif
44 
45 // request struct for mavlink decoder
47 
48 
49 // callback function on message reception
50 static void decode_optical_flow_msg(struct mavlink_message *msg __attribute__((unused)))
51 {
53 
54  // Y negated to get to the body of the drone
55  AbiSendMsgVELOCITY_ESTIMATE(PX4FLOW_VELOCITY_ID, 0,
58  0.0f,
60 }
61 
64 void px4flow_init(void)
65 {
67 
68  // register a mavlink message
73 
74 }
75 
76 // Messages
77 #include "mcu_periph/uart.h"
78 #include "messages.h"
80 
83 void px4flow_downlink(void)
84 {
85  DOWNLINK_SEND_PX4FLOW(DefaultChannel, DefaultDevice,
93 }
94 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
struct mavlink_optical_flow optical_flow
Definition: px4flow.c:33
static void decode_optical_flow_msg(struct mavlink_message *msg)
Definition: px4flow.c:50
void px4flow_downlink(void)
Downlink message for debug.
Definition: px4flow.c:83
driver for the optical flow sensor PX4FLOW
Main include for ABI (AirBorneInterface).
int16_t flow_x
Flow in pixels in x-sensor direction.
Definition: px4flow.h:44
#define MAVLINK_OPTICAL_FLOW_MSG_ID
Definition: px4flow.c:37
#define PX4FLOW_VELOCITY_ID
float flow_comp_m_x
Flow in meters in x-sensor direction, angular-speed compensated.
Definition: px4flow.h:41
float ground_distance
Ground distance in meters. Positive value: distance known. Negative value: Unknown distance...
Definition: px4flow.h:43
#define FALSE
Definition: std.h:5
#define TRUE
Definition: std.h:4
uint8_t sensor_id
Sensor ID.
Definition: px4flow.h:46
#define PX4FLOW_NOISE
Definition: px4flow.c:42
uint8_t quality
Optical flow quality / confidence. 0: bad, 255: maximum quality.
Definition: px4flow.h:47
float flow_comp_m_y
Flow in meters in y-sensor direction, angular-speed compensated.
Definition: px4flow.h:42
unsigned char uint8_t
Definition: types.h:14
struct mavlink_msg_req req
Definition: px4flow.c:46
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
bool_t optical_flow_available
Definition: px4flow.c:34
int16_t flow_y
Flow in pixels in y-sensor direction.
Definition: px4flow.h:45
void px4flow_init(void)
Initialization function.
Definition: px4flow.c:64