mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Make sure we don't use null pointers when refreshing the revo sensor bar graphs
This commit is contained in:
parent
7f15e87890
commit
d94ab30616
@ -76,9 +76,6 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
|||||||
m_ui = new Ui_RevoSensorsWidget();
|
m_ui = new Ui_RevoSensorsWidget();
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
addUAVObject("RevoCalibration");
|
|
||||||
autoLoadWidgets();
|
|
||||||
|
|
||||||
// Initialization of the Paper plane widget
|
// Initialization of the Paper plane widget
|
||||||
m_ui->sixPointsHelp->setScene(new QGraphicsScene(this));
|
m_ui->sixPointsHelp->setScene(new QGraphicsScene(this));
|
||||||
|
|
||||||
@ -209,6 +206,11 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
|||||||
mag_z->setPos(startX,startY);
|
mag_z->setPos(startX,startY);
|
||||||
mag_z->setTransform(QTransform::fromScale(1,0),true);
|
mag_z->setTransform(QTransform::fromScale(1,0),true);
|
||||||
|
|
||||||
|
// Must set up the UI (above) before setting up the UAVO mappings or refreshWidgetValues
|
||||||
|
// will be dealing with some null pointers
|
||||||
|
addUAVObject("RevoCalibration");
|
||||||
|
autoLoadWidgets();
|
||||||
|
|
||||||
// Connect the signals
|
// Connect the signals
|
||||||
connect(m_ui->accelBiasStart, SIGNAL(clicked()), this, SLOT(launchAccelBiasCalibration()));
|
connect(m_ui->accelBiasStart, SIGNAL(clicked()), this, SLOT(launchAccelBiasCalibration()));
|
||||||
|
|
||||||
@ -708,31 +710,42 @@ void ConfigRevoWidget::drawVariancesGraph()
|
|||||||
{
|
{
|
||||||
RevoCalibration * revoCalibration = RevoCalibration::GetInstance(getObjectManager());
|
RevoCalibration * revoCalibration = RevoCalibration::GetInstance(getObjectManager());
|
||||||
Q_ASSERT(revoCalibration);
|
Q_ASSERT(revoCalibration);
|
||||||
|
if(!revoCalibration)
|
||||||
|
return;
|
||||||
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
||||||
|
|
||||||
// The expected range is from 1E-6 to 1E-1
|
// The expected range is from 1E-6 to 1E-1
|
||||||
double steps = 6; // 6 bars on the graph
|
double steps = 6; // 6 bars on the graph
|
||||||
float accel_x_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_X]));
|
float accel_x_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_X]));
|
||||||
accel_x->setTransform(QTransform::fromScale(1,accel_x_var),false);
|
if(accel_x)
|
||||||
|
accel_x->setTransform(QTransform::fromScale(1,accel_x_var),false);
|
||||||
float accel_y_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_Y]));
|
float accel_y_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_Y]));
|
||||||
accel_y->setTransform(QTransform::fromScale(1,accel_y_var),false);
|
if(accel_y)
|
||||||
|
accel_y->setTransform(QTransform::fromScale(1,accel_y_var),false);
|
||||||
float accel_z_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_Z]));
|
float accel_z_var = -1/steps*(1+steps+log10(revoCalibrationData.accel_var[RevoCalibration::ACCEL_VAR_Z]));
|
||||||
accel_z->setTransform(QTransform::fromScale(1,accel_z_var),false);
|
if(accel_z)
|
||||||
|
accel_z->setTransform(QTransform::fromScale(1,accel_z_var),false);
|
||||||
|
|
||||||
float gyro_x_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_X]));
|
float gyro_x_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_X]));
|
||||||
gyro_x->setTransform(QTransform::fromScale(1,gyro_x_var),false);
|
if(gyro_x)
|
||||||
|
gyro_x->setTransform(QTransform::fromScale(1,gyro_x_var),false);
|
||||||
float gyro_y_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_Y]));
|
float gyro_y_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_Y]));
|
||||||
gyro_y->setTransform(QTransform::fromScale(1,gyro_y_var),false);
|
if(gyro_y)
|
||||||
|
gyro_y->setTransform(QTransform::fromScale(1,gyro_y_var),false);
|
||||||
float gyro_z_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_Z]));
|
float gyro_z_var = -1/steps*(1+steps+log10(revoCalibrationData.gyro_var[RevoCalibration::GYRO_VAR_Z]));
|
||||||
gyro_z->setTransform(QTransform::fromScale(1,gyro_z_var),false);
|
if(gyro_z)
|
||||||
|
gyro_z->setTransform(QTransform::fromScale(1,gyro_z_var),false);
|
||||||
|
|
||||||
// Scale by 1e-3 because mag vars are much higher.
|
// Scale by 1e-3 because mag vars are much higher.
|
||||||
float mag_x_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_X]));
|
float mag_x_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_X]));
|
||||||
mag_x->setTransform(QTransform::fromScale(1,mag_x_var),false);
|
if(mag_x)
|
||||||
|
mag_x->setTransform(QTransform::fromScale(1,mag_x_var),false);
|
||||||
float mag_y_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_Y]));
|
float mag_y_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_Y]));
|
||||||
mag_y->setTransform(QTransform::fromScale(1,mag_y_var),false);
|
if(mag_y)
|
||||||
|
mag_y->setTransform(QTransform::fromScale(1,mag_y_var),false);
|
||||||
float mag_z_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_Z]));
|
float mag_z_var = -1/steps*(1+steps+log10(1e-3*revoCalibrationData.mag_var[RevoCalibration::MAG_VAR_Z]));
|
||||||
mag_z->setTransform(QTransform::fromScale(1,mag_z_var),false);
|
if(mag_z)
|
||||||
|
mag_z->setTransform(QTransform::fromScale(1,mag_z_var),false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user