Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baro event handling using ABI interface #525

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
71104eb
[isa] conversion tools from pressure to meters
gautierhattenberger Aug 22, 2013
4bb23ae
[abi/baro] binding to ABI baro message is compiling
gautierhattenberger Aug 22, 2013
3230e0a
[baro] data are send and received with ABI (works on a navgo)
gautierhattenberger Aug 23, 2013
629dd68
[isa] atmosphere function all in float
gautierhattenberger Aug 26, 2013
3604171
[abi] pass sender id in the callback function
gautierhattenberger Aug 26, 2013
82589c7
[air_data] introduice air_data subsystem
gautierhattenberger Aug 26, 2013
046ce69
[ins/baro] pressure in float in ABI messages
gautierhattenberger Aug 26, 2013
4970368
[baro] update baro_board files for ABI
gautierhattenberger Aug 26, 2013
cb14ba3
Merge remote-tracking branch 'paparazzi/master' into baro_abi
gautierhattenberger Aug 28, 2013
815f7a9
[baro] convert remaining baro_board to ABI
gautierhattenberger Aug 28, 2013
081188d
[boards] fix baro for lisa_m
flixr Aug 28, 2013
e867282
[dox] doxygen headers for abi
flixr Aug 28, 2013
d1d1a7e
[baro] convert baro modules to ABI
gautierhattenberger Sep 1, 2013
0896232
Merge remote-tracking branch 'paparazzi/master' into baro_abi
gautierhattenberger Sep 2, 2013
175e51a
[baro] convert new boards to ABI for baro
gautierhattenberger Sep 2, 2013
4dd6772
[ins] conver alt_float ins to ABI for baro
gautierhattenberger Sep 2, 2013
93cf55b
[baro] fix baro ABI for sim target with amsys sensor
gautierhattenberger Sep 2, 2013
6f15edb
[message] fix message format for BARO_RAW
gautierhattenberger Sep 2, 2013
a7eeb48
[nps] sim proper baro pressure in pascal
flixr Sep 4, 2013
dadd73e
[messages] INS_REF: baro_qfe in float
flixr Sep 4, 2013
c459bb0
[ins] fix ins_baro_alt, ned frame, z-down!
flixr Sep 4, 2013
2d87a6a
[ins] some cleanup and refactoring
flixr Sep 4, 2013
577df90
Merge branch 'master' into baro_abi
flixr Sep 5, 2013
3aada52
[nps] sim_overwrite_ins updates
flixr Sep 5, 2013
ddb2e04
[conf] baro_board makefile for both fw and rotorcraft
flixr Sep 5, 2013
9deae5e
[baro] fix baro_board ms5611 wrappers
flixr Sep 5, 2013
0845b6f
[conf] fix nps settings file
flixr Sep 5, 2013
4eced1b
[ins] clean ins_ardrone2
flixr Sep 5, 2013
1e50aac
[rotorcraft] add nav_move_waypoint_lla function
flixr Sep 5, 2013
5e4f494
[baro] some ms5611 cleanup
flixr Sep 5, 2013
54c14ae
[tests] fix test_baro
flixr Sep 6, 2013
ee86ce1
[jsbsim] fix baro
flixr Sep 6, 2013
8e3a7b7
[conf] remove obsolete baro_board module from airframes
flixr Sep 6, 2013
1bb10ac
[conf] fix some fixedwing ins makefiles
flixr Sep 6, 2013
49ab4df
[ins] ins.status to running for fw ins
flixr Sep 6, 2013
6ab91ac
[baro_board] disable onboard baro with <configure name="USE_BARO_BOAR…
flixr Sep 6, 2013
f106f62
[tests] finally fix test_baro
flixr Sep 6, 2013
37a59a4
[math] convert PPRZ_ISA_M_OF_P_CONST from define to static const float
flixr Sep 6, 2013
aa4bb5c
[conf] remove all INS_BARO_SENS
flixr Sep 6, 2013
4c8e57f
[state] fix local/global coordinate validity checks
flixr Sep 9, 2013
cf17836
[rotorcraft] telemetry: use state interface instead of ins_impl
flixr Sep 10, 2013
381eb34
[fixedwing] fix nps autopilot include
flixr Sep 10, 2013
1a26a6f
[conf] add baro_board for simulators from baro_board.makefile
flixr Sep 11, 2013
8f8a267
Merge branch 'master' into baro_abi
flixr Sep 13, 2013
d817c1e
Merge branch 'master' into baro_abi
flixr Sep 13, 2013
dcd89a1
[boards][apogee] remove unneeded APOGEE_BARO_SENS
flixr Sep 13, 2013
d38ad85
Merge branch 'master' into baro_abi
flixr Sep 13, 2013
b424bba
[peripherals] refactor baro mpl3115
flixr Sep 13, 2013
6e4d202
[peripherals] baro mpl3115 pressure is in 1/4 pascal
flixr Sep 14, 2013
7dae549
[modules] fix baro_m5611
flixr Sep 15, 2013
413cd51
[modules] baro_ms611 SENSOR_SYNC_SEND for sending coeff every 30s
flixr Sep 16, 2013
49ab9ba
[conf] remove baro_board.xml module file
flixr Oct 7, 2013
bfe0072
[modules] baro modules for real sensors only for ap target, not sim
flixr Oct 7, 2013
c81d770
[modules] baro_ets: BARO_ETS_SCALE
flixr Oct 7, 2013
86bea39
[boards] roughly correct BOOZ_BARO_SENS
flixr Oct 7, 2013
1734b1d
[sim] remove unused sim_baro
flixr Oct 8, 2013
3c4f223
[modules] add baro_sim
flixr Oct 7, 2013
4dd2226
[boards] sim pc: only USE_BARO_BOARD for nps
flixr Oct 8, 2013
c0b9260
[baro] fix baro scaling for booz and navgo
gautierhattenberger Oct 9, 2013
b2814e7
[abi] split abi messages from telemetry messages
gautierhattenberger Oct 10, 2013
78ede47
[abi] define ABI x_SENDER_IDs in abi_sender_ids.h
flixr Oct 10, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions conf/firmwares/rotorcraft.makefile
Expand Up @@ -150,8 +150,10 @@ ap.srcs += subsystems/actuators.c
#

#
# BARO
# AIR DATA and BARO (if needed)
#
ap.srcs += subsystems/air_data.c

# booz baro
ifeq ($(BOARD), booz)
ap.srcs += $(SRC_BOARD)/baro_board.c
Expand All @@ -162,8 +164,6 @@ ap.srcs += $(SRC_BOARD)/baro_board.c
# Ardrone baro
else ifeq ($(BOARD)$(BOARD_TYPE), ardroneraw)
ap.srcs += $(SRC_BOARD)/baro_board.c
else ifeq ($(BOARD)$(BOARD_TYPE), ardronesdk)
ap.srcs += $(SRC_BOARD)/baro_board_dummy.c

# Lisa/M baro
else ifeq ($(BOARD), lisa_m)
Expand Down Expand Up @@ -248,7 +248,7 @@ ap.srcs += $(SRC_BOARD)/baro_board.c
endif

ifneq ($(BARO_LED),none)
ap.CFLAGS += -DROTORCRAFT_BARO_LED=$(BARO_LED)
ap.CFLAGS += -DBARO_LED=$(BARO_LED)
endif

#
Expand Down
22 changes: 22 additions & 0 deletions conf/firmwares/subsystems/fixedwing/autopilot.makefile
Expand Up @@ -163,16 +163,36 @@ ap_srcs += state.c
ap_srcs += subsystems/settings.c
ap_srcs += $(SRC_ARCH)/subsystems/settings_arch.c

# AIR DATA
ap_srcs += subsystems/air_data.c

# BARO

# Umarim
ifeq ($(BOARD), umarim)
ifeq ($(BOARD_VERSION), 1.0)
ap_srcs += boards/umarim/baro_board.c
ap_CFLAGS += -DUSE_I2C1 -DUSE_ADS1114_1
ap_CFLAGS += -DADS1114_I2C_DEV=i2c1
ap_srcs += peripherals/ads1114.c
endif

# Lisa/L
else ifeq ($(BOARD), lisa_l)
ap_CFLAGS += -DUSE_I2C2

# Apogee
else ifeq ($(BOARD), apogee)
ap_CFLAGS += -DUSE_I2C1
ap_CFLAGS += -DMPL3115_I2C_DEV=i2c1
ap_CFLAGS += -DMPL3115_ALT_MODE=0
ap_srcs += peripherals/mpl3115.c
ap_srcs += $(SRC_BOARD)/baro_board.c

endif # End baro

ifneq ($(BARO_LED),none)
ap_CFLAGS += -DBARO_LED=$(BARO_LED)
endif

# ahrs frequencies if configured
Expand Down Expand Up @@ -204,6 +224,8 @@ sim.srcs += $(SRC_ARCH)/sim_ap.c
sim.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport
sim.srcs += subsystems/datalink/downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/sim_gps.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/sim_adc_generic.c

sim.srcs += $(SRC_BOARD)/baro_board.c

sim.srcs += subsystems/settings.c
sim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c

Expand Down
2 changes: 1 addition & 1 deletion conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile
Expand Up @@ -92,7 +92,7 @@ nps.srcs += $(SRC_FIRMWARE)/datalink.c
#
nps.srcs += math/pprz_geodetic_int.c math/pprz_geodetic_float.c math/pprz_geodetic_double.c math/pprz_trig_int.c math/pprz_orientation_conversion.c

nps.CFLAGS += -DROTORCRAFT_BARO_LED=2
nps.CFLAGS += -DBARO_LED=2
nps.srcs += $(SRC_BOARD)/baro_board.c

nps.CFLAGS += -DUSE_ADC
Expand Down
14 changes: 11 additions & 3 deletions conf/messages.xml
Expand Up @@ -1873,8 +1873,8 @@
</message>

<message name="BARO_RAW" id="221">
<field name="abs" type="int32"/>
<field name="diff" type="int32"/>
<field name="abs" type="float"/>
<field name="diff" type="float"/>
</message>

<!--222 is free -->
Expand Down Expand Up @@ -2568,10 +2568,18 @@


<class name="airborne">
<message name="TEST_ABI" id="0">
<!--message name="TEST_ABI" id="0">
<field name="value" type="int8_t"/>
<field name="boo" type="struct abi_boo"/>
<field name="vect" type="struct Int32Vect3 *"/>
</message-->

<message name="BARO_ABS" id="1">
<field name="pressure" type="float" unit="Pa"/>
</message>

<message name="BARO_DIFF" id="2">
<field name="pressure" type="float" unit="Pa"/>
</message>
</class>

Expand Down
57 changes: 42 additions & 15 deletions sw/airborne/boards/apogee/baro_board.c
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 ENAC
* Copyright (C) 2013 Gautier Hattenberger (ENAC)
*
* This file is part of paparazzi.
*
Expand All @@ -26,40 +26,67 @@
* integrated barometer for Apogee boards (mpl3115)
*/

#include "std.h"
#include "subsystems/sensors/baro.h"
#include "peripherals/mpl3115.h"

// to get MPU status
#include "boards/apogee/imu_apogee.h"

#include "subsystems/abi.h"
#include "led.h"

/* Common Baro struct */
struct Baro baro;

// FIXME
#ifndef APOGEE_BARO_SENS
#define APOGEE_BARO_SENS 0.0274181
#endif

#ifndef APOGEE_BARO_SENDER_ID
#define APOGEE_BARO_SENDER_ID 12
#endif

/** Counter to init ads1114 at startup */
#define BARO_STARTUP_COUNTER 200
uint16_t startup_cnt;

void baro_init( void ) {
mpl3115_init();
baro.status = BS_UNINITIALIZED;
baro.absolute = 0;
baro.differential = 1; /* not handled on this board, use extra module */
#ifdef BARO_LED
LED_OFF(BARO_LED);
#endif
startup_cnt = BARO_STARTUP_COUNTER;
}

void baro_periodic( void ) {

if (baro.status == BS_UNINITIALIZED && mpl3115_data_available) {
// Run some loops to get correct readings from the adc
--startup_cnt;
mpl3115_data_available = FALSE;
if (startup_cnt == 0) {
baro.status = BS_RUNNING;
// Baro is slave of the MPU, only start reading it after MPU is configured
if (imu_apogee.mpu.config.initialized) {

if (startup_cnt > 0 && mpl3115_data_available) {
// Run some loops to get correct readings from the adc
--startup_cnt;
mpl3115_data_available = FALSE;
#ifdef BARO_LED
LED_TOGGLE(BARO_LED);
if (startup_cnt == 0) {
LED_ON(BARO_LED);
}
#endif
}
// Read the sensor
Mpl3115Periodic();
}
}

// Baro is slave of the MPU, only start reading it after MPU is configured
if (imu_apogee.mpu.config.initialized)
Mpl3115Periodic();
void apogee_baro_event(void) {
mpl3115_event();
if (mpl3115_data_available) {
if (startup_cnt == 0) {
float pressure = ((float)mpl3115_pressure/(1<<2));
AbiSendMsgBARO_ABS(APOGEE_BARO_SENDER_ID, &pressure);
}
mpl3115_data_available = FALSE;
}
}

29 changes: 2 additions & 27 deletions sw/airborne/boards/apogee/baro_board.h
Expand Up @@ -29,32 +29,7 @@
#ifndef BOARDS_APOGEE_BARO_H
#define BOARDS_APOGEE_BARO_H

#include "std.h"
#include "peripherals/mpl3115.h"

/* There is no differential pressure on the board but
* it can be available from an external sensor
* */

#define BaroAbs(_handler) { \
mpl3115_event(); \
if (mpl3115_data_available) { \
baro.absolute = mpl3115_pressure; \
if (baro.status == BS_RUNNING) { \
_handler(); \
mpl3115_data_available = FALSE; \
} \
} \
}

// TODO handle baro diff
#ifndef BaroDiff
#define BaroDiff(_h) {}
#endif

#define BaroEvent(_b_abs_handler, _b_diff_handler) { \
BaroAbs(_b_abs_handler); \
BaroDiff(_b_diff_handler); \
}
extern void apogee_baro_event(void);
#define BaroEvent apogee_baro_event

#endif // BOARDS_APOGEE_BARO_H
2 changes: 1 addition & 1 deletion sw/airborne/boards/apogee_0.99.h
Expand Up @@ -184,7 +184,7 @@
//#define SPI_SELECT_SLAVE5_PIN GPIO4

/* Activate onboard baro */
#define BOARD_HAS_BARO 1
#define USE_BARO_BOARD 1

/* PWM */
#define PWM_USE_TIM2 1
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/boards/apogee_1.0.h
Expand Up @@ -254,7 +254,7 @@


/* Activate onboard baro */
#define BOARD_HAS_BARO 1
#define USE_BARO_BOARD 1

/* PWM */
#define PWM_USE_TIM2 1
Expand Down
42 changes: 23 additions & 19 deletions sw/airborne/boards/ardrone/baro_board.c
Expand Up @@ -27,18 +27,25 @@
*/

#include "subsystems/sensors/baro.h"
#include "subsystems/abi.h"
#include "baro_board.h"
#include "navdata.h"

struct Baro baro;
// FIXME
#ifndef ARDRONE2_BARO_SENS
#define ARDRONE2_BARO_SENS 1.0
#endif

#ifndef ARDRONE2_BARO_SENDER_ID
#define ARDRONE2_BARO_SENDER_ID 13
#endif


#define BMP180_OSS 0 // Parrot ARDrone uses no oversampling

void baro_init(void) {
baro.status = BS_UNINITIALIZED;
baro.absolute = 0;
baro.differential = 0;
}
void baro_init(void) {}

void baro_periodic(void) {}

static inline int32_t baro_apply_calibration(int32_t raw)
{
Expand Down Expand Up @@ -69,20 +76,17 @@ static inline int32_t baro_apply_calibration_temp(int32_t tmp_raw)
return (baro_calibration.b5 + 8) >> 4;
}

void baro_periodic(void)
void ardrone_baro_event(void)
{
}

void process_ardrone_baro(void)
{
if(baro.status == BS_RUNNING) {
// first read temperature because pressure calibration depends on temperature
baro.differential = baro_apply_calibration_temp(navdata->temperature_pressure); // We store the temperature in Baro-Diff
baro.absolute = baro_apply_calibration(navdata->pressure);
}
else {
if (baro_calibrated == TRUE) {
baro.status = BS_RUNNING;
if (navdata_baro_available) {
if (baro_calibrated) {
// first read temperature because pressure calibration depends on temperature
// TODO send Temperature message
baro_apply_calibration_temp(navdata->temperature_pressure);
// FIXME apply correct sensitivity here
float pressure = ARDRONE2_BARO_SENS*(float)baro_apply_calibration(navdata->pressure);
AbiSendMsgBARO_ABS(ARDRONE2_BARO_SENDER_ID, &pressure);
}
navdata_baro_available = FALSE;
}
}
23 changes: 2 additions & 21 deletions sw/airborne/boards/ardrone/baro_board.h
Expand Up @@ -30,26 +30,7 @@
#ifndef BOARDS_ARDRONE2_BARO_H
#define BOARDS_ARDRONE2_BARO_H

#if BOARD_HAS_BARO
#include "navdata.h"

void process_ardrone_baro(void);


static inline void baro_event(void (*b_abs_handler)(void), void (*b_diff_handler)(void)){
if (navdata_baro_available)
{
navdata_baro_available = 0;
process_ardrone_baro();
b_abs_handler();
}
}

#define BaroEvent(_b_abs_handler, _b_diff_handler) {\
baro_event(_b_abs_handler,_b_diff_handler);\
}
#else
#define BaroEvent(_b_abs_handler, _b_diff_handler) {}
#endif
extern void ardrone_baro_event(void);
#define BaroEvent ardrone_baro_event

#endif /* BOARDS_ARDRONE2_BARO_H */
40 changes: 0 additions & 40 deletions sw/airborne/boards/ardrone/baro_board_dummy.c

This file was deleted.

2 changes: 1 addition & 1 deletion sw/airborne/boards/ardrone2_raw.h
Expand Up @@ -9,6 +9,6 @@
#define ActuatorsDefaultInit() ActuatorsArdroneInit()
#define ActuatorsDefaultCommit() ActuatorsArdroneCommit()

#define BOARD_HAS_BARO 1
#define USE_BARO_BOARD 1

#endif /* CONFIG_ARDRONE2_RAW */