Browse Source

Fix airspeed checking (#3672)

QGC4.4
Don Gagne 9 years ago committed by GitHub
parent
commit
12c771520f
  1. 23
      src/AutoPilotPlugins/PX4/SensorsComponent.cc
  2. 2
      src/AutoPilotPlugins/PX4/SensorsComponent.h

23
src/AutoPilotPlugins/PX4/SensorsComponent.cc

@ -16,13 +16,14 @@
#include "QGCQmlWidgetHolder.h" #include "QGCQmlWidgetHolder.h"
#include "SensorsComponentController.h" #include "SensorsComponentController.h"
const char* SensorsComponent::_airspeedBreaker = "CBRK_AIRSPD_CHK"; const char* SensorsComponent::_airspeedBreaker = "CBRK_AIRSPD_CHK";
const char* SensorsComponent::_airspeedCal = "SENS_DPRES_OFF";
SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent), VehicleComponent(vehicle, autopilot, parent),
_name(tr("Sensors")) _name(tr("Sensors"))
{ {
_deviceIds << QStringLiteral("CAL_MAG0_ID") << QStringLiteral("CAL_GYRO0_ID") << QStringLiteral("CAL_ACC0_ID");
} }
QString SensorsComponent::name(void) const QString SensorsComponent::name(void) const
@ -48,12 +49,20 @@ bool SensorsComponent::requiresSetup(void) const
bool SensorsComponent::setupComplete(void) const bool SensorsComponent::setupComplete(void) const
{ {
foreach(const QString &triggerParam, setupCompleteChangedTriggerList()) { foreach (const QString &triggerParam, _deviceIds) {
if (triggerParam != _airspeedBreaker && _autopilot->getParameterFact(FactSystem::defaultComponentId, triggerParam)->rawValue().toFloat() == 0.0f) { if (_autopilot->getParameterFact(FactSystem::defaultComponentId, triggerParam)->rawValue().toFloat() == 0.0f) {
return false; return false;
} }
} }
if (_vehicle->fixedWing() || _vehicle->vtol()) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, _airspeedBreaker)->rawValue().toInt() != 162128) {
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, _airspeedCal)->rawValue().toFloat() == 0.0f) {
return false;
}
}
}
return true; return true;
} }
@ -61,9 +70,9 @@ QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const
{ {
QStringList triggers; QStringList triggers;
triggers << "CAL_MAG0_ID" << "CAL_GYRO0_ID" << "CAL_ACC0_ID" << "CBRK_AIRSPD_CHK"; triggers << _deviceIds;
if ((_vehicle->fixedWing() || _vehicle->vtol()) && _autopilot->getParameterFact(FactSystem::defaultComponentId, _airspeedBreaker)->rawValue().toInt() != 162128) { if (_vehicle->fixedWing() || _vehicle->vtol()) {
triggers << "SENS_DPRES_OFF"; triggers << _airspeedCal << _airspeedBreaker;
} }
return triggers; return triggers;

2
src/AutoPilotPlugins/PX4/SensorsComponent.h

@ -40,8 +40,10 @@ public:
private: private:
const QString _name; const QString _name;
QVariantList _summaryItems; QVariantList _summaryItems;
QStringList _deviceIds;
static const char* _airspeedBreaker; static const char* _airspeedBreaker;
static const char* _airspeedCal;
}; };
#endif #endif

Loading…
Cancel
Save