diff --git a/conf/airframes/twisted.xml b/conf/airframes/twisted.xml new file mode 100644 index 0000000000..26431a6ddb --- /dev/null +++ b/conf/airframes/twisted.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + +include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile + +FLASH_MODE=IAP + +ap.CFLAGS += -DFBW -DAP -DCONFIG=\"tiny_1_1.h\" -DLED -DTIME_LED=1 +ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_coax.c main.c + +ap.CFLAGS += -DACTUATORS=\"servos_4015_MAT_hw.h\" -DSERVOS_4015_MAT +ap.srcs += $(SRC_ARCH)/servos_4015_MAT_hw.c actuators.c commands.c + +ap.CFLAGS += -DRADIO_CONTROL -DRADIO_CONTROL_TYPE=RC_FUTABA +ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c + +ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B19200 +ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c pprz_transport.c + +ap.CFLAGS += -DUSE_SPI -DSPI_MASTER -DUSE_SPI_SLAVE0 -DUSE_BARO_MS5534A +ap.srcs += spi.c $(SRC_ARCH)/spi_hw.c $(SRC_ARCH)/baro_MS5534A.c + +ap.CFLAGS += -DALT_KALMAN +ap.srcs += estimator.c + + +
diff --git a/conf/settings/twisted.xml b/conf/settings/twisted.xml new file mode 100644 index 0000000000..a1e088f5b4 --- /dev/null +++ b/conf/settings/twisted.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/debian/control.sid b/debian/control.sid index d88d05a877..9a0f053dec 100644 --- a/debian/control.sid +++ b/debian/control.sid @@ -8,9 +8,9 @@ Standards-Version: 3.6.1 Package: paparazzi-dev Architecture: any -Suggests: mlview, lustre, paparazzi-avr, paparazzi-arm +Suggests: paparazzi-avr, paparazzi-arm7 Recommends: eagle, gs-common, tetex-extra, dia-gnome -Depends: ivy-c-dev, ivy-c, ivy-perl, ivy-ocaml, xml-light-ocaml, liblablgtk2-ocaml-dev, make, gcc, boa, gnuplot, libgnomecanvas2-dev, libxml-dom-perl, libsubject-perl, libfile-ncopy-perl, libpcre3-dev, bzip2, libexpect-perl, cvs, liblablgl-ocaml-dev, liblablgtk2-gl-ocaml-dev, liblablgtk2-gnome-ocaml-dev, libcamlimages-ocaml-dev, libusb-dev +Depends: ivy-c-dev, ivy-c, ivy-ocaml, xml-light-ocaml, liblablgtk2-ocaml-dev, make, gcc, boa, gnuplot, libgnomecanvas2-dev, bzip2, cvs, liblablgl-ocaml-dev, liblablgtk2-gl-ocaml-dev, liblablgtk2-gnome-ocaml-dev, libcamlimages-ocaml-dev, libusb-dev, speech-dispatcher, glade, gedit, imagemagick Description: Paparazzi Meta Package : common support @@ -22,12 +22,12 @@ Description: Paparazzi Meta Package. Atmel AVR support Package: paparazzi-arm7 Architecture: any -Depends: lpc21isp, gcc-arm, binutils-arm, newlib-arm, libusb-dev +Depends: lpc21isp, gcc-arm, binutils-arm, libusb-dev Description: Paparazzi Meta Package. Philips ARM7 support Package: paparazzi-bin Architecture: i386 -Depends: ivy-c-dev, ivy-c, ivy-perl, ivy-ocaml, xml-light-ocaml, liblablgtk2-ocaml-dev, make, gcc, boa, gnuplot, libxml-dom-perl, libsubject-perl, libfile-ncopy-perl, libpcre3-dev, bzip2, libexpect-perl +Depends: ivy-c-dev, ivy-c, ivy-ocaml, xml-light-ocaml, liblablgtk2-ocaml-dev, make, gcc, boa, gnuplot, bzip2, liblablgtk2-gnome-ocaml-dev, speech-dispatcher, gedit, imagemagick Description: Paparazzi main package diff --git a/sw/airborne/main_coax.c b/sw/airborne/main_coax.c new file mode 100644 index 0000000000..579ed83346 --- /dev/null +++ b/sw/airborne/main_coax.c @@ -0,0 +1,93 @@ +#include "std.h" +#include "init_hw.h" +#include "sys_time.h" +#include "led.h" +#include "interrupt_hw.h" +#include "uart.h" + +#include "main_ap.h" +#include "airframe.h" + +#include "messages.h" +#include "downlink.h" +#include "spi.h" +#include "baro_MS5534A.h" + +#include "estimator.h" + +float ground_alt; + +#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE + +static bool_t dl_msg_available; +static inline void main_dl_parse_msg( void ); + +void init_ap( void ) { + /** init done in main_fbw */ + spi_init(); + + baro_MS5534A_init(); + + int_enable(); + + baro_MS5534A_init(); +} + +void periodic_task_ap( void ) { + // LED_TOGGLE(1); + // DOWNLINK_SEND_TAKEOFF(&cpu_time_sec); + + static uint8_t _20Hz = 0; + _20Hz++; + if (_20Hz>=3) _20Hz=0; + + if (!_20Hz) { + baro_MS5534A_send(); + } +} + +void event_task_ap( void ) { + if (PprzBuffer()) { + ReadPprzBuffer(); + if (pprz_msg_received) { + pprz_parse_payload(); + pprz_msg_received = FALSE; + } + } + if (dl_msg_available) { + main_dl_parse_msg(); + dl_msg_available = FALSE; + LED_TOGGLE(1); + } + + if (spi_message_received) { + /* Got a message on SPI. */ + spi_message_received = FALSE; + baro_MS5534A_event_task(); + if (baro_MS5534A_available) { + baro_MS5534A_available = FALSE; + + baro_MS5534A_z = ground_alt +((float)baro_MS5534A_ground_pressure - baro_MS5534A_pressure)*0.084; + if (alt_baro_enabled) { + EstimatorSetAlt(baro_MS5534A_z); + } + } + } +} + +#define MSG_SIZE 128 +uint8_t dl_buffer[MSG_SIZE] __attribute__ ((aligned)); + +#include "settings.h" + +#define IdOfMsg(x) (x[1]) + +static inline void main_dl_parse_msg(void) { + uint8_t msg_id = IdOfMsg(dl_buffer); + if (msg_id == DL_SETTING) { + uint8_t i = DL_SETTING_index(dl_buffer); + float var = DL_SETTING_value(dl_buffer); + DlSetting(i, var); + DOWNLINK_SEND_DL_VALUE(&i, &var); + } +} diff --git a/sw/airborne/sim/baro_MS5534A.h b/sw/airborne/sim/baro_MS5534A.h new file mode 100644 index 0000000000..df9bdb470d --- /dev/null +++ b/sw/airborne/sim/baro_MS5534A.h @@ -0,0 +1,59 @@ +/* + * $Id$ + * + * Copyright (C) 2007 ENAC + * + * This file is part of paparazzi. + * + * paparazzi is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * paparazzi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with paparazzi; see the file COPYING. If not, write to + * the Free Software Foundation, 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** \file baro_MS5534A.h + * \brief Handling of the MS5534a pressure sensor + * + */ + +#ifndef BARO_MS5534A_H +#define BARO_MS5534A_H + +#include "std.h" + +#ifdef USE_BARO_MS5534A + +extern bool_t spi_message_received; +extern bool_t baro_MS5534A_available; +extern uint32_t baro_MS5534A_pressure; +extern uint16_t baro_MS5534A_temp; +extern bool_t alt_baro_enabled; +extern uint32_t baro_MS5534A_ground_pressure; +extern float baro_MS5534A_r; +extern float baro_MS5534A_sigma2; +extern float baro_MS5534A_z; + + +void baro_MS5534A_init(void); +void baro_MS5534A_reset(void); + +/* To be called not faster than 30Hz */ +void baro_MS5534A_send(void); + +/* Set baro_MS5534A_available when pressure and temp are readable */ +void baro_MS5534A_event_task( void ); + +#endif // USE_BARO_MS5534A + +#endif // BARO_MS5534A_H diff --git a/sw/airborne/sim/sim_baro.c b/sw/airborne/sim/sim_baro.c new file mode 100644 index 0000000000..d6e737e3b0 --- /dev/null +++ b/sw/airborne/sim/sim_baro.c @@ -0,0 +1,37 @@ +#include +#include "estimator.h" +#include "nav.h" +#include "gps.h" +#include "baro_MS5534A.h" + +bool_t alt_baro_enabled; +bool_t spi_message_received; +bool_t baro_MS5534A_available; +uint32_t baro_MS5534A_pressure; +uint32_t baro_MS5534A_ground_pressure; +uint16_t baro_MS5534A_temp; +float baro_MS5534A_r; +float baro_MS5534A_sigma2; +float baro_MS5534A_z; + +void baro_MS5534A_init(void) { + baro_MS5534A_ground_pressure = 100000; + + baro_MS5534A_r = 10.; + baro_MS5534A_sigma2 = 1; +} + +// void baro_MS5534A_reset(void); + +void baro_MS5534A_send(void) { + static bool_t even = FALSE; + even = !even; + + spi_message_received = even; +} + +void baro_MS5534A_event_task( void ) { + baro_MS5534A_pressure = baro_MS5534A_ground_pressure - (gps_alt/100.-ground_alt) / 0.08 + ((10.*random()) / RAND_MAX); + baro_MS5534A_temp = 10 + estimator_z; + baro_MS5534A_available = TRUE; +}