diff --git a/.gitignore b/.gitignore index 78379d4bf0..b50369e075 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,7 @@ /sw/logalizer/ivy_example /sw/logalizer/motor_bench /sw/logalizer/tmclient +/sw/logalizer/openlog2tlm # /sw/simulator/ /sw/simulator/gaia diff --git a/BUGS b/BUGS index 1cc0f35ac7..ff03a58fd4 100644 --- a/BUGS +++ b/BUGS @@ -1,2 +1,3 @@ We count on your for finding them +Please see the bug/issue tracker on https://github.com/paparazzi/paparazzi/issues \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index ed5b36cc2c..0000000000 --- a/README +++ /dev/null @@ -1,100 +0,0 @@ -# Paparazzi $Id$ -# Copyright (C) 2003-2010 The Paparazzi Team -# -# 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. - - -Intro ------ - -Paparazzi is an attempt to develop a free software Unmanned (Air) Vehicle System. - As of today the system is being used successfuly by a number of hobyists, universities and companies all over the world, on vehicle of various size ( 100g to 25Kg ) and of various nature ( fixed wing, rotorcrafts, boats and surface vehicles). - -Up to date informations are available from the wiki website - - http://paparazzi.enac.fr - -and from the mailing list (http://savannah.nongnu.org/mail/?group=paparazzi) -and the IRC channel (freenode, #paparazzi). - -Directories quick and dirty description: ---------------------------------------- - -conf: the configuration directory (airframe, radio, ... descriptions). - -data: where to put read-only data (e.g. maps, terrain elevation files, icons) - -sw: software (onboard, ground station, simulation, ...) - -var: products of compilation, cache for the map tiles, ... - -debian: Debian packaging control files - - -Required Software ------------------ - -Installation is described in the wiki (paparazzi.enac.fr/wiki/Installation). -Main requirements include - - OCaml (ocaml.org), xml-light library (http://tech.motion-twin.com/xmllight) - - gcc, GTK2, Glib2, libgnomecanvas, libxml2 - - ARM7 micro-controller development environnment (gcc, loader, libc, binutils) - - ... - -For Debian or Ubuntu users, required packages are available at - - http://paparazzi.enac.fr/debian - - - - "paparazzi-dev" will provide everything needed to compile and run the ground segment and the simulator. If something is missing, please report it. - - "paparazzi-arm7" is required to compile the code for LPC21 based boards ( tiny, twog, booz, etc). - - "paparazzi-stm32" is needed for building code for STM32 based boards (lisa/L, lisa/M) - - "paparazzi-omap" is needed for building code for the optional Gumstix Overo module available on lisa/L - - - "paparazzi-jsbsim" is needed for using jsbsim as flight dynamic model for the simulator. - -Compilation and demo simulation -------------------------------- - - 1) type "make" in the top directory to compile all the libraries and tools. - - 2) "./paparazzi" to run the Paparazzi Center - - 3) Select the "Microjet" aircraft in the upper-left A/C -combo box. Select "sim" from upper-middle "target" combo box. Click -"Build". When the compilation is finished, select "Simulation" from -the upper-right session combo box and click "Execute". - - 4) In the GCS, wait about 10s for the aircraft to be in the "Holding -point" navigation block. Switch to the "Takeoff" block (lower-left -blue airway button in the strip). Takeoff with the green launch button. - -Uploading of the embedded software ----------------------------------- - - 1) Power the flight controller board while it is connected to the PC with -the USB cable. - - 2) From the Paparazzi center, select the "ap" target, and click "Upload". - - -Flight -------------------------------------- - - 1) From the Paparazzi Center, select the flight session and ... do -the same than in simulation ! diff --git a/README.md b/README.md new file mode 100644 index 0000000000..8400e0d98a --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +Paparazzi UAS +============= + +Paparazzi is an attempt to develop a free software Unmanned (Air) Vehicle System. + As of today the system is being used successfuly by a number of hobyists, universities and companies all over the world, on vehicle of various size ( 100g to 25Kg ) and of various nature ( fixed wing, rotorcrafts, boats and surface vehicles). + +Up to date information is available in the wiki http://paparazzi.enac.fr + +and from the mailing list [paparazzi-devel@nongnu.org] (http://savannah.nongnu.org/mail/?group=paparazzi) +and the IRC channel (freenode, #paparazzi). + + +Required Software +----------------- + +Installation is described in the wiki (http://paparazzi.enac.fr/wiki/Installation). + +For Ubuntu users, required packages are available in the [paparazzi-uav PPA] (https://launchpad.net/~paparazzi-uav/+archive/ppa), +Debian users can use http://paparazzi.enac.fr/debian + + +- **paparazzi-dev** is the meta-package that depends on everything needed to compile and run the ground segment and the simulator. +- **paparazzi-arm-multilib** ARM cross-compiling toolchain for LPC21 and STM32 based boards. +- **paparazzi-omap** toolchain for the optional Gumstix Overo module available on lisa/L. +- **paparazzi-jsbsim** is needed for using JSBSim as flight dynamic model for the simulator. + + +Directories quick and dirty description: +---------------------------------------- + +_conf_: the configuration directory (airframe, radio, ... descriptions). + +_data_: where to put read-only data (e.g. maps, terrain elevation files, icons) + +_doc_: documentation (diagrams, manual source files, ...) + +_sw_: software (onboard, ground station, simulation, ...) + +_var_: products of compilation, cache for the map tiles, ... + + +Compilation and demo simulation +------------------------------- + +1. type "make" in the top directory to compile all the libraries and tools. + +2. "./paparazzi" to run the Paparazzi Center + +3. Select the "Microjet" aircraft in the upper-left A/C combo box. + Select "sim" from upper-middle "target" combo box. Click "Build". + When the compilation is finished, select "Simulation" from + the upper-right session combo box and click "Execute". + +4. In the GCS, wait about 10s for the aircraft to be in the "Holding point" navigation block. + Switch to the "Takeoff" block (lower-left blue airway button in the strip). + Takeoff with the green launch button. + +Uploading of the embedded software +---------------------------------- + +1. Power the flight controller board while it is connected to the PC with the USB cable. + +2. From the Paparazzi center, select the "ap" target, and click "Upload". + + +Flight +------ + +1. From the Paparazzi Center, select the flight session and ... do the same than in simulation ! \ No newline at end of file diff --git a/conf/airframes/TU_Delft/yapa_xsens.xml b/conf/airframes/CDW/LisaAspirin2.xml similarity index 65% rename from conf/airframes/TU_Delft/yapa_xsens.xml rename to conf/airframes/CDW/LisaAspirin2.xml index daf296a3c2..d79308e98b 100644 --- a/conf/airframes/TU_Delft/yapa_xsens.xml +++ b/conf/airframes/CDW/LisaAspirin2.xml @@ -1,15 +1,15 @@ - + - - - + + + @@ -28,53 +28,58 @@ -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - + + - - - + + +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
@@ -88,11 +93,6 @@
-
- - -
-
@@ -177,40 +177,62 @@ - - - - + - - - - + --> + + + - + - - + + + + + + + + + + + + + + + + + + + + - + @@ -218,9 +240,10 @@ - + + diff --git a/conf/airframes/CDW/yapa3_aspirin2.xml b/conf/airframes/CDW/yapa3_aspirin2.xml new file mode 100644 index 0000000000..7696df9c4a --- /dev/null +++ b/conf/airframes/CDW/yapa3_aspirin2.xml @@ -0,0 +1,274 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ +
+ + + + + + + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/conf/airframes/ENAC/fixed-wing/twinjet2.xml b/conf/airframes/ENAC/fixed-wing/twinjet2.xml index 959a400c62..a2c9fe7535 100644 --- a/conf/airframes/ENAC/fixed-wing/twinjet2.xml +++ b/conf/airframes/ENAC/fixed-wing/twinjet2.xml @@ -14,10 +14,10 @@ - + @@ -33,7 +33,7 @@ - + @@ -217,103 +217,4 @@
- -
diff --git a/conf/airframes/ENAC/quadrotor/blender.xml b/conf/airframes/ENAC/quadrotor/blender.xml index c1682f0477..7be545c03f 100644 --- a/conf/airframes/ENAC/quadrotor/blender.xml +++ b/conf/airframes/ENAC/quadrotor/blender.xml @@ -1,11 +1,11 @@ - + @@ -22,13 +22,13 @@ - - - + + + @@ -48,17 +48,11 @@ - - - - - - + @@ -67,20 +61,15 @@ - + +
- - - -
- - +
diff --git a/conf/airframes/ENAC/quadrotor/navgo.xml b/conf/airframes/ENAC/quadrotor/navgo.xml index a42bd6d411..a02481fe70 100644 --- a/conf/airframes/ENAC/quadrotor/navgo.xml +++ b/conf/airframes/ENAC/quadrotor/navgo.xml @@ -21,7 +21,6 @@ - @@ -30,17 +29,17 @@ - - - - + + + + - - + + @@ -73,68 +72,34 @@
- - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
@@ -149,7 +114,9 @@
- + + +
@@ -220,8 +187,8 @@ - - + + @@ -268,11 +235,9 @@
- - - +
diff --git a/conf/airframes/TU_Delft/EasyStartPanTiltCHIMU_SPI.xml b/conf/airframes/TU_Delft/EasyStartPanTiltCHIMU_SPI.xml deleted file mode 100644 index 96d2fce242..0000000000 --- a/conf/airframes/TU_Delft/EasyStartPanTiltCHIMU_SPI.xml +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- - -
- -
- - - - - - - - - -
- -
- - - -
- -
- - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - -
- -
- - - - - - - - -
- -
- - - - - - - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/conf/airframes/TU_Delft/MicrojetBR.xml b/conf/airframes/TU_Delft/MicrojetBR.xml deleted file mode 100644 index 117bc78989..0000000000 --- a/conf/airframes/TU_Delft/MicrojetBR.xml +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- -
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - -
- -
- - - - - -
- -
- - - - - - - - - -
- - -
- - - - -
- -
- - - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/conf/airframes/TU_Delft/MicrojetBRimu.xml b/conf/airframes/TU_Delft/MicrojetBRimu.xml deleted file mode 100644 index 681291c9d6..0000000000 --- a/conf/airframes/TU_Delft/MicrojetBRimu.xml +++ /dev/null @@ -1,307 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - -
- - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- - -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- -
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - -
- -
- - - - - -
- -
- - - - - - - - - -
- - -
- - - - -
- -
- - - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/conf/airframes/TU_Delft/MicrojetCDW.xml b/conf/airframes/TU_Delft/MicrojetCDW.xml deleted file mode 100644 index a778aeb5ff..0000000000 --- a/conf/airframes/TU_Delft/MicrojetCDW.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - -
- - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- - -
- -
- - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - -
- -
- - - - - - - - -
- -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/conf/airframes/TU_Delft/Trip50A.xml b/conf/airframes/TU_Delft/Trip50A.xml deleted file mode 100644 index a37429aeb5..0000000000 --- a/conf/airframes/TU_Delft/Trip50A.xml +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - -
- - -
- - - - - - - - - -
- -
- - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - -
- -
- - - - -
- -
- -
- - -CONFIG = \"tiny_sense.h\" - -include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile - -FLASH_MODE=IAP - -ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DUSE_LED -DTIME_LED=2 -ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c - -ap.srcs += commands.c - -ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017 -ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c - -ap.CFLAGS += -DRADIO_CONTROL -ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c - -#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B57600 -#ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c xbee.c - -#TRANSPARENT -#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -#DDATALINK=PPRZ -DUART1_BAUD=B9600 -#ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c pprz_transport.c - -# Maxstream API protocol -ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B9600 -ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c xbee.c - -ap.CFLAGS += -DINTER_MCU -ap.srcs += inter_mcu.c - -ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 -DUSE_ADC_4 -DUSE_ADC_5 -DUSE_GYRO -DIDG300 -ap.srcs += $(SRC_ARCH)/adc_hw.c - -ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART0 -DGPS_LINK=Uart0 -DUART0_BAUD=B38400 -DGPS_USE_LATLONG -ap.srcs += gps_ubx.c gps.c latlong.c - -ap.CFLAGS += -DUSE_INFRARED -DALT_KALMAN -DWIND_INFO -DWIND_INFO_RET -DSTRONG_WIND -ap.srcs += infrared.c estimator.c gyro.c - -ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM -ap.srcs += subsystems/nav.c fw_h_ctl.c fw_v_ctl.c - -ap.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c - -#ap.srcs += baro_bmp.c $(SRC_ARCH)/i2c_hw.c i2c.c -#ap.CFLAGS += -DUSE_I2C0 -DUSE_BARO_BMP -DBARO_BMP_ACCEL - -# Config for SITL simulation -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile -sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -sim.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c - -sim.srcs += joystick.c -sim.CFLAGS += -DUSE_JOYSTICK - - - -
diff --git a/conf/airframes/TU_Delft/Trip50B.xml b/conf/airframes/TU_Delft/Trip50B.xml deleted file mode 100644 index a95827c333..0000000000 --- a/conf/airframes/TU_Delft/Trip50B.xml +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- -
- - -
- -
- - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - -
- - -
- - - - - - - - - -
- -
- - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - -
- -
- - - - -
- -
- -
- - -CONFIG = \"tiny_sense.h\" - -include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile - -FLASH_MODE=IAP - -ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DUSE_LED -DTIME_LED=2 -ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c - -ap.srcs += commands.c - -ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017 -ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c - -ap.CFLAGS += -DRADIO_CONTROL -ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c - -#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B57600 -#ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c xbee.c - -#TRANSPARENT -#ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DPPRZ_UART=Uart1 -#DDATALINK=PPRZ -DUART1_BAUD=B9600 -#ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c pprz_transport.c - -# Maxstream API protocol -ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DDOWNLINK_FBW_DEVICE=Uart1 -DDOWNLINK_AP_DEVICE=Uart1 -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B9600 -ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c xbee.c - -ap.CFLAGS += -DINTER_MCU -ap.srcs += inter_mcu.c - -ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 -DUSE_ADC_4 -DUSE_ADC_5 -DUSE_GYRO -DIDG300 -ap.srcs += $(SRC_ARCH)/adc_hw.c - -ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART0 -DGPS_LINK=Uart0 -DUART0_BAUD=B38400 -DGPS_USE_LATLONG -ap.srcs += gps_ubx.c gps.c latlong.c - -ap.CFLAGS += -DUSE_INFRARED -DALT_KALMAN -DWIND_INFO -DWIND_INFO_RET -DSTRONG_WIND -ap.srcs += infrared.c estimator.c gyro.c - -ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM -ap.srcs += subsystems/nav.c fw_h_ctl.c fw_v_ctl.c - -ap.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c - -ap.srcs += baro_bmp.c $(SRC_ARCH)/i2c_hw.c i2c.c -ap.CFLAGS += -DUSE_I2C0 -DUSE_BARO_BMP -DBARO_BMP_ACCEL - -# camera control -ap.CFLAGS += -DCAM -DMOBILE_CAM -DPOINT_CAM -DPOINT_CAM_PITCH_ROLL -ap.srcs += cam.c point.c - -# Config for SITL simulation -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile -sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -sim.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c - -sim.srcs += joystick.c -sim.CFLAGS += -DUSE_JOYSTICK - -sim.CFLAGS += -DCAM -DMOBILE_CAM -DPOINT_CAM -DPOINT_CAM_PITCH_ROLL -# -DTEST_CAM -sim.srcs += cam.c point.c -sim.srcs += subsystems/navigation/bomb.c - - - - - -
diff --git a/conf/airframes/TU_Delft/holiday50.xml b/conf/airframes/TU_Delft/holiday50.xml deleted file mode 100644 index 5a2724fbdb..0000000000 --- a/conf/airframes/TU_Delft/holiday50.xml +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- -
- - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - -
- -
- - - - - -
- - -
- - - - - - - - -
- -
- - - - -
- -
- - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - -
- -
- - - - - - - - -
- -
- - - - -
- -
- -
- - -include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile - -FLASH_MODE=IAP - -# main files (including the 60Hz timing) -ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=\"tiny_1_1.h\" -DUSE_LED -DTIME_LED=1 -ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c - -# Command allocation and Radio Mixers -ap.srcs += commands.c - -# Actuators: tiny1.1 board has 4015_MAT servos -ap.CFLAGS += -DACTUATORS=\"servos_4015_MAT_hw.h\" -DSERVOS_4015_MAT -ap.srcs += $(SRC_ARCH)/servos_4015_MAT_hw.c actuators.c - -# 35MHz Radio -ap.CFLAGS += -DRADIO_CONTROL -ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c - -# Paparazzi protocol on UART0 at 57600 -ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B57600 -ap.srcs += downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c pprz_transport.c - -# communication from FBW and AP -ap.CFLAGS += -DINTER_MCU -ap.srcs += inter_mcu.c - - -ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_3 -DUSE_ADC_4 -DUSE_ADC_5 -ap.srcs += $(SRC_ARCH)/adc_hw.c - -# USE_GPS on UART1 -ap.CFLAGS += -DUSE_GPS -DUBX -DUSE_UART1 -DGPS_LINK=Uart1 -DUART1_BAUD=B38400 -#ap.CFLAGS += -DGPS_CONFIGURE -DGPS_BAUD=38400 -ap.srcs += gps_ubx.c gps.c latlong.c - -ap.CFLAGS += -DUSE_INFRARED -ap.srcs += infrared.c estimator.c - -ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -ap.srcs += subsystems/nav.c fw_h_ctl.c fw_v_ctl.c -ap.CFLAGS += -DTUNE_AGRESSIVE_CLIMB - -ap.CFLAGS += -DUSE_GYRO -DADXRS150 -ap.srcs += gyro.c - -ap.CFLAGS += -DUSE_MODULES - -ap.srcs += subsystems/navigation/nav_line.c subsystems/navigation/nav_survey_rectangle.c -ap.srcs += subsystems/navigation/traffic_info.c - -# camera control -ap.CFLAGS += -DCAM -DMOBILE_CAM -DPOINT_CAM -DPOINT_CAM_PITCH_ROLL -# -DTEST_CAM -ap.srcs += cam.c point.c -# subsystems/navigation/traffic_info.c - -ap.CFLAGS += -DWIND_INFO -DSTRONG_WIND -ap.srcs += subsystems/navigation/bomb.c - -# Config for SITL simulation -include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile -sim.CFLAGS += -DBOARD_CONFIG=\"tiny_1_1.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN -DWIND_INFO -DSTRONG_WIND -sim.srcs += subsystems/navigation/nav_survey_rectangle.c subsystems/navigation/nav_line.c -sim.CFLAGS += -DTUNE_AGRESSIVE_CLIMB -# subsystems/navigation/traffic_info.c -sim.CFLAGS += -DUSE_MODULES - -sim.CFLAGS += -DCAM -DMOBILE_CAM -DPOINT_CAM -DPOINT_CAM_PITCH_ROLL -# -DTEST_CAM -sim.srcs += cam.c point.c -sim.srcs += subsystems/navigation/bomb.c - - -
diff --git a/conf/airframes/TU_Delft/skywalker.xml b/conf/airframes/TU_Delft/skywalker.xml deleted file mode 100644 index 6b7b00e008..0000000000 --- a/conf/airframes/TU_Delft/skywalker.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - -
- -
- - -
- -
- - - - - -
- -
- - -
- -
- - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - -
- -
- - - - - - - - -
- -
- - - - - - - -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/conf/airframes/TU_Delft/skywalkerfiber.xml b/conf/airframes/TU_Delft/skywalkerfiber.xml deleted file mode 100644 index a962c1f226..0000000000 --- a/conf/airframes/TU_Delft/skywalkerfiber.xml +++ /dev/null @@ -1,326 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - -
- -
- - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - - - - - -
- - - -
- - - - - - - - - - - - - - - - - -
- - -
- - - - - - - - -
- - -
- - - - - - - -
- - -
- - -
- -
diff --git a/conf/airframes/example_heli_lisam.xml b/conf/airframes/example_heli_lisam.xml new file mode 100644 index 0000000000..616a32ed0a --- /dev/null +++ b/conf/airframes/example_heli_lisam.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
diff --git a/conf/airframes/fraser_lisa_m_rotorcraft.xml b/conf/airframes/fraser_lisa_m_rotorcraft.xml new file mode 100644 index 0000000000..575f5f9b60 --- /dev/null +++ b/conf/airframes/fraser_lisa_m_rotorcraft.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+ +
+ + + +
+ +
+ +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+ +
diff --git a/conf/airframes/logger_sd.xml b/conf/airframes/logger_sd.xml index 68ed0a2db5..7042581ce5 100644 --- a/conf/airframes/logger_sd.xml +++ b/conf/airframes/logger_sd.xml @@ -37,6 +37,7 @@ + diff --git a/conf/airframes/microjet_example.xml b/conf/airframes/microjet_example.xml index ec56ab56e9..62174e71f2 100644 --- a/conf/airframes/microjet_example.xml +++ b/conf/airframes/microjet_example.xml @@ -190,6 +190,7 @@ + diff --git a/conf/autopilot/logger.makefile b/conf/autopilot/logger.makefile index 680131df66..f6e87ecea4 100644 --- a/conf/autopilot/logger.makefile +++ b/conf/autopilot/logger.makefile @@ -34,10 +34,10 @@ ifeq ($(ARCH), lpc21) ap.CFLAGS += -DUSE_LED ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c $(SRC_FIRMWARE)/main_logger.c -#choose one -ap.CFLAGS += -DLOG_XBEE -#ap.CFLAGS += -DLOG_PPRZ - +# PPRZ message format is default +ifndef LOG_MSG_FMT +LOG_MSG_FMT = LOG_PPRZ +endif #set the speed ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=$(UART0_BAUD) -DUSE_UART0_RX_ONLY @@ -50,6 +50,9 @@ ap.srcs += mcu.c #set SPI interface for SD card (0 or 1) ap.CFLAGS += -DHW_ENDPOINT_LPC2000_SPINUM=$(SPI_CHANNEL) +#message format pprz/xbee +ap.CFLAGS += -D$(LOG_MSG_FMT) + #LPC2148 USB hw module needs at least 18MHz PCLK ap.CFLAGS += -DUSE_USB_HIGH_PCLK diff --git a/conf/autopilot/rotorcraft.makefile b/conf/autopilot/rotorcraft.makefile index c8e4b37502..d7aec02ce9 100644 --- a/conf/autopilot/rotorcraft.makefile +++ b/conf/autopilot/rotorcraft.makefile @@ -145,9 +145,11 @@ else ifeq ($(BOARD), lisa_l) ap.CFLAGS += -DUSE_I2C2 else ifeq ($(BOARD), navgo) ap.CFLAGS += -DROTORCRAFT_BARO_LED=$(BARO_LED) -ap.CFLAGS += -DUSE_I2C1 -ap.CFLAGS += -DADS1114_I2C_DEVICE=i2c1 -ap.srcs += peripherals/ads1114.c +include $(CFG_ROTORCRAFT)/spi.makefile +ap.CFLAGS += -DUSE_SPI_SLAVE0 +ap.CFLAGS += -DSPI_NO_UNSELECT_SLAVE +ap.CFLAGS += -DSPI_MASTER +ap.srcs += peripherals/mcp355x.c endif # @@ -195,6 +197,7 @@ endif ap.srcs += $(SRC_FIRMWARE)/autopilot.c ap.srcs += $(SRC_FIRMWARE)/stabilization.c +ap.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_none.c ap.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_rate.c ap.CFLAGS += -DUSE_NAVIGATION diff --git a/conf/autopilot/subsystems/fixedwing/gps_xsens.makefile b/conf/autopilot/subsystems/fixedwing/gps_xsens.makefile deleted file mode 100644 index 0d5dba7efd..0000000000 --- a/conf/autopilot/subsystems/fixedwing/gps_xsens.makefile +++ /dev/null @@ -1,9 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- - -# XSens Mti-G - - -# ap.CFLAGS += -DGPS - -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c - diff --git a/conf/autopilot/subsystems/fixedwing/ins_xsens.makefile b/conf/autopilot/subsystems/fixedwing/ins_xsens.makefile new file mode 100644 index 0000000000..2e3e92f26c --- /dev/null +++ b/conf/autopilot/subsystems/fixedwing/ins_xsens.makefile @@ -0,0 +1,79 @@ +# Hey Emacs, this is a -*- makefile -*- + +# XSens Mti-G + +# +# +# + + + +######################################### +## ATTITUDE + +ifeq ($(TARGET), ap) + +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# + +# ImuEvent -> XSensEvent +ap.CFLAGS += -DUSE_AHRS +ap.CFLAGS += -DIMU_TYPE_H=\"modules/ins/ins_xsens.h\" + +# AHRS Results +ap.CFLAGS += -DAHRS_TYPE_H=\"modules/ins/ins_xsens.h\" +ap.CFLAGS += -DINS_MODULE_H=\"modules/ins/ins_xsens.h\" + +ap.CFLAGS += -DUSE_UART$(XSENS_UART_NR) +ap.CFLAGS += -DINS_LINK=Uart$(XSENS_UART_NR) +ap.CFLAGS += -DUART$(XSENS_UART_NR)_BAUD=B230400 +ap.CFLAGS += -DUSE_GPS_XSENS +ap.CFLAGS += -DUSE_GPS_XSENS_RAW_DATA +ap.CFLAGS += -DGPS_NB_CHANNELS=16 +ap.CFLAGS += -DXSENS_OUTPUT_MODE=0x1836 +ap.srcs += $(SRC_MODULES)/ins/ins_xsens.c +ap.CFLAGS += -DAHRS_TRIGGERED_ATTITUDE_LOOP + + +endif + + +ifeq ($(TARGET), sim) + +sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\" +sim.CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR + +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c + +endif + +######################################### +## GPS + +# ap.CFLAGS += -DGPS + +$(TARGET).srcs += $(SRC_SUBSYSTEMS)/gps.c + +sim.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG +sim.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sim.h\" +sim.srcs += $(SRC_SUBSYSTEMS)/gps/gps_sim.c + + + + + diff --git a/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile b/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile index 00b92d675e..52f040875e 100644 --- a/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile +++ b/conf/autopilot/subsystems/rotorcraft/fdm_nps.makefile @@ -115,6 +115,8 @@ sim.srcs += $(SRC_FIRMWARE)/autopilot.c sim.srcs += $(SRC_FIRMWARE)/stabilization.c sim.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_rate.c +sim.srcs += $(SRC_FIRMWARE)/stabilization/stabilization_none.c + NUM_TYPE=integer #NUM_TYPE=float diff --git a/conf/autopilot/subsystems/shared/imu_navgo.makefile b/conf/autopilot/subsystems/shared/imu_navgo.makefile index e10385bbc3..2a24fbf0d0 100644 --- a/conf/autopilot/subsystems/shared/imu_navgo.makefile +++ b/conf/autopilot/subsystems/shared/imu_navgo.makefile @@ -12,10 +12,12 @@ IMU_NAVGO_CFLAGS += -DUSE_I2C1 -DI2C1_SCLL=25 -DI2C1_SCLH=25 IMU_NAVGO_CFLAGS += -DITG3200_I2C_DEVICE=$(IMU_NAVGO_I2C_DEVICE) IMU_NAVGO_CFLAGS += -DITG3200_I2C_ADDR=ITG3200_ADDR_ALT IMU_NAVGO_CFLAGS += -DITG3200_SMPLRT_DIV=1 +IMU_NAVGO_CFLAGS += -DITG3200_DLFP_CFG=5 IMU_NAVGO_SRCS += peripherals/itg3200.c IMU_NAVGO_CFLAGS += -DADXL345_I2C_DEVICE=$(IMU_NAVGO_I2C_DEVICE) IMU_NAVGO_CFLAGS += -DADXL345_I2C_ADDR=ADXL345_ADDR_ALT +IMU_NAVGO_CFLAGS += -DADXL345_BW_RATE=0x8 IMU_NAVGO_SRCS += peripherals/adxl345.i2c.c IMU_NAVGO_CFLAGS += -DHMC58XX_I2C_DEVICE=$(IMU_NAVGO_I2C_DEVICE) diff --git a/conf/conf.xml.example b/conf/conf.xml.example index 69d70d82b6..aeebdc0bf6 100644 --- a/conf/conf.xml.example +++ b/conf/conf.xml.example @@ -99,5 +99,15 @@ settings="settings/tuning.xml settings/infrared.xml" gui_color="red" /> + diff --git a/conf/messages.xml b/conf/messages.xml index fd43ca95d8..b4a3661036 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -941,7 +941,9 @@ - + + + diff --git a/conf/modules/ins_xsens_MTiG_fixedwing.xml b/conf/modules/ins_xsens_MTiG_fixedwing.xml deleted file mode 100644 index 6ff0911806..0000000000 --- a/conf/modules/ins_xsens_MTiG_fixedwing.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -
- -
- - - - - - - - - - - - - - - - -
- diff --git a/conf/modules/nav_catapult.xml b/conf/modules/nav_catapult.xml new file mode 100644 index 0000000000..1421af27ea --- /dev/null +++ b/conf/modules/nav_catapult.xml @@ -0,0 +1,14 @@ + + + +
+ +
+ + + + + + +
+ diff --git a/conf/modules/openlog.xml b/conf/modules/openlog.xml new file mode 100755 index 0000000000..5f23717266 --- /dev/null +++ b/conf/modules/openlog.xml @@ -0,0 +1,13 @@ + + + +
+ +
+ + + + + +
+ diff --git a/conf/radios/R6107SP_7ch_xyz.xml b/conf/radios/R6107SP_7ch_xyz.xml new file mode 100644 index 0000000000..75c4b48190 --- /dev/null +++ b/conf/radios/R6107SP_7ch_xyz.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + diff --git a/conf/settings/tuning_ctl_new.xml b/conf/settings/tuning_ctl_new.xml index 38f5e825fe..22f9080376 100644 --- a/conf/settings/tuning_ctl_new.xml +++ b/conf/settings/tuning_ctl_new.xml @@ -42,6 +42,8 @@ + + diff --git a/conf/settings/tuning_ins.xml b/conf/settings/tuning_ins.xml index 0aa57141ef..1f9f978604 100644 --- a/conf/settings/tuning_ins.xml +++ b/conf/settings/tuning_ins.xml @@ -57,7 +57,9 @@ - + + + @@ -67,6 +69,9 @@ + + + diff --git a/sw/README b/sw/README deleted file mode 100644 index 0bc10093a6..0000000000 --- a/sw/README +++ /dev/null @@ -1,21 +0,0 @@ -# -# $Id$ -# Copyright (C) 2003 Pascal Brisset Antoine Drouin -# -# 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. -# diff --git a/sw/airborne/ap_downlink.h b/sw/airborne/ap_downlink.h index 85ef723bc2..cf830eca10 100644 --- a/sw/airborne/ap_downlink.h +++ b/sw/airborne/ap_downlink.h @@ -148,18 +148,6 @@ #define PERIODIC_SEND_SEGMENT(_chan) if (nav_in_segment) { DOWNLINK_SEND_SEGMENT(_chan, &nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2); } #ifdef IMU_TYPE_H -# include "subsystems/imu.h" -# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) { DOWNLINK_SEND_IMU_ACCEL_RAW(_chan, &imu.accel_unscaled.x, &imu.accel_unscaled.y, &imu.accel_unscaled.z)} -# define PERIODIC_SEND_IMU_GYRO_RAW(_chan) { DOWNLINK_SEND_IMU_GYRO_RAW(_chan, &imu.gyro_unscaled.p, &imu.gyro_unscaled.q, &imu.gyro_unscaled.r)} -# define PERIODIC_SEND_IMU_MAG_RAW(_chan) { DOWNLINK_SEND_IMU_MAG_RAW(_chan, &imu.mag_unscaled.x, &imu.mag_unscaled.y, &imu.mag_unscaled.z)} -# define PERIODIC_SEND_IMU_ACCEL(_chan) { struct FloatVect3 accel_float; ACCELS_FLOAT_OF_BFP(accel_float, imu.accel); DOWNLINK_SEND_IMU_ACCEL(_chan, &accel_float.x, &accel_float.y, &accel_float.z)} -# define PERIODIC_SEND_IMU_GYRO(_chan) { struct FloatRates gyro_float; RATES_FLOAT_OF_BFP(gyro_float, imu.gyro); DOWNLINK_SEND_IMU_GYRO(_chan, &gyro_float.p, &gyro_float.q, &gyro_float.r)} -# ifdef USE_MAGNETOMETER -# define PERIODIC_SEND_IMU_MAG(_chan) { struct FloatVect3 mag_float; MAGS_FLOAT_OF_BFP(mag_float, imu.mag); DOWNLINK_SEND_IMU_MAG(_chan, &mag_float.x, &mag_float.y, &mag_float.z)} -# else -# define PERIODIC_SEND_IMU_MAG(_chan) {} -# endif -#else # ifdef INS_MODULE_H # include "modules/ins/ins_module.h" # define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {} @@ -169,13 +157,25 @@ # define PERIODIC_SEND_IMU_ACCEL(_chan) { DOWNLINK_SEND_IMU_ACCEL(_chan, &ins_ax, &ins_ay, &ins_az)} # define PERIODIC_SEND_IMU_MAG(_chan) { DOWNLINK_SEND_IMU_MAG(_chan, &ins_mx, &ins_my, &ins_mz)} # else +# include "subsystems/imu.h" +# define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) { DOWNLINK_SEND_IMU_ACCEL_RAW(_chan, &imu.accel_unscaled.x, &imu.accel_unscaled.y, &imu.accel_unscaled.z)} +# define PERIODIC_SEND_IMU_GYRO_RAW(_chan) { DOWNLINK_SEND_IMU_GYRO_RAW(_chan, &imu.gyro_unscaled.p, &imu.gyro_unscaled.q, &imu.gyro_unscaled.r)} +# define PERIODIC_SEND_IMU_MAG_RAW(_chan) { DOWNLINK_SEND_IMU_MAG_RAW(_chan, &imu.mag_unscaled.x, &imu.mag_unscaled.y, &imu.mag_unscaled.z)} +# define PERIODIC_SEND_IMU_ACCEL(_chan) { struct FloatVect3 accel_float; ACCELS_FLOAT_OF_BFP(accel_float, imu.accel); DOWNLINK_SEND_IMU_ACCEL(_chan, &accel_float.x, &accel_float.y, &accel_float.z)} +# define PERIODIC_SEND_IMU_GYRO(_chan) { struct FloatRates gyro_float; RATES_FLOAT_OF_BFP(gyro_float, imu.gyro); DOWNLINK_SEND_IMU_GYRO(_chan, &gyro_float.p, &gyro_float.q, &gyro_float.r)} +# ifdef USE_MAGNETOMETER +# define PERIODIC_SEND_IMU_MAG(_chan) { struct FloatVect3 mag_float; MAGS_FLOAT_OF_BFP(mag_float, imu.mag); DOWNLINK_SEND_IMU_MAG(_chan, &mag_float.x, &mag_float.y, &mag_float.z)} +# else +# define PERIODIC_SEND_IMU_MAG(_chan) {} +# endif +# endif +#else # define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) {} # define PERIODIC_SEND_IMU_GYRO_RAW(_chan) {} # define PERIODIC_SEND_IMU_MAG_RAW(_chan) {} # define PERIODIC_SEND_IMU_ACCEL(_chan) {} # define PERIODIC_SEND_IMU_GYRO(_chan) {} # define PERIODIC_SEND_IMU_MAG(_chan) {} -# endif #endif #ifdef IMU_ANALOG diff --git a/sw/airborne/arch/lpc21/mcu_periph/spi_arch.c b/sw/airborne/arch/lpc21/mcu_periph/spi_arch.c index 5ec122bcb8..d7286e6dcd 100644 --- a/sw/airborne/arch/lpc21/mcu_periph/spi_arch.c +++ b/sw/airborne/arch/lpc21/mcu_periph/spi_arch.c @@ -193,7 +193,9 @@ void SPI1_ISR(void) { } if (bit_is_set(SSPMIS, RTMIS)) { /* Rx fifo is not empty and no receive took place in the last 32 bits period */ +#if !SPI_NO_UNSELECT_SLAVE SpiUnselectCurrentSlave(); +#endif SpiReceive(); SpiDisableRti(); SpiClearRti(); /* clear interrupt */ diff --git a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c index 8d69b3f9da..125b7350c8 100644 --- a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c +++ b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c @@ -13,6 +13,10 @@ static inline void i2c_reset_init(struct i2c_periph *p); #define I2C_BUSY 0x20 +// If a hard reset cannot free up SDA, SCL lines abort. Previously stm32 would hang +// when lines stuck i.e. no pullups on I2C lines +#define I2C_MAX_RESET_FAIL_COUNT 20 + #ifdef DEBUG_I2C #define SPURIOUS_INTERRUPT(_periph, _status, _event) { while(1); } #define OUT_OF_SYNC_STATE_MACHINE(_periph, _status, _event) { while(1); } @@ -355,6 +359,7 @@ static inline void i2c_error(struct i2c_periph *p) static inline void i2c_hard_reset(struct i2c_periph *p) { + uint8_t timeout_fails=0; I2C_TypeDef *regs = (I2C_TypeDef *) p->reg_addr; I2C_DeInit(p->reg_addr); @@ -366,10 +371,13 @@ static inline void i2c_hard_reset(struct i2c_periph *p) GPIO_SetBits(GPIOB, p->scl_pin | p->sda_pin); GPIO_Init(GPIOB, &GPIO_InitStructure); - while(GPIO_ReadInputDataBit(GPIOB, p->sda_pin) == Bit_RESET) { + while((GPIO_ReadInputDataBit(GPIOB, p->sda_pin) == Bit_RESET) && timeout_fails < I2C_MAX_RESET_FAIL_COUNT) { // Raise SCL, wait until SCL is high (in case of clock stretching) GPIO_SetBits(GPIOB, p->scl_pin); - while (GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET); + while ((GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET) && timeout_fails < I2C_MAX_RESET_FAIL_COUNT) { + i2c_delay(); + timeout_fails++; + } i2c_delay(); // Lower SCL, wait @@ -379,6 +387,7 @@ static inline void i2c_hard_reset(struct i2c_periph *p) // Raise SCL, wait GPIO_SetBits(GPIOB, p->scl_pin); i2c_delay(); + timeout_fails++; } // Generate a start condition followed by a stop condition @@ -391,10 +400,17 @@ static inline void i2c_hard_reset(struct i2c_periph *p) // Raise both SCL and SDA and wait for SCL high (in case of clock stretching) GPIO_SetBits(GPIOB, p->scl_pin | p->sda_pin); - while (GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET); + while (GPIO_ReadInputDataBit(GPIOB, p->scl_pin) == Bit_RESET && timeout_fails < I2C_MAX_RESET_FAIL_COUNT) { + i2c_delay(); + timeout_fails++; + } // Wait for SDA to be high - while (GPIO_ReadInputDataBit(GPIOB, p->sda_pin) != Bit_SET); + while (GPIO_ReadInputDataBit(GPIOB, p->sda_pin) != Bit_SET && timeout_fails < I2C_MAX_RESET_FAIL_COUNT) + { + i2c_delay(); + timeout_fails++; + } // SCL and SDA should be high at this point, bus should be free // Return the GPIO pins to the alternate function diff --git a/sw/airborne/boards/lisa_l/baro_board.c b/sw/airborne/boards/lisa_l/baro_board.c index 8f1bb5421e..ef0a295885 100644 --- a/sw/airborne/boards/lisa_l/baro_board.c +++ b/sw/airborne/boards/lisa_l/baro_board.c @@ -82,7 +82,14 @@ void baro_periodic(void) { void baro_board_send_config_abs(void) { +#ifndef BARO_LOW_GAIN +#pragma message "Using High LisaL Baro Gain: Do not use below 1000hPa" baro_board_write_to_register(BARO_ABS_ADDR, 0x01, 0x86, 0x83); +#else +#pragma message "Using Low LisaL Baro Gain, capable of measuring below 1000hPa or more" + //config register should be 0x84 in low countries, or 0x86 in normal countries + baro_board_write_to_register(BARO_ABS_ADDR, 0x01, 0x84, 0x83); +#endif } void baro_board_send_config_diff(void) { diff --git a/sw/airborne/boards/navgo/baro_board.c b/sw/airborne/boards/navgo/baro_board.c index 87ac9fdbe7..b42b69ee3a 100644 --- a/sw/airborne/boards/navgo/baro_board.c +++ b/sw/airborne/boards/navgo/baro_board.c @@ -27,57 +27,43 @@ #include "subsystems/sensors/baro.h" #include "led.h" +#include "mcu_periph/spi.h" /* Common Baro struct */ struct Baro baro; -/* Number of values to compute an offset at startup */ -#define OFFSET_NBSAMPLES_AVRG 300 -uint16_t offset_cnt; - -#ifdef USE_BARO_AS_ALTIMETER -/* Weight for offset IIR filter */ -#define OFFSET_FILTER 7 - -float baro_alt; -float baro_alt_offset; -#endif +/* Counter to init mcp355x at startup */ +#define STARTUP_COUNTER 200 +uint16_t startup_cnt; void baro_init( void ) { - ads1114_init(); + mcp355x_init(); + SpiSelectSlave0(); // never unselect this slave (continious conversion mode) baro.status = BS_UNINITIALIZED; baro.absolute = 0; baro.differential = 0; /* not handled on this board */ #ifdef ROTORCRAFT_BARO_LED LED_OFF(ROTORCRAFT_BARO_LED); #endif - offset_cnt = OFFSET_NBSAMPLES_AVRG; -#ifdef USE_BARO_AS_ALTIMETER - baro_alt = 0.; - baro_alt_offset = 0.; -#endif + startup_cnt = STARTUP_COUNTER; } void baro_periodic( void ) { if (baro.status == BS_UNINITIALIZED) { -#ifdef USE_BARO_AS_ALTIMETER - // IIR filter to compute an initial offset - baro_alt_offset = (OFFSET_FILTER * baro_alt_offset + (float)baro.absolute) / (OFFSET_FILTER + 1); -#endif - // decrease init counter - --offset_cnt; + // Run some loops to get correct readings from the adc + --startup_cnt; #ifdef ROTORCRAFT_BARO_LED LED_TOGGLE(ROTORCRAFT_BARO_LED); #endif - if (offset_cnt == 0) { + if (startup_cnt == 0) { baro.status = BS_RUNNING; #ifdef ROTORCRAFT_BARO_LED LED_ON(ROTORCRAFT_BARO_LED); #endif } } - // Read the ADC - ads1114_read(); + // Read the ADC (at 50/4 Hz, conversion time is 68 ms) + RunOnceEvery(4,mcp355x_read()); } diff --git a/sw/airborne/boards/navgo/baro_board.h b/sw/airborne/boards/navgo/baro_board.h index de705d46d0..250476b148 100644 --- a/sw/airborne/boards/navgo/baro_board.h +++ b/sw/airborne/boards/navgo/baro_board.h @@ -31,22 +31,16 @@ #include "std.h" -#include "peripherals/ads1114.h" - -#ifdef USE_BARO_AS_ALTIMETER -extern float baro_alt; -extern float baro_alt_offset; -#define BaroAltHandler() { baro_alt = BARO_SENS*(baro_alt_offset - (float)baro.absolute); } -#endif +#include "peripherals/mcp355x.h" #define BARO_FILTER_GAIN 5 #define BaroEvent(_b_abs_handler, _b_diff_handler) { \ - Ads1114Event(); \ - if (ads1114_data_available) { \ - baro.absolute = (baro.absolute + BARO_FILTER_GAIN*Ads1114GetValue()) / (BARO_FILTER_GAIN+1); \ + mcp355x_event(); \ + if (mcp355x_data_available) { \ + baro.absolute = (baro.absolute + BARO_FILTER_GAIN*mcp355x_data) / (BARO_FILTER_GAIN+1); \ _b_abs_handler(); \ - ads1114_data_available = FALSE; \ + mcp355x_data_available = FALSE; \ } \ } diff --git a/sw/airborne/boards/navgo/imu_navgo.c b/sw/airborne/boards/navgo/imu_navgo.c index b872219e9e..cf19cfefd6 100644 --- a/sw/airborne/boards/navgo/imu_navgo.c +++ b/sw/airborne/boards/navgo/imu_navgo.c @@ -103,7 +103,7 @@ void imu_navgo_event( void ) // If the itg3200 I2C transaction has succeeded: convert the data itg3200_event(); if (itg3200_data_available) { - RATES_COPY(imu.gyro_unscaled, itg3200_data); + RATES_ASSIGN(imu.gyro_unscaled, -itg3200_data.q, itg3200_data.p, itg3200_data.r); itg3200_data_available = FALSE; gyr_valid = TRUE; } @@ -119,7 +119,7 @@ void imu_navgo_event( void ) // HMC58XX event task hmc58xx_event(); if (hmc58xx_data_available) { - VECT3_ASSIGN(imu.mag_unscaled, -hmc58xx_data.x, -hmc58xx_data.y, hmc58xx_data.z); + VECT3_ASSIGN(imu.mag_unscaled, hmc58xx_data.x, hmc58xx_data.y, hmc58xx_data.z); hmc58xx_data_available = FALSE; mag_valid = TRUE; } diff --git a/sw/airborne/boards/navgo_1.0.h b/sw/airborne/boards/navgo_1.0.h index 17a6fbf118..3f1121dbbe 100644 --- a/sw/airborne/boards/navgo_1.0.h +++ b/sw/airborne/boards/navgo_1.0.h @@ -18,17 +18,17 @@ #define PCLK (CCLK / PBSD_VAL) /* Onboard LEDs */ -#define LED_1_BANK 1 -#define LED_1_PIN 25 +#define LED_1_BANK 0 +#define LED_1_PIN 22 #define LED_2_BANK 1 -#define LED_2_PIN 24 +#define LED_2_PIN 28 #define LED_3_BANK 1 -#define LED_3_PIN 23 +#define LED_3_PIN 29 #define LED_4_BANK 1 -#define LED_4_PIN 31 +#define LED_4_PIN 30 /* PPM : rc rx on P0.28 ( CAP0.2 ) */ #define PPM_PINSEL PINSEL1 @@ -45,19 +45,22 @@ /* battery */ /* allow to define ADC_CHANNEL_VSUPPLY in the airframe file*/ #ifndef ADC_CHANNEL_VSUPPLY -#define ADC_CHANNEL_VSUPPLY AdcBank1(3) -#ifndef USE_AD1 -#define USE_AD1 +#define ADC_CHANNEL_VSUPPLY AdcBank0(2) +#ifndef USE_AD0 +#define USE_AD0 #endif -#define USE_AD1_3 +#define USE_AD0_2 #endif -#define DefaultVoltageOfAdc(adc) (0.01837*adc) +#define DefaultVoltageOfAdc(adc) (0.017889*adc) /* SPI (SSP) */ #define SPI_SELECT_SLAVE0_PORT 0 #define SPI_SELECT_SLAVE0_PIN 20 +//#define SPI_SELECT_SLAVE1_PORT 1 +//#define SPI_SELECT_SLAVE1_PIN 19 + #define SPI1_DRDY_PINSEL PINSEL1 #define SPI1_DRDY_PINSEL_BIT 0 #define SPI1_DRDY_PINSEL_VAL 1 diff --git a/sw/airborne/firmwares/fixedwing/guidance/guidance_v.c b/sw/airborne/firmwares/fixedwing/guidance/guidance_v.c index 6d27c606a0..4af7e1c4c0 100644 --- a/sw/airborne/firmwares/fixedwing/guidance/guidance_v.c +++ b/sw/airborne/firmwares/fixedwing/guidance/guidance_v.c @@ -42,6 +42,8 @@ float v_ctl_altitude_setpoint; float v_ctl_altitude_pre_climb; float v_ctl_altitude_pgain; float v_ctl_altitude_error; +float v_ctl_altitude_pre_climb_correction; +float v_ctl_altitude_max_climb; /* inner loop */ float v_ctl_climb_setpoint; @@ -51,6 +53,8 @@ uint8_t v_ctl_auto_throttle_submode; /* "auto throttle" inner loop parameters */ float v_ctl_auto_throttle_cruise_throttle; float v_ctl_auto_throttle_nominal_cruise_throttle; +float v_ctl_auto_throttle_min_cruise_throttle; +float v_ctl_auto_throttle_max_cruise_throttle; float v_ctl_auto_throttle_climb_throttle_increment; float v_ctl_auto_throttle_pgain; float v_ctl_auto_throttle_igain; @@ -105,6 +109,11 @@ float v_ctl_auto_groundspeed_sum_err; #endif +#ifndef V_CTL_ALTITUDE_PRE_CLIMB_CORRECTION +#define V_CTL_ALTITUDE_PRE_CLIMB_CORRECTION 1.0f +#endif + + void v_ctl_init( void ) { /* mode */ v_ctl_mode = V_CTL_MODE_MANUAL; @@ -114,6 +123,8 @@ void v_ctl_init( void ) { v_ctl_altitude_pre_climb = 0.; v_ctl_altitude_pgain = V_CTL_ALTITUDE_PGAIN; v_ctl_altitude_error = 0.; + v_ctl_altitude_pre_climb_correction = V_CTL_ALTITUDE_PRE_CLIMB_CORRECTION; + v_ctl_altitude_max_climb = V_CTL_ALTITUDE_MAX_CLIMB; /* inner loops */ v_ctl_climb_setpoint = 0.; @@ -122,6 +133,8 @@ void v_ctl_init( void ) { /* "auto throttle" inner loop parameters */ v_ctl_auto_throttle_nominal_cruise_throttle = V_CTL_AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE; + v_ctl_auto_throttle_min_cruise_throttle = V_CTL_AUTO_THROTTLE_MIN_CRUISE_THROTTLE; + v_ctl_auto_throttle_max_cruise_throttle = V_CTL_AUTO_THROTTLE_MAX_CRUISE_THROTTLE; v_ctl_auto_throttle_cruise_throttle = v_ctl_auto_throttle_nominal_cruise_throttle; v_ctl_auto_throttle_climb_throttle_increment = V_CTL_AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT; @@ -195,8 +208,8 @@ void v_ctl_altitude_loop( void ) { v_ctl_altitude_error = estimator_z - v_ctl_altitude_setpoint; v_ctl_climb_setpoint = altitude_pgain_boost * v_ctl_altitude_pgain * v_ctl_altitude_error - + v_ctl_altitude_pre_climb; - BoundAbs(v_ctl_climb_setpoint, V_CTL_ALTITUDE_MAX_CLIMB); + + v_ctl_altitude_pre_climb * v_ctl_altitude_pre_climb_correction; + BoundAbs(v_ctl_climb_setpoint, v_ctl_altitude_max_climb); #ifdef AGR_CLIMB if ( v_ctl_climb_mode == V_CTL_CLIMB_MODE_AUTO_THROTTLE) { @@ -336,7 +349,7 @@ inline static void v_ctl_climb_auto_throttle_loop(void) { controlled_throttle = (err_airspeed + v_ctl_auto_airspeed_sum_err * v_ctl_auto_airspeed_igain) * v_ctl_auto_airspeed_pgain; // Done, set outputs - Bound(controlled_throttle, 0, V_CTL_AUTO_THROTTLE_MAX_CRUISE_THROTTLE); + Bound(controlled_throttle, 0, v_ctl_auto_throttle_max_cruise_throttle); f_throttle = controlled_throttle; nav_pitch = v_ctl_pitch_of_vz; v_ctl_throttle_setpoint = TRIM_UPPRZ(f_throttle * MAX_PPRZ); diff --git a/sw/airborne/firmwares/fixedwing/guidance/guidance_v.h b/sw/airborne/firmwares/fixedwing/guidance/guidance_v.h index dfcc49be94..a66d3c9d5e 100644 --- a/sw/airborne/firmwares/fixedwing/guidance/guidance_v.h +++ b/sw/airborne/firmwares/fixedwing/guidance/guidance_v.h @@ -47,6 +47,8 @@ extern float v_ctl_altitude_error; extern float v_ctl_altitude_setpoint; extern float v_ctl_altitude_pre_climb; extern float v_ctl_altitude_pgain; +extern float v_ctl_altitude_pre_climb_correction; +extern float v_ctl_altitude_max_climb; /* inner loop */ extern float v_ctl_climb_setpoint; @@ -61,6 +63,8 @@ extern uint8_t v_ctl_auto_throttle_submode; /* "auto throttle" inner loop parameters */ extern float v_ctl_auto_throttle_nominal_cruise_throttle; +extern float v_ctl_auto_throttle_min_cruise_throttle; +extern float v_ctl_auto_throttle_max_cruise_throttle; extern float v_ctl_auto_throttle_cruise_throttle; extern float v_ctl_auto_throttle_climb_throttle_increment; extern float v_ctl_auto_throttle_pgain; @@ -115,7 +119,7 @@ extern void v_ctl_throttle_slew( void ); #define guidance_v_SetCruiseThrottle(_v) { \ v_ctl_auto_throttle_cruise_throttle = (_v ? _v : v_ctl_auto_throttle_nominal_cruise_throttle); \ - Bound(v_ctl_auto_throttle_cruise_throttle, V_CTL_AUTO_THROTTLE_MIN_CRUISE_THROTTLE, V_CTL_AUTO_THROTTLE_MAX_CRUISE_THROTTLE); \ + Bound(v_ctl_auto_throttle_cruise_throttle, v_ctl_auto_throttle_min_cruise_throttle, v_ctl_auto_throttle_max_cruise_throttle); \ } #define guidance_v_SetAutoThrottleIgain(_v) { \ diff --git a/sw/airborne/firmwares/fixedwing/guidance/guidance_v_n.c b/sw/airborne/firmwares/fixedwing/guidance/guidance_v_n.c index 1cb63583c6..c651f4d975 100644 --- a/sw/airborne/firmwares/fixedwing/guidance/guidance_v_n.c +++ b/sw/airborne/firmwares/fixedwing/guidance/guidance_v_n.c @@ -52,6 +52,8 @@ uint8_t v_ctl_auto_throttle_submode; /* "auto throttle" inner loop parameters */ float v_ctl_auto_throttle_cruise_throttle; float v_ctl_auto_throttle_nominal_cruise_throttle; +float v_ctl_auto_throttle_min_cruise_throttle; +float v_ctl_auto_throttle_max_cruise_throttle; float v_ctl_auto_throttle_climb_throttle_increment; float v_ctl_auto_throttle_pgain; float v_ctl_auto_throttle_igain; @@ -128,6 +130,8 @@ void v_ctl_init( void ) { /* "auto throttle" inner loop parameters */ v_ctl_auto_throttle_nominal_cruise_throttle = V_CTL_AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE; v_ctl_auto_throttle_cruise_throttle = v_ctl_auto_throttle_nominal_cruise_throttle; + v_ctl_auto_throttle_min_cruise_throttle = V_CTL_AUTO_THROTTLE_MIN_CRUISE_THROTTLE; + v_ctl_auto_throttle_max_cruise_throttle = V_CTL_AUTO_THROTTLE_MAX_CRUISE_THROTTLE; v_ctl_auto_throttle_climb_throttle_increment = V_CTL_AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT; v_ctl_auto_throttle_pgain = V_CTL_AUTO_THROTTLE_PGAIN; v_ctl_auto_throttle_igain = V_CTL_AUTO_THROTTLE_IGAIN; diff --git a/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c b/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c index 1951252929..196dc528fe 100644 --- a/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c +++ b/sw/airborne/firmwares/rotorcraft/actuators/actuators_heli.c @@ -43,7 +43,9 @@ #endif #define Actuator(_x) actuators_pwm_values[_x] +#ifndef ChopServo #define ChopServo(x,a,b) Chop(x, a, b) +#endif #define ActuatorsCommit actuators_pwm_commit int32_t actuators_pwm_values[ACTUATORS_PWM_NB]; diff --git a/sw/airborne/firmwares/rotorcraft/autopilot.c b/sw/airborne/firmwares/rotorcraft/autopilot.c index 125937e453..17d33379ec 100644 --- a/sw/airborne/firmwares/rotorcraft/autopilot.c +++ b/sw/airborne/firmwares/rotorcraft/autopilot.c @@ -123,6 +123,9 @@ void autopilot_set_mode(uint8_t new_autopilot_mode) { autopilot_motors_on = FALSE; guidance_h_mode_changed(GUIDANCE_H_MODE_KILL); break; + case AP_MODE_RC_DIRECT: + guidance_h_mode_changed(GUIDANCE_H_MODE_RC_DIRECT); + break; case AP_MODE_RATE_DIRECT: case AP_MODE_RATE_Z_HOLD: guidance_h_mode_changed(GUIDANCE_H_MODE_RATE); @@ -154,6 +157,7 @@ void autopilot_set_mode(uint8_t new_autopilot_mode) { case AP_MODE_KILL: guidance_v_mode_changed(GUIDANCE_V_MODE_KILL); break; + case AP_MODE_RC_DIRECT: case AP_MODE_RATE_DIRECT: case AP_MODE_ATTITUDE_DIRECT: case AP_MODE_HOVER_DIRECT: diff --git a/sw/airborne/firmwares/rotorcraft/autopilot.h b/sw/airborne/firmwares/rotorcraft/autopilot.h index b2eda139d3..ad9bc6f23f 100644 --- a/sw/airborne/firmwares/rotorcraft/autopilot.h +++ b/sw/airborne/firmwares/rotorcraft/autopilot.h @@ -45,6 +45,7 @@ #define AP_MODE_HOVER_CLIMB 10 #define AP_MODE_HOVER_Z_HOLD 11 #define AP_MODE_NAV 12 +#define AP_MODE_RC_DIRECT 13 // Safety Pilot Direct Commands for helicopter direct control: appropriately chosen as mode "13" extern uint8_t autopilot_mode; diff --git a/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c b/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c index 2471d0f3a9..208f078656 100644 --- a/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c +++ b/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.c @@ -109,6 +109,10 @@ void guidance_h_mode_changed(uint8_t new_mode) { switch (new_mode) { + case GUIDANCE_H_MODE_RC_DIRECT: + stabilization_none_enter(); + break; + case GUIDANCE_H_MODE_RATE: stabilization_rate_enter(); break; @@ -137,6 +141,10 @@ void guidance_h_read_rc(bool_t in_flight) { switch ( guidance_h_mode ) { + case GUIDANCE_H_MODE_RC_DIRECT: + stabilization_none_read_rc(); + break; + case GUIDANCE_H_MODE_RATE: stabilization_rate_read_rc(); break; @@ -168,6 +176,10 @@ void guidance_h_read_rc(bool_t in_flight) { void guidance_h_run(bool_t in_flight) { switch ( guidance_h_mode ) { + case GUIDANCE_H_MODE_RC_DIRECT: + stabilization_none_run(in_flight); + break; + case GUIDANCE_H_MODE_RATE: stabilization_rate_run(in_flight); break; diff --git a/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.h b/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.h index 3ca5cab494..20a761d987 100644 --- a/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.h +++ b/sw/airborne/firmwares/rotorcraft/guidance/guidance_h.h @@ -29,11 +29,12 @@ #include "firmwares/rotorcraft/guidance/guidance_h_ref.h" -#define GUIDANCE_H_MODE_KILL 0 -#define GUIDANCE_H_MODE_RATE 1 -#define GUIDANCE_H_MODE_ATTITUDE 2 -#define GUIDANCE_H_MODE_HOVER 3 -#define GUIDANCE_H_MODE_NAV 4 +#define GUIDANCE_H_MODE_KILL 0 +#define GUIDANCE_H_MODE_RATE 1 +#define GUIDANCE_H_MODE_ATTITUDE 2 +#define GUIDANCE_H_MODE_HOVER 3 +#define GUIDANCE_H_MODE_NAV 4 +#define GUIDANCE_H_MODE_RC_DIRECT 5 extern uint8_t guidance_h_mode; diff --git a/sw/airborne/firmwares/rotorcraft/stabilization.c b/sw/airborne/firmwares/rotorcraft/stabilization.c index f273b4e76c..449d30eff3 100644 --- a/sw/airborne/firmwares/rotorcraft/stabilization.c +++ b/sw/airborne/firmwares/rotorcraft/stabilization.c @@ -27,6 +27,7 @@ int32_t stabilization_cmd[COMMANDS_NB]; void stabilization_init(void) { #ifndef STABILIZATION_SKIP_RATE + stabilization_none_init(); stabilization_rate_init(); #endif stabilization_attitude_init(); diff --git a/sw/airborne/firmwares/rotorcraft/stabilization.h b/sw/airborne/firmwares/rotorcraft/stabilization.h index b3c2d2d268..fae6fa0b06 100644 --- a/sw/airborne/firmwares/rotorcraft/stabilization.h +++ b/sw/airborne/firmwares/rotorcraft/stabilization.h @@ -28,9 +28,11 @@ #include "generated/airframe.h" +#include "firmwares/rotorcraft/stabilization/stabilization_none.h" #include "firmwares/rotorcraft/stabilization/stabilization_rate.h" #include "firmwares/rotorcraft/stabilization/stabilization_attitude.h" + extern void stabilization_init(void); extern int32_t stabilization_cmd[COMMANDS_NB]; diff --git a/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.c b/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.c new file mode 100644 index 0000000000..760c5a0a0e --- /dev/null +++ b/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.c @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * Copyright (C) 2008-2009 Antoine Drouin + * Copyright (C) 2010 Felix Ruess + * + * 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. + */ + +#include "firmwares/rotorcraft/stabilization.h" +#include "firmwares/rotorcraft/stabilization/stabilization_none.h" + +#include "subsystems/radio_control.h" +#include "generated/airframe.h" + +#define F_UPDATE_RES 9 +#define REF_DOT_FRAC 11 +#define REF_FRAC 16 + + +#define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b)) +#define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b)) + +struct Int32Rates stabilization_none_rc_cmd; + +void stabilization_none_init(void) { + + INT_RATES_ZERO(stabilization_none_rc_cmd); + +} + + +void stabilization_none_read_rc( void ) { + + + stabilization_none_rc_cmd.p = (int32_t)-radio_control.values[RADIO_ROLL]; + + stabilization_none_rc_cmd.q = (int32_t)radio_control.values[RADIO_PITCH]; + + stabilization_none_rc_cmd.r = (int32_t)-radio_control.values[RADIO_YAW]; +} + +void stabilization_none_enter(void) { + INT_RATES_ZERO(stabilization_none_rc_cmd); +} + +void stabilization_none_run(bool_t in_flight) { + + /* sum to final command */ + stabilization_cmd[COMMAND_ROLL] = stabilization_none_rc_cmd.p * SUPERVISION_SCALE / MAX_PPRZ; + stabilization_cmd[COMMAND_PITCH] = stabilization_none_rc_cmd.q * SUPERVISION_SCALE / MAX_PPRZ; + stabilization_cmd[COMMAND_YAW] = stabilization_none_rc_cmd.r * SUPERVISION_SCALE / MAX_PPRZ; + +} diff --git a/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.h b/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.h new file mode 100644 index 0000000000..515d4e844a --- /dev/null +++ b/sw/airborne/firmwares/rotorcraft/stabilization/stabilization_none.h @@ -0,0 +1,37 @@ +/* + * $Id$ + * + * Copyright (C) 2008-2009 Antoine Drouin + * + * 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. + */ + +#ifndef STABILIZATION_NONE +#define STABILIZATION_NONE + +#include "math/pprz_algebra_int.h" + +extern void stabilization_none_init(void); +extern void stabilization_none_read_rc(void); +extern void stabilization_none_run(bool_t in_flight); +extern void stabilization_none_enter(void); + +extern struct Int32Rates stabilization_none_rc_cmd; + + +#endif /* STABILIZATION_NONE */ diff --git a/sw/airborne/math/Makefile b/sw/airborne/math/Makefile new file mode 100644 index 0000000000..782cfb0b30 --- /dev/null +++ b/sw/airborne/math/Makefile @@ -0,0 +1,47 @@ +# Build shared pprz math library +# + +CC= gcc +CFLAGS= -fpic +INCLUDES= -I $(PAPARAZZI_SRC)/sw/include -I $(PAPARAZZI_SRC)/sw/airborne + +# build in ../../../var/build/math +ifndef BUILDDIR +BUILDDIR=../../../var/build/math +endif + +ifndef PREFIX +PREFIX=/usr +endif +LIB_INSTALLDIR=${PREFIX}/lib +INCLUDE_INSTALLDIR=${PREFIX}/include/pprz +PKGCONFIG_INSTALLDIR=${PREFIX}/lib/pkgconfig +PKGCONFIG_FILE=pprzmath.pc + +SRC= $(wildcard *.c) +OBJ= $(addprefix $(BUILDDIR)/,$(SRC:.c=.o)) + +LIBNAME=libpprzmath + +all: + @cat README + +shared_lib: $(OBJ) + $(CC) -shared -o $(BUILDDIR)/$(LIBNAME).so $(OBJ) + +install_shared_lib: shared_lib + test -d $(LIB_INSTALLDIR) || mkdir -p $(LIB_INSTALLDIR) + cp $(BUILDDIR)/$(LIBNAME).so $(LIB_INSTALLDIR) + test -d $(INCLUDE_INSTALLDIR)/math || mkdir -p $(INCLUDE_INSTALLDIR)/math + cp *.h $(INCLUDE_INSTALLDIR)/math + cp ../../include/std.h $(INCLUDE_INSTALLDIR) + test -d $(PKGCONFIG_INSTALLDIR) || mkdir -p $(PKGCONFIG_INSTALLDIR) + sed -e 's#PREFIX#$(PREFIX)#g' $(PKGCONFIG_FILE).in > $(PKGCONFIG_INSTALLDIR)/$(PKGCONFIG_FILE) + +$(BUILDDIR)/%.o: %.c + test -d $(BUILDDIR) || mkdir -p $(BUILDDIR) + $(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@ + +clean: + rm -f $(BUILDDIR)/*.o $(BUILDDIR)/$(LIBNAME).so + diff --git a/sw/airborne/math/README b/sw/airborne/math/README new file mode 100644 index 0000000000..9c68398093 --- /dev/null +++ b/sw/airborne/math/README @@ -0,0 +1,34 @@ +Math lib used in all airborne code of paparazzi + +HOWTO install a shared library to use in other projects + +1. Build library: in this folder, type + make shared_lib + + the default build directory is var/build/math + to change it: BUILDDIR= make shared_lib + +2. Install library: in this folder, type + make install_shared_lib + + the default install dir is /usr + and will install files in + /usr/lib + /usr/lib/pkgconfig + /usr/include/pprz + + to change the install dir: PREFIX= make install_shared_lib + + note that the default install dir needs root privilege + +HOWTO use the shared library + +1. with pkg-config --cflags --libs + +2. by hand: + LIBS: -L/lib -lpprzmath + CFLAGS: -I/include/pprz + + +"make clean" will only clean the build directory + diff --git a/sw/airborne/math/pprzmath.pc.in b/sw/airborne/math/pprzmath.pc.in new file mode 100644 index 0000000000..b70fbd26f4 --- /dev/null +++ b/sw/airborne/math/pprzmath.pc.in @@ -0,0 +1,9 @@ +prefix=PREFIX +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${exec_prefix}/include +Name: pprzmath +Description: math library used in Paparazzi project (http://paparazzi.enac.fr) +Version:0.1 +Libs: -L${libdir} -lpprzmath +Cflags: -I${includedir}/pprz diff --git a/sw/airborne/modules/digital_cam/dc.c b/sw/airborne/modules/digital_cam/dc.c index 9e7f4e5f2e..605d2b75b5 100644 --- a/sw/airborne/modules/digital_cam/dc.c +++ b/sw/airborne/modules/digital_cam/dc.c @@ -36,7 +36,7 @@ float dc_circle_start_angle = 0; float dc_circle_last_block = 0; float dc_circle_max_blocks = 0; -float dc_gps_dist = 0; +float dc_gps_dist = 50; float dc_gps_next_dist = 0; float dc_gps_x = 0; float dc_gps_y = 0; diff --git a/sw/airborne/modules/digital_cam/led_cam_ctrl.h b/sw/airborne/modules/digital_cam/led_cam_ctrl.h index 6fe8ef72c8..541b691eed 100644 --- a/sw/airborne/modules/digital_cam/led_cam_ctrl.h +++ b/sw/airborne/modules/digital_cam/led_cam_ctrl.h @@ -102,6 +102,8 @@ static inline void dc_send_command(uint8_t cmd) DC_PUSH(DC_POWER_LED); break; #endif + default: + break; } } diff --git a/sw/airborne/modules/ins/ins_xsens.c b/sw/airborne/modules/ins/ins_xsens.c index cce76a36ac..8411e3d474 100644 --- a/sw/airborne/modules/ins/ins_xsens.c +++ b/sw/airborne/modules/ins/ins_xsens.c @@ -71,7 +71,22 @@ INS_FORMAT ins_mz; float ins_pitch_neutral; float ins_roll_neutral; -volatile uint8_t new_ins_attitude; +//volatile uint8_t new_ins_attitude; + +#include "subsystems/imu.h" + +void ahrs_init(void) +{ + ins_init(); +} + +void imu_periodic(void) +{ + ins_periodic_task(); +} + +//struct Imu imu; + ////////////////////////////////////////////////////////////////////////////////////////// // diff --git a/sw/airborne/modules/ins/ins_xsens.h b/sw/airborne/modules/ins/ins_xsens.h index 790e65bf5a..959aa16e86 100644 --- a/sw/airborne/modules/ins/ins_xsens.h +++ b/sw/airborne/modules/ins/ins_xsens.h @@ -31,6 +31,8 @@ #include "std.h" +#include "ins_module.h" + extern int8_t xsens_hour; extern int8_t xsens_min; extern int8_t xsens_sec; @@ -41,5 +43,10 @@ extern int8_t xsens_day; extern uint8_t xsens_msg_status; extern uint16_t xsens_time_stamp; +#define AhrsEvent(_ahrs_handler) { \ + LED_TOGGLE(3); \ + InsEventCheckAndHandle(handle_ins_msg()) \ +} + #endif diff --git a/sw/airborne/modules/nav/nav_catapult.c b/sw/airborne/modules/nav/nav_catapult.c new file mode 100644 index 0000000000..8527674756 --- /dev/null +++ b/sw/airborne/modules/nav/nav_catapult.c @@ -0,0 +1,194 @@ +/* + * + * Copyright (C) 2012, Christophe De Wagter + * + * 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 module/nav/nav_catapult.h + * @brief catapult launch timing system + * + * + * Phase 1: -Zero Roll, Climb Pitch, Zero Throttle + * Phase 2: After Feeling the Start Acceleration + * -Zero Roll, Climb Pitch, Full Throttle + * Phase 3: After feeling the GPS heading (time based) + * -Place climb 300m in front of us + * -GoTo(climb) +*/ + + + +#include "generated/airframe.h" +#include "estimator.h" +#include "ap_downlink.h" +#include "modules/nav/nav_catapult.h" +#include "subsystems/nav.h" +#include "generated/flight_plan.h" +#include "firmwares/fixedwing/autopilot.h" +#include "firmwares/fixedwing/stabilization/stabilization_attitude.h" + +// Imu is required +#include "subsystems/imu.h" + +#ifndef DOWNLINK_DEVICE +#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE +#endif +#include "mcu_periph/uart.h" +#include "messages.h" +#include "downlink.h" + + +static bool_t nav_catapult_armed = FALSE; +static uint16_t nav_catapult_launch = 0; + +#ifndef NAV_CATAPULT_ACCELERATION_THRESHOLD +#define NAV_CATAPULT_ACCELERATION_THRESHOLD (1.5 * 9.81); +#endif + +#ifndef NAV_CATAPULT_MOTOR_DELAY +#define NAV_CATAPULT_MOTOR_DELAY 20 // Main Control Loops +#endif + +#define NAV_CATAPULT_HEADING_DELAY (60 * 3) + +static float nav_catapult_x = 0; +static float nav_catapult_y = 0; + +//############################################################################################### +// Code that Runs in a Fast Module + +void nav_catapult_highrate_module(void) +{ + // Only run when + if (nav_catapult_armed) + { + if (nav_catapult_launch < NAV_CATAPULT_HEADING_DELAY) + nav_catapult_launch ++; + + // Launch detection Filter + if (nav_catapult_launch < 5) + { + // Five consecutive measurements > 1.5 +#ifndef SITL + if (ACCEL_FLOAT_OF_BFP(imu.accel.x) < (1.5f * 9.1)) +#else + if (launch != 1) +#endif + { + nav_catapult_launch = 0; + } + } + // Launch was detected: Motor Delay Counter + else if (nav_catapult_launch == NAV_CATAPULT_MOTOR_DELAY) + { + // Turn on Motor + NavVerticalThrottleMode(9600*(1)); + launch = 1; + } + } + else + { + nav_catapult_launch = 0; + } +} + +//############################################################################################### +// Code that runs in 4Hz Nav + +bool_t nav_catapult_init(void) +{ + + nav_catapult_armed = TRUE; + nav_catapult_launch = 0; + + return FALSE; +} + + + +bool_t nav_catapult(uint8_t _climb) +{ + float alt = WaypointAlt(_climb); + + nav_catapult_armed = 1; + +/* + + float nav_final_progress = ((estimator_x - WaypointX(_tod)) * final_x + (estimator_y - WaypointY(_tod)) * final_y) / final2; + Bound(nav_final_progress,-1,1); + float nav_final_length = sqrt(final2); + + float pre_climb = -(WaypointAlt(_tod) - WaypointAlt(_td)) / (nav_final_length / estimator_hspeed_mod); + Bound(pre_climb, -5, 0.); + + float start_alt = WaypointAlt(_tod); + float diff_alt = WaypointAlt(_td) - start_alt; + float alt = start_alt + nav_final_progress * diff_alt; + Bound(alt, WaypointAlt(_td), start_alt +(pre_climb/(v_ctl_altitude_pgain))) // to prevent climbing before intercept + +*/ + + // No Roll, Climb Pitch, No motor Phase + if (nav_catapult_launch <= NAV_CATAPULT_MOTOR_DELAY) + { + NavAttitude(RadOfDeg(0)); + NavVerticalAutoThrottleMode(RadOfDeg(15)); + NavVerticalThrottleMode(9600*(0)); + + // Store take-off waypoint + nav_catapult_x = estimator_x; + nav_catapult_y = estimator_y; + + } + // No Roll, Climb Pitch, Full Power + else if (nav_catapult_launch < NAV_CATAPULT_HEADING_DELAY) + { + NavAttitude(RadOfDeg(0)); + NavVerticalAutoThrottleMode(RadOfDeg(15)); + NavVerticalThrottleMode(9600*(1.0)); + } + // Heading Lock + else if (nav_catapult_launch == 0xffff) + { + NavVerticalAltitudeMode(alt, 0); // vertical mode (folow glideslope) + NavVerticalAutoThrottleMode(RadOfDeg(15)); // throttle mode + NavGotoWaypoint(_climb); // horizontal mode (stay on localiser) + } + else + { + // Store Heading, move Climb + nav_catapult_launch = 0xffff; + + float dir_x = estimator_x - nav_catapult_x; + float dir_y = estimator_y - nav_catapult_y; + + float dir_L = sqrt(dir_x * dir_x + dir_y * dir_y); + + WaypointX(_climb) = nav_catapult_x + (dir_x / dir_L) * 300; + WaypointY(_climb) = nav_catapult_y + (dir_y / dir_L) * 300; + + DownlinkSendWp(DefaultChannel, _climb); + } + + +return TRUE; + +} // end of gls() diff --git a/sw/airborne/modules/nav/nav_catapult.h b/sw/airborne/modules/nav/nav_catapult.h new file mode 100644 index 0000000000..5898612255 --- /dev/null +++ b/sw/airborne/modules/nav/nav_catapult.h @@ -0,0 +1,45 @@ +/* + * + * Copyright (C) 2012, Christophe De Wagter + * + * 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 module/nav/nav_catapult.h + * @brief catapult launch timing system + */ + +#ifndef NAV_CATAPULT_H +#define NAV_CATAPULT_H + +#include "std.h" +#include "paparazzi.h" + +// Module Code +void nav_catapult_highrate_module(void); + +// Flightplan Code +extern bool_t nav_catapult_init(void); + +extern bool_t nav_catapult_arm(void); +extern bool_t nav_catapult(uint8_t _climb); +extern bool_t nav_catapult_disarm(void); + +#endif diff --git a/sw/airborne/modules/openlog/openlog.c b/sw/airborne/modules/openlog/openlog.c new file mode 100755 index 0000000000..e2b8532151 --- /dev/null +++ b/sw/airborne/modules/openlog/openlog.c @@ -0,0 +1,49 @@ +/* + * $Id$ + * + * Copyright (C) 2011 Christoph Niemann + * + * 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. + * + */ + +/** + * This module provides a timestamp-message, allowing + * sw/logalizer/openlog2tlm to convert a recorded dumpfile, + * created by openlog into the pprz-tlm format, to be converted into + * .data and .log files by sw/logalizer/sd2log + */ + +#include "openlog.h" +#include "messages.h" +#include "downlink.h" +#include "mcu_periph/uart.h" + +#ifndef DOWNLINK_DEVICE +#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE +#endif + +uint32_t timestamp = 0; ///< Timestamp to be incremented during operation + +void init_openlog(void) { +} + +void periodic_2Hz_openlog(void) { + timestamp=timestamp+500; + DOWNLINK_SEND_TIMESTAMP(DefaultChannel, ×tamp); +} diff --git a/sw/airborne/modules/openlog/openlog.h b/sw/airborne/modules/openlog/openlog.h new file mode 100755 index 0000000000..8c2e5ca70c --- /dev/null +++ b/sw/airborne/modules/openlog/openlog.h @@ -0,0 +1,38 @@ +/* + * $Id$ + * + * Copyright (C) 2011 Christoph Niemann + * + * 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 openlog.h + * This module provides a timestamp-message, allowing + * sw/logalizer/openlog2tlm to convert a recorded dumpfile, + * created by openlog into the pprz-tlm format, to be converted into + * .data and .log files by sw/logalizer/sd2log + */ + +#ifndef OPENLOG_H +#define OPENLOG_H + +void init_openlog(void); +void periodic_2Hz_openlog(void); + +#endif diff --git a/sw/airborne/peripherals/mcp355x.c b/sw/airborne/peripherals/mcp355x.c index 386f1aae59..3eec8438ab 100644 --- a/sw/airborne/peripherals/mcp355x.c +++ b/sw/airborne/peripherals/mcp355x.c @@ -41,32 +41,20 @@ void mcp355x_init(void) { void mcp355x_read(void) { spi_buffer_length = 4; spi_buffer_input = mcp355x_spi_buf; - SpiSelectSlave0(); + //SpiSelectSlave0(); SpiStart(); } -#ifndef DOWNLINK_DEVICE -#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE -#endif - -#include "mcu_periph/uart.h" -#include "messages.h" -#include "downlink.h" - void mcp355x_event(void) { - static uint32_t filtered = 0; if (spi_message_received) { spi_message_received = FALSE; if ((mcp355x_spi_buf[0]>>4) == 0) { - //mcp355x_data = (int32_t)(((uint32_t)mcp355x_spi_buf[0]<<16) | ((uint32_t)mcp355x_spi_buf[1]<<8) | (mcp355x_spi_buf[2])); mcp355x_data = (int32_t)( ((uint32_t)mcp355x_spi_buf[0]<<17) | ((uint32_t)mcp355x_spi_buf[1]<<9) | ((uint32_t)mcp355x_spi_buf[2]<<1) | (mcp355x_spi_buf[3]>>7)); - filtered = (5*filtered + mcp355x_data) / (6); - DOWNLINK_SEND_DEBUG(DefaultChannel,4,mcp355x_spi_buf); - DOWNLINK_SEND_BARO_RAW(DefaultChannel,&mcp355x_data,&filtered); + mcp355x_data_available = TRUE; } } } diff --git a/sw/airborne/subsystems/imu/imu_b2.h b/sw/airborne/subsystems/imu/imu_b2.h index 1860501be9..02b7e69c59 100644 --- a/sw/airborne/subsystems/imu/imu_b2.h +++ b/sw/airborne/subsystems/imu/imu_b2.h @@ -169,7 +169,7 @@ } \ } #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843 -include "peripherals/hmc5843.h" +#include "peripherals/hmc5843.h" #define foo_handler() {} #define ImuMagEvent(_mag_handler) { \ MagEvent(foo_handler); \ diff --git a/sw/airborne/subsystems/nav.c b/sw/airborne/subsystems/nav.c index 12aadf70d6..bf33d3867e 100644 --- a/sw/airborne/subsystems/nav.c +++ b/sw/airborne/subsystems/nav.c @@ -148,11 +148,6 @@ void nav_circle_XY(float x, float y, float radius) { } -#define NavGotoWaypoint(_wp) { \ - horizontal_mode = HORIZONTAL_MODE_WAYPOINT; \ - fly_to_xy(waypoints[_wp].x, waypoints[_wp].y); \ -} - #define NavGlide(_last_wp, _wp) { \ float start_alt = waypoints[_last_wp].a; \ float diff_alt = waypoints[_wp].a - start_alt; \ diff --git a/sw/airborne/subsystems/nav.h b/sw/airborne/subsystems/nav.h index fbda094cbb..47d9625028 100644 --- a/sw/airborne/subsystems/nav.h +++ b/sw/airborne/subsystems/nav.h @@ -76,6 +76,12 @@ extern uint8_t horizontal_mode; extern void fly_to_xy(float x, float y); +#define NavGotoWaypoint(_wp) { \ + horizontal_mode = HORIZONTAL_MODE_WAYPOINT; \ + fly_to_xy(waypoints[_wp].x, waypoints[_wp].y); \ +} + + extern void nav_eight_init( void ); extern void nav_eight(uint8_t, uint8_t, float); #define Eight(a, b, c) nav_eight((a), (b), (c)) @@ -134,6 +140,7 @@ bool_t nav_approaching_xy(float x, float y, float from_x, float from_y, float ap #define NavApproaching(wp, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, last_x, last_y, time) #define NavApproachingFrom(wp, from, time) nav_approaching_xy(waypoints[wp].x, waypoints[wp].y, waypoints[from].x, waypoints[from].y, time) + /** Set the climb control to auto-throttle with the specified pitch pre-command */ #define NavVerticalAutoThrottleMode(_pitch) { \ diff --git a/sw/airborne/subsystems/navigation/OSAMNav.c b/sw/airborne/subsystems/navigation/OSAMNav.c index 0fa98b71be..11a2f27a5c 100644 --- a/sw/airborne/subsystems/navigation/OSAMNav.c +++ b/sw/airborne/subsystems/navigation/OSAMNav.c @@ -128,6 +128,8 @@ bool_t FlowerNav(void) } break; + default: + break; } return TRUE; } @@ -844,6 +846,8 @@ bool_t VerticalRaster(uint8_t l1, uint8_t l2, float radius, float AltSweep) { line_status = LR12; nav_init_stage(); } + default: + break; } return TRUE; /* This pattern never ends */ } diff --git a/sw/airborne/subsystems/navigation/discsurvey.c b/sw/airborne/subsystems/navigation/discsurvey.c index dc20e9a558..1a56f3b8f2 100644 --- a/sw/airborne/subsystems/navigation/discsurvey.c +++ b/sw/airborne/subsystems/navigation/discsurvey.c @@ -74,6 +74,8 @@ bool_t disc_survey( uint8_t center, float radius) { nav_init_stage(); } break; + default: + break; } NavVerticalAutoThrottleMode(0.); /* No pitch */ diff --git a/sw/airborne/subsystems/navigation/poly_survey_adv.c b/sw/airborne/subsystems/navigation/poly_survey_adv.c index 0edfc465b7..73f6e74852 100644 --- a/sw/airborne/subsystems/navigation/poly_survey_adv.c +++ b/sw/airborne/subsystems/navigation/poly_survey_adv.c @@ -85,11 +85,11 @@ static void nav_points(point2d start, point2d end) **/ static bool_t intercept_two_lines(point2d *p, point2d x, point2d y, float a1, float a2, float b1, float b2) { - float div, fac; + float divider, fac; - div = (((b2 - a2)*(y.x - x.x)) + ((x.y - y.y)*(b1 - a1))); - if (div == 0) return FALSE; - fac = ((y.x*(x.y - a2)) + (x.x*(a2 - y.y)) + (a1*(y.y - x.y))) / div; + divider = (((b2 - a2)*(y.x - x.x)) + ((x.y - y.y)*(b1 - a1))); + if (divider == 0) return FALSE; + fac = ((y.x*(x.y - a2)) + (x.x*(a2 - y.y)) + (a1*(y.y - x.y))) / divider; if (fac > 1.0) return FALSE; if (fac < 0.0) return FALSE; @@ -164,7 +164,7 @@ bool_t init_poly_survey_adv(uint8_t first_wp, uint8_t size, float angle, float s { int i; point2d small, sweep; - float div, len, angle_rad = angle/180.0*M_PI; + float divider, len, angle_rad = angle/180.0*M_PI; if (angle < 0.0) angle += 360.0; if (angle >= 360.0) angle -= 360.0; @@ -224,10 +224,10 @@ bool_t init_poly_survey_adv(uint8_t first_wp, uint8_t size, float angle, float s small.x = waypoints[poly_first].x; small.y = waypoints[poly_first].y; - div = (sweep_vec.y*dir_vec.x) - (sweep_vec.x*dir_vec.y); + divider = (sweep_vec.y*dir_vec.x) - (sweep_vec.x*dir_vec.y); //cacluate the leftmost point if one sees the dir vec as going "up" and the sweep vec as going right - if (div < 0.0) { + if (divider < 0.0) { for(i=1;i 0.0) { small.x = waypoints[poly_first+i].x; diff --git a/sw/airborne/subsystems/navigation/spiral.c b/sw/airborne/subsystems/navigation/spiral.c index e05b26df5e..f611843dd7 100644 --- a/sw/airborne/subsystems/navigation/spiral.c +++ b/sw/airborne/subsystems/navigation/spiral.c @@ -166,7 +166,8 @@ bool_t SpiralNav(void) } CSpiralStatus = Circle; break; - + default: + break; } return TRUE; } diff --git a/sw/ground_segment/cockpit/gcs.ml b/sw/ground_segment/cockpit/gcs.ml index 488aeb7f30..1b4f699598 100644 --- a/sw/ground_segment/cockpit/gcs.ml +++ b/sw/ground_segment/cockpit/gcs.ml @@ -338,6 +338,7 @@ and edit = ref false and display_particules = ref false and wid = ref None and srtm = ref false +and hide_fp = ref false let options = [ @@ -369,6 +370,7 @@ let options = "-utm", Arg.Unit (fun () -> projection:=G.UTM),"Switch to UTM local projection"; "-wid", Arg.String (fun s -> wid := Some (Int32.of_string s)), " Id of an existing window to be attached to"; "-zoom", Arg.Set_float zoom, "Initial zoom"; + "-auto_hide_fp", Arg.Unit (fun () -> Live.auto_hide_fp true; hide_fp := true), "Automatically hide flight plans of unselected aircraft"; ] @@ -389,6 +391,7 @@ let create_geomap = fun switch_fullscreen editor_frame -> ignore (geomap#canvas#event#connect#motion_notify (motion_notify geomap)); ignore (geomap#canvas#event#connect#any (any_event geomap)); + ignore (menu_fact#add_check_item "Auto hide FP" ~callback:(fun hide -> Live.auto_hide_fp hide) ~active:!hide_fp); ignore (menu_fact#add_item "Redraw" ~key:GdkKeysyms._L ~callback:(fun _ -> geomap#canvas#misc#draw None)); let fullscreen = menu_fact#add_image_item ~stock:(`STOCK "gtk-fullscreen") ~callback:switch_fullscreen () in fullscreen#add_accelerator accel_group GdkKeysyms._F11; diff --git a/sw/ground_segment/cockpit/live.ml b/sw/ground_segment/cockpit/live.ml index 9018f8cb2a..1f830ff35b 100644 --- a/sw/ground_segment/cockpit/live.ml +++ b/sw/ground_segment/cockpit/live.ml @@ -41,6 +41,8 @@ let gcs_id = "GCS" let approaching_alert_time = 3. let track_size = ref 500 +let _auto_hide_fp = ref false + let min_height = 200 let lines_height = 30 @@ -73,6 +75,7 @@ type aircraft = { track : MapTrack.track; color: color; fp_group : MapFP.flight_plan; + fp_show : GMenu.check_menu_item; wp_HOME : MapWaypoints.waypoint option; fp : Xml.xml; blocks : (int * string) list; @@ -117,6 +120,32 @@ let get_ac = fun vs -> let ac_id = Pprz.string_assoc "ac_id" vs in find_ac ac_id +let show_fp = fun ac -> + ac.fp_group#show (); + ac.fp_show#set_active true + +let hide_fp = fun ac -> + ac.fp_group#hide (); + ac.fp_show#set_active false + +(* callback for FP check button in menu *) +let show_mission = fun ac on_off -> + let a = find_ac ac in + if on_off then + a.fp_group#show () + else + a.fp_group#hide () + +let auto_hide_fp = fun hide -> + let _hide_fp = fun () -> + Hashtbl.iter (fun _ a -> hide_fp a) aircrafts; + if !active_ac <> "" then begin + let a = find_ac !active_ac in + show_fp a + end; + in + _auto_hide_fp := hide; + if hide then _hide_fp () else Hashtbl.iter (fun _ a -> show_fp a) aircrafts let select_ac = fun acs_notebook ac_id -> if !active_ac <> ac_id then @@ -127,11 +156,13 @@ let select_ac = fun acs_notebook ac_id -> if !active_ac <> "" then begin let ac' = find_ac !active_ac in ac'.strip#hide_buttons (); - ac'.notebook_label#set_width_chars (String.length ac'.notebook_label#text) + ac'.notebook_label#set_width_chars (String.length ac'.notebook_label#text); + if !_auto_hide_fp then hide_fp ac' end; (* Set the new active *) active_ac := ac_id; + if !_auto_hide_fp then show_fp ac; (* Select and enlarge the label of the A/C notebook *) let n = acs_notebook#page_num ac.pages in @@ -150,13 +181,6 @@ let log = let log_and_say = fun a ac_id s -> log ~say:true a ac_id s -let show_mission = fun ac on_off -> - let a = find_ac ac in - if on_off then - a.fp_group#show () - else - a.fp_group#hide () - let resize_track = fun ac track -> match GToolbox.input_string ~text:(string_of_int track#size) ~title:ac "Track size" @@ -392,8 +416,8 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id let ac_menu = GMenu.menu () in ac_mi#set_submenu ac_menu; let ac_menu_fact = new GMenu.factory ac_menu in - let fp = ac_menu_fact#add_check_item "Fligh Plan" ~active:true in - ignore (fp#connect#toggled (fun () -> show_mission ac_id fp#active)); + let fp_show = ac_menu_fact#add_check_item "Fligh Plan" ~active:true in + ignore (fp_show#connect#toggled (fun () -> show_mission ac_id fp_show#active)); let track = new MapTrack.track ~size: !track_size ~name ~color:color geomap in geomap#register_to_fit (track:>MapCanvas.geographic); @@ -606,16 +630,16 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id loop fp#waypoints in let ac = { track = track; color = color; last_dist_to_wp = 0.; - fp_group = fp ; config = config ; wp_HOME = wp_HOME; - fp = fp_xml; ac_name = name; + fp_group = fp; fp_show = fp_show ; config = config ; + wp_HOME = wp_HOME; fp = fp_xml; ac_name = name; blocks = blocks; last_ap_mode= ""; last_stage = (-1,-1); ir_page = ir_page; flight_time = 0; gps_page = gps_page; - pfd_page = pfd_page; + pfd_page = pfd_page; misc_page = misc_page; dl_settings_page = dl_settings_page; - rc_settings_page = rc_settings_page; + rc_settings_page = rc_settings_page; strip = strip; first_pos = true; last_block_name = ""; alt = 0.; target_alt = 0.; in_kill_mode = false; speed = 0.; @@ -623,7 +647,7 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id wind_speed = 0.; pages = ac_frame#coerce; notebook_label = _label; - got_track_status_timer = 1000; + got_track_status_timer = 1000; dl_values = [||]; last_unix_time = 0.; airspeed = 0. } in diff --git a/sw/ground_segment/cockpit/live.mli b/sw/ground_segment/cockpit/live.mli index debcc70748..4f781b312e 100644 --- a/sw/ground_segment/cockpit/live.mli +++ b/sw/ground_segment/cockpit/live.mli @@ -32,6 +32,7 @@ type aircraft = private { track : MapTrack.track; color: color; fp_group : MapFP.flight_plan; + fp_show : GMenu.check_menu_item; wp_HOME : MapWaypoints.waypoint option; fp : Xml.xml; blocks : (int * string) list; @@ -70,6 +71,9 @@ val safe_bind : string -> (string -> Pprz.values -> unit) -> unit val track_size : int ref (** Default length for A/C tracks on the 2D view *) +val auto_hide_fp : bool -> unit +(** Automatically hide flight plan of not selected ac *) + val listen_acs_and_msgs : MapCanvas.widget -> GPack.notebook -> Pages.alert -> bool -> Gtk_tools.pixmap_in_drawin_area -> unit (** [listen_acs_and_msgs geomap aircraft_notebook alert_page auto_center_new_ac alt_graph] *) diff --git a/sw/ground_segment/lpc21iap/Makefile b/sw/ground_segment/lpc21iap/Makefile index dc4a954a37..f9b7ab4716 100644 --- a/sw/ground_segment/lpc21iap/Makefile +++ b/sw/ground_segment/lpc21iap/Makefile @@ -27,8 +27,8 @@ endif UNAME = $(shell uname -s) ifeq ("$(UNAME)","Darwin") - LIBRARYS = -L /opt/paparazzi/lib -L /opt/local/lib - INCLUDES = -I /opt/paparazzi/include -I /opt/local/include/ + LIBRARYS = -L/opt/paparazzi/lib -L/opt/local/lib + INCLUDES = -I/opt/paparazzi/include -I/opt/local/include/ endif diff --git a/sw/ground_segment/misc/Makefile b/sw/ground_segment/misc/Makefile index 7870fe7e62..c5965d691f 100644 --- a/sw/ground_segment/misc/Makefile +++ b/sw/ground_segment/misc/Makefile @@ -1,8 +1,8 @@ UNAME = $(shell uname -s) ifeq ("$(UNAME)","Darwin") - LIBRARYS = -L /opt/paparazzi/lib -L /opt/local/lib - INCLUDES = -I /opt/paparazzi/include -I /opt/local/include/ + LIBRARYS = -L/opt/paparazzi/lib -L/opt/local/lib + INCLUDES = -I/opt/paparazzi/include -I/opt/local/include/ else LIBRARYS = -s endif diff --git a/sw/lib/ocaml/ivy/Makefile b/sw/lib/ocaml/ivy/Makefile index 574935c6d6..6a1a7cb70d 100644 --- a/sw/lib/ocaml/ivy/Makefile +++ b/sw/lib/ocaml/ivy/Makefile @@ -52,8 +52,8 @@ UNAME = $(shell uname -s) UNAME = $(shell uname -s) ifeq ("$(UNAME)","Darwin") - LIBRARYS = -L /opt/paparazzi/lib -L /opt/local/lib - INCLUDES = -I /opt/paparazzi/include -I /opt/local/include/ + LIBRARYS = -L/opt/paparazzi/lib -L/opt/local/lib + INCLUDES = -I/opt/paparazzi/include -I/opt/local/include/ endif LIBS = ivy-ocaml.cma ivy-ocaml.cmxa glibivy-ocaml.cma glibivy-ocaml.cmxa diff --git a/sw/lib/ocaml/mapTrack.ml b/sw/lib/ocaml/mapTrack.ml index 2bdbc979c0..42501fad1f 100644 --- a/sw/lib/ocaml/mapTrack.ml +++ b/sw/lib/ocaml/mapTrack.ml @@ -75,13 +75,14 @@ class track = fun ?(name="Noname") ?(size = 500) ?(color="red") (geomap:MapCanva (** rectangle representing the field covered by the cam *) let _ac_cam_targeted = ignore ( GnoCanvas.ellipse ~x1: (-. 2.5) ~y1: (-. 2.5 ) ~x2: 2.5 ~y2: 2.5 ~fill_color:color ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR color; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] cam) in + let _ = cam#hide () in let mission_target = GnoCanvas.group group in (** red circle : target of the mission *) - let ac_mission_target = - GnoCanvas.ellipse ~x1: (-5.) ~y1: (-5.) ~x2: 5. ~y2: 5. ~fill_color:"red" ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR "red"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] mission_target in - let _ = ac_mission_target#hide () in + let _ac_mission_target = + ignore ( GnoCanvas.ellipse ~x1: (-5.) ~y1: (-5.) ~x2: 5. ~y2: 5. ~fill_color:"red" ~props:[`WIDTH_UNITS 1.; `OUTLINE_COLOR "red"; `FILL_STIPPLE (Gdk.Bitmap.create_from_data ~width:2 ~height:2 "\002\001")] mission_target) in + let _ = mission_target#hide () in (** data at map scale *) let max_cam_half_height_scaled = 10000.0 in @@ -92,6 +93,8 @@ class track = fun ?(name="Noname") ?(size = 500) ?(color="red") (geomap:MapCanva let _desired_circle = GnoCanvas.ellipse group and _desired_segment = GnoCanvas.line group in + let _ = aircraft#raise_to_top () in + object (self) val mutable top = 0 val mutable color = color diff --git a/sw/logalizer/Makefile b/sw/logalizer/Makefile index 71d397db08..185058bc34 100644 --- a/sw/logalizer/Makefile +++ b/sw/logalizer/Makefile @@ -27,7 +27,7 @@ OCAMLC = ocamlc OCAMLOPT = ocamlopt INCLUDES= $(shell ocamlfind query -r -i-format xml-light) $(shell ocamlfind query -r -i-format lablgtk2) -I ../lib/ocaml -all: play plotter plot sd2log plotprofile +all: play plotter plot sd2log plotprofile openlog2tlm play : log_file.cmo play_core.cmo play.cmo @echo OL $@ @@ -49,6 +49,13 @@ sd2log : sd2log.cmo @echo OL $@ $(Q)$(OCAMLC) $(INCLUDES) -custom -o $@ unix.cma str.cma xml-light.cma glibivy-ocaml.cma lib-pprz.cma $^ +CC = gcc +CFLAGS=-g -O2 -Wall +LDFLAGS= + +openlog2tlm: openlog2tlm.c + $(CC) $(CFLAGS) -g -o $@ $^ + play play-nox plotter sd2log : ../lib/ocaml/lib-pprz.cma plot : ../lib/ocaml/lib-pprz.cmxa @@ -115,7 +122,7 @@ test3: test3.c sliding_plot.c $(CC) $(CFLAGS) -g -o $@ $^ $(LDFLAGS) clean: - rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* play ahrsview imuview ahrs2fg plot plotter gtk_export.ml + rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* play ahrsview imuview ahrs2fg plot plotter gtk_export.ml openlog2tlm #FGFS_PREFIX=/home/poine/local FGFS_PREFIX=/home/poine/flightgear diff --git a/sw/logalizer/openlog2tlm.c b/sw/logalizer/openlog2tlm.c new file mode 100755 index 0000000000..72bfea4e62 --- /dev/null +++ b/sw/logalizer/openlog2tlm.c @@ -0,0 +1,99 @@ +/* + * $Id$ + * + * Converter for OpenLog logfiles to TLM + * + * Copyright (C) 2011 Christoph Niemann + * + * 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. + * + */ + +/** Converts a Paparazzi Message dump, containing a timestamp, + to Paparazzi TLM, wich can be converted to .data and .log by + sw/logalizer/sd2log . + The openlog Module has to be loaded for use +*/ + +#include +#include + +/* define the message id for the TIMESTAMP message (default is 129) */ +#define MSG_NUMBER 129 + +int main(int argc, char *argv[]) { + FILE *in,*out; + + int current_timestamp = 0; + int timestamp_bytes[4] = {0,0,0,0}; + int temp = 0; + + if(argc != 3){ + puts("wrong number of parameters!\n" + "usage is openlog2tlm "); + return EXIT_FAILURE; + } + if((in=fopen(argv[1],"rb"))==NULL){ + puts("openlog2tlm wasn't able to open the inputfile\n"); + return EXIT_FAILURE; + } + if((out=fopen(argv[2],"wb"))==NULL){ + puts("openlog2tlm wasn't able to open the outputfile\n"); + return EXIT_FAILURE; + } + + printf("converting %s to %s\n",argv[1],argv[2]); + + temp = fgetc(in); + + while(!feof(in)){ + if(temp==0x99){/// if a message starts + int length=fgetc(in); /// determining the length of the message + int message[length-2]; /// allocate an array that fits for the message + int i; + for(i = 0; i<(length-2); i++){/// read the complete message first + message[i]=fgetc(in); + } + temp = fgetc(in); + if(message[1]==MSG_NUMBER){ + current_timestamp = message[2]+(message[3]<<8)+(message[4]<<16)+(message[5]<<24); + current_timestamp = current_timestamp*10; /// now according to 100 microsecond grid for tlm + /// splitting the timestamp into bytes again, to use it for the messages + timestamp_bytes[0] = current_timestamp & 0xff; + timestamp_bytes[1] = ( current_timestamp >> 8 ) & 0xff; + timestamp_bytes[2] = ( current_timestamp >> 16 ) & 0xff; + timestamp_bytes[3] = ( current_timestamp >> 24 ) & 0xff; + } + /// start to write the message to the tlm-file + fputc(0x99,out);/// write PPRZ_STX + fputc(length-4,out);/// write LENGTH, recalculated for TLM + fputc(0,out); /// write SOURCE, defaults to uart0 + fputc(timestamp_bytes[0],out); /// write TIMESTAMP_LSB + fputc(timestamp_bytes[1],out); /// write TIMESTAMP + fputc(timestamp_bytes[2],out); /// write TIMESTAMP + fputc(timestamp_bytes[3],out); /// write TIMESTAMP_MSB + int checksum = length-4+timestamp_bytes[0]+timestamp_bytes[1]+timestamp_bytes[2]+timestamp_bytes[3]; + for(i = 0; i<(length-4); i++){/// write payload + fputc(message[i],out); + checksum+=message[i]; + } + fputc(checksum,out);/// write checksum, recalculated for tlm + } + } + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/sw/logalizer/plotter.ml b/sw/logalizer/plotter.ml index d925600091..fc1f523d88 100644 --- a/sw/logalizer/plotter.ml +++ b/sw/logalizer/plotter.ml @@ -80,6 +80,7 @@ type status = class plot = fun ~size ~width ~height ~packing () -> let curves = Hashtbl.create 3 in + let bindings = Hashtbl.create 3 in object (self) inherit Gtk_tools.pixmap_in_drawin_area ~width ~height ~packing () as pm @@ -119,184 +120,189 @@ class plot = fun ~size ~width ~height ~packing () -> method reset () = if auto_scale then begin - min <- max_float; - max <- -. max_float + min <- max_float; + max <- -. max_float end; Hashtbl.iter (fun _ a -> - a.index <- 0; - a.average#set_value 0.; - a.stdev#set_value 0.; - for i = 0 to Array.length a.array - 1 do a.array.(i) <- None done) - curves + a.index <- 0; + a.average#set_value 0.; + a.stdev#set_value 0.; + for i = 0 to Array.length a.array - 1 do a.array.(i) <- None done) + curves method set_size = fun new_size -> if new_size <> size && new_size > 0 then begin - Hashtbl.iter (fun _ a -> - let new_array = Array.create new_size None in - for i = 0 to Pervasives.min size new_size - 1 do - new_array.(new_size - 1 - i) <- a.array.((a.index-i+size) mod size) - done; - a.array <- new_array; - a.index <- new_size - 1) - curves; - size <- new_size + Hashtbl.iter (fun _ a -> + let new_array = Array.create new_size None in + for i = 0 to Pervasives.min size new_size - 1 do + new_array.(new_size - 1 - i) <- a.array.((a.index-i+size) mod size) + done; + a.array <- new_array; + a.index <- new_size - 1) + curves; + size <- new_size end - method create_curve = fun (name:string) -> + method create_curve = fun (name:string) binding -> let color = colors.(color_index) in let values = create_values size color in color_index <- (color_index+1) mod Array.length colors; Hashtbl.add curves name values; + Hashtbl.add bindings name binding; values method delete_curve = fun name -> - Hashtbl.remove curves name + Hashtbl.remove curves name; + try (* this try should not be needed *) + let binding = Hashtbl.find bindings name in + Ivy.unbind binding; + Hashtbl.remove bindings name + with _ -> () method add_value = fun name v -> if status <> Stop then - let a = Hashtbl.find curves name in - a.array.(a.index) <- Some v; - if auto_scale then begin - min <- Pervasives.min min v; - max <- Pervasives.max max v - end + let a = Hashtbl.find curves name in + a.array.(a.index) <- Some v; + if auto_scale then begin + min <- Pervasives.min min v; + max <- Pervasives.max max v + end method reset_scale = fun () -> min <- max_float; max <- -. max_float; Hashtbl.iter (* for all curves *) - (fun name a -> - Array.iter (* for all values *) - (function - None -> () - | Some v -> - min <- Pervasives.min min v; - max <- Pervasives.max max v) - a.array) - curves + (fun name a -> + Array.iter (* for all values *) + (function + None -> () + | Some v -> + min <- Pervasives.min min v; + max <- Pervasives.max max v) + a.array) + curves method shift = fun () -> Hashtbl.iter - (fun _ a -> - (* Shift *) - a.index <- (a.index + 1) mod (Array.length a.array); - a.array.(a.index) <- None) - curves + (fun _ a -> + (* Shift *) + a.index <- (a.index + 1) mod (Array.length a.array); + a.array.(a.index) <- None) + curves method update_curves = fun () -> if Hashtbl.length curves > 0 then - try - if status <> Stop then - self#shift (); - if status <> Suspend then - let da = pm#drawing_area in - let {Gtk.width=width; height=height} = da#misc#allocation in - let dr = pm#get_pixmap () in - dr#set_foreground (`NAME "white"); - dr#rectangle ~x:0 ~y:0 ~width ~height ~filled:true (); - let margin = Pervasives.min (height / 10) 20 in + try + if status <> Stop then + self#shift (); + if status <> Suspend then + let da = pm#drawing_area in + let {Gtk.width=width; height=height} = da#misc#allocation in + let dr = pm#get_pixmap () in + dr#set_foreground (`NAME "white"); + dr#rectangle ~x:0 ~y:0 ~width ~height ~filled:true (); + let margin = Pervasives.min (height / 10) 20 in - (* Time Graduations *) - let context = da#misc#create_pango_context in - context#set_font_by_name ("sans " ^ string_of_int (margin/2)); - let layout = context#create_layout in + (* Time Graduations *) + let context = da#misc#create_pango_context in + context#set_font_by_name ("sans " ^ string_of_int (margin/2)); + let layout = context#create_layout in - Pango.Layout.set_text layout "X"; - let (_, h) = Pango.Layout.get_pixel_size layout in + Pango.Layout.set_text layout "X"; + let (_, h) = Pango.Layout.get_pixel_size layout in - let f = fun x y s -> - Pango.Layout.set_text layout s; - let (w, h) = Pango.Layout.get_pixel_size layout in - dr#put_layout ~x ~y:(y-h/2) ~fore:`BLACK layout in + let f = fun x y s -> + Pango.Layout.set_text layout s; + let (w, h) = Pango.Layout.get_pixel_size layout in + dr#put_layout ~x ~y:(y-h/2) ~fore:`BLACK layout in - let t = dt *. float size in - f (width-width/size) (height-h/2) "0"; - f (width/2) (height-h/2) (Printf.sprintf "-%.1fs" (t/.2.)); - f 0 (height-h/2) (Printf.sprintf "-%.1fs" t); + let t = dt *. float size in + f (width-width/size) (height-h/2) "0"; + f (width/2) (height-h/2) (Printf.sprintf "-%.1fs" (t/.2.)); + f 0 (height-h/2) (Printf.sprintf "-%.1fs" t); - (* Y graduations *) - let (min, max) = - if max > min then (min, max) - else let d = abs_float max /. 10. in (max -. d, max +. d) in - let delta = max -. min in + (* Y graduations *) + let (min, max) = + if max > min then (min, max) + else let d = abs_float max /. 10. in (max -. d, max +. d) in + let delta = max -. min in - let dy = float (height-2*margin) /. delta in - let y = fun v -> - height - margin - truncate ((v-.min)*.dy) in + let dy = float (height-2*margin) /. delta in + let y = fun v -> + height - margin - truncate ((v-.min)*.dy) in - let scale = log delta /. log 10. in - let d = 10. ** floor scale in - let u = - if delta < 2.*.d then d/.5. - else if delta < 5.*.d then d/.2. - else d in - let tick_min = min -. mod_float min u in - for i = 0 to truncate (delta/.u) + 1 do - let tick = tick_min +. float i *. u in - f 0 (y tick) (Printf.sprintf "%.*f" (Pervasives.max 0 (2-truncate scale)) tick) - done; + let scale = log delta /. log 10. in + let d = 10. ** floor scale in + let u = + if delta < 2.*.d then d/.5. + else if delta < 5.*.d then d/.2. + else d in + let tick_min = min -. mod_float min u in + for i = 0 to truncate (delta/.u) + 1 do + let tick = tick_min +. float i *. u in + f 0 (y tick) (Printf.sprintf "%.*f" (Pervasives.max 0 (2-truncate scale)) tick) + done; - (* Constants *) - List.iter (fun v -> - dr#set_foreground (`NAME "black"); - dr#lines [(0, y v); (width-width/size, y v)]) - csts; + (* Constants *) + List.iter (fun v -> + dr#set_foreground (`NAME "black"); + dr#lines [(0, y v); (width-width/size, y v)]) + csts; - let margin = 3 in - let title_y = ref margin in - Hashtbl.iter - (fun title a -> - (* Draw and compute average and stdev*) - let curve = ref [] - and sum = ref 0. and sum_squares = ref 0. - and n = ref 0 in - assert (size = Array.length a.array); - let last_value = ref None in - for i = 0 to size - 1 do - let i' = (i+a.index) mod size in - match a.array.(i') with - None -> () - | Some v -> - incr n; - sum := !sum +. v; - sum_squares := !sum_squares +. v *. v; - let x = (i * width) / size in - begin - match !last_value with - Some lv when a.discrete -> - curve := (x, y lv) :: !curve - | _ -> () - end; - curve := (x, y v) :: !curve; - last_value := Some v - done; - if !curve <> [] then begin - dr#set_foreground (`NAME a.color); - dr#lines !curve; - end; - let fn = float !n in - let avg = !sum /. fn in - let stdev = sqrt ((!sum_squares -. fn *. avg *. avg) /. fn) in - set_float_value a.average avg; - set_float_value a.stdev stdev; + let margin = 3 in + let title_y = ref margin in + Hashtbl.iter (fun title a -> + (* Draw and compute average and stdev*) + let curve = ref [] + and sum = ref 0. and sum_squares = ref 0. + and n = ref 0 in + assert (size = Array.length a.array); + let last_value = ref None in + for i = 0 to size - 1 do + let i' = (i+a.index) mod size in + match a.array.(i') with + None -> () + | Some v -> + incr n; + sum := !sum +. v; + sum_squares := !sum_squares +. v *. v; + let x = (i * width) / size in + begin + match !last_value with + Some lv when a.discrete -> + curve := (x, y lv) :: !curve + | _ -> () + end; + curve := (x, y v) :: !curve; + last_value := Some v + done; + if !curve <> [] then begin + dr#set_foreground (`NAME a.color); + dr#lines !curve; + end; + let fn = float !n in + let avg = !sum /. fn in + let stdev = sqrt ((!sum_squares -. fn *. avg *. avg) /. fn) in + set_float_value a.average avg; + set_float_value a.stdev stdev; - (* Title *) - Pango.Layout.set_text layout title; - let (w, h) = Pango.Layout.get_pixel_size layout in - dr#rectangle ~x:(width-h-margin) ~y:!title_y ~width:h ~height:h ~filled:true (); + (* Title *) + Pango.Layout.set_text layout title; + let (w, h) = Pango.Layout.get_pixel_size layout in + dr#rectangle ~x:(width-h-margin) ~y:!title_y ~width:h ~height:h ~filled:true (); - dr#set_foreground `BLACK; - dr#put_layout ~x:(width-2*margin-w-h) ~y:(!title_y) layout; - title_y := !title_y + h + margin) + dr#set_foreground `BLACK; + dr#put_layout ~x:(width-2*margin-w-h) ~y:(!title_y) layout; + title_y := !title_y + h + margin) curves; pm#redraw () - with - exc -> - prerr_endline (Printexc.to_string exc) + with + exc -> + prerr_endline (Printexc.to_string exc) method stop_timer = fun () -> match timer with - None -> () + None -> () | Some t -> GMain.Timeout.remove t method set_update_time = fun delay -> @@ -306,7 +312,7 @@ class plot = fun ~size ~width ~height ~packing () -> method button_press = fun ev -> match GdkEvent.Button.button ev with - 3 -> self#reset_scale (); true + 3 -> self#reset_scale (); true | _ -> false initializer ignore (self#drawing_area#event#add [`BUTTON_PRESS]) @@ -327,7 +333,7 @@ let base_and_index = fun field_descr -> if Str.string_match field_regexp field_descr 0 then ( Str.matched_group 1 field_descr, - int_of_string (Str.matched_group 2 field_descr)) + int_of_string (Str.matched_group 2 field_descr)) else (field_descr, 0) @@ -339,26 +345,32 @@ let rec plot_window = fun window -> (* Register the window *) let oid = plotter#get_oid in - Hashtbl.add windows oid (); + Hashtbl.add windows oid []; ignore (plotter#parse_geometry window.geometry); plotter#set_icon (Some (GdkPixbuf.from_file Env.icon_file)); let vbox = GPack.vbox ~packing:plotter#add () in - let quit = fun () -> GMain.Main.quit (); exit 0 in - - let close = fun () -> - plotter#destroy (); - Hashtbl.remove windows oid; - if Hashtbl.length windows = 0 then - quit () in - - let tooltips = GData.tooltips () in - let menubar = GMenu.menu_bar ~packing:vbox#pack () in let factory = new GMenu.factory menubar in let accel_group = factory#accel_group in let file_menu = factory#add_submenu "Plot" in let file_menu_fact = new GMenu.factory file_menu ~accel_group in + let h = GPack.hbox ~packing:vbox#pack () in + let curves_menu = factory#add_submenu "Curves" in + let curves_menu_fact = new GMenu.factory curves_menu in + let tooltips = GData.tooltips () in + + let width = 900 and height = 200 in + let plot = new plot ~size: !size ~width ~height ~packing:(vbox#pack ~expand:true) () in + + let quit = fun () -> GMain.Main.quit (); exit 0 in + + let close = fun () -> + List.iter (fun c -> plot#delete_curve c) (Hashtbl.find windows oid); + plotter#destroy (); + Hashtbl.remove windows oid; + if Hashtbl.length windows = 0 then + quit () in ignore (file_menu_fact#add_item "New" ~key:GdkKeysyms._N ~callback:(fun () -> plot_window {window with curves=[]})); @@ -369,18 +381,12 @@ let rec plot_window = fun window -> ignore (file_menu_fact#add_separator ()); ignore (file_menu_fact#add_item "Close" ~key:GdkKeysyms._W ~callback:close); ignore (file_menu_fact#add_item "Quit" ~key:GdkKeysyms._Q ~callback:quit); - let curves_menu = factory#add_submenu "Curves" in - let curves_menu_fact = new GMenu.factory curves_menu in tooltips#set_tip reset_item#coerce ~text:"Reset the current display and the current data"; tooltips#set_tip curves_menu#coerce ~text:"Delete the curve"; tooltips#set_tip suspend_item#coerce ~text:"Freeze the display while the data are still updated"; tooltips#set_tip stop_item#coerce ~text:"Freeze the data update while the display is active (e.g. resizable)"; tooltips#set_tip start_item#coerce ~text:"UnFreeze"; - let h = GPack.hbox ~packing:vbox#pack () in - - let width = 900 and height = 200 in - let plot = new plot ~size: !size ~width ~height ~packing:(vbox#pack ~expand:true) () in tooltips#set_tip plot#drawing_area#coerce ~text:"Drop a messages field here to draw it"; ignore (plotter#connect#destroy ~callback:close); @@ -448,8 +454,7 @@ let rec plot_window = fun window -> (* Delete *) let delete_item = submenu_fact#add_item "Delete" in let delete = fun () -> - plot#delete_curve name; - Ivy.unbind binding; + plot#delete_curve name; curves_menu#remove (curve_item :> GMenu.menu_item) in ignore (delete_item#connect#activate ~callback:delete); @@ -471,7 +476,8 @@ let rec plot_window = fun window -> let _item = submenu_fact#add_image_item ~image:stdev_value#coerce ~label:"Stdev" () in let update_stdev_value = fun () -> stdev_value#set_text (sprintf "%.6f" curve.stdev#value) in - ignore (curve.stdev#connect#value_changed update_stdev_value) in + ignore (curve.stdev#connect#value_changed update_stdev_value) + in let add_curve = fun ?(factor=(1.,0.)) name -> let (a, b) = factor in @@ -482,10 +488,9 @@ let rec plot_window = fun window -> let cb = fun _sender values -> let (field_name, index) = base_and_index field_descr in let value = - match Pprz.assoc field_name values with - Pprz.Array array -> - array.(index) - | scalar -> scalar in + match Pprz.assoc field_name values with + Pprz.Array array -> array.(index) + | scalar -> scalar in let float = pprz_float value in let v = float *. a +. b in plot#add_value name v in @@ -493,30 +498,35 @@ let rec plot_window = fun window -> let module P = Pprz.Messages (struct let name = class_name end) in let binding = if sender = "*" then - P.message_bind msg_name cb + P.message_bind msg_name cb else - P.message_bind ~sender msg_name cb in + P.message_bind ~sender msg_name cb in - let curve = plot#create_curve name in - insert_in_menu curve name binding in + let curve = plot#create_curve name binding in + insert_in_menu curve name binding; + + (* store name of the curves associated to a window correct closing *) + let curves_name = Hashtbl.find windows oid in + Hashtbl.replace windows oid (curves_name @ [name]) + in (* Drag and drop handler *) - let data_received = fun context ~x ~y data ~info ~time -> - let factor = Ocaml_tools.affine_transform factor#text in - try - let name = data#data in - add_curve ~factor name - with - exc -> prerr_endline (Printexc.to_string exc) + let data_received = fun context ~x ~y data ~info ~time -> + let factor = Ocaml_tools.affine_transform factor#text in + try + let name = data#data in + add_curve ~factor name + with + exc -> prerr_endline (Printexc.to_string exc) in - plotter#drag#dest_set dnd_targets ~actions:[`COPY]; - ignore (plotter#drag#connect#data_received ~callback:(data_received)); + plotter#drag#dest_set dnd_targets ~actions:[`COPY]; + ignore (plotter#drag#connect#data_received ~callback:(data_received)); - (* Init curves *) - List.iter add_curve window.curves; + (* Init curves *) + List.iter add_curve window.curves; - plotter#add_accel_group accel_group; - plotter#show () + plotter#add_accel_group accel_group; + plotter#show () diff --git a/sw/simulator/old_booz/tests/Makefile b/sw/simulator/old_booz/tests/Makefile index 13d0e57905..4784790c47 100644 --- a/sw/simulator/old_booz/tests/Makefile +++ b/sw/simulator/old_booz/tests/Makefile @@ -4,10 +4,10 @@ #JSBSIM = /usr/local #CC = g++ -#CFLAGS = -Wall -I $(JSBSIM)/include/JSBSim -I../include -#LDFLAGS = -L $(JSBSIM)/lib -lJSBSim -#CFLAGS += -I /usr/include/meschach -I /usr/local/include/ -#LDFLAGS += -lmeschach -L /usr/lib +#CFLAGS = -Wall -I$(JSBSIM)/include/JSBSim -I../include +#LDFLAGS = -L$(JSBSIM)/lib -lJSBSim +#CFLAGS += -I/usr/include/meschach -I/usr/local/include/ +#LDFLAGS += -lmeschach -L/usr/lib #CFLAGS += `pkg-config glib-2.0 --cflags` #LDFLAGS += `pkg-config glib-2.0 --libs` -lm -lglibivy -lpcre @@ -24,16 +24,16 @@ JSBSIM = /home/violato/enac/programs/install_jsbsim CFLAGS = -Wall \ - -I .. \ - -I ../../../var/BOOZ2_A1 \ - -I ../../airborne \ - -I ../../include \ - -I $(JSBSIM)/include/JSBSim \ + -I.. \ + -I../../../var/BOOZ2_A1 \ + -I../../airborne \ + -I../../include \ + -I$(JSBSIM)/include/JSBSim \ `pkg-config glib-2.0 --cflags` \ LDFLAGS = -lm \ -lglibivy \ - -L $(JSBSIM)/lib -lJSBSim \ + -L$(JSBSIM)/lib -lJSBSim \ `pkg-config glib-2.0 --libs` \ SIMDIR = ..