diff --git a/flight/Modules/Airspeed/revolution/airspeed.c b/flight/Modules/Airspeed/revolution/airspeed.c new file mode 100644 index 000000000..9273fc871 --- /dev/null +++ b/flight/Modules/Airspeed/revolution/airspeed.c @@ -0,0 +1,159 @@ +/** + ****************************************************************************** + * @addtogroup OpenPilotModules OpenPilot Modules + * @{ + * @addtogroup AirspeedModule Airspeed Module + * @brief Communicate with BMP085 and update @ref BaroAirspeed "BaroAirspeed UAV Object" + * @{ + * + * @file airspeed.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Airspeed module, handles temperature and pressure readings from BMP085 + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * Output object: BaroAirspeed + * + * This module will periodically update the value of the BaroAirspeed object. + * + */ + +#include "openpilot.h" +#include "hwsettings.h" +#include "airspeed.h" +#include "baroairspeed.h" // object that will be updated by the module +#if defined(PIOS_INCLUDE_HCSR04) +#include "sonarairspeed.h" // object that will be updated by the module +#endif + +// Private constants +#define STACK_SIZE_BYTES 500 +#define TASK_PRIORITY (tskIDLE_PRIORITY+1) +#define SAMPLING_DELAY_MS 50 +#define CALIBRATION_IDLE 40 +#define CALIBRATION_COUNT 40 +#define ETS_AIRSPEED_SCALE 1.0f + +// Private types + +// Private variables +static xTaskHandle taskHandle; + +// Private functions +static void airspeedTask(void *parameters); + + +static bool airspeedEnabled = false; + +/** + * Initialise the module, called on startup + * \returns 0 on success or -1 if initialisation failed + */ +int32_t AirspeedStart() +{ + + if (airspeedEnabled == false) { + return -1; + } + // Start main task + xTaskCreate(airspeedTask, (signed char *)"Airspeed", STACK_SIZE_BYTES/4, NULL, TASK_PRIORITY, &taskHandle); + TaskMonitorAdd(TASKINFO_RUNNING_AIRSPEED, taskHandle); + + return 0; +} + +/** + * Initialise the module, called on startup + * \returns 0 on success or -1 if initialisation failed + */ +int32_t AirspeedInitialize() +{ + #ifdef MODULE_AIRSPEED_BUILTIN + airspeedEnabled = true; + #else + + HwSettingsInitialize(); + uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; + HwSettingsOptionalModulesGet(optionalModules); + + if (optionalModules[HWSETTINGS_OPTIONALMODULES_AIRSPEED] == HWSETTINGS_OPTIONALMODULES_ENABLED) { + airspeedEnabled = true; + } else { + airspeedEnabled = false; + return -1; + } + #endif + + BaroAirspeedInitialize(); + + return 0; +} +MODULE_INITCALL(AirspeedInitialize, AirspeedStart) +/** + * Module thread, should not return. + */ +static void airspeedTask(void *parameters) +{ + BaroAirspeedData data; + + uint8_t calibrationCount = 0; + uint32_t calibrationSum = 0; + + // Main task loop + while (1) + { + // Update the airspeed + vTaskDelay(SAMPLING_DELAY_MS); + + BaroAirspeedGet(&data); + data.SensorValue = PIOS_ETASV3_ReadAirspeed(); + if (data.SensorValue==-1) { + data.Connected = BAROAIRSPEED_CONNECTED_FALSE; + data.Airspeed = 0; + BaroAirspeedSet(&data); + continue; + } + + if (calibrationCount #include +#include #if defined(PIOS_INCLUDE_BMP085) #include #endif diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index 2553004c4..f282c0445 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -51,7 +51,8 @@ FLASH_TOOL = OPENOCD # List of modules to include MODULES = Sensors Attitude/revolution ManualControl Stabilization Actuator MODULES += Altitude/revolution GPS FirmwareIAP -MODULES += AltitudeHold VtolPathFollower PathPlanner +MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner +MODULES += Airspeed/revolution MODULES += CameraStab MODULES += OveroSync MODULES += Telemetry @@ -146,6 +147,7 @@ include $(PIOS)/STM32F4xx/library.mk ## PIOS Hardware (Common) SRC += $(PIOSCOMMON)/pios_mpu6000.c SRC += $(PIOSCOMMON)/pios_bma180.c +SRC += $(PIOSCOMMON)/pios_etasv3.c SRC += $(PIOSCOMMON)/pios_l3gd20.c SRC += $(PIOSCOMMON)/pios_hmc5883.c SRC += $(PIOSCOMMON)/pios_ms5611.c diff --git a/flight/Revolution/System/inc/pios_config.h b/flight/Revolution/System/inc/pios_config.h index 7a82695fb..67901ad4d 100644 --- a/flight/Revolution/System/inc/pios_config.h +++ b/flight/Revolution/System/inc/pios_config.h @@ -63,6 +63,7 @@ #define PIOS_MPU6000_ACCEL #define PIOS_INCLUDE_L3GD20 #define PIOS_INCLUDE_MS5611 +#define PIOS_INCLUDE_ETASV3 //#define PIOS_INCLUDE_HCSR04 #define PIOS_FLASH_ON_ACCEL /* true for second revo */ #define FLASH_FREERTOS diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 67dfe5dad..83c7b726e 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -669,15 +669,12 @@ void PIOS_Board_Init(void) { case HWSETTINGS_RV_FLEXIPORT_DISABLED: break; case HWSETTINGS_RV_FLEXIPORT_I2C: -//TODO: Enable I2C #if defined(PIOS_INCLUDE_I2C) -/* { - if (PIOS_I2C_Init(&pios_i2c_flexi_adapter_id, &pios_i2c_flexi_adapter_cfg)) { + if (PIOS_I2C_Init(&pios_i2c_flexiport_adapter_id, &pios_i2c_flexiport_adapter_cfg)) { PIOS_Assert(0); } } -*/ #endif /* PIOS_INCLUDE_I2C */ break; diff --git a/flight/Revolution/UAVObjects.inc b/flight/Revolution/UAVObjects.inc index 326961d0d..1955a5ccc 100644 --- a/flight/Revolution/UAVObjects.inc +++ b/flight/Revolution/UAVObjects.inc @@ -36,6 +36,7 @@ UAVOBJSRCFILENAMES += gyrosbias UAVOBJSRCFILENAMES += accels UAVOBJSRCFILENAMES += magnetometer UAVOBJSRCFILENAMES += baroaltitude +UAVOBJSRCFILENAMES += baroairspeed UAVOBJSRCFILENAMES += flightbatterysettings UAVOBJSRCFILENAMES += firmwareiapobj UAVOBJSRCFILENAMES += flightbatterystate diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index ab54007b1..508fe9815 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -25,6 +25,7 @@ OTHER_FILES += UAVObjects.pluginspec # Add in all of the synthetic/generated uavobject files HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/baroaltitude.h \ + $$UAVOBJECT_SYNTHETICS/baroairspeed.h \ $$UAVOBJECT_SYNTHETICS/attitudeactual.h \ $$UAVOBJECT_SYNTHETICS/attitudesimulated.h \ $$UAVOBJECT_SYNTHETICS/altholdsmoothed.h \ @@ -92,6 +93,7 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/baroaltitude.cpp \ + $$UAVOBJECT_SYNTHETICS/baroairspeed.cpp \ $$UAVOBJECT_SYNTHETICS/attitudeactual.cpp \ $$UAVOBJECT_SYNTHETICS/attitudesimulated.cpp \ $$UAVOBJECT_SYNTHETICS/altholdsmoothed.cpp \ diff --git a/shared/uavobjectdefinition/baroairspeed.xml b/shared/uavobjectdefinition/baroairspeed.xml new file mode 100644 index 000000000..1566b89ce --- /dev/null +++ b/shared/uavobjectdefinition/baroairspeed.xml @@ -0,0 +1,13 @@ + + + The raw data from the dynamic pressure sensor with pressure, temperature and airspeed. + + + + + + + + + + diff --git a/shared/uavobjectdefinition/hwsettings.xml b/shared/uavobjectdefinition/hwsettings.xml index 5ff7238d3..a457b98df 100644 --- a/shared/uavobjectdefinition/hwsettings.xml +++ b/shared/uavobjectdefinition/hwsettings.xml @@ -18,7 +18,7 @@ - + diff --git a/shared/uavobjectdefinition/taskinfo.xml b/shared/uavobjectdefinition/taskinfo.xml index d8599a9a5..fe2c15c6a 100644 --- a/shared/uavobjectdefinition/taskinfo.xml +++ b/shared/uavobjectdefinition/taskinfo.xml @@ -1,9 +1,9 @@ Task information - - - + + +