mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-31 16:52:10 +01:00
LP-388 Use UAVObjectUpdaterHelper and avoid telemetry errors
This commit is contained in:
parent
daba66d32f
commit
b16e4838eb
@ -2,7 +2,8 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file sixpointcalibrationmodel.cpp
|
* @file sixpointcalibrationmodel.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||||
*
|
*
|
||||||
* @brief Six point calibration for Magnetometer and Accelerometer
|
* @brief Six point calibration for Magnetometer and Accelerometer
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "calibration/calibrationuiutils.h"
|
#include "calibration/calibrationuiutils.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
|
#include <uavobjecthelper.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -156,6 +158,8 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
|
|||||||
// Store and reset board rotation before calibration starts
|
// Store and reset board rotation before calibration starts
|
||||||
storeAndClearBoardRotation();
|
storeAndClearBoardRotation();
|
||||||
|
|
||||||
|
UAVObjectUpdaterHelper updateHelper;
|
||||||
|
|
||||||
// Calibration accel
|
// Calibration accel
|
||||||
AccelGyroSettings::DataFields accelGyroSettingsData = accelGyroSettings->getData();
|
AccelGyroSettings::DataFields accelGyroSettingsData = accelGyroSettings->getData();
|
||||||
memento.accelGyroSettingsData = accelGyroSettingsData;
|
memento.accelGyroSettingsData = accelGyroSettingsData;
|
||||||
@ -167,7 +171,8 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
|
|||||||
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Y] = 0;
|
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Y] = 0;
|
||||||
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Z] = 0;
|
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Z] = 0;
|
||||||
|
|
||||||
accelGyroSettings->setData(accelGyroSettingsData);
|
accelGyroSettings->setData(accelGyroSettingsData, false);
|
||||||
|
updateHelper.doObjectAndWait(accelGyroSettings);
|
||||||
|
|
||||||
// Calibration mag
|
// Calibration mag
|
||||||
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
||||||
@ -187,7 +192,8 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
|
|||||||
// Disable adaptive mag nulling
|
// Disable adaptive mag nulling
|
||||||
revoCalibrationData.MagBiasNullingRate = 0;
|
revoCalibrationData.MagBiasNullingRate = 0;
|
||||||
|
|
||||||
revoCalibration->setData(revoCalibrationData);
|
revoCalibration->setData(revoCalibrationData, false);
|
||||||
|
updateHelper.doObjectAndWait(revoCalibration);
|
||||||
|
|
||||||
// Calibration AuxMag
|
// Calibration AuxMag
|
||||||
AuxMagSettings::DataFields auxMagSettingsData = auxMagSettings->getData();
|
AuxMagSettings::DataFields auxMagSettingsData = auxMagSettings->getData();
|
||||||
@ -207,9 +213,8 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
|
|||||||
// Disable adaptive mag nulling
|
// Disable adaptive mag nulling
|
||||||
auxMagSettingsData.MagBiasNullingRate = 0;
|
auxMagSettingsData.MagBiasNullingRate = 0;
|
||||||
|
|
||||||
auxMagSettings->setData(auxMagSettingsData);
|
auxMagSettings->setData(auxMagSettingsData, false);
|
||||||
|
updateHelper.doObjectAndWait(auxMagSettings);
|
||||||
QThread::usleep(100000);
|
|
||||||
|
|
||||||
mag_accum_x.clear();
|
mag_accum_x.clear();
|
||||||
mag_accum_y.clear();
|
mag_accum_y.clear();
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file ConfigRevoWidget.h
|
* @file ConfigRevoWidget.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||||
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup ConfigPlugin Config Plugin
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
@ -28,6 +29,7 @@
|
|||||||
|
|
||||||
#include "ui_revosensors.h"
|
#include "ui_revosensors.h"
|
||||||
|
|
||||||
|
#include <uavobjecthelper.h>
|
||||||
#include <attitudestate.h>
|
#include <attitudestate.h>
|
||||||
#include <attitudesettings.h>
|
#include <attitudesettings.h>
|
||||||
#include <revocalibration.h>
|
#include <revocalibration.h>
|
||||||
@ -255,6 +257,8 @@ void ConfigRevoWidget::updateVisualHelp()
|
|||||||
void ConfigRevoWidget::storeAndClearBoardRotation()
|
void ConfigRevoWidget::storeAndClearBoardRotation()
|
||||||
{
|
{
|
||||||
if (!isBoardRotationStored) {
|
if (!isBoardRotationStored) {
|
||||||
|
UAVObjectUpdaterHelper updateHelper;
|
||||||
|
|
||||||
// Store current board rotation
|
// Store current board rotation
|
||||||
isBoardRotationStored = true;
|
isBoardRotationStored = true;
|
||||||
AttitudeSettings *attitudeSettings = AttitudeSettings::GetInstance(getObjectManager());
|
AttitudeSettings *attitudeSettings = AttitudeSettings::GetInstance(getObjectManager());
|
||||||
@ -268,7 +272,9 @@ void ConfigRevoWidget::storeAndClearBoardRotation()
|
|||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_YAW] = 0;
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_YAW] = 0;
|
||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_ROLL] = 0;
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_ROLL] = 0;
|
||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_PITCH] = 0;
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_PITCH] = 0;
|
||||||
attitudeSettings->setData(data);
|
|
||||||
|
attitudeSettings->setData(data, false);
|
||||||
|
updateHelper.doObjectAndWait(attitudeSettings);
|
||||||
|
|
||||||
// Store current aux mag board rotation
|
// Store current aux mag board rotation
|
||||||
AuxMagSettings *auxMagSettings = AuxMagSettings::GetInstance(getObjectManager());
|
AuxMagSettings *auxMagSettings = AuxMagSettings::GetInstance(getObjectManager());
|
||||||
@ -282,13 +288,17 @@ void ConfigRevoWidget::storeAndClearBoardRotation()
|
|||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_YAW] = 0;
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_YAW] = 0;
|
||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_ROLL] = 0;
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_ROLL] = 0;
|
||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_PITCH] = 0;
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_PITCH] = 0;
|
||||||
auxMagSettings->setData(auxMagData);
|
|
||||||
|
auxMagSettings->setData(auxMagData, false);
|
||||||
|
updateHelper.doObjectAndWait(auxMagSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigRevoWidget::recallBoardRotation()
|
void ConfigRevoWidget::recallBoardRotation()
|
||||||
{
|
{
|
||||||
if (isBoardRotationStored) {
|
if (isBoardRotationStored) {
|
||||||
|
UAVObjectUpdaterHelper updateHelper;
|
||||||
|
|
||||||
// Recall current board rotation
|
// Recall current board rotation
|
||||||
isBoardRotationStored = false;
|
isBoardRotationStored = false;
|
||||||
|
|
||||||
@ -299,7 +309,9 @@ void ConfigRevoWidget::recallBoardRotation()
|
|||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_YAW] = storedBoardRotation[AttitudeSettings::BOARDROTATION_YAW];
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_YAW] = storedBoardRotation[AttitudeSettings::BOARDROTATION_YAW];
|
||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_ROLL] = storedBoardRotation[AttitudeSettings::BOARDROTATION_ROLL];
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_ROLL] = storedBoardRotation[AttitudeSettings::BOARDROTATION_ROLL];
|
||||||
data.BoardRotation[AttitudeSettings::BOARDROTATION_PITCH] = storedBoardRotation[AttitudeSettings::BOARDROTATION_PITCH];
|
data.BoardRotation[AttitudeSettings::BOARDROTATION_PITCH] = storedBoardRotation[AttitudeSettings::BOARDROTATION_PITCH];
|
||||||
attitudeSettings->setData(data);
|
|
||||||
|
attitudeSettings->setData(data, false);
|
||||||
|
updateHelper.doObjectAndWait(attitudeSettings);
|
||||||
|
|
||||||
// Restore the aux mag board rotation
|
// Restore the aux mag board rotation
|
||||||
AuxMagSettings *auxMagSettings = AuxMagSettings::GetInstance(getObjectManager());
|
AuxMagSettings *auxMagSettings = AuxMagSettings::GetInstance(getObjectManager());
|
||||||
@ -308,7 +320,9 @@ void ConfigRevoWidget::recallBoardRotation()
|
|||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_YAW] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_YAW];
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_YAW] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_YAW];
|
||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_ROLL] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_ROLL];
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_ROLL] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_ROLL];
|
||||||
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_PITCH] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_PITCH];
|
auxMagData.BoardRotation[AuxMagSettings::BOARDROTATION_PITCH] = auxMagStoredBoardRotation[AuxMagSettings::BOARDROTATION_PITCH];
|
||||||
auxMagSettings->setData(auxMagData);
|
|
||||||
|
auxMagSettings->setData(auxMagData, false);
|
||||||
|
updateHelper.doObjectAndWait(auxMagSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user