PX4 Firmware
PX4 Autopilot Software http://px4.io
i2c_frame.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file i2c_frame.h
36  * Definition of i2c frames.
37  * There are different I2C readouts available: i2c_frame and i2c_integral_frame.
38  * The ic2_frame can be requested via the register 0x0, the i2c_integral_frame via 0x16.
39  *
40  * @author Thomas Boehm <thomas.boehm@fortiss.org>
41  * @author James Goppert <james.goppert@gmail.com>
42  */
43 
44 #pragma once
45 
46 #include <inttypes.h>
47 
48 typedef struct i2c_frame {
49  uint16_t frame_count; /**< counts created I2C frames [#frames] */
50  int16_t pixel_flow_x_sum; /**< latest x flow measurement in pixels*10 [pixels] */
51  int16_t pixel_flow_y_sum; /**< latest y flow measurement in pixels*10 [pixels] */
52  int16_t flow_comp_m_x; /**< x velocity*1000 [meters/sec] */
53  int16_t flow_comp_m_y; /**< y velocity*1000 [meters/sec] */
54  int16_t qual; /**< Optical flow quality / confidence [0: bad, 255: maximum quality] */
55  int16_t gyro_x_rate; /**< latest gyro x rate [rad/sec] */
56  int16_t gyro_y_rate; /**< latest gyro y rate [rad/sec] */
57  int16_t gyro_z_rate; /**< latest gyro z rate [rad/sec] */
58  uint8_t gyro_range; /**< gyro range [0 .. 7] equals [50 deg/sec .. 2000 deg/sec] */
59  uint8_t sonar_timestamp; /**< time since last sonar update [milliseconds] */
60  int16_t ground_distance; /**< Ground distance in meters*1000 [meters]. Positive value: distance known. Negative value: Unknown distance */
61 } i2c_frame;
62 
63 #define I2C_FRAME_SIZE (sizeof(i2c_frame))
64 
65 
66 typedef struct i2c_integral_frame {
67  uint16_t frame_count_since_last_readout; /**< number of flow measurements since last I2C readout [#frames] */
68  int16_t pixel_flow_x_integral; /**< accumulated flow in radians*10000 around x axis since last I2C readout [rad*10000] */
69  int16_t pixel_flow_y_integral; /**< accumulated flow in radians*10000 around y axis since last I2C readout [rad*10000] */
70  int16_t gyro_x_rate_integral; /**< accumulated gyro x rates in radians*10000 since last I2C readout [rad*10000] */
71  int16_t gyro_y_rate_integral; /**< accumulated gyro y rates in radians*10000 since last I2C readout [rad*10000] */
72  int16_t gyro_z_rate_integral; /**< accumulated gyro z rates in radians*10000 since last I2C readout [rad*10000] */
73  uint32_t integration_timespan; /**< accumulation timespan in microseconds since last I2C readout [microseconds] */
74  uint32_t sonar_timestamp; /**< time since last sonar update [microseconds] */
75  uint16_t ground_distance; /**< Ground distance in meters*1000 [meters*1000] */
76  int16_t gyro_temperature; /**< Temperature * 100 in centi-degrees Celsius [degcelsius*100] */
77  uint8_t qual; /**< averaged quality of accumulated flow values [0:bad quality;255: max quality] */
79 
80 #define I2C_INTEGRAL_FRAME_SIZE (sizeof(i2c_integral_frame))
int16_t pixel_flow_x_sum
latest x flow measurement in pixels*10 [pixels]
Definition: i2c_frame.h:50
int16_t pixel_flow_y_sum
latest y flow measurement in pixels*10 [pixels]
Definition: i2c_frame.h:51
uint16_t frame_count
counts created I2C frames [#frames]
Definition: i2c_frame.h:49
int16_t pixel_flow_x_integral
accumulated flow in radians*10000 around x axis since last I2C readout [rad*10000] ...
Definition: i2c_frame.h:68
int16_t flow_comp_m_y
y velocity*1000 [meters/sec]
Definition: i2c_frame.h:53
int16_t ground_distance
Ground distance in meters*1000 [meters].
Definition: i2c_frame.h:60
int16_t gyro_temperature
Temperature * 100 in centi-degrees Celsius [degcelsius*100].
Definition: i2c_frame.h:76
uint16_t frame_count_since_last_readout
number of flow measurements since last I2C readout [#frames]
Definition: i2c_frame.h:67
uint8_t sonar_timestamp
time since last sonar update [milliseconds]
Definition: i2c_frame.h:59
uint32_t sonar_timestamp
time since last sonar update [microseconds]
Definition: i2c_frame.h:74
struct i2c_integral_frame i2c_integral_frame
uint32_t integration_timespan
accumulation timespan in microseconds since last I2C readout [microseconds]
Definition: i2c_frame.h:73
int16_t qual
Optical flow quality / confidence [0: bad, 255: maximum quality].
Definition: i2c_frame.h:54
struct i2c_frame i2c_frame
uint16_t ground_distance
Ground distance in meters*1000 [meters*1000].
Definition: i2c_frame.h:75
int16_t pixel_flow_y_integral
accumulated flow in radians*10000 around y axis since last I2C readout [rad*10000] ...
Definition: i2c_frame.h:69
int16_t gyro_z_rate
latest gyro z rate [rad/sec]
Definition: i2c_frame.h:57
uint8_t gyro_range
gyro range [0 .
Definition: i2c_frame.h:58
int16_t gyro_x_rate_integral
accumulated gyro x rates in radians*10000 since last I2C readout [rad*10000]
Definition: i2c_frame.h:70
int16_t gyro_z_rate_integral
accumulated gyro z rates in radians*10000 since last I2C readout [rad*10000]
Definition: i2c_frame.h:72
int16_t gyro_y_rate_integral
accumulated gyro y rates in radians*10000 since last I2C readout [rad*10000]
Definition: i2c_frame.h:71
uint8_t qual
averaged quality of accumulated flow values [0:bad quality;255: max quality]
Definition: i2c_frame.h:77
int16_t gyro_y_rate
latest gyro y rate [rad/sec]
Definition: i2c_frame.h:56
int16_t flow_comp_m_x
x velocity*1000 [meters/sec]
Definition: i2c_frame.h:52
int16_t gyro_x_rate
latest gyro x rate [rad/sec]
Definition: i2c_frame.h:55