Commit 96e5674d authored by Don Gagne's avatar Don Gagne

Support two param sets for calibration

The parameters for calibration were changed in the latest master. QGC
needs to work with both. Hacked in for now, waiting on a true parameter
re-mapping implementation.
parent 72167dd0
......@@ -31,12 +31,17 @@
// These two list must be kept in sync
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL };
static const char* triggerParamsV1[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL };
static const char* triggerParamsV2[] = { "CAL_MAG0_ID", "CAL_GYRO0_ID", "CAL_ACC0_ID", "SENS_DPRES_OFF", NULL };
SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Sensors"))
{
// Determine what set of parameters are available. This is a temporary hack for now. Will need real parameter
// mapping in the future.
QVariant value;
_paramsV1 = _paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SENS_MAG_XOFF", value);
}
QString SensorsComponent::name(void) const
......@@ -97,14 +102,18 @@ QString SensorsComponent::setupStateDescription(void) const
const char** SensorsComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
return _paramsV1 ? triggerParamsV1 : triggerParamsV2;
}
QStringList SensorsComponent::paramFilterList(void) const
{
QStringList list;
list << "SENS_*";
if (_paramsV1) {
list << "SENS_*";
} else {
list << "CAL_*";
}
return list;
}
......
......@@ -55,6 +55,7 @@ public:
private:
const QString _name;
QVariantList _summaryItems;
bool _paramsV1;
};
#endif
......@@ -15,7 +15,8 @@ Column {
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - compass.contentWidth;
text: autopilot.parameters["SENS_MAG_XOFF"].value == 0.0 ? "Setup required" : "Ready"
property bool setupRequiredValue: autopilot.parameters["SENS_MAG_XOFF"] ? autopilot.parameters["SENS_MAG_XOFF"].value : autopilot.parameters["CAL_MAG0_ID"].value
text: setupRequiredValue == 0 ? "Setup required" : "Ready"
}
}
......@@ -26,7 +27,8 @@ Column {
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - gyro.contentWidth;
text: autopilot.parameters["SENS_GYRO_XOFF"].value == 0.0 ? "Setup required" : "Ready"
property bool setupRequiredValue: autopilot.parameters["SENS_GYRO_XOFF"] ? autopilot.parameters["SENS_GYRO_XOFF"].value : autopilot.parameters["CAL_GYRO0_ID"].value
text: setupRequiredValue == 0 ? "Setup required" : "Ready"
}
}
......@@ -37,7 +39,8 @@ Column {
Text {
horizontalAlignment: Text.AlignRight;
width: parent.width - accel.contentWidth;
text: autopilot.parameters["SENS_ACC_XOFF"].value == 0.0 ? "Setup required" : "Ready"
property bool setupRequiredValue: autopilot.parameters["SENS_ACC_XOFF"] ? autopilot.parameters["SENS_ACC_XOFF"].value : autopilot.parameters["CAL_ACC0_ID"].value
text: setupRequiredValue == 0 ? "Setup required" : "Ready"
}
}
......
......@@ -142,7 +142,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p
}
// Check mag calibration naively
if (parameterName.contains("SENS_MAG_XOFF")) {
if (parameterName.contains("SENS_MAG_XOFF") || parameterName.contains("CAL_MAG0_ID")) {
float offset = value.toFloat();
if (offset < 0.000001f && offset > -0.000001f) {
// Must be zero, not good
......@@ -153,7 +153,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p
}
// Check gyro calibration naively
if (parameterName.contains("SENS_GYRO_XOFF")) {
if (parameterName.contains("SENS_GYRO_XOFF") || parameterName.contains("CAL_GYRO0_ID")) {
float offset = value.toFloat();
if (offset < 0.000001f && offset > -0.000001f) {
// Must be zero, not good
......@@ -164,7 +164,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p
}
// Check accel calibration naively
if (parameterName.contains("SENS_ACC_XOFF")) {
if (parameterName.contains("SENS_ACC_XOFF") || parameterName.contains("CAL_ACC0_ID")) {
float offset = value.toFloat();
if (offset < 0.000001f && offset > -0.000001f) {
// Must be zero, not good
......@@ -354,17 +354,24 @@ void QGCPX4SensorCalibration::setActiveUAS(UASInterface* uas)
// If the parameters are ready, we aren't going to get paramterChanged signals. So fake them in order to make the UI work.
if (uas->getParamManager()->parametersReady()) {
QVariant value;
static const char* rgParams[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF" };
static const char* rgParamsV1[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF" };
static const char* rgParamsV2[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "CAL_MAG0_XOFF", "CAL_GYRO0_XOFF", "CAL_ACC0_XOFF", "SENS_DPRES_OFF" };
QGCUASParamManagerInterface* paramMgr = uas->getParamManager();
for (size_t i=0; i<sizeof(rgParams)/sizeof(rgParams[0]); i++) {
// Temp hack for parameter mapping
bool paramsV1 = paramMgr->getComponentForParam("SENS_MAG_XOFF").count();
static const char** prgParamList = paramsV1 ? rgParamsV1 : rgParamsV2;
for (size_t i=0; i<sizeof(rgParamsV1)/sizeof(rgParamsV1[0]); i++) {
QVariant value;
QList<int> compIds = paramMgr->getComponentForParam(rgParams[i]);
QList<int> compIds = paramMgr->getComponentForParam(prgParamList[i]);
Q_ASSERT(compIds.count() == 1);
paramMgr->getParameterValue(compIds[0], rgParams[i], value);
parameterChanged(uas->getUASID(), compIds[0], rgParams[i], value);
bool found = paramMgr->getParameterValue(compIds[0], prgParamList[i], value);
Q_ASSERT(found);
Q_UNUSED(found);
parameterChanged(uas->getUASID(), compIds[0], prgParamList[i], value);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment