mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Merge remote branch 'origin/stac/etasv3' into corvuscorax/new_navigation
Conflicts: flight/Revolution/Makefile shared/uavobjectdefinition/hwsettings.xml shared/uavobjectdefinition/taskinfo.xml
This commit is contained in:
commit
435b494b0c
159
flight/Modules/Airspeed/revolution/airspeed.c
Normal file
159
flight/Modules/Airspeed/revolution/airspeed.c
Normal file
@ -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<CALIBRATION_IDLE) {
|
||||
calibrationCount++;
|
||||
} else if (calibrationCount<CALIBRATION_IDLE + CALIBRATION_COUNT) {
|
||||
calibrationCount++;
|
||||
calibrationSum += data.SensorValue;
|
||||
if (calibrationCount==CALIBRATION_IDLE+CALIBRATION_COUNT) {
|
||||
data.ZeroPoint = calibrationSum / CALIBRATION_COUNT;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
data.Connected = BAROAIRSPEED_CONNECTED_TRUE;
|
||||
|
||||
data.Airspeed = ETS_AIRSPEED_SCALE * sqrtf((float)abs(data.SensorValue - data.ZeroPoint));
|
||||
|
||||
// Update the AirspeedActual UAVObject
|
||||
BaroAirspeedSet(&data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
41
flight/Modules/Airspeed/revolution/inc/airspeed.h
Normal file
41
flight/Modules/Airspeed/revolution/inc/airspeed.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup OpenPilotModules OpenPilot Modules
|
||||
* @{
|
||||
* @addtogroup AirspeedModule Airspeed Module
|
||||
* @brief Communicate with EagleTree Airspeed Sensor and update @ref BaroAirspeed "BaroAirspeed UAV Object"
|
||||
* @{
|
||||
*
|
||||
* @file airspeed.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Airspeed module, reads temperature and pressure 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
|
||||
*/
|
||||
#ifndef AIRSPEED_H
|
||||
#define AIRSPEED_H
|
||||
|
||||
int32_t AirspeedInitialize();
|
||||
|
||||
#endif // AIRSPEED_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -103,6 +103,9 @@ TIM8 | | | |
|
||||
#define PIOS_I2C_MAX_DEVS 3
|
||||
extern uint32_t pios_i2c_mag_adapter_id;
|
||||
#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_mag_adapter_id)
|
||||
extern uint32_t pios_i2c_flexiport_adapter_id;
|
||||
#define PIOS_I2C_FLEXI_ADAPTER (pios_i2c_flexiport_adapter_id)
|
||||
#define PIOS_I2C_ETASV3_ADAPTER (PIOS_I2C_FLEXI_ADAPTER)
|
||||
|
||||
//-------------------------
|
||||
// PIOS_USART
|
||||
|
65
flight/PiOS/Common/pios_etasv3.c
Normal file
65
flight/PiOS/Common/pios_etasv3.c
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_ETASV3 ETASV3 Functions
|
||||
* @brief Hardware functions to deal with the Eagle Tree Airspeed MicroSensor V3
|
||||
* @{
|
||||
*
|
||||
* @file pios_etasv3.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief ETASV3 Airspeed Sensor Driver
|
||||
* @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
|
||||
*/
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_ETASV3)
|
||||
|
||||
#include "pios_etasv3.h"
|
||||
|
||||
static bool PIOS_ETASV3_Read(uint8_t * buffer, uint8_t len)
|
||||
{
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = ETASV3_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = len,
|
||||
.buf = buffer,
|
||||
}
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_ETASV3_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
int16_t PIOS_ETASV3_ReadAirspeed (void)
|
||||
{
|
||||
uint8_t airspeed_raw[2];
|
||||
|
||||
if (PIOS_ETASV3_Read(airspeed_raw, sizeof(airspeed_raw)) != 0) {
|
||||
/* Failed to read airspeed */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (airspeed_raw[0] | (airspeed_raw[1]<<8));
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_ETASV3 */
|
34
flight/PiOS/inc/pios_etasv3.h
Normal file
34
flight/PiOS/inc/pios_etasv3.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_ETASV3 ETASV3 Functions
|
||||
* @brief Hardware functions to deal with the Eagle Tree Airspeed MicroSensor V3
|
||||
* @{
|
||||
*
|
||||
* @file pios_etasv3.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief ETASV3 Airspeed Sensor Driver
|
||||
* @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
|
||||
*/
|
||||
|
||||
#define ETASV3_I2C_ADDR 0x75
|
||||
|
||||
|
||||
int16_t PIOS_ETASV3_ReadAirspeed (void);
|
@ -100,6 +100,7 @@
|
||||
/* PIOS Hardware Includes (Common) */
|
||||
#include <pios_sdcard.h>
|
||||
#include <pios_com.h>
|
||||
#include <pios_etasv3.h>
|
||||
#if defined(PIOS_INCLUDE_BMP085)
|
||||
#include <pios_bmp085.h>
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -36,6 +36,7 @@ UAVOBJSRCFILENAMES += gyrosbias
|
||||
UAVOBJSRCFILENAMES += accels
|
||||
UAVOBJSRCFILENAMES += magnetometer
|
||||
UAVOBJSRCFILENAMES += baroaltitude
|
||||
UAVOBJSRCFILENAMES += baroairspeed
|
||||
UAVOBJSRCFILENAMES += flightbatterysettings
|
||||
UAVOBJSRCFILENAMES += firmwareiapobj
|
||||
UAVOBJSRCFILENAMES += flightbatterystate
|
||||
|
@ -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 \
|
||||
|
13
shared/uavobjectdefinition/baroairspeed.xml
Normal file
13
shared/uavobjectdefinition/baroairspeed.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<xml>
|
||||
<object name="BaroAirspeed" singleinstance="true" settings="false">
|
||||
<description>The raw data from the dynamic pressure sensor with pressure, temperature and airspeed.</description>
|
||||
<field name="Connected" units="" type="enum" elements="1" options="False,True"/>
|
||||
<field name="SensorValue" units="raw" type="uint16" elements="1"/>
|
||||
<field name="ZeroPoint" units="raw" type="uint16" elements="1"/>
|
||||
<field name="Airspeed" units="m/s" type="float" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
@ -18,7 +18,7 @@
|
||||
<field name="USB_HIDPort" units="function" type="enum" elements="1" options="USBTelemetry,Disabled" defaultvalue="USBTelemetry"/>
|
||||
<field name="USB_VCPPort" units="function" type="enum" elements="1" options="USBTelemetry,ComBridge,Disabled" defaultvalue="Disabled"/>
|
||||
|
||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault,Altitude,TxPID,VtolPathFollower,FixedWingPathFollower" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault,Altitude,Airspeed,TxPID,VtolPathFollower,FixedWingPathFollower" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
|
||||
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<xml>
|
||||
<object name="TaskInfo" singleinstance="true" settings="false">
|
||||
<description>Task information</description>
|
||||
<field name="StackRemaining" units="bytes" type="uint16" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<field name="Running" units="bool" type="enum" options="False,True" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<field name="RunningTime" units="%" type="uint8" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<field name="StackRemaining" units="bytes" type="uint16" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Airspeed,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<field name="Running" units="bool" type="enum" options="False,True" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Airspeed,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<field name="RunningTime" units="%" type="uint8" elementnames="System,Actuator,Attitude,Sensors,TelemetryTx,TelemetryTxPri,TelemetryRx,GPS,ManualControl,Altitude,Airspeed,Stabilization,AltitudeHold,PathFollower,FlightPlan,PathPlanner,Com2UsbBridge,Usb2ComBridge,OveroSync"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="10000"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user