diff --git a/.gitmodules b/.gitmodules index bf9e3ff49b..4120557974 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "sw/ext/fatfs"] path = sw/ext/fatfs url = https://github.com/enacuavlab/fatfs.git -[submodule "sw/ext/ardrone2_vision"] - path = sw/ext/ardrone2_vision - url = https://github.com/tudelft/ardrone2_vision.git [submodule "sw/ext/chibios"] path = sw/ext/chibios url = https://github.com/mabl/ChibiOS.git diff --git a/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml b/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml index 8ab5c8f96c..e8d4b5c50d 100644 --- a/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml +++ b/conf/airframes/ENAC/quadrotor/ard2_base_digit.xml @@ -5,7 +5,7 @@ - + diff --git a/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml b/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml index e52c35ae25..acf6d6cc47 100644 --- a/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml +++ b/conf/airframes/ENAC/quadrotor/ard2_base_vision.xml @@ -5,7 +5,7 @@ - + diff --git a/conf/airframes/TUDelft/IMAV2013/ardrone2_raw.xml b/conf/airframes/TUDelft/IMAV2013/ardrone2.xml similarity index 98% rename from conf/airframes/TUDelft/IMAV2013/ardrone2_raw.xml rename to conf/airframes/TUDelft/IMAV2013/ardrone2.xml index 2d1bff2fdb..de8231534f 100644 --- a/conf/airframes/TUDelft/IMAV2013/ardrone2_raw.xml +++ b/conf/airframes/TUDelft/IMAV2013/ardrone2.xml @@ -1,10 +1,10 @@ - + - + diff --git a/conf/airframes/TUDelft/IMAV2013/conf.xml b/conf/airframes/TUDelft/IMAV2013/conf.xml index dff3725763..aa0994d26c 100644 --- a/conf/airframes/TUDelft/IMAV2013/conf.xml +++ b/conf/airframes/TUDelft/IMAV2013/conf.xml @@ -1,160 +1,160 @@ - + - + - - - + + + @@ -25,9 +25,12 @@ + - + + + @@ -94,6 +97,7 @@
+ diff --git a/conf/airframes/ardrone2_indi.xml b/conf/airframes/ardrone2_indi.xml index 14146371f7..9a5e319c42 100644 --- a/conf/airframes/ardrone2_indi.xml +++ b/conf/airframes/ardrone2_indi.xml @@ -3,20 +3,19 @@ - + - - - - + + + @@ -32,6 +31,7 @@ + diff --git a/conf/airframes/ardrone2_opticflow_hover.xml b/conf/airframes/ardrone2_opticflow_hover.xml index 706ee24529..b207f57f8e 100644 --- a/conf/airframes/ardrone2_opticflow_hover.xml +++ b/conf/airframes/ardrone2_opticflow_hover.xml @@ -3,7 +3,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - - -
- -
- - - - - -
- -
- - - - -
- -
- - - - -
- -
- - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
diff --git a/conf/airframes/bebop.xml b/conf/airframes/bebop.xml index ed1e393509..338ae31145 100644 --- a/conf/airframes/bebop.xml +++ b/conf/airframes/bebop.xml @@ -110,10 +110,7 @@
- - + diff --git a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml index 2d8d0ef731..3144c7ba43 100644 --- a/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml +++ b/conf/airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml @@ -49,6 +49,12 @@ + + + + + + @@ -88,9 +94,11 @@
- - - + + + + +
diff --git a/conf/boards/ardrone2_sdk.makefile b/conf/boards/ardrone2.makefile similarity index 66% rename from conf/boards/ardrone2_sdk.makefile rename to conf/boards/ardrone2.makefile index 27852f94e8..7c57158a2e 100644 --- a/conf/boards/ardrone2_sdk.makefile +++ b/conf/boards/ardrone2.makefile @@ -1,14 +1,13 @@ # Hey Emacs, this is a -*- makefile -*- # -# ardrone2_sdk.makefile +# ardrone2.makefile # # http://wiki.paparazziuav.org/wiki/AR.Drone_2_-_Specifications # BOARD=ardrone BOARD_VERSION=2 -BOARD_TYPE=sdk -BOARD_CFG=\"boards/$(BOARD)$(BOARD_VERSION)_$(BOARD_TYPE).h\" +BOARD_CFG=\"boards/$(BOARD)$(BOARD_VERSION).h\" ARCH=linux $(TARGET).ARCHDIR = $(ARCH) @@ -17,8 +16,8 @@ ap.MAKEFILE = ardrone2 # ----------------------------------------------------------------------- USER=foobar -HOST=192.168.1.1 -SUB_DIR=sdk +HOST?=192.168.1.1 +SUB_DIR=paparazzi FTP_DIR=/data/video TARGET_DIR=$(FTP_DIR)/$(SUB_DIR) # ----------------------------------------------------------------------- @@ -30,20 +29,24 @@ ARDRONE2_IP_ADDRESS_PROBE ?= 1 # ----------------------------------------------------------------------- # The GPS sensor is connected trough USB so we have to define the device -GPS_PORT ?= UART1 -GPS_BAUD ?= B57600 +GPS_PORT ?= UART1 +GPS_BAUD ?= B57600 # The datalink default uses UDP -MODEM_HOST ?= 192.168.1.255 +MODEM_HOST ?= 192.168.1.255 -# for distinction between SDK and RAW version -ap.CFLAGS +=-DARDRONE2_SDK +# handle linux signals by hand +$(TARGET).CFLAGS += -DUSE_LINUX_SIGNAL -D_GNU_SOURCE + +# Link static (Done for GLIBC) +$(TARGET).CFLAGS += -DLINUX_LINK_STATIC +$(TARGET).LDFLAGS += -static # ----------------------------------------------------------------------- # default LED configuration -RADIO_CONTROL_LED ?= none +RADIO_CONTROL_LED ?= 6 BARO_LED ?= none -AHRS_ALIGNER_LED ?= none -GPS_LED ?= none -SYS_TIME_LED ?= none +AHRS_ALIGNER_LED ?= 5 +GPS_LED ?= 3 +SYS_TIME_LED ?= 0 diff --git a/conf/boards/ardrone2_raw.makefile b/conf/boards/ardrone2_raw.makefile index eed9e4c415..468815255e 100644 --- a/conf/boards/ardrone2_raw.makefile +++ b/conf/boards/ardrone2_raw.makefile @@ -1,56 +1,4 @@ -# Hey Emacs, this is a -*- makefile -*- -# -# ardrone2_raw.makefile -# -# http://wiki.paparazziuav.org/wiki/AR.Drone_2_-_Specifications -# +$(info Error: ardrone2_raw has been renamed to ardrone2) +$(info Please replace with ) -BOARD=ardrone -BOARD_VERSION=2 -BOARD_TYPE=raw -BOARD_CFG=\"boards/$(BOARD)$(BOARD_VERSION)_$(BOARD_TYPE).h\" - -ARCH=linux -$(TARGET).ARCHDIR = $(ARCH) -# include conf/Makefile.ardrone2 (with specific upload rules) instead of only Makefile.linux: -ap.MAKEFILE = ardrone2 - -# ----------------------------------------------------------------------- -USER=foobar -HOST?=192.168.1.1 -SUB_DIR=raw -FTP_DIR=/data/video -TARGET_DIR=$(FTP_DIR)/$(SUB_DIR) -# ----------------------------------------------------------------------- -ARDRONE2_START_PAPARAZZI ?= 0 -ARDRONE2_WIFI_MODE ?= 0 -ARDRONE2_SSID ?= ardrone2_paparazzi -ARDRONE2_IP_ADDRESS_BASE ?= 192.168.1. -ARDRONE2_IP_ADDRESS_PROBE ?= 1 -# ----------------------------------------------------------------------- - -# The GPS sensor is connected trough USB so we have to define the device -GPS_PORT ?= UART1 -GPS_BAUD ?= B57600 - -# The datalink default uses UDP -MODEM_HOST ?= 192.168.1.255 - -# for distinction between RAW and SDK version -$(TARGET).CFLAGS +=-DARDRONE2_RAW - -# handle linux signals by hand -$(TARGET).CFLAGS += -DUSE_LINUX_SIGNAL - -# Link static (Done for GLIBC) -$(TARGET).CFLAGS += -DLINUX_LINK_STATIC -$(TARGET).LDFLAGS += -static - -# ----------------------------------------------------------------------- - -# default LED configuration -RADIO_CONTROL_LED ?= 6 -BARO_LED ?= none -AHRS_ALIGNER_LED ?= 5 -GPS_LED ?= 3 -SYS_TIME_LED ?= 0 +$(error The ardrone2_raw board has been renamed to ardrone2) diff --git a/conf/conf_example.xml b/conf/conf_example.xml index 83e9cce29b..781b1b5281 100644 --- a/conf/conf_example.xml +++ b/conf/conf_example.xml @@ -25,7 +25,7 @@ name="Bumblebee_Quad" ac_id="40" airframe="airframes/examples/bumblebee_quad.xml" - radio="radios/cockpitSX.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/control/stabilization_rate.xml settings/estimation/ahrs_int_cmpl_quat.xml" @@ -102,7 +102,7 @@ name="Quad_LisaMX" ac_id="30" airframe="airframes/examples/quadrotor_lisa_mx.xml" - radio="radios/spektrum.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/estimation/ahrs_float_mlkf.xml" @@ -113,11 +113,11 @@ name="Quad_LisaM_2" ac_id="162" airframe="airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml" - radio="radios/cockpitSX.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/control/stabilization_rate.xml settings/estimation/ahrs_int_cmpl_quat.xml" - settings_modules="" + settings_modules="modules/gps_ubx_ucenter.xml modules/air_data.xml" gui_color="white" /> - @@ -245,7 +234,7 @@ name="quadshot" ac_id="19" airframe="airframes/examples/quadshot_asp21_spektrum.xml" - radio="radios/spektrum.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/estimation/ahrs_int_cmpl_quat.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int_quat.xml" diff --git a/conf/conf_tests.xml b/conf/conf_tests.xml index dfe12baae9..20a404c6b8 100644 --- a/conf/conf_tests.xml +++ b/conf/conf_tests.xml @@ -212,7 +212,7 @@ name="Quad_LisaMX" ac_id="30" airframe="airframes/examples/quadrotor_lisa_mx.xml" - radio="radios/spektrum.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/estimation/ahrs_float_mlkf.xml" @@ -223,11 +223,11 @@ name="Quad_LisaM_2" ac_id="162" airframe="airframes/examples/quadrotor_lisa_m_2_pwm_spektrum.xml" - radio="radios/cockpitSX.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int.xml settings/control/stabilization_rate.xml settings/estimation/ahrs_int_cmpl_quat.xml" - settings_modules="" + settings_modules="modules/gps_ubx_ucenter.xml modules/air_data.xml" gui_color="white" /> + - - @@ -399,7 +388,7 @@ name="quadshot" ac_id="19" airframe="airframes/examples/quadshot_asp21_spektrum.xml" - radio="radios/spektrum.xml" + radio="radios/dummy.xml" telemetry="telemetry/default_rotorcraft.xml" flight_plan="flight_plans/rotorcraft_basic.xml" settings="settings/rotorcraft_basic.xml settings/estimation/ahrs_int_cmpl_quat.xml settings/control/rotorcraft_guidance.xml settings/control/stabilization_att_int_quat.xml" diff --git a/conf/firmwares/rotorcraft.makefile b/conf/firmwares/rotorcraft.makefile index 0043002910..197320dda0 100644 --- a/conf/firmwares/rotorcraft.makefile +++ b/conf/firmwares/rotorcraft.makefile @@ -137,10 +137,8 @@ endif ifeq ($(BOARD), booz) ns_CFLAGS += -DUSE_DAC ns_srcs += $(SRC_ARCH)/mcu_periph/dac_arch.c -else ifeq ($(BOARD)$(BOARD_TYPE), ardronesdk) -ns_srcs += $(SRC_BOARD)/electrical_dummy.c -else ifeq ($(BOARD)$(BOARD_TYPE), ardroneraw) -ns_srcs += $(SRC_BOARD)/electrical_raw.c +else ifeq ($(BOARD), ardrone) +ns_srcs += $(SRC_BOARD)/electrical.c else ifeq ($(BOARD), bebop) ns_srcs += $(SRC_BOARD)/electrical.c endif @@ -169,7 +167,7 @@ ifeq ($(ARCH), stm32) ns_srcs += $(SRC_ARCH)/led_hw.c endif -ifeq ($(BOARD)$(BOARD_TYPE), ardroneraw) +ifeq ($(BOARD), ardrone) ns_srcs += $(SRC_BOARD)/gpio_ardrone.c endif diff --git a/conf/firmwares/subsystems/rotorcraft/ahrs_ardrone2.makefile b/conf/firmwares/subsystems/rotorcraft/ahrs_ardrone2.makefile deleted file mode 100644 index 4d8ce6e126..0000000000 --- a/conf/firmwares/subsystems/rotorcraft/ahrs_ardrone2.makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Hey Emacs, this is a -*- makefile -*- -# -# Fixed point complementary filter using euler angles for attitude estimation -# - -AHRS_CFLAGS = -DUSE_AHRS - -AHRS_CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_ardrone2.h\" -AHRS_SRCS += subsystems/ahrs.c -AHRS_SRCS += subsystems/ahrs/ahrs_ardrone2.c - -ap.CFLAGS += $(AHRS_CFLAGS) -ap.srcs += $(AHRS_SRCS) - -nps.CFLAGS += $(AHRS_CFLAGS) -nps.srcs += $(AHRS_SRCS) diff --git a/conf/firmwares/subsystems/shared/actuators_ardrone2.makefile b/conf/firmwares/subsystems/shared/actuators_ardrone2.makefile index 8273f4461d..01a040a1a1 100644 --- a/conf/firmwares/subsystems/shared/actuators_ardrone2.makefile +++ b/conf/firmwares/subsystems/shared/actuators_ardrone2.makefile @@ -1,11 +1,5 @@ -# Actuator drivers for both ardrone versions are conditionally included here -# The AT-command and RAW drivers are not interchangeble +# Actuator drivers for the raw ardrone version are included here -ifeq ($(BOARD_TYPE), sdk) - $(TARGET).srcs += $(SRC_BOARD)/actuators_at.c - $(TARGET).srcs += $(SRC_BOARD)/at_com.c -else ifeq ($(BOARD_TYPE), raw) - $(TARGET).CFLAGS += -DACTUATORS - $(TARGET).srcs += $(SRC_BOARD)/actuators_ardrone2_raw.c -endif +ap.CFLAGS += -DACTUATORS +ap.srcs += $(SRC_BOARD)/actuators.c diff --git a/conf/firmwares/subsystems/shared/baro_board.makefile b/conf/firmwares/subsystems/shared/baro_board.makefile index 1452a4bf6b..d0a54828ee 100644 --- a/conf/firmwares/subsystems/shared/baro_board.makefile +++ b/conf/firmwares/subsystems/shared/baro_board.makefile @@ -26,7 +26,7 @@ else ifeq ($(BOARD), navstik) BARO_BOARD_SRCS += $(SRC_BOARD)/baro_board.c # Ardrone baro -else ifeq ($(BOARD)$(BOARD_TYPE), ardroneraw) +else ifeq ($(BOARD), ardrone) BARO_BOARD_SRCS += $(SRC_BOARD)/baro_board.c # Bebop baro diff --git a/conf/firmwares/subsystems/shared/imu_ardrone2.makefile b/conf/firmwares/subsystems/shared/imu_ardrone2.makefile index 5f7a9efe9b..260b99fdb0 100644 --- a/conf/firmwares/subsystems/shared/imu_ardrone2.makefile +++ b/conf/firmwares/subsystems/shared/imu_ardrone2.makefile @@ -1,15 +1,9 @@ # imu AR.Drone2 -ifeq ($(BOARD_TYPE), sdk) -imu_CFLAGS += -DIMU_TYPE_H=\"subsystems/imu/imu_ardrone2_sdk.h\" -DUSE_IMU +imu_CFLAGS += -DIMU_TYPE_H=\"subsystems/imu/imu_ardrone2.h\" -DUSE_IMU imu_srcs += $(SRC_SUBSYSTEMS)/imu.c -imu_srcs += $(SRC_SUBSYSTEMS)/imu/imu_ardrone2_sdk.c -else ifeq ($(BOARD_TYPE), raw) -imu_CFLAGS += -DIMU_TYPE_H=\"subsystems/imu/imu_ardrone2_raw.h\" -DUSE_IMU -imu_srcs += $(SRC_SUBSYSTEMS)/imu.c -imu_srcs += $(SRC_SUBSYSTEMS)/imu/imu_ardrone2_raw.c +imu_srcs += $(SRC_SUBSYSTEMS)/imu/imu_ardrone2.c imu_srcs += $(SRC_BOARD)/navdata.c -endif # add it for all targets except sim, fbw and nps diff --git a/conf/messages.xml b/conf/messages.xml index d335029d3b..a8570eb1ee 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -1960,21 +1960,7 @@ - - - - - - - - - - - - - - - + diff --git a/conf/telemetry/default_ardrone.xml b/conf/telemetry/default_ardrone.xml deleted file mode 100644 index 7f96c17535..0000000000 --- a/conf/telemetry/default_ardrone.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/telemetry/default_rotorcraft.xml b/conf/telemetry/default_rotorcraft.xml index eb714ad745..485f1e5703 100644 --- a/conf/telemetry/default_rotorcraft.xml +++ b/conf/telemetry/default_rotorcraft.xml @@ -25,6 +25,7 @@ + @@ -46,6 +47,7 @@ + @@ -101,7 +103,8 @@ - + + @@ -138,6 +141,13 @@ + + + + + + + diff --git a/sw/airborne/arch/linux/led_hw.h b/sw/airborne/arch/linux/led_hw.h index ce84086c8e..2d4e36cc28 100644 --- a/sw/airborne/arch/linux/led_hw.h +++ b/sw/airborne/arch/linux/led_hw.h @@ -31,7 +31,7 @@ #include #include BOARD_CONFIG -#if defined BOARD_ARDRONE2_SDK || defined BOARD_ARDRONE2_RAW +#if defined BOARD_ARDRONE2 extern uint32_t led_hw_values; #define LED_INIT(i) { led_hw_values &= ~(1<> 6); cmd[3] = ((pwm2 & 0x1ff) << 2) | ((pwm3 & 0x1ff) >> 7); cmd[4] = ((pwm3 & 0x1ff) << 1); - full_write(actuator_ardrone2_raw_fd, cmd, 5); + full_write(actuator_ardrone2_fd, cmd, 5); RunOnceEvery(20, actuators_ardrone_led_run()); } @@ -265,10 +265,10 @@ void actuators_ardrone_set_leds(uint8_t led0, uint8_t led1, uint8_t led2, uint8_ cmd[0] = 0x60 | ((led0 & 1) << 4) | ((led1 & 1) << 3) | ((led2 & 1) << 2) | ((led3 & 1) << 1); cmd[1] = ((led0 & 2) << 3) | ((led1 & 2) << 2) | ((led2 & 2) << 1) | ((led3 & 2) << 0); - full_write(actuator_ardrone2_raw_fd, cmd, 2); + full_write(actuator_ardrone2_fd, cmd, 2); } void actuators_ardrone_close(void) { - close(actuator_ardrone2_raw_fd); + close(actuator_ardrone2_fd); } diff --git a/sw/airborne/boards/ardrone/actuators_ardrone2_raw.h b/sw/airborne/boards/ardrone/actuators.h similarity index 92% rename from sw/airborne/boards/ardrone/actuators_ardrone2_raw.h rename to sw/airborne/boards/ardrone/actuators.h index c564dd0ecc..69caa44a4c 100644 --- a/sw/airborne/boards/ardrone/actuators_ardrone2_raw.h +++ b/sw/airborne/boards/ardrone/actuators.h @@ -24,12 +24,12 @@ */ /** - * @file boards/ardrone/actuators_ardrone2_raw.h + * @file boards/ardrone/actuators.h * Actuator driver for ardrone2-raw version */ -#ifndef ACTUATORS_ARDRONE2_RAW_H_ -#define ACTUATORS_ARDRONE2_RAW_H_ +#ifndef ACTUATORS_ARDRONE2_H_ +#define ACTUATORS_ARDRONE2_H_ #include @@ -59,4 +59,4 @@ void actuators_ardrone_set_pwm(uint16_t pwm0, uint16_t pwm1, uint16_t pwm2, uint void actuators_ardrone_set_leds(uint8_t led0, uint8_t led1, uint8_t led2, uint8_t led3); void actuators_ardrone_close(void); -#endif /* ACTUATORS_ARDRONE2_RAW_H_ */ +#endif /* ACTUATORS_ARDRONE2_H_ */ diff --git a/sw/airborne/boards/ardrone/actuators_at.c b/sw/airborne/boards/ardrone/actuators_at.c deleted file mode 100644 index 20b19c4799..0000000000 --- a/sw/airborne/boards/ardrone/actuators_at.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 boards/ardrone/actuators_at.c - * ardrone2-sdk actuators are driven by external software controller by AT-commands - */ - -#include "subsystems/ahrs/ahrs_ardrone2.h" -#include "actuators_at.h" -#include "generated/airframe.h" -#include "boards/ardrone/at_com.h" - -void actuators_init(void) -{ - init_at_com(); -} - -void actuators_set(pprz_t commands[]) -{ - //Calculate the thrus, roll, pitch and yaw from the PPRZ commands - float thrust = ((float)(commands[COMMAND_THRUST] - MAX_PPRZ / 2) / (float)MAX_PPRZ) * 2.0f; - float roll = ((float)commands[COMMAND_ROLL] / (float)MAX_PPRZ); - float pitch = ((float)commands[COMMAND_PITCH] / (float)MAX_PPRZ); - float yaw = ((float)commands[COMMAND_YAW] / (float)MAX_PPRZ); - - //Starting engine - if(thrust > 0 && (ahrs_ardrone2.control_state == CTRL_DEFAULT || ahrs_ardrone2.control_state == CTRL_INIT - || ahrs_ardrone2.control_state == CTRL_LANDED)) { - at_com_send_ref(REF_TAKEOFF); - } - - //Check emergency or stop engine - if ((ahrs_ardrone2.state & ARDRONE_EMERGENCY_MASK) != 0) { - at_com_send_ref(REF_EMERGENCY); - } else if(thrust < -0.9 && !(ahrs_ardrone2.control_state == CTRL_DEFAULT || - ahrs_ardrone2.control_state == CTRL_INIT || ahrs_ardrone2.control_state == CTRL_LANDED)) { - at_com_send_ref(0); - } - - //Calibration - if ((ahrs_ardrone2.state & ARDRONE_MAGNETO_NEEDS_CALIB) != 0 && - (ahrs_ardrone2.control_state == CTRL_FLYING || ahrs_ardrone2.control_state == CTRL_HOVERING)) { - at_com_send_calib(0); - } - - //Moving - if ((ahrs_ardrone2.state & ARDRONE_MAGNETO_NEEDS_CALIB) == 0 && - (ahrs_ardrone2.control_state == CTRL_FLYING || ahrs_ardrone2.control_state == CTRL_HOVERING)) { - at_com_send_pcmd(1, thrust, roll, pitch, yaw); - } - - //Keep alive (FIXME) - at_com_send_config("general:navdata_demo", "FALSE"); -} diff --git a/sw/airborne/boards/ardrone/actuators_at.h b/sw/airborne/boards/ardrone/actuators_at.h deleted file mode 100644 index b862a92c6c..0000000000 --- a/sw/airborne/boards/ardrone/actuators_at.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 boards/ardrone/actuators_at.h - * ardrone2-sdk actuators are driven by external software controller by AT-commands - */ - -#ifndef BOARDS_ARDRONE_ACTUATORS_AT_H -#define BOARDS_ARDRONE_ACTUATORS_AT_H - -#include "paparazzi.h" - -extern void actuators_init(void); -extern void actuators_set(pprz_t commands[]); -#define SetActuatorsFromCommands(commands, AP_MODE) actuators_set(commands) - -#endif /* BOARDS_ARDRONE_ACTUATORS_AT_H */ diff --git a/sw/airborne/boards/ardrone/at_com.c b/sw/airborne/boards/ardrone/at_com.c deleted file mode 100644 index 188a216ba9..0000000000 --- a/sw/airborne/boards/ardrone/at_com.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 boards/ardrone/at_com.c - * Sending and receiving of AT-commands specified by the ardrone API - */ - -#include "at_com.h" -#include "boards/ardrone2_sdk.h" -#include "generated/airframe.h" - -#include -#include -#include -#include -#include -#include - -int packet_seq = 1; //Packet sequence number - -int at_socket = -1, //AT socket connection - navdata_socket = -1; //Navdata socket connection - -struct sockaddr_in pc_addr, //Own pc address - drone_at, //Drone AT address - drone_nav, //Drone nav address - from; //From address - -bool_t at_com_ready = FALSE; //Status of the at communication -char sessionId[9]; //THe config session ID - -void at_com_send(char *command); -void init_at_config(void); - -//Init the at_com -void init_at_com(void) -{ - //Check if already initialized - if (at_com_ready) { - return; - } - - //Create the at and navdata socket - if ((at_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - printf("at_com: at_socket error (%s)\n", strerror(errno)); - } - if ((navdata_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - printf("at_com: navdata_socket error (%s)\n", strerror(errno)); - } - - //For recvfrom - pc_addr.sin_family = AF_INET; - pc_addr.sin_addr.s_addr = htonl(INADDR_ANY); - pc_addr.sin_port = htons(9800); - - //For sendto AT - drone_at.sin_family = AF_INET; - drone_at.sin_addr.s_addr = inet_addr(ARDRONE_IP); - drone_at.sin_port = htons(ARDRONE_AT_PORT); - - //For sendto navadata init - drone_nav.sin_family = AF_INET; - drone_nav.sin_addr.s_addr = inet_addr(ARDRONE_IP); - drone_nav.sin_port = htons(ARDRONE_NAVDATA_PORT); - - //Bind the navdata socket - if (bind(navdata_socket, (struct sockaddr *) &pc_addr, sizeof(pc_addr)) < 0) { - printf("at_com: bind error (%s)\n", strerror(errno)); - } - - //Set unicast mode on - int one = 1; - sendto(navdata_socket, &one, 4, 0, (struct sockaddr *) &drone_nav, - sizeof(drone_nav)); - - //Init at config - init_at_config(); - - //Set at_com to ready - at_com_ready = TRUE; -} - -//Init the at config -void init_at_config(void) -{ - //Generate a session id - uint32_t binaryId = (uint32_t) rand(); - binaryId = (0 != binaryId) ? binaryId : 1u; - snprintf(sessionId, 9, "%08x", binaryId); - sessionId[8] = '\0'; - - //Send session, application and user id: - at_com_send_config("custom:session_id", sessionId); - at_com_send_config("custom:application_id", "9D7BFD45"); - at_com_send_config("custom:profile_id", "2BF07F58"); - - //Send config values - at_com_send_config("control:euler_angle_max", "0.52"); - at_com_send_config("control:altitude_max", "20000"); - at_com_send_config("control:control_vz_max", "2000"); - at_com_send_config("control:control_yaw", "6.11"); - - //Send config values with the airframe.h -#ifndef ARDRONE_FLIGHT_INDOOR - at_com_send_config("control:outdoor", "TRUE"); -#else - at_com_send_config("control:outdoor", "FALSE"); -#endif -#ifndef ARDRONE_WITHOUT_SHELL - at_com_send_config("control:flight_without_shell", "FALSE"); -#else - at_com_send_config("control:flight_without_shell", "TRUE"); -#endif -#ifdef ARDRONE_OWNER_MAC - at_com_send_config("network:owner_mac", ARDRONE_OWNER_MAC); -#endif -} - -//Recieve a navdata packet -int at_com_recieve_navdata(unsigned char *buffer) -{ - int l = sizeof(from); - int n; - // FIXME(ben): not clear why recvfrom() and not recv() is used. - n = recvfrom(navdata_socket, buffer, ARDRONE_NAVDATA_BUFFER_SIZE, 0x0, - (struct sockaddr *) &from, (socklen_t *) &l); - - return n; -} - -//Send an AT command -void at_com_send(char *command) -{ - sendto(at_socket, command, strlen(command), 0, (struct sockaddr *) &drone_at, - sizeof(drone_at)); -} - -//Send a Config -void at_com_send_config(char *key, char *value) -{ - char command[256]; - sprintf(command, "AT*CONFIG_IDS=%d,\"%s\",\"2BF07F58\",\"9D7BFD45\"\r", - packet_seq++, sessionId); - at_com_send(command); - sprintf(command, "AT*CONFIG=%d,\"%s\",\"%s\"\r", packet_seq++, key, value); - at_com_send(command); -} - -//Send a Flat trim -void at_com_send_ftrim(void) -{ - char command[256]; - sprintf(command, "AT*FTRIM=%d\r", packet_seq++); - at_com_send(command); -} - -//Send a Ref -void at_com_send_ref(int bits) -{ - char command[256]; - sprintf(command, "AT*REF=%d,%d\r", packet_seq++, bits | REF_DEFAULT); - at_com_send(command); -} - -//Send a Pcmd -void at_com_send_pcmd(int mode, float thrust, float roll, float pitch, - float yaw) -{ - int f_thrust, f_roll, f_pitch, f_yaw; - char command[256]; - - //Change the floats to ints(dereferencing) - memcpy(&f_thrust, &thrust, sizeof thrust); - memcpy(&f_roll, &roll, sizeof roll); - memcpy(&f_pitch, &pitch, sizeof pitch); - memcpy(&f_yaw, &yaw, sizeof yaw); - - sprintf(command, "AT*PCMD=%d,%d,%d,%d,%d,%d\r", packet_seq++, mode, f_roll, - f_pitch, f_thrust, f_yaw); - at_com_send(command); -} - -//Send a Calib -void at_com_send_calib(int device) -{ - char command[256]; - sprintf(command, "AT*CALIB=%d,%d\r", packet_seq++, device); - at_com_send(command); -} diff --git a/sw/airborne/boards/ardrone/at_com.h b/sw/airborne/boards/ardrone/at_com.h deleted file mode 100644 index f5196399e1..0000000000 --- a/sw/airborne/boards/ardrone/at_com.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 boards/ardrone/at_com.h - * Sending and receiving of AT-commands specified by the ardrone API - */ - -#include "math/pprz_algebra_float.h" - -#ifndef BOARDS_ARDRONE_AT_COM_H -#define BOARDS_ARDRONE_AT_COM_H - -#define NAVDATA_HEADER (0x55667788) - -//Define the AT_REF bits -typedef enum { - REF_TAKEOFF = 1U << 9, - REF_EMERGENCY = 1U << 8, - REF_DEFAULT = 0x11540000 -} AT_REFS; - -//Define control states -typedef enum { - CTRL_DEFAULT, - CTRL_INIT, - CTRL_LANDED, - CTRL_FLYING, - CTRL_HOVERING, - CTRL_TEST, - CTRL_TRANS_TAKEOFF, - CTRL_TRANS_GOTOFIX, - CTRL_TRANS_LANDING, - CTRL_TRANS_LOOPING, - CTRL_NUM_STATES -} CTRL_STATES; - -//Define the AR.Drone states -typedef enum { - ARDRONE_FLY_MASK = 1U << 0, /*!< FLY MASK : (0) ardrone is landed, (1) ardrone is flying */ - ARDRONE_VIDEO_MASK = 1U << 1, /*!< VIDEO MASK : (0) video disable, (1) video enable */ - ARDRONE_VISION_MASK = 1U << 2, /*!< VISION MASK : (0) vision disable, (1) vision enable */ - ARDRONE_CONTROL_MASK = 1U << 3, /*!< CONTROL ALGO : (0) euler angles control, (1) angular speed control */ - ARDRONE_ALTITUDE_MASK = 1U << 4, /*!< ALTITUDE CONTROL ALGO : (0) altitude control inactive (1) altitude control active */ - ARDRONE_USER_FEEDBACK_START = 1U << 5, /*!< USER feedback : Start button state */ - ARDRONE_COMMAND_MASK = 1U << 6, /*!< Control command ACK : (0) None, (1) one received */ - ARDRONE_CAMERA_MASK = 1U << 7, /*!< CAMERA MASK : (0) camera not ready, (1) Camera ready */ - ARDRONE_TRAVELLING_MASK = 1U << 8, /*!< Travelling mask : (0) disable, (1) enable */ - ARDRONE_USB_MASK = 1U << 9, /*!< USB key : (0) usb key not ready, (1) usb key ready */ - ARDRONE_NAVDATA_DEMO_MASK = 1U << 10, /*!< Navdata demo : (0) All navdata, (1) only navdata demo */ - ARDRONE_NAVDATA_BOOTSTRAP = 1U << 11, /*!< Navdata bootstrap : (0) options sent in all or demo mode, (1) no navdata options sent */ - ARDRONE_MOTORS_MASK = 1U << 12, /*!< Motors status : (0) Ok, (1) Motors problem */ - ARDRONE_COM_LOST_MASK = 1U << 13, /*!< Communication Lost : (1) com problem, (0) Com is ok */ - ARDRONE_SOFTWARE_FAULT = 1U << 14, /*!< Software fault detected - user should land as quick as possible (1) */ - ARDRONE_VBAT_LOW = 1U << 15, /*!< VBat low : (1) too low, (0) Ok */ - ARDRONE_USER_EL = 1U << 16, /*!< User Emergency Landing : (1) User EL is ON, (0) User EL is OFF*/ - ARDRONE_TIMER_ELAPSED = 1U << 17, /*!< Timer elapsed : (1) elapsed, (0) not elapsed */ - ARDRONE_MAGNETO_NEEDS_CALIB = 1U << 18, /*!< Magnetometer calibration state : (0) Ok, no calibration needed, (1) not ok, calibration needed */ - ARDRONE_ANGLES_OUT_OF_RANGE = 1U << 19, /*!< Angles : (0) Ok, (1) out of range */ - ARDRONE_WIND_MASK = 1U << 20, /*!< WIND MASK: (0) ok, (1) Too much wind */ - ARDRONE_ULTRASOUND_MASK = 1U << 21, /*!< Ultrasonic sensor : (0) Ok, (1) deaf */ - ARDRONE_CUTOUT_MASK = 1U << 22, /*!< Cutout system detection : (0) Not detected, (1) detected */ - ARDRONE_PIC_VERSION_MASK = 1U << 23, /*!< PIC Version number OK : (0) a bad version number, (1) version number is OK */ - ARDRONE_ATCODEC_THREAD_ON = 1U << 24, /*!< ATCodec thread ON : (0) thread OFF (1) thread ON */ - ARDRONE_NAVDATA_THREAD_ON = 1U << 25, /*!< Navdata thread ON : (0) thread OFF (1) thread ON */ - ARDRONE_VIDEO_THREAD_ON = 1U << 26, /*!< Video thread ON : (0) thread OFF (1) thread ON */ - ARDRONE_ACQ_THREAD_ON = 1U << 27, /*!< Acquisition thread ON : (0) thread OFF (1) thread ON */ - ARDRONE_CTRL_WATCHDOG_MASK = 1U << 28, /*!< CTRL watchdog : (1) delay in control execution (> 5ms), (0) control is well scheduled */ - ARDRONE_ADC_WATCHDOG_MASK = 1U << 29, /*!< ADC Watchdog : (1) delay in uart2 dsr (> 5ms), (0) uart2 is good */ - ARDRONE_COM_WATCHDOG_MASK = 1U << 30, /*!< Communication Watchdog : (1) com problem, (0) Com is ok */ - ARDRONE_EMERGENCY_MASK = 1U << 31 /*!< Emergency landing : (0) no emergency, (1) emergency */ -} ARDRONE_STATES; - -//Navdata option packet without data -typedef struct _navdata_option_t { - uint16_t tag; - uint16_t size; - uint8_t data[1]; -} __attribute__((packed)) navdata_option_t; - -//Main navdata packet -typedef struct _navdata_t { - uint32_t header; /*!< Always set to NAVDATA_HEADER */ - uint32_t ardrone_state; /*!< Bit mask built from def_ardrone_state_mask_t */ - uint32_t sequence; /*!< Sequence number, incremented for each sent packet */ - uint32_t vision_defined; - - navdata_option_t options[1]; -} __attribute__((packed)) navdata_t; - -//Navdata checksum packet -typedef struct _navdata_cks_t { - uint16_t tag; - uint16_t size; - uint32_t cks; -} __attribute__((packed)) navdata_cks_t; - -//Navdata demo option -typedef struct _navdata_demo_t { - uint16_t tag; /*!< Navdata block ('option') identifier */ - uint16_t size; /*!< set this to the size of this structure */ - uint32_t ctrl_state; /*!< Flying state (landed, flying, hovering, etc.) defined in CTRL_STATES enum. */ - uint32_t vbat_flying_percentage; /*!< battery voltage filtered (mV) */ - float theta; /*!< UAV's pitch in milli-degrees */ - float phi; /*!< UAV's roll in milli-degrees */ - float psi; /*!< UAV's yaw in milli-degrees */ - int32_t altitude; /*!< UAV's altitude in centimeters */ - float vx; /*!< UAV's estimated linear velocity */ - float vy; /*!< UAV's estimated linear velocity */ - float vz; /*!< UAV's estimated linear velocity */ - uint32_t num_frames; /*!< streamed frame index */ // Not used -> To integrate in video stage. - // Camera parameters compute by detection - struct FloatMat33 detection_camera_rot; /*!< Deprecated ! Don't use ! */ - struct FloatVect3 detection_camera_trans; /*!< Deprecated ! Don't use ! */ - uint32_t detection_tag_index; /*!< Deprecated ! Don't use ! */ - uint32_t detection_camera_type; /*!< Type of tag searched in detection */ - // Camera parameters compute by drone - struct FloatMat33 drone_camera_rot; /*!< Deprecated ! Don't use ! */ - struct FloatVect3 drone_camera_trans; /*!< Deprecated ! Don't use ! */ -} __attribute__((packed)) navdata_demo_t; - -//Navdata physical measures option -typedef struct _navdata_phys_measures_t { - uint16_t tag; - uint16_t size; - - float accs_temp; - uint16_t gyro_temp; - struct FloatVect3 phys_accs; - struct FloatVect3 phys_gyros; - uint32_t alim3V3; // 3.3volt alim [LSB] - uint32_t vrefEpson; // ref volt Epson gyro [LSB] - uint32_t vrefIDG; // ref volt IDG gyro [LSB] -} __attribute__((packed)) navdata_phys_measures_t; - -//Navdata gps packet -typedef double float64_t; //TODO: Fix this nicely, but this is only used here -typedef float float32_t; //TODO: Fix this nicely, but this is only used here -typedef struct _navdata_gps_t { - uint16_t tag; /*!< Navdata block ('option') identifier */ - uint16_t size; /*!< set this to the size of this structure */ - float64_t lat; /*!< Latitude */ - float64_t lon; /*!< Longitude */ - float64_t elevation; /*!< Elevation */ - float64_t hdop; /*!< hdop */ - int32_t data_available; /*!< When there is data available */ - uint8_t unk_0[8]; - float64_t lat0; /*!< Latitude ??? */ - float64_t lon0; /*!< Longitude ??? */ - float64_t lat_fuse; /*!< Latitude fused */ - float64_t lon_fuse; /*!< Longitude fused */ - uint32_t gps_state; /*!< State of the GPS, still need to figure out */ - uint8_t unk_1[40]; - float64_t vdop; /*!< vdop */ - float64_t pdop; /*!< pdop */ - float32_t speed; /*!< speed */ - uint32_t last_frame_timestamp; /*!< Timestamp from the last frame */ - float32_t degree; /*!< Degree */ - float32_t degree_mag; /*!< Degree of the magnetic */ - uint8_t unk_2[16]; - struct { - uint8_t sat; - uint8_t cn0; - } channels[12]; - int32_t gps_plugged; /*!< When the gps is plugged */ - uint8_t unk_3[108]; - float64_t gps_time; /*!< The gps time of week */ - uint16_t week; /*!< The gps week */ - uint8_t gps_fix; /*!< The gps fix */ - uint8_t num_sattelites; /*!< Number of sattelites */ - uint8_t unk_4[24]; - float64_t ned_vel_c0; /*!< NED velocity */ - float64_t ned_vel_c1; /*!< NED velocity */ - float64_t ned_vel_c2; /*!< NED velocity */ - float64_t pos_accur_c0; /*!< Position accuracy */ - float64_t pos_accur_c1; /*!< Position accuracy */ - float64_t pos_accur_c2; /*!< Position accuracy */ - float32_t speed_acur; /*!< Speed accuracy */ - float32_t time_acur; /*!< Time accuracy */ - uint8_t unk_5[72]; - float32_t temprature; - float32_t pressure; -} __attribute__((packed)) navdata_gps_t; - -//External functions -extern void init_at_com(void); -extern int at_com_recieve_navdata(unsigned char *buffer); -extern void at_com_send_config(char *key, char *value); -extern void at_com_send_ftrim(void); -extern void at_com_send_ref(int bits); -extern void at_com_send_pcmd(int mode, float thrust, float roll, float pitch, float yaw); -extern void at_com_send_calib(int device); - -#endif /* BOARDS_ARDRONE_AT_COM_H */ diff --git a/sw/airborne/boards/ardrone/electrical_raw.c b/sw/airborne/boards/ardrone/electrical.c similarity index 99% rename from sw/airborne/boards/ardrone/electrical_raw.c rename to sw/airborne/boards/ardrone/electrical.c index bbc5ece085..bb8dad54fe 100644 --- a/sw/airborne/boards/ardrone/electrical_raw.c +++ b/sw/airborne/boards/ardrone/electrical.c @@ -26,7 +26,7 @@ * arch specific electrical status readings */ -#include "electrical_raw.h" +#include "electrical.h" #include #include #include diff --git a/sw/airborne/boards/ardrone/electrical_raw.h b/sw/airborne/boards/ardrone/electrical.h similarity index 100% rename from sw/airborne/boards/ardrone/electrical_raw.h rename to sw/airborne/boards/ardrone/electrical.h diff --git a/sw/airborne/boards/ardrone/electrical_dummy.c b/sw/airborne/boards/ardrone/electrical_dummy.c deleted file mode 100644 index 0093d0a011..0000000000 --- a/sw/airborne/boards/ardrone/electrical_dummy.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Copyright (C) 2009-2013 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. - * - */ - -/** - * @file boards/ardrone/electrical_dummy.c - * dummy electrical status readings for ardrone-sdk version. - * - * Because ardrone2-sdk version does its battery updating in ahrs_adrone2.c. - */ - -#include "subsystems/electrical.h" - -struct Electrical electrical; - -void electrical_init(void) { } - -void electrical_periodic(void) { } diff --git a/sw/airborne/boards/ardrone/gpio_ardrone.c b/sw/airborne/boards/ardrone/gpio_ardrone.c index efcff4b390..2c77947434 100644 --- a/sw/airborne/boards/ardrone/gpio_ardrone.c +++ b/sw/airborne/boards/ardrone/gpio_ardrone.c @@ -22,8 +22,6 @@ * ardrone GPIO driver */ -#ifdef ARDRONE2_RAW - #include /* File control definitions */ #include /* Error number definitions */ #include @@ -133,5 +131,3 @@ uint16_t gpio_get(uint32_t port, uint16_t pin) ioctl(gpiofp, GPIO_READ, &data); return data.value; } - -#endif diff --git a/sw/airborne/boards/ardrone2_raw.h b/sw/airborne/boards/ardrone2.h similarity index 64% rename from sw/airborne/boards/ardrone2_raw.h rename to sw/airborne/boards/ardrone2.h index 957e3d9c88..f7431abcbc 100644 --- a/sw/airborne/boards/ardrone2_raw.h +++ b/sw/airborne/boards/ardrone2.h @@ -1,12 +1,12 @@ -#ifndef CONFIG_ARDRONE2_RAW -#define CONFIG_ARDRONE2_RAW +#ifndef CONFIG_ARDRONE2 +#define CONFIG_ARDRONE2 -#define BOARD_ARDRONE2_RAW +#define BOARD_ARDRONE2 #define UART1_DEV "/dev/ttyUSB0" /* Default actuators driver */ -#define DEFAULT_ACTUATORS "boards/ardrone/actuators_ardrone2_raw.h" +#define DEFAULT_ACTUATORS "boards/ardrone/actuators.h" #define ActuatorDefaultSet(_x,_y) ActuatorArdroneSet(_x,_y) #define ActuatorsDefaultInit() ActuatorsArdroneInit() #define ActuatorsDefaultCommit() ActuatorsArdroneCommit() @@ -17,4 +17,4 @@ #define USE_BARO_BOARD 1 #endif -#endif /* CONFIG_ARDRONE2_RAW */ +#endif /* CONFIG_ARDRONE2 */ diff --git a/sw/airborne/boards/ardrone2_sdk.h b/sw/airborne/boards/ardrone2_sdk.h deleted file mode 100644 index 12b7237ef5..0000000000 --- a/sw/airborne/boards/ardrone2_sdk.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONFIG_ARDRONE2_SDK -#define CONFIG_ARDRONE2_SDK - -#define BOARD_ARDRONE2_SDK - -#define UART1_DEV "/dev/ttyUSB0" - -/* Internal communication */ -#define ARDRONE_NAVDATA_PORT 5554 -#define ARDRONE_AT_PORT 5556 -#define ARDRONE_NAVDATA_BUFFER_SIZE 4096 -#define ARDRONE_IP "192.168.1.1" - -/* Default actuators driver */ -#define DEFAULT_ACTUATORS "boards/ardrone/actuators_at.h" -#define ActuatorDefaultSet(_x,_y) {} -#define ActuatorsDefaultInit() {} -#define ActuatorsDefaultCommit() {} - -#define USE_BARO_BOARD 0 - -#endif /* CONFIG_ARDRONE2_SDK */ diff --git a/sw/airborne/subsystems/ahrs/ahrs_ardrone2.c b/sw/airborne/subsystems/ahrs/ahrs_ardrone2.c deleted file mode 100644 index 520f465394..0000000000 --- a/sw/airborne/subsystems/ahrs/ahrs_ardrone2.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 subsystems/ahrs/ahrs_ardrone2.c - * AHRS implementation for ardrone2-sdk based on AT-commands. - * - * Uses AT-Commands to communicate with ardrone api to retrieve AHRS data - * and also sets battery level. - */ - -#ifdef ARDRONE2_DEBUG -# include -# include -#endif - -#include "subsystems/ahrs.h" -#include "ahrs_ardrone2.h" -#include "state.h" -#include "math/pprz_algebra_float.h" -#include "boards/ardrone/at_com.h" -#include "subsystems/electrical.h" - -#ifdef USE_GPS_ARDRONE2 -#include "subsystems/gps/gps_ardrone2.h" -#endif - -struct AhrsARDrone ahrs_ardrone2; -unsigned char buffer[4096]; //Packet buffer - -#if PERIODIC_TELEMETRY -#include "subsystems/datalink/telemetry.h" - -static void send_ahrs_ad2(struct transport_tx *trans, struct link_device *dev) -{ - pprz_msg_send_AHRS_ARDRONE2(trans, dev, AC_ID, - &ahrs_ardrone2.state, - &ahrs_ardrone2.control_state, - &ahrs_ardrone2.eulers.phi, - &ahrs_ardrone2.eulers.theta, - &ahrs_ardrone2.eulers.psi, - &ahrs_ardrone2.speed.x, - &ahrs_ardrone2.speed.y, - &ahrs_ardrone2.speed.z, - &ahrs_ardrone2.accel.x, - &ahrs_ardrone2.accel.y, - &ahrs_ardrone2.accel.z, - &ahrs_ardrone2.altitude, - &ahrs_ardrone2.battery); -} -#endif - -void ahrs_ardrone2_register(void) -{ - ahrs_ardrone2_init(); - /// @todo: provide enable function - ahrs_register_impl(NULL); -} - -void ahrs_ardrone2_init(void) -{ - init_at_com(); - - //Set navdata_demo to FALSE and flat trim the ar drone - at_com_send_config("general:navdata_demo", "FALSE"); - at_com_send_ftrim(); - - ahrs_ardrone2.is_aligned = TRUE; - -#if PERIODIC_TELEMETRY - register_periodic_telemetry(DefaultPeriodic, "AHRS_ARDRONE2", send_ahrs_ad2); -#endif -} - -#ifdef ARDRONE2_DEBUG -static void dump(const void *_b, size_t s) -{ - const unsigned char *b = _b; - size_t n; - - for (n = 0; n < s; ++n) { - printf("%02x ", b[n]); - if (n % 16 == 15) { - printf("\n"); - } - } - if (n % 16 != 0) { - printf("\n"); - } -} -#endif - -void ahrs_ardrone2_propagate(void) -{ - int l; - - //Recieve the main packet - l = at_com_recieve_navdata(buffer); - navdata_t *main_packet = (navdata_t *) &buffer; - -#ifdef ARDRONE2_DEBUG - if (l < 0) { - printf("errno = %d\n", errno); - } -#endif - - //When this isn't a valid packet return - if (l < 0 || main_packet->header != NAVDATA_HEADER) { - return; - } - -#ifdef ARDRONE2_DEBUG - printf("Read %d\n", l); - dump(buffer, l); -#endif - - //Set the state - ahrs_ardrone2.state = main_packet->ardrone_state; - - //Init the option - navdata_option_t *navdata_option = (navdata_option_t *) & (main_packet->options[0]); - bool_t full_read = FALSE; - - //The possible packets - navdata_demo_t *navdata_demo; - navdata_gps_t *navdata_gps; - navdata_phys_measures_t *navdata_phys_measures; - - //Read the navdata until packet is fully readed - while (!full_read && navdata_option->size > 0) { -#ifdef ARDRONE2_DEBUG - printf("tag = %d\n", navdata_option->tag); -#endif - //Check the tag for the right option - switch (navdata_option->tag) { - case 0: //NAVDATA_DEMO - navdata_demo = (navdata_demo_t *) navdata_option; - - //Set the AHRS state - ahrs_ardrone2.control_state = navdata_demo->ctrl_state >> 16; - ahrs_ardrone2.eulers.phi = navdata_demo->phi; - ahrs_ardrone2.eulers.theta = navdata_demo->theta; - ahrs_ardrone2.eulers.psi = navdata_demo->psi; - ahrs_ardrone2.speed.x = navdata_demo->vx / 1000; - ahrs_ardrone2.speed.y = navdata_demo->vy / 1000; - ahrs_ardrone2.speed.z = navdata_demo->vz / 1000; - ahrs_ardrone2.altitude = navdata_demo->altitude / 10; - ahrs_ardrone2.battery = navdata_demo->vbat_flying_percentage; - - //Set the ned to body eulers - struct FloatEulers angles; - angles.theta = navdata_demo->theta / 180000.*M_PI; - angles.psi = navdata_demo->psi / 180000.*M_PI; - angles.phi = navdata_demo->phi / 180000.*M_PI; - stateSetNedToBodyEulers_f(&angles); - - //Update the electrical supply - electrical.vsupply = navdata_demo->vbat_flying_percentage; - break; - case 3: //NAVDATA_PHYS_MEASURES - navdata_phys_measures = (navdata_phys_measures_t *) navdata_option; - - //Set the AHRS accel state - INT32_VECT3_SCALE_2(ahrs_ardrone2.accel, navdata_phys_measures->phys_accs, 9.81, 1000) - break; -#ifdef USE_GPS_ARDRONE2 - case 27: //NAVDATA_GPS -# ifdef ARDRONE2_DEBUG - dump(navdata_option, navdata_option->size); -# endif - navdata_gps = (navdata_gps_t *) navdata_option; - - // Send the data to the gps parser - gps_ardrone2_parse(navdata_gps); - break; -#endif - case 0xFFFF: //CHECKSUM - //TODO: Check the checksum - full_read = TRUE; - break; - default: -#ifdef ARDRONE2_DEBUG - printf("NAVDATA UNKNOWN TAG: %d %d\n", navdata_option->tag, navdata_option->size); -#endif - break; - } - navdata_option = (navdata_option_t *)((uint32_t)navdata_option + navdata_option->size); - } -} diff --git a/sw/airborne/subsystems/ahrs/ahrs_ardrone2.h b/sw/airborne/subsystems/ahrs/ahrs_ardrone2.h deleted file mode 100644 index ee1f668f6c..0000000000 --- a/sw/airborne/subsystems/ahrs/ahrs_ardrone2.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 subsystems/ahrs/ahrs_ardrone2.h - * AHRS implementation for ardrone2-sdk based on AT-commands. - * - * Uses AT-Commands to communicate with ardrone api to retrieve AHRS data - * and also sets battery level. - */ - -#ifndef AHRS_ARDRONE2_H -#define AHRS_ARDRONE2_H - -#include "std.h" -#include "math/pprz_algebra_int.h" -#include "math/pprz_geodetic_float.h" - -struct AhrsARDrone { - uint32_t state; // ARDRONE_STATES - uint32_t control_state; // CTRL_STATES - struct FloatEulers eulers; // in radians - struct NedCoor_f speed; // in m/s - struct NedCoor_f accel; // in m/s^2 - int32_t altitude; // in cm above ground - uint32_t battery; // in percentage - struct Int32Quat ltp_to_imu_quat; - bool_t is_aligned; -}; -extern struct AhrsARDrone ahrs_ardrone2; - -#ifndef PRIMARY_AHRS -#define PRIMARY_AHRS ahrs_ardrone2 -#endif - -extern void ahrs_ardrone2_register(void); -extern void ahrs_ardrone2_init(void); -extern void ahrs_ardrone2_propagate(void); - -#endif /* AHRS_ARDRONE2_H */ diff --git a/sw/airborne/subsystems/gps/gps_ardrone2.c b/sw/airborne/subsystems/gps/gps_ardrone2.c deleted file mode 100644 index 1eb5c76b50..0000000000 --- a/sw/airborne/subsystems/gps/gps_ardrone2.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * Copyright (C) 2013 Freek van Tienen - * - * 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 subsystems/gps/gps_ardrone2.c - * ARdrone 2 gps trough navdata for the SDK version and only works in combination with the ahrs ardrone2. - */ - -#ifdef ARDRONE2_DEBUG -# include -#endif - -#include "subsystems/gps.h" -#include "subsystems/abi.h" -#include "math/pprz_geodetic_double.h" - -void gps_impl_init(void) -{ -} - -void gps_ardrone2_parse(navdata_gps_t *navdata_gps) -{ - int i; - -#ifdef ARDRONE2_DEBUG - printf("state = %d\n", navdata_gps->gps_state); -#endif - // Set the lla double struct from the navdata - struct LlaCoor_d gps_lla_d; - gps_lla_d.lat = RadOfDeg(navdata_gps->lat); - gps_lla_d.lon = RadOfDeg(navdata_gps->lon); - gps_lla_d.alt = navdata_gps->elevation; - - // Convert it to ecef - struct EcefCoor_d gps_ecef_d; - ecef_of_lla_d(&gps_ecef_d, &gps_lla_d); - - // Convert the lla and ecef to int and set them in gps - ECEF_BFP_OF_REAL(gps.ecef_pos, gps_ecef_d); - LLA_BFP_OF_REAL(gps.lla_pos, gps_lla_d); - - // TODO: parse other stuff - gps.nb_channels = GPS_NB_CHANNELS; - - for (i = 0; i < GPS_NB_CHANNELS; i++) { - gps.svinfos[i].svid = navdata_gps->channels[i].sat; - gps.svinfos[i].cno = navdata_gps->channels[i].cn0; - } - - // Check if we have a fix TODO: check if 2D or 3D fix? - if (navdata_gps->gps_state == 1) { - gps.fix = GPS_FIX_3D; - } else { - gps.fix = GPS_FIX_NONE; - } - - gps.last_msg_ticks = sys_time.nb_sec_rem; - gps.last_msg_time = sys_time.nb_sec; - if (gps.fix == GPS_FIX_3D) { - gps.last_3dfix_ticks = sys_time.nb_sec_rem; - gps.last_3dfix_time = sys_time.nb_sec; - } - - uint32_t now_ts = get_sys_time_usec(); - AbiSendMsgGPS(GPS_ARDRONE2_ID, now_ts, &gps); -} diff --git a/sw/airborne/subsystems/gps/gps_ardrone2.h b/sw/airborne/subsystems/gps/gps_ardrone2.h deleted file mode 100644 index 804ff136d4..0000000000 --- a/sw/airborne/subsystems/gps/gps_ardrone2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2013 Freek van Tienen - * - * 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 subsystems/gps/gps_ardrone2.h - * ARdrone 2 gps trough navdata for the SDK version and only works in combination with the ahrs ardrone2. - * -*/ - -#ifndef GPS_ARDRONE_H -#define GPS_ARDRONE_H - -#include "boards/ardrone/at_com.h" - -#define GPS_NB_CHANNELS 12 - -/* - * The GPS event (dummy) - */ -#define GpsEvent() {} - -void gps_ardrone2_parse(navdata_gps_t *navdata_gps); - -/* Maybe needed? -#define gps_nmea_Reset(_val) { } -*/ - -#endif /* GPS_ARDRONE_H */ diff --git a/sw/airborne/subsystems/imu/imu_ardrone2_raw.c b/sw/airborne/subsystems/imu/imu_ardrone2.c similarity index 89% rename from sw/airborne/subsystems/imu/imu_ardrone2_raw.c rename to sw/airborne/subsystems/imu/imu_ardrone2.c index 4e7312e214..9af41d13ba 100644 --- a/sw/airborne/subsystems/imu/imu_ardrone2_raw.c +++ b/sw/airborne/subsystems/imu/imu_ardrone2.c @@ -20,13 +20,13 @@ */ /** - * @file subsystems/imu/imu_ardrone2_raw.c - * IMU implementation for ardrone2-raw. + * @file subsystems/imu/imu_ardrone2.c + * IMU implementation for ardrone2. */ #include "subsystems/imu.h" #include "navdata.h" -#include "imu_ardrone2_raw.h" +#include "imu_ardrone2.h" #include "mcu_periph/uart.h" void imu_impl_init(void) diff --git a/sw/airborne/subsystems/imu/imu_ardrone2_raw.h b/sw/airborne/subsystems/imu/imu_ardrone2.h similarity index 93% rename from sw/airborne/subsystems/imu/imu_ardrone2_raw.h rename to sw/airborne/subsystems/imu/imu_ardrone2.h index 7efbbcc796..4696193657 100644 --- a/sw/airborne/subsystems/imu/imu_ardrone2_raw.h +++ b/sw/airborne/subsystems/imu/imu_ardrone2.h @@ -20,12 +20,12 @@ */ /** - * @file subsystems/imu/imu_ardrone2_raw.h - * IMU implementation for ardrone2-raw. + * @file subsystems/imu/imu_ardrone2.h + * IMU implementation for ardrone2. */ -#ifndef IMU_ARDRONE2_RAW_H_ -#define IMU_ARDRONE2_RAW_H_ +#ifndef IMU_ARDRONE2_H_ +#define IMU_ARDRONE2_H_ #include "generated/airframe.h" #include "navdata.h" @@ -87,4 +87,4 @@ #define ImuEvent navdata_update -#endif /* IMU_ARDRONE2_RAW_H_ */ +#endif /* IMU_ARDRONE2_H_ */ diff --git a/sw/airborne/subsystems/imu/imu_ardrone2_sdk.c b/sw/airborne/subsystems/imu/imu_ardrone2_sdk.c deleted file mode 100644 index 5437cf590b..0000000000 --- a/sw/airborne/subsystems/imu/imu_ardrone2_sdk.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 Dino Hensen - * - * 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 subsystems/imu/imu_ardrone2_sdk.c - * dummy IMU implementation for ardrone2-sdk. - */ - -#include "subsystems/imu.h" -#include "imu_ardrone2_sdk.h" - - -void imu_impl_init(void) -{ - -} - -void imu_periodic(void) -{ - -} diff --git a/sw/airborne/subsystems/imu/imu_ardrone2_sdk.h b/sw/airborne/subsystems/imu/imu_ardrone2_sdk.h deleted file mode 100644 index 52a5be71c4..0000000000 --- a/sw/airborne/subsystems/imu/imu_ardrone2_sdk.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2013 Dino Hensen - * - * 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 subsystems/imu/imu_ardrone2_sdk.h - * dummy IMU implementation for ardrone2-sdk. - */ - -#ifndef IMU_ARDRONE2_SDK_H_ -#define IMU_ARDRONE2_SDK_H_ - - -#define ImuEvent() {} - - -#endif /* IMU_ARDRONE2_SDK_H_ */ diff --git a/sw/airborne/subsystems/ins/ins_ardrone2.c b/sw/airborne/subsystems/ins/ins_ardrone2.c deleted file mode 100644 index 27209aaa54..0000000000 --- a/sw/airborne/subsystems/ins/ins_ardrone2.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 subsystems/ins/ins_ardrone2.c - * INS implementation for ardrone2-sdk. - */ - -#include "subsystems/ins/ins_ardrone2.h" -#include "subsystems/ahrs.h" -#include "subsystems/gps.h" -#include "generated/airframe.h" -#include "generated/flight_plan.h" -#include "math/pprz_geodetic_int.h" - -#ifdef SITL -#include "nps_fdm.h" -#include -#endif - -#ifndef USE_INS_NAV_INIT -#define USE_INS_NAV_INIT TRUE -PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE") -#endif - -struct InsArdrone2 ins_ardrone2; - -void ins_ardrone2_init(void) -{ -#if USE_INS_NAV_INIT - struct LlaCoor_i llh_nav0; /* Height above the ellipsoid */ - llh_nav0.lat = NAV_LAT0; - llh_nav0.lon = NAV_LON0; - /* NAV_ALT0 = ground alt above msl, NAV_MSL0 = geoid-height (msl) over ellipsoid */ - llh_nav0.alt = NAV_ALT0 + NAV_MSL0; - - struct EcefCoor_i ecef_nav0; - ecef_of_lla_i(&ecef_nav0, &llh_nav0); - - ltp_def_from_ecef_i(&ins_ardrone2.ltp_def, &ecef_nav0); - ins_ardrone2.ltp_def.hmsl = NAV_ALT0; - stateSetLocalOrigin_i(&ins_ardrone2.ltp_def); - - ins_ardrone2.ltp_initialized = TRUE; -#else - ins_ardrone2.ltp_initialized = FALSE; -#endif - - INT32_VECT3_ZERO(ins_ardrone2.ltp_pos); - INT32_VECT3_ZERO(ins_ardrone2.ltp_speed); - INT32_VECT3_ZERO(ins_ardrone2.ltp_accel); -} - -void ins_reset_local_origin(void) -{ -#if USE_GPS - if (gps.fix == GPS_FIX_3D) { - ltp_def_from_ecef_i(&ins_ardrone2.ltp_def, &gps.ecef_pos); - ins_ardrone2.ltp_def.lla.alt = gps.lla_pos.alt; - ins_ardrone2.ltp_def.hmsl = gps.hmsl; - ins_ardrone2.ltp_initialized = TRUE; - stateSetLocalOrigin_i(&ins_ardrone2.ltp_def); - } - else { - ins_ardrone2.ltp_initialized = FALSE; - } -#else - ins_ardrone2.ltp_initialized = FALSE; -#endif -} - -void ins_reset_altitude_ref(void) -{ -#if USE_GPS - struct LlaCoor_i lla = { - .lat = state.ned_origin_i.lla.lat, - .lon = state.ned_origin_i.lla.lon, - .alt = gps.lla_pos.alt - }; - ltp_def_from_lla_i(&ins_ardrone2.ltp_def, &lla); - ins_ardrone2.ltp_def.hmsl = gps.hmsl; - stateSetLocalOrigin_i(&ins_ardrone2.ltp_def); -#endif -} - -void ins_ardrone2_periodic(void) -{ - /* untilt accels and speeds */ - float_rmat_transp_vmult((struct FloatVect3 *)&ins_ardrone2.ltp_accel, - stateGetNedToBodyRMat_f(), - (struct FloatVect3 *)&ahrs_ardrone2.accel); - float_rmat_transp_vmult((struct FloatVect3 *)&ins_ardrone2.ltp_speed, - stateGetNedToBodyRMat_f(), - (struct FloatVect3 *)&ahrs_ardrone2.speed); - - //Add g to the accelerations - ins_ardrone2.ltp_accel.z += 9.81; - - //Save the accelerations and speeds - stateSetAccelNed_f(&ins_ardrone2.ltp_accel); - stateSetSpeedNed_f(&ins_ardrone2.ltp_speed); - - //Don't set the height if we use the one from the gps -#if !USE_GPS_HEIGHT - //Set the height and save the position - ins_ardrone2.ltp_pos.z = -(ahrs_ardrone2.altitude * INT32_POS_OF_CM_NUM) / INT32_POS_OF_CM_DEN; - stateSetPositionNed_i(&ins_ardrone2.ltp_pos); -#endif -} - - -void ins_ardrone2_update_gps(void) -{ -#if USE_GPS - //Check for GPS fix - if (gps.fix == GPS_FIX_3D) { - //Set the initial coordinates - if (!ins_ardrone2.ltp_initialized) { - ltp_def_from_ecef_i(&ins_ardrone2.ltp_def, &gps.ecef_pos); - ins_ardrone2.ltp_def.lla.alt = gps.lla_pos.alt; - ins_ardrone2.ltp_def.hmsl = gps.hmsl; - ins_ardrone2.ltp_initialized = TRUE; - stateSetLocalOrigin_i(&ins_ardrone2.ltp_def); - } - - //Set the x and y and maybe z position in ltp and save - struct NedCoor_i ins_gps_pos_cm_ned; - ned_of_ecef_point_i(&ins_gps_pos_cm_ned, &ins_ardrone2.ltp_def, &gps.ecef_pos); - - //When we don't want to use the height of the navdata we can use the gps height -#if USE_GPS_HEIGHT - INT32_VECT3_SCALE_2(ins_ardrone2.ltp_pos, ins_gps_pos_cm_ned, INT32_POS_OF_CM_NUM, INT32_POS_OF_CM_DEN); -#else - INT32_VECT2_SCALE_2(ins_ardrone2.ltp_pos, ins_gps_pos_cm_ned, INT32_POS_OF_CM_NUM, INT32_POS_OF_CM_DEN); -#endif - - //Set the local origin - stateSetPositionNed_i(&ins_ardrone2.ltp_pos); - } -#endif /* USE_GPS */ -} - -#include "subsystems/abi.h" -static abi_event gps_ev; -static void gps_cb(uint8_t sender_id __attribute__((unused)), - uint32_t stamp __attribute__((unused)), - struct GpsState *gps_s) -{ - ins_ardrone2_update_gps(); -} - -void ins_ardrone2_register(void) -{ - ins_register_impl(ins_ardrone2_init); - - AbiBindMsgGPS(ABI_BROADCAST, &gps_ev, gps_cb); - // FIXME: ins_ardrone2_periodic is currently called via InsPeriodic hack directly from main -} diff --git a/sw/airborne/subsystems/ins/ins_ardrone2.h b/sw/airborne/subsystems/ins/ins_ardrone2.h deleted file mode 100644 index 9c703d82d0..0000000000 --- a/sw/airborne/subsystems/ins/ins_ardrone2.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012-2013 Freek van Tienen - * - * 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 subsystems/ins/ins_ardrone2.h - * INS implementation for ardrone2-sdk. - */ - -#ifndef INS_ARDRONE2_SDK_H -#define INS_ARDRONE2_SDK_H - -#include "subsystems/ins.h" -#include "std.h" -#include "math/pprz_geodetic_int.h" -#include "math/pprz_algebra_float.h" - -struct InsArdrone2 { - struct LtpDef_i ltp_def; - bool_t ltp_initialized; - - float qfe; ///< not used, only dummy for INS_REF message - - /* output LTP NED */ - struct NedCoor_i ltp_pos; - struct NedCoor_f ltp_speed; - struct NedCoor_f ltp_accel; -}; - -extern struct InsArdrone2 ins_ardrone2; - -#define DefaultInsImpl ins_ardrone2 -#define InsPeriodic ins_ardrone2_periodic - -extern void ins_ardrone2_init(void); -extern void ins_ardrone2_periodic(void); -extern void ins_ardrone2_update_gps(void); - -extern void ins_ardrone2_register(void); - -#endif /* INS_ARDRONE2_SDK_H */ diff --git a/sw/ext/ardrone2_vision b/sw/ext/ardrone2_vision deleted file mode 160000 index 2563e95725..0000000000 --- a/sw/ext/ardrone2_vision +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2563e957251899e03a5206ff437a56c2fe1c12a3 diff --git a/sw/ext/bebop.py b/sw/ext/bebop.py deleted file mode 100755 index da9c398967..0000000000 --- a/sw/ext/bebop.py +++ /dev/null @@ -1,488 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function -import re -import argparse -import socket -import telnetlib -import os -from time import sleep -from ftplib import FTP - - -# Check if IP is valid -def is_ip(address): - try: - socket.inet_aton(address) - ip = True - except socket.error: - ip = False - return ip - -# Execute a command -def execute_command(command): - tn.write(command + '\n') - return tn.read_until('# ')[len(command) + 2:-4] - -# Helper function -def split_into_path_and_file(name): - if name.count('/') <= 0: - return ["./", name] - return name.rsplit('/', 1) - -# Read from config.ini -def read_from_config(name, config=''): - if config == '': - config = execute_command('cat /data/config.ini') - search = re.search(name + '[^=]+=[\r\n\t ]([^\r\n\t ]+)', config) - if search is None: - return '' - else: - return search.group(1) - -# Write to config -def write_to_config(name, value): - if read_from_config(name) == '': - execute_command('echo "' + name + ' = ' + value + '\" >> /data/config.ini') - else: - execute_command('sed -i "s/\(' + name + ' *= *\).*/\\1' + value + '/g" /data/config.ini') - -# Check the version -def check_version(): - return execute_command('cat /firmware/version.txt') - -# Check what currently is running on the drone -def check_running(): - ps_aux = execute_command('ps') - running = "" - - if 'program.elf' in ps_aux: - running += ' Native (program.elf),' - if 'ap.elf' in ps_aux: - running += ' Paparazzi (ap.elf),' - if 'gst-launch' in ps_aux: - running += ' GStreamer (gst-launch)' - return running[1:] - -# Check if vision framework is installed -def check_vision_installed(): - du_opt = execute_command('du -d 2 /data/video/opt') - return '/data/video/opt/arm/gst' in du_opt or '/data/video/opt/arm/lib' in du_opt or '/data/video/opt/arm/tidsp-binaries-23.i3.8' in du_opt - -# Check if the vision framework is running -def check_vision_running(): - du_opt = execute_command('du -d 2 /opt') - return '/opt/arm/gst' in du_opt and '/opt/arm/lib' in du_opt and '/opt/arm/tidsp-binaries-23.i3.8' in du_opt - -# Check if autoboot is installed -def check_autoboot(): - check_update = execute_command('grep "START_PAPARAZZI" /bin/check_update.sh') - wifi_setup = execute_command('grep "BASE_ADRESS" /bin/wifi_setup.sh') - if "START_PAPARAZZI" in check_update and "BASE_ADRESS" in wifi_setup: - return True - else: - return False - -# Check if custom wifi_setup script is installed -def check_wifi_setup(): - check_wifi = execute_command('grep "static_ip_address_base" /bin/wifi_setup.sh') - if "static_ip_address_base" in check_wifi: - return True - else: - return False - -# Check the filesystem -def check_filesystem(): - return execute_command('df -h') - -# Reboot the drone -def bebop_reboot(): - execute_command('reboot') - -# Install the vision framework -def bebop_install_vision(): - print('Uploading GST') - ftp.storbinary("STOR arm_light.tgz", file("bin/arm_light.tgz", "rb")) - print(execute_command("cd /data/video && tar -xzf arm_light.tgz")) - print(execute_command("rm -rf /data/video/arm_light.tgz")) - print('Now Starting Vision') - bebop_start_vision() - -# Remove the vision framework -def bebop_remove_vision(): - execute_command("rm -rf /opt/arm") - execute_command("rm -rf /lib/dsp") - execute_command("rm -rf /data/video/opt") - -# Start the vision framework -def bebop_start_vision(): - # Mount the directories - execute_command("mkdir -p /opt/arm") - execute_command("mkdir -p /lib/dsp") - execute_command("mount --bind /data/video/opt/arm /opt/arm") - execute_command("mount --bind /data/video/opt/arm/lib/dsp /lib/dsp") - # Start The DSP programs - execute_command("kill -9 `pidof program.elf`") - execute_command("kill -9 `pidof gst-launch-0.10`") - execute_command("export PATH=/opt/arm/gst/bin:$PATH") - execute_command("export DSP_PATH=/opt/arm/tidsp-binaries-23.i3.8/") - execute_command("/bin/dspbridge/cexec.out -T /opt/arm/tidsp-binaries-23.i3.8/baseimage.dof -v") - execute_command("/bin/dspbridge/dynreg.out -r /opt/arm/tidsp-binaries-23.i3.8/m4venc_sn.dll64P -v") - # Show result - execute_command("ls -altr /opt/arm/gst/bin") - -# Install autoboot script -def bebop_install_autoboot(): - print('Uploading autoboot script') - ftp.storbinary("STOR check_update.sh", file("check_update.sh", "rb")) - print(execute_command("mv /data/video/check_update.sh /bin/check_update.sh")) - print(execute_command("chmod 777 /bin/check_update.sh")) - -# Install network script -def bebop_install_network_script(): - print('Uploading Wifi script') - ftp.storbinary("STOR wifi_setup.sh", file("wifi_setup.sh", "rb")) - print(execute_command("mv /data/video/wifi_setup.sh /bin/wifi_setup.sh")) - print(execute_command("chmod 777 /bin/wifi_setup.sh")) - -# Set network SSID -def bebop_set_ssid(name): - write_to_config('ssid_single_player', name) - print('The network ID (SSID) of the Bebop is changed to ' + name) - -# Set IP address -def bebop_set_ip_address(address): - splitted_ip = address.split(".") - write_to_config('static_ip_address_base', splitted_ip[0] + '.' + splitted_ip[1] + '.' + splitted_ip[2] + '.') - write_to_config('static_ip_address_probe', splitted_ip[3]) - print('The IP Address of the Bebop is changed to ' + address) - -# Set wifi mode (0: master, 1: ad-hoc, 2: managed, *: master) -def bebop_set_wifi_mode(mode): - modes = { 'master' : '0', 'ad-hoc' : '1', 'managed' : '2' } - try: - val = modes[mode] - except: - print('Unexpected wifi mode, setting to master (default)') - val = modes['master'] - write_to_config('wifi_mode', val) - print('The Wifi mode of the Bebop is changed to ' + mode + ' (' + val + ')') - -def bebop_status(): - config_ini = execute_command('cat /data/config.ini') - - print('======================== Bebop Status ========================') - print('Version:\t\t' + check_version()) - print('Host:\t\t\t' + args.host + ' (' + read_from_config('static_ip_address_base', config_ini) + - read_from_config('static_ip_address_probe', config_ini) + ' after boot)') - print('Currently running:\t' + check_running()) - print('Serial number:\t\t' + read_from_config('drone_serial', config_ini)) - print('Network id:\t\t' + read_from_config('ssid_single_player', config_ini)) - print('Motor software:\t\t' + - read_from_config('motor1_soft', config_ini) + '\t' + read_from_config('motor2_soft', config_ini) + '\t' + - read_from_config('motor3_soft', config_ini) + '\t' + read_from_config('motor4_soft', config_ini)) - print('Motor hardware:\t\t' + - read_from_config('motor1_hard', config_ini) + '\t' + read_from_config('motor2_hard', config_ini) + '\t' + - read_from_config('motor3_hard', config_ini) + '\t' + read_from_config('motor4_hard', config_ini)) - - autorun = {'': 'Native', '0': 'Native', '1': 'Paparazzi RAW', '2': 'Paparazzi SDK'} - if check_autoboot(): - print('Autorun at start:\tInstalled booting ' + autorun[read_from_config('start_paparazzi', config_ini)]) - else: - print('Autorun at start:\tNot installed') - - # Check if the vision framework is installed and running - vision_framework = "" - if check_vision_installed(): - vision_framework += "Installed" - if check_vision_running(): - vision_framework += " and running" - print('Vision framework:\t' + vision_framework) - - # Request the filesystem status - print('\n======================== Filesystem Status ========================') - print(check_filesystem()) - - -# Parse the arguments -parser = argparse.ArgumentParser(description='Bebop python helper. Use bebop.py -h for help') -parser.add_argument('--host', metavar='HOST', default='192.168.42.1', - help='the ip address of bebop') -subparsers = parser.add_subparsers(title='Command to execute', metavar='command', dest='command') - -# All the subcommands and arguments -subparsers.add_parser('status', help='Request the status of the Bebop') -subparsers.add_parser('reboot', help='Reboot the Bebop') -subparsers.add_parser('installvision', help='Install the vision framework') -subparser_upload_gst = subparsers.add_parser('upload_gst_module', - help='Upload, configure and move a gstreamer0.10 module libXXX.so') -subparser_upload_gst.add_argument('file', help='Filename of *.so module') -subparser_upload_and_run = subparsers.add_parser('upload_file_and_run', help='Upload and run software (for instance the Paparazzi autopilot)') -subparser_upload_and_run.add_argument('file', help='Filename of an executable') -subparser_upload_and_run.add_argument('folder', help='Destination subfolder (raw or sdk for Paparazzi autopilot)') -subparser_upload = subparsers.add_parser('upload_file', help='Upload a file to the Bebop') -subparser_upload.add_argument('file', help='Filename') -subparser_upload.add_argument('folder', help='Destination subfolder (base destination folder is /data/video)') -subparser_download = subparsers.add_parser('download_file', help='Download a file from the Bebop') -subparser_download.add_argument('file', help='Filename (with the path on the local machine)') -subparser_download.add_argument('folder', help='Remote subfolder (base folder is /data/video)') -subparser_download_dir = subparsers.add_parser('download_dir', help='Download all files from a folder from the Bebop') -subparser_download_dir.add_argument('dest', help='destination folder (on the local machine)') -subparser_download_dir.add_argument('folder', help='Remote subfolder (base folder is /data/video)') -subparser_rm_dir = subparsers.add_parser('rm_dir', help='Remove a directory and all its files from the Bebop') -subparser_rm_dir.add_argument('folder', help='Remote subfolder (base folder is /data/video)') -subparser_insmod = subparsers.add_parser('insmod', help='Upload and insert kernel module') -subparser_insmod.add_argument('file', help='Filename of *.ko kernel module') -subparsers.add_parser('startvision', help='Start the vision framework') -subparser_start = subparsers.add_parser('start', help='Start a program on the Bebop') -subparser_start.add_argument('program', help='the program to start') -subparser_kill = subparsers.add_parser('kill', help='Kill a program on the Bebop') -subparser_kill.add_argument('program', help='the program to kill') -subparser_networkid = subparsers.add_parser('networkid', help='Set the network ID(SSID) of the Bebop') -subparser_networkid.add_argument('name', help='the new network ID(SSID)') -subparser_ipaddress = subparsers.add_parser('ipaddress', help='Set the IP address of the Bebop') -subparser_ipaddress.add_argument('address', help='the new IP address') -subparser_wifimode = subparsers.add_parser('wifimode', help='Set the Wifi mode the Bebop') -subparser_wifimode.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed']) -subparser_configure_network = subparsers.add_parser('configure_network', help='Configure the network on the Bebop') -subparser_configure_network.add_argument('name', help='the new network ID(SSID)') -subparser_configure_network.add_argument('address', help='the new IP address') -subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed']) -subparser_install_autostart = subparsers.add_parser('install_autostart', help='Install custom autostart script and set what to start on boot for the Bebop') -subparser_install_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'], - help='what to start on boot') -subparser_autostart = subparsers.add_parser('autostart', help='Set what to start on boot for the Bebop') -subparser_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'], - help='what to start on boot') - -args = parser.parse_args() - -# Connect with telnet and ftp -try: - tn = telnetlib.Telnet(args.host) - ftp = FTP(args.host) - ftp.login() -except: - print('Could not connect to Bebop (host: ' + args.host + ')') - exit(2) - -# Read until after login -tn.read_until('# ') - -# Check the Bebop status -if args.command == 'status': - bebop_status() - -# Reboot the drone -elif args.command == 'reboot': - bebop_reboot() - print('The Bebop is rebooting...') - -# Kill a program -elif args.command == 'kill': - execute_command('killall -9 ' + args.program) - print('Program "' + args.program + '" is now killed') - -# Start a program -elif args.command == 'start': - execute_command(args.start + ' &') - print('Program "' + args.start + '" is now started') - -# Change the network ID -elif args.command == 'networkid': - bebop_set_ssid(args.name) - - if raw_input("Shall I restart the Bebop? (y/N) ").lower() == 'y': - bebop_reboot() - -# Change the IP address -elif args.command == 'ipaddress': - bebop_set_ip_address(args.address) - - if raw_input("Shall I restart the Bebop? (y/N) ").lower() == 'y': - bebop_reboot() - -# Change the wifi mode -elif args.command == 'wifimode': - bebop_set_wifi_mode(args.mode) - - if raw_input("Shall I restart the Bebop? (y/N) ").lower() == 'y': - bebop_reboot() - -# Install and configure network -elif args.command == 'configure_network': - config_ini = execute_command('cat /data/config.ini') - print('=== Current network setup ===') - print('Network id:\t' + read_from_config('ssid_single_player', config_ini)) - print('Host:\t\t' + args.host + ' (' + read_from_config('static_ip_address_base', config_ini) + - read_from_config('static_ip_address_probe', config_ini) + ' after boot)') - print('Mode:\t\t' + read_from_config('wifi_mode', config_ini)) - print('=============================') - if check_wifi_setup(): - print('Custom Wifi script already installed') - if raw_input("Shall I reinstall the Wifi script (y/N) ").lower() == 'y': - bebop_install_network_script() - else: - if raw_input("Shall I install custom Wifi script (recommanded) (y/N) ").lower() == 'y': - bebop_install_network_script() - bebop_set_ssid(args.name) - bebop_set_ip_address(args.address) - bebop_set_wifi_mode(args.mode) - config_ini = execute_command('cat /data/config.ini') - print('== New network setup after boot ==') - print('Network id:\t' + read_from_config('ssid_single_player', config_ini)) - print('Host:\t\t' + read_from_config('static_ip_address_base', config_ini) + - read_from_config('static_ip_address_probe', config_ini)) - print('Mode:\t\t' + read_from_config('wifi_mode', config_ini)) - print('==================================') - - if raw_input("Shall I restart the Bebop? (y/N) ").lower() == 'y': - bebop_reboot() - -# Install and configure autostart -elif args.command == 'install_autostart': - if check_autoboot(): - print('Custom autostart script already installed') - if raw_input("Shall I reinstall the autostart script (y/N) ").lower() == 'y': - bebop_install_autoboot() - else: - bebop_install_autoboot() - autorun = {'native': '0', 'paparazzi_raw': '1', 'paparazzi_sdk': '2'} - write_to_config('start_paparazzi', autorun[args.type]) - print('The autostart on boot is changed to ' + args.type) - - if raw_input("Shall I restart the Bebop? (y/N) ").lower() == 'y': - bebop_reboot() - -# Change the autostart -elif args.command == 'autostart': - autorun = {'native': '0', 'paparazzi_raw': '1', 'paparazzi_sdk': '2'} - write_to_config('start_paparazzi', autorun[args.type]) - print('The autostart on boot is changed to ' + args.type) - -# Install Vision framework -elif args.command == 'installvision': - if check_vision_installed(): - print('Vision framework already installed') - if raw_input("Shall I reinstall the vision framework? (y/N) ").lower() == 'y': - bebop_remove_vision() - bebop_install_vision() - - bebop_install_vision() - print('Vision framework installed') - -# Start Vision framework -elif args.command == 'startvision': - if check_vision_running(): - print('Vision framework already started') - else: - if not check_vision_installed(): - print('No vision framework installed') - if raw_input("Shall I install the vision framework? (y/N) ").lower() == 'y': - bebop_install_vision() - - if check_vision_installed(): - bebop_start_vision() - print('Vision framework started') - -elif args.command == 'upload_gst_module': - print('Uploading ...' + args.file) - ftp.storbinary("STOR " + args.file, file(args.file, "rb")) - execute_command("chmod 777 /data/video/" + args.file) - execute_command("mv /data/video/" + args.file + " /data/video/opt/arm/gst/lib/gstreamer-0.10") - if check_vision_running(): - print('Info: Vision framework already started') - else: - if not check_vision_installed(): - print('Warning: No vision framework installed') - if raw_input("Warning: Shall I install the vision framework? (y/N) ").lower() == 'y': - bebop_install_vision() - - if check_vision_installed(): - bebop_start_vision() - print('#pragma message: Vision framework started') - print('#pragma message: Vision Plugin Uploaded and DSP Started.') - - -elif args.command == 'insmod': - modfile = split_into_path_and_file(args.file) - print('Uploading \'' + modfile[1]) - ftp.storbinary("STOR " + modfile[1], file(args.file, "rb")) - print(execute_command("insmod /data/video/" + modfile[1])) - -elif args.command == 'upload_file_and_run': - # Split filename and path - f = split_into_path_and_file(args.file) - - print("Kill running " + f[1] + " and make folder " + args.folder) - execute_command("killall -9 " + f[1]) - sleep(1) - execute_command("mkdir -p /data/ftp/" + args.folder) - print('Uploading \'' + f[1] + "\' from " + f[0] + " to " + args.folder) - ftp.storbinary("STOR " + args.folder + "/" + f[1], file(args.file, "rb")) - sleep(0.5) - execute_command("chmod 777 /data/ftp/" + args.folder + "/" + f[1]) - execute_command("/data/ftp/" + args.folder + "/" + f[1] + " > /dev/null 2>&1 &") - print("#pragma message: Upload and Start of ap.elf to Bebop Succes!") - -elif args.command == 'upload_file': - # Split filename and path - f = split_into_path_and_file(args.file) - - execute_command("mkdir -p /data/video/" + args.folder) - print('Uploading \'' + f[1] + "\' from " + f[0] + " to /data/video/" + args.folder) - ftp.storbinary("STOR " + args.folder + "/" + f[1], file(args.file, "rb")) - print("#pragma message: Upload of " + f[1] + " to Bebop Succes!") - -elif args.command == 'download_file': - # Split filename and path - f = split_into_path_and_file(args.file) - # Open file and download - try: - file = open(args.file, 'wb') - print('Downloading \'' + f[1] + "\' from " + args.folder + " to " + f[0]) - ftp.retrbinary("RETR " + args.folder + "/" + f[1], file.write) - print("#pragma message: Download of " + f[1] + " from Bebop Succes!") - except IOError: - print("#pragma message: Fail to open file " + args.file) - except: - os.remove(args.file) - print("#pragma message: Download of " + f[1] + " from Bebop Failed!") - else: - file.close() - -elif args.command == 'download_dir': - # Split filename and path - files = execute_command('find /data/video/' + args.folder + ' -name \'*.*\'') - # Create dest dir if needed - if not os.path.exists(args.dest): - os.mkdir(args.dest) - # Open file and download - for f in files.split(): - file_name = split_into_path_and_file(f) - file_source = args.folder + '/' + file_name[1] - file_dest = args.dest + '/' + file_name[1] - try: - file = open(file_dest, 'wb') - print('Downloading \'' + f + "\' to " + file_dest) - ftp.retrbinary("RETR " + file_source, file.write) - except IOError: - print("#pragma message: Fail to open file " + file_dest) - except: - os.remove(file_dest) - print("#pragma message: Download of " + f + " from Bebop Failed!") - else: - file.close() - print("#pragma message: End download of folder " + args.folder + " from Bebop") - -elif args.command == 'rm_dir': - # Split filename and path - print("Deleting folder /data/video/" + args.folder + " from Bebop") - print(execute_command('rm -r /data/video/' + args.folder)) - - - -# Close the telnet and python script -tn.close() -ftp.close() -exit(0) diff --git a/sw/tools/parrot/ardrone2.py b/sw/tools/parrot/ardrone2.py index ed7dd482aa..81ba416c97 100755 --- a/sw/tools/parrot/ardrone2.py +++ b/sw/tools/parrot/ardrone2.py @@ -173,7 +173,7 @@ def ardrone2_status(): read_from_config('motor1_hard', config_ini) + '\t' + read_from_config('motor2_hard', config_ini) + '\t' + read_from_config('motor3_hard', config_ini) + '\t' + read_from_config('motor4_hard', config_ini)) - autorun = {'': 'Native', '0': 'Native', '1': 'Paparazzi RAW', '2': 'Paparazzi SDK'} + autorun = {'': 'Native', '0': 'Native', '1': 'Paparazzi'} if check_autoboot(): print('Autorun at start:\tInstalled booting ' + autorun[read_from_config('start_paparazzi', config_ini)]) else: @@ -207,7 +207,7 @@ subparser_upload_gst = subparsers.add_parser('upload_gst_module', subparser_upload_gst.add_argument('file', help='Filename of *.so module') subparser_upload_and_run = subparsers.add_parser('upload_file_and_run', help='Upload and run software (for instance the Paparazzi autopilot)') subparser_upload_and_run.add_argument('file', help='Filename of an executable') -subparser_upload_and_run.add_argument('folder', help='Destination subfolder (raw or sdk for Paparazzi autopilot)') +subparser_upload_and_run.add_argument('folder', help='Destination subfolder (raw for Paparazzi autopilot)') subparser_upload = subparsers.add_parser('upload_file', help='Upload a file to the ARDrone 2') subparser_upload.add_argument('file', help='Filename') subparser_upload.add_argument('folder', help='Destination subfolder (base destination folder is /data/video)') @@ -238,10 +238,10 @@ subparser_configure_network.add_argument('address', help='the new IP address') subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed', 'ad-hoc-olsr']) subparser_configure_network.add_argument('--channel', help='the wifi channel (auto or 1 to 11)', default='auto') subparser_install_autostart = subparsers.add_parser('install_autostart', help='Install custom autostart script and set what to start on boot for the ARDrone 2') -subparser_install_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'], +subparser_install_autostart.add_argument('type', choices=['native', 'paparazzi'], help='what to start on boot') subparser_autostart = subparsers.add_parser('autostart', help='Set what to start on boot for the ARDrone 2') -subparser_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'], +subparser_autostart.add_argument('type', choices=['native', 'paparazzi'], help='what to start on boot') args = parser.parse_args() @@ -285,7 +285,7 @@ elif args.command == 'ipaddress': # Change the wifi mode elif args.command == 'wifimode': ardrone2_set_wifi_mode(args.mode) - + if raw_input("Shall I restart the ARDrone 2? (y/N) ").lower() == 'y': parrot_utils.reboot(tn) @@ -332,7 +332,7 @@ elif args.command == 'install_autostart': ardrone2_install_autoboot() else: ardrone2_install_autoboot() - autorun = {'native': '0', 'paparazzi_raw': '1', 'paparazzi_sdk': '2'} + autorun = {'native': '0', 'paparazzi': '1'} write_to_config('start_paparazzi', autorun[args.type]) print('The autostart on boot is changed to ' + args.type) @@ -341,7 +341,7 @@ elif args.command == 'install_autostart': # Change the autostart elif args.command == 'autostart': - autorun = {'native': '0', 'paparazzi_raw': '1', 'paparazzi_sdk': '2'} + autorun = {'native': '0', 'paparazzi': '1'} write_to_config('start_paparazzi', autorun[args.type]) print('The autostart on boot is changed to ' + args.type) diff --git a/sw/tools/parrot/ardrone2/check_update.sh b/sw/tools/parrot/ardrone2/check_update.sh index 3fee525f48..bd344c22fd 100755 --- a/sw/tools/parrot/ardrone2/check_update.sh +++ b/sw/tools/parrot/ardrone2/check_update.sh @@ -9,10 +9,7 @@ echo "Check if need to start paparazzi ..." START_PAPARAZZI=`grep start_paparazzi /data/config.ini | awk -F "=" '{ gsub(/ */,"",$2); print $2}'` case $START_PAPARAZZI in 1) - START_PAPARAZZI=raw - ;; -2) - START_PAPARAZZI=sdk + START_PAPARAZZI=yes ;; *) START_PAPARAZZI=no @@ -28,7 +25,7 @@ PELF_ARGS=$(cat /tmp/.program.elf.arguments | tr '\n' ' ') echo "Check if update is necessary ..." if [ -e $UPDATE_PATH ] ; then VERSION=`cat $VERSION_PATH` - + if [ -e $ERR_PATH ] ; then CHECK_ERR=`cat $ERR_PATH` if [ "$CHECK_ERR" = "NEED_TO_FLASH" ] ; then @@ -36,17 +33,17 @@ if [ -e $UPDATE_PATH ] ; then if [ "$CHECK_PLF" = "NEED_TO_FLASH" ] ; then echo "ERR=FLASH_KO" > $ERR_PATH else - /bin/checkplf $UPDATE_PATH $VERSION > $ERR_PATH + /bin/checkplf $UPDATE_PATH $VERSION > $ERR_PATH fi else - /bin/checkplf $UPDATE_PATH $VERSION > $ERR_PATH + /bin/checkplf $UPDATE_PATH $VERSION > $ERR_PATH fi else /bin/checkplf $UPDATE_PATH $VERSION > $ERR_PATH fi - + CHECK_ERR=`cat $ERR_PATH` - if [ "$CHECK_ERR" = "NEED_TO_FLASH" ] ; then + if [ "$CHECK_ERR" = "NEED_TO_FLASH" ] ; then echo "File $UPDATE_PATH exists... Start updating..." pinst_trigger echo "Rebooting..." @@ -64,12 +61,10 @@ if [ -e $UPDATE_PATH ] ; then cp /firmware/version.txt $VERSION_PATH echo "Start Drone software..." inetd - + # Check what to start - if [ "$START_PAPARAZZI" = "raw" ] ; then - (/data/video/raw/ap.elf; gpio 181 -d ho 1) & - elif [ "$START_PAPARAZZI" = "sdk" ] ; then - (/data/video/sdk/ap.elf; gpio 181 -d ho 1) & + if [ "$START_PAPARAZZI" = "yes" ] ; then + (/data/video/paparazzi/ap.elf; gpio 181 -d ho 1) & else (/bin/program.elf ${PELF_ARGS}; gpio 181 -d ho 1) & fi @@ -82,14 +77,10 @@ else inetd # Check what to start - if [ "$START_PAPARAZZI" = "raw" ] ; then + if [ "$START_PAPARAZZI" = "yes" ] ; then (/bin/program.elf ${PELF_ARGS}; gpio 181 -d ho 1) & sleep 10 - (/data/video/raw/ap.elf; gpio 181 -d ho 1) & - elif [ "$START_PAPARAZZI" = "sdk" ] ; then - (/bin/program.elf ${PELF_ARGS}; gpio 181 -d ho 1) & - sleep 10 - (/data/video/sdk/ap.elf; gpio 181 -d ho 1) & + (/data/video/paparazzi/ap.elf; gpio 181 -d ho 1) & else (/bin/program.elf ${PELF_ARGS}; gpio 181 -d ho 1) & fi diff --git a/sw/tools/parrot/bebop.py b/sw/tools/parrot/bebop.py index 2f7c1555aa..13923e32f7 100755 --- a/sw/tools/parrot/bebop.py +++ b/sw/tools/parrot/bebop.py @@ -67,7 +67,7 @@ subparsers.add_parser('status', help='Request the status of the Bebop') subparsers.add_parser('reboot', help='Reboot the Bebop') subparser_upload_and_run = subparsers.add_parser('upload_file_and_run', help='Upload and run software (for instance the Paparazzi autopilot)') subparser_upload_and_run.add_argument('file', help='Filename of an executable') -subparser_upload_and_run.add_argument('folder', help='Destination subfolder (raw or sdk for Paparazzi autopilot)') +subparser_upload_and_run.add_argument('folder', help='Destination subfolder (raw for Paparazzi autopilot)') subparser_upload = subparsers.add_parser('upload_file', help='Upload a file to the Bebop') subparser_upload.add_argument('file', help='Filename') subparser_upload.add_argument('folder', help='Destination subfolder (base destination folder is /data/ftp)')