Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
baro_board.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 TU Delft Quatrotor Team 1
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
30#include "modules/core/abi.h"
31#include "baro_board.h"
32#include "navdata.h"
33
36#if USE_BARO_MEDIAN_FILTER
39#endif
40
41
42#define BMP180_OSS 0 // Parrot ARDrone uses no oversampling
43
44void baro_init(void)
45{
46#if USE_BARO_MEDIAN_FILTER
48#endif
49}
50
51void baro_periodic(void) {}
52
59{
61 int32_t x1 = (((int32_t)navdata.bmp180_calib.b2) * (b6 * b6 >> 12)) >> 11;
62 int32_t x2 = ((int32_t)navdata.bmp180_calib.ac2) * b6 >> 11;
63 int32_t x3 = x1 + x2;
64 int32_t b3 = (((((int32_t)navdata.bmp180_calib.ac1) * 4 + x3) << BMP180_OSS) + 2) / 4;
65 x1 = ((int32_t)navdata.bmp180_calib.ac3) * b6 >> 13;
66 x2 = (((int32_t)navdata.bmp180_calib.b1) * (b6 * b6 >> 12)) >> 16;
67 x3 = ((x1 + x2) + 2) >> 2;
68 uint32_t b4 = (((int32_t)navdata.bmp180_calib.ac4) * (uint32_t)(x3 + 32768L)) >> 15;
69 uint32_t b7 = (raw - b3) * (50000L >> BMP180_OSS);
70 int32_t p = b7 < 0x80000000L ? (b7 * 2) / b4 : (b7 / b4) * 2;
71 x1 = (p >> 8) * (p >> 8);
72 x1 = (x1 * 3038UL) >> 16;
73 x2 = (-7357L * p) >> 16;
74 int32_t press = p + ((x1 + x2 + 3791L) >> 4);
75 // Zero at sealevel
76 return press;
77}
78
91
93{
96 // first read temperature because pressure calibration depends on temperature
101#if USE_BARO_MEDIAN_FILTER
103#endif
104 float pressure = (float)press_pascal;
106 }
107 navdata.baro_available = false;
108 }
109}
Main include for ABI (AirBorneInterface).
#define BARO_BOARD_SENDER_ID
default onboard baro
void baro_periodic(void)
Definition baro_board.c:90
void baro_init(void)
Definition baro_board.c:76
#define BMP180_OSS
Use an extra median filter to filter baro data.
Definition baro_board.c:42
static int32_t baro_apply_calibration(int32_t raw)
Apply temperature and sensor calibration to get pressure in Pa.
Definition baro_board.c:58
static int32_t baro_apply_calibration_temp(int32_t tmp_raw)
Apply temperature calibration.
Definition baro_board.c:84
void ardrone_baro_event(void)
Definition baro_board.c:92
Common barometric sensor implementation.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static float p[2][2]
uint16_t foo
Definition main_demo5.c:58
static void init_median_filter_i(struct MedianFilterInt *filter, uint8_t size)
static int32_t update_median_filter_i(struct MedianFilterInt *filter, int32_t new_data)
#define MEDIAN_DEFAULT_SIZE
struct navdata_t navdata
Definition navdata.c:59
ardrone2 navdata aquisition driver.
int32_t pressure
Definition navdata.h:75
struct bmp180_calib_t bmp180_calib
BMP180 calibration receieved from navboard.
Definition navdata.h:126
int16_t ac2
Definition navdata.h:89
uint16_t ac4
Definition navdata.h:91
int16_t ac3
Definition navdata.h:90
int16_t mc
Definition navdata.h:97
struct navdata_measure_t measure
Main navdata packet receieved from navboard.
Definition navdata.h:125
int16_t ac1
Definition navdata.h:88
uint16_t ac6
Definition navdata.h:93
bool baro_calibrated
Whenever the baro is calibrated.
Definition navdata.h:128
int16_t b1
Definition navdata.h:94
bool baro_available
Whenever the baro is available.
Definition navdata.h:129
int16_t md
Definition navdata.h:98
int32_t b5
Definition navdata.h:101
int16_t b2
Definition navdata.h:95
uint16_t ac5
Definition navdata.h:92
uint16_t temperature_pressure
Definition navdata.h:76
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.