1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merge remote-tracking branch 'origin/rel-12.10.2' into next

This commit is contained in:
Oleg Semyonov 2012-11-14 17:26:18 +02:00
commit 79f95983da
13 changed files with 103 additions and 40 deletions

View File

@ -1,5 +1,18 @@
Short summary of changes. For a complete list see the git log.
2012-11-11
Added support for Mode 3 and Mode 4 to the TX Configuration Wizard.
Few minor bugfixes.
--- RELEASE-12.10.1 ---
2012-10-26
Temporary disabled AutoTune GCS GUI. It was listed as an experimental
feature in the previous release, there were however a few cases where
it did not behave as expected.
--- RELEASE-12.10 ---
2012-10-06
Receiver port can now be configured as PPM *and* PWM inputs.
Pin 1 is PPM, other pins are PWM inputs.

View File

@ -86,6 +86,10 @@ static void settingsUpdatedCb(UAVObjEvent * objEv);
static float accelKi = 0;
static float accelKp = 0;
static float accel_alpha = 0;
static bool accel_filter_enabled = false;
static float accels_filtered[3];
static float grot_filtered[3];
static float yawBiasRate = 0;
static float gyroGain = 0.42;
static int16_t accelbias[3];
@ -215,18 +219,22 @@ static void AttitudeTask(void *parameters)
accelKp = 1;
accelKi = 0.9;
yawBiasRate = 0.23;
accel_filter_enabled = false;
init = 0;
}
else if (zero_during_arming && (flightStatus.Armed == FLIGHTSTATUS_ARMED_ARMING)) {
accelKp = 1;
accelKi = 0.9;
yawBiasRate = 0.23;
accel_filter_enabled = false;
init = 0;
} else if (init == 0) {
// Reload settings (all the rates)
AttitudeSettingsAccelKiGet(&accelKi);
AttitudeSettingsAccelKpGet(&accelKp);
AttitudeSettingsYawBiasRateGet(&yawBiasRate);
if (accel_alpha > 0.0f)
accel_filter_enabled = true;
init = 1;
}
@ -429,6 +437,19 @@ static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData)
return 0;
}
static inline void apply_accel_filter(const float *raw, float *filtered)
{
if (accel_filter_enabled) {
filtered[0] = filtered[0] * accel_alpha + raw[0] * (1 - accel_alpha);
filtered[1] = filtered[1] * accel_alpha + raw[1] * (1 - accel_alpha);
filtered[2] = filtered[2] * accel_alpha + raw[2] * (1 - accel_alpha);
} else {
filtered[0] = raw[0];
filtered[1] = raw[1];
filtered[2] = raw[2];
}
}
static void updateAttitude(AccelsData * accelsData, GyrosData * gyrosData)
{
float dT;
@ -444,21 +465,38 @@ static void updateAttitude(AccelsData * accelsData, GyrosData * gyrosData)
float grot[3];
float accel_err[3];
// Apply smoothing to accel values, to reduce vibration noise before main calculations.
apply_accel_filter(accels, accels_filtered);
// Rotate gravity to body frame and cross with accels
// Rotate gravity unit vector to body frame, filter and cross with accels
grot[0] = -(2 * (q[1] * q[3] - q[0] * q[2]));
grot[1] = -(2 * (q[2] * q[3] + q[0] * q[1]));
grot[2] = -(q[0] * q[0] - q[1]*q[1] - q[2]*q[2] + q[3]*q[3]);
CrossProduct((const float *) accels, (const float *) grot, accel_err);
apply_accel_filter(grot, grot_filtered);
CrossProduct((const float *)accels_filtered, (const float *)grot_filtered, accel_err);
// Account for accel magnitude
float accel_mag = sqrtf(accels[0]*accels[0] + accels[1]*accels[1] + accels[2]*accels[2]);
if(accel_mag < 1.0e-3f)
float accel_mag = sqrtf(accels_filtered[0]*accels_filtered[0] + accels_filtered[1]*accels_filtered[1] + accels_filtered[2]*accels_filtered[2]);
if (accel_mag < 1.0e-3f)
return;
accel_err[0] /= accel_mag;
accel_err[1] /= accel_mag;
accel_err[2] /= accel_mag;
// Account for filtered gravity vector magnitude
float grot_mag;
if (accel_filter_enabled)
grot_mag = sqrtf(grot_filtered[0]*grot_filtered[0] + grot_filtered[1]*grot_filtered[1] + grot_filtered[2]*grot_filtered[2]);
else
grot_mag = 1.0f;
if (grot_mag < 1.0e-3f)
return;
accel_err[0] /= (accel_mag*grot_mag);
accel_err[1] /= (accel_mag*grot_mag);
accel_err[2] /= (accel_mag*grot_mag);
// Accumulate integral of error. Scale here so that units are (deg/s) but Ki has units of s
gyro_correct_int[0] += accel_err[0] * accelKi;
@ -530,6 +568,16 @@ static void settingsUpdatedCb(UAVObjEvent * objEv) {
accelKi = attitudeSettings.AccelKi;
yawBiasRate = attitudeSettings.YawBiasRate;
gyroGain = attitudeSettings.GyroGain;
// Calculate accel filter alpha, in the same way as for gyro data in stabilization module.
const float fakeDt = 0.0025;
if (attitudeSettings.AccelTau < 0.0001) {
accel_alpha = 0; // not trusting this to resolve to 0
accel_filter_enabled = false;
} else {
accel_alpha = expf(-fakeDt / attitudeSettings.AccelTau);
accel_filter_enabled = true;
}
zero_during_arming = attitudeSettings.ZeroDuringArming == ATTITUDESETTINGS_ZERODURINGARMING_TRUE;
bias_correct_gyro = attitudeSettings.BiasCorrectGyro == ATTITUDESETTINGS_BIASCORRECTGYRO_TRUE;

View File

@ -38,8 +38,7 @@ HEADERS += configplugin.h \
configrevowidget.h \
config_global.h \
mixercurve.h \
dblspindelegate.h \
configautotunewidget.h
dblspindelegate.h
SOURCES += configplugin.cpp \
configgadgetconfiguration.cpp \
configgadgetwidget.cpp \
@ -72,8 +71,7 @@ SOURCES += configplugin.cpp \
outputchannelform.cpp \
cfg_vehicletypes/vehicleconfig.cpp \
mixercurve.cpp \
dblspindelegate.cpp \
configautotunewidget.cpp
dblspindelegate.cpp
FORMS += airframe.ui \
cc_hw_settings.ui \
pro_hw_settings.ui \
@ -90,13 +88,5 @@ FORMS += airframe.ui \
revosensors.ui \
txpid.ui \
pipxtreme.ui \
mixercurve.ui \
autotune.ui
mixercurve.ui
RESOURCES += configgadget.qrc

View File

@ -32,7 +32,6 @@
#include "configinputwidget.h"
#include "configoutputwidget.h"
#include "configstabilizationwidget.h"
#include "configautotunewidget.h"
#include "configcamerastabilizationwidget.h"
#include "configtxpidwidget.h"
#include "config_pro_hw_widget.h"
@ -103,12 +102,6 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
qwd = new ConfigStabilizationWidget(this);
ftw->insertTab(ConfigGadgetWidget::stabilization, qwd, *icon, QString("Stabilization"));
icon = new QIcon();
icon->addFile(":/configgadget/images/autotune_normal.png", QSize(), QIcon::Normal, QIcon::Off);
icon->addFile(":/configgadget/images/autotune_selected.png", QSize(), QIcon::Selected, QIcon::Off);
qwd = new ConfigAutotuneWidget(this);
ftw->insertTab(ConfigGadgetWidget::autotune, qwd, *icon, QString("Autotune"));
icon = new QIcon();
icon->addFile(":/configgadget/images/camstab_normal.png", QSize(), QIcon::Normal, QIcon::Off);
icon->addFile(":/configgadget/images/camstab_selected.png", QSize(), QIcon::Selected, QIcon::Off);

View File

@ -48,7 +48,7 @@ class ConfigGadgetWidget: public QWidget
public:
ConfigGadgetWidget(QWidget *parent = 0);
~ConfigGadgetWidget();
enum widgetTabs {hardware=0, aircraft, input, output, sensors, stabilization, camerastabilization, txpid, pipxtreme, autotune};
enum widgetTabs {hardware=0, aircraft, input, output, sensors, stabilization, camerastabilization, txpid, pipxtreme};
void startInputWizard();
public slots:

View File

@ -158,9 +158,9 @@ bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
{
myDevice->lblGitTag->setText(onBoardDescription.gitHash);
myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4,"-").insert(7,"-"));
if (onBoardDescription.gitTag.compare("master") == 0)
if(onBoardDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
myDevice->lblDescription->setText(QString("Firmware tag: ")+onBoardDescription.gitTag);
myDevice->lblDescription->setText(onBoardDescription.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/application-certificate.svg"));
myDevice->lblCertified->setPixmap(pix);
myDevice->lblCertified->setToolTip(tr("Tagged officially released firmware build"));
@ -188,7 +188,7 @@ bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
{
myDevice->lblGitTagL->setText(LoadedDescription.gitHash);
myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4,"-").insert(7,"-"));
if (LoadedDescription.gitTag.compare("master") == 0)
if(LoadedDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
@ -302,7 +302,7 @@ void deviceWidget::loadFirmware()
myDevice->statusLabel->setText(tr("The board has newer firmware than loaded. Are you sure you want to update?"));
px.load(QString(":/uploader/images/warning.svg"));
}
else if (LoadedDescription.gitTag.compare("master"))
else if(!LoadedDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
myDevice->statusLabel->setText(tr("The loaded firmware is untagged or custom build. Update only if it was received from a trusted source (official website or your own build)"));
px.load(QString(":/uploader/images/warning.svg"));

View File

@ -103,7 +103,7 @@ void runningDeviceWidget::populate()
deviceDescriptorStruct devDesc;
if(UAVObjectUtilManager::descriptionToStructure(description,devDesc))
{
if (devDesc.gitTag.compare("master") == 0)
if(devDesc.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
{
myDevice->lblFWTag->setText(QString("Firmware tag: ")+devDesc.gitTag);
QPixmap pix = QPixmap(QString(":uploader/images/application-certificate.svg"));

View File

@ -167,7 +167,7 @@ class Repo:
print "hash: ", self.hash()
print "short hash: ", self.hash(8)
print "branch: ", self.branch()
print "commit tag: ", self.tag()
print "commit tag: ", self.tag('')
print "dirty: ", self.dirty('yes', 'no')
def file_from_template(tpl_name, out_name, dict):
@ -324,6 +324,12 @@ variable substitution and writes the result into output file. Output
file will be overwritten only if its content differs from expected.
Otherwise it will not be touched, so make utility will not remake
dependent targets.
Optional positional arguments may be used to add more dictionary
strings for replacement. Each argument has the form:
VARIABLE=replacement
and each ${VARIABLE} reference will be replaced with replacement
string given.
"""
# Parse command line.
@ -359,8 +365,6 @@ dependent targets.
parser.add_option('--uavodir', default = "",
help='uav object definition directory');
(args, positional_args) = parser.parse_args()
if len(positional_args) != 0:
parser.error("incorrect number of arguments, try --help for help")
# Process arguments. No advanced error handling is here.
# Any error will raise an exception and terminate process
@ -373,6 +377,7 @@ dependent targets.
ORIGIN = r.origin(),
HASH = r.hash(),
HASH8 = r.hash(8),
TAG = r.tag(''),
TAG_OR_BRANCH = r.tag(r.branch('unreleased')),
TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')),
DIRTY = r.dirty(),
@ -387,6 +392,12 @@ dependent targets.
UAVOSHA1 = GetHashofDirs(args.uavodir,verbose=0,raw=0),
)
# Process positional arguments in the form of:
# VAR1=str1 VAR2="string 2"
for var in positional_args:
(key, value) = var.split('=', 1)
dictionary[key] = value
if args.info:
r.info()

View File

@ -14,7 +14,13 @@ ROOT_DIR := $(realpath $(WHEREAMI)/../)
# Set up some macros
BUILD_DIR := $(ROOT_DIR)/build
VERSION_CMD := python $(ROOT_DIR)/make/scripts/version-info.py --path="$(ROOT_DIR)"
# If there is a tag, use it for label instead of date-hash string
PACKAGE_TAG := $(shell $(VERSION_CMD) --format=\$${TAG})
ifneq ($(PACKAGE_TAG),)
PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${TAG}\$${DIRTY})
else
PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${DIRTY})
endif
PACKAGE_DIR := $(BUILD_DIR)/package-$(PACKAGE_LBL)
FW_DIR := $(PACKAGE_DIR)/firmware-$(PACKAGE_LBL)
BL_DIR := $(FW_DIR)/bootloaders
@ -152,4 +158,5 @@ opfw_resource:
$(V1) echo '$(OPFW_CONTENTS)' > $(BUILD_DIR)/ground/$@/opfw_resource.qrc
$(V1) $(foreach fw_targ, $(FW_TARGETS), mkdir -p $(BUILD_DIR)/ground/$@/build/$(fw_targ);)
$(V1)$(foreach fw_targ, $(FW_TARGETS), cp $(BUILD_DIR)/$(fw_targ)/$(fw_targ).opfw $(BUILD_DIR)/ground/$@/build/$(fw_targ)/;)
include $(WHEREAMI)/Makefile.$(PLATFORM)

View File

@ -11,7 +11,7 @@ NSIS_HEADER := $(BUILD_DIR)/ground/openpilotgcs/openpilotgcs.nsh
win_package: gcs package_flight
$(V1) mkdir -p "$(dir $(NSIS_HEADER))"
$(VERSION_CMD) --template="$(NSIS_TEMPLATE)" --outfile="$(NSIS_HEADER)"
$(VERSION_CMD) --template="$(NSIS_TEMPLATE)" --outfile="$(NSIS_HEADER)" PACKAGE_LBL="$(PACKAGE_LBL)"
$(V1) echo "Building Windows installer, please wait..."
$(V1) echo "If you have a script error in line 1 - use Unicode NSIS 2.46+"
$(V1) echo " http://www.scratchpaper.com"

View File

@ -72,7 +72,7 @@
VIAddVersionKey "Comments" "${INSTALLER_NAME}. ${BUILD_DESCRIPTION}"
VIAddVersionKey "CompanyName" "The OpenPilot Team, http://www.openpilot.org"
VIAddVersionKey "LegalTrademarks" "${PRODUCT_NAME} is a trademark of The OpenPilot Team"
VIAddVersionKey "LegalCopyright" "© 2010-2011 The OpenPilot Team"
VIAddVersionKey "LegalCopyright" "© 2010-2012 The OpenPilot Team"
VIAddVersionKey "FileDescription" "${INSTALLER_NAME}"
;--------------------------------

View File

@ -12,7 +12,7 @@
#
; Some names, paths and constants
!define PACKAGE_LBL "${DATE}-${TAG_OR_HASH8}${DIRTY}"
!define PACKAGE_LBL "${PACKAGE_LBL}"
!define PACKAGE_DIR "..\..\build\package-$${PACKAGE_LBL}"
!define OUT_FILE "OpenPilot-$${PACKAGE_LBL}-install.exe"
!define FIRMWARE_DIR "firmware-$${PACKAGE_LBL}"
@ -20,4 +20,4 @@
; Installer version info
!define PRODUCT_VERSION "0.0.0.0"
!define FILE_VERSION "${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME}"
!define BUILD_DESCRIPTION "${TAG_OR_BRANCH}:${HASH8}${DIRTY} built using ${ORIGIN} as origin, committed ${DATETIME} as ${HASH}"
!define BUILD_DESCRIPTION "${PACKAGE_LBL} built using ${ORIGIN} as origin, committed ${DATETIME} as ${HASH}"

View File

@ -7,6 +7,7 @@
<field name="GyroGain" units="(rad/s)/lsb" type="float" elements="1" defaultvalue="0.42"/>
<field name="AccelKp" units="channel" type="float" elements="1" defaultvalue="0.05"/>
<field name="AccelKi" units="channel" type="float" elements="1" defaultvalue="0.0001"/>
<field name="AccelTau" units="" type="float" elements="1" defaultvalue="0"/>
<field name="YawBiasRate" units="channel" type="float" elements="1" defaultvalue="0.000001"/>
<field name="ZeroDuringArming" units="channel" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="TRUE"/>
<field name="BiasCorrectGyro" units="channel" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="TRUE"/>