diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index 72f94e64d4b7d829dc5f286452ce37577eb5149d..9e9391735e19cc51336559fa62c2cc881a9d6919 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -46,7 +46,8 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments terraSync(NULL), flightGearVersion(0), startupArguments(startupArguments), - _sensorHilEnabled(true) + _sensorHilEnabled(true), + barometerOffsetkPa(0.0) { this->host = host; this->port = port+mav->getUASID(); @@ -279,7 +280,8 @@ void QGCFlightGearLink::readBytes() mag_dip = values.at(18).toFloat(); temperature = values.at(19).toFloat(); - abs_pressure = values.at(20).toFloat()*1e2; //convert to Pa from hPa + abs_pressure = values.at(20).toFloat() * 1e2f; //convert to Pa from hPa + abs_pressure += barometerOffsetkPa * 1e3f; //add offset, convert from kPa to Pa //calculate differential pressure const float air_gas_constant = 287.1f; // J/(kg * K) @@ -736,3 +738,8 @@ void QGCFlightGearLink::setName(QString name) this->name = name; // emit nameChanged(this->name); } + +void QGCFlightGearLink::setBarometerOffset(float barometerOffsetkPa) +{ + this->barometerOffsetkPa = barometerOffsetkPa; +} diff --git a/src/comm/QGCFlightGearLink.h b/src/comm/QGCFlightGearLink.h index 27ba6d2cd1ad9657872a4bdc64edf656609f1aed..dc074fee02f5540fa6c191c524b52b5222c79166 100644 --- a/src/comm/QGCFlightGearLink.h +++ b/src/comm/QGCFlightGearLink.h @@ -42,6 +42,7 @@ This file is part of the QGROUNDCONTROL project #include #include "UASInterface.h" #include "QGCHilLink.h" +#include class QGCFlightGearLink : public QGCHilLink { @@ -134,6 +135,7 @@ public slots: void printFgfsOutput(); void printFgfsError(); void setStartupArguments(QString startupArguments); + void setBarometerOffset(float barometerOffsetkPa); protected: QString name; @@ -161,6 +163,7 @@ protected: unsigned int flightGearVersion; QString startupArguments; bool _sensorHilEnabled; + float barometerOffsetkPa; void setName(QString name); diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 6aa4258a785099de901bda7786374ebc5ec993e8..71277ac1b2ddabbb7458e7a722b885e977d27916 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -2982,7 +2982,7 @@ bool UAS::emergencyKILL() /** * If enabled, connect the flight gear link. */ -void UAS::enableHilFlightGear(bool enable, QString options, bool sensorHil) +void UAS::enableHilFlightGear(bool enable, QString options, bool sensorHil, QObject * configuration) { QGCFlightGearLink* link = dynamic_cast(simulation); if (!link || !simulation) { @@ -2997,6 +2997,7 @@ void UAS::enableHilFlightGear(bool enable, QString options, bool sensorHil) link = dynamic_cast(simulation); link->setStartupArguments(options); link->sensorHilEnabled(sensorHil); + QObject::connect(configuration, SIGNAL(barometerOffsetChanged(float)), link, SLOT(setBarometerOffset(float))); if (enable) { startHil(); diff --git a/src/uas/UAS.h b/src/uas/UAS.h index 9db1399a78ccd600a3cf356945aa47b2c4821b10..5f5a77ac0658883e7049bafe451d4610a349273b 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -757,7 +757,7 @@ public slots: void go(); /** @brief Enable / disable HIL */ - void enableHilFlightGear(bool enable, QString options, bool sensorHil); + void enableHilFlightGear(bool enable, QString options, bool sensorHil, QObject * configuration); void enableHilJSBSim(bool enable, QString options); void enableHilXPlane(bool enable); diff --git a/src/ui/QGCHilConfiguration.cc b/src/ui/QGCHilConfiguration.cc index 8d2a52af4e99119df9357c0f113cff7274d01588..2ea1c7d7fa9424657fdc4331373e567f8bba5c5f 100644 --- a/src/ui/QGCHilConfiguration.cc +++ b/src/ui/QGCHilConfiguration.cc @@ -64,7 +64,7 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index) if(1 == index) { // Ensure the sim exists and is disabled - mav->enableHilFlightGear(false, "", true); + mav->enableHilFlightGear(false, "", true, this); QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this); hfgconf->show(); ui->simulatorConfigurationLayout->addWidget(hfgconf); diff --git a/src/ui/QGCHilFlightGearConfiguration.cc b/src/ui/QGCHilFlightGearConfiguration.cc index ddbccb7c7fa94edb6d6a0caa3dd08796e0f25e1a..67f4eb21d8bf26de12135698970523e3c7a4e9de 100644 --- a/src/ui/QGCHilFlightGearConfiguration.cc +++ b/src/ui/QGCHilFlightGearConfiguration.cc @@ -40,10 +40,16 @@ void QGCHilFlightGearConfiguration::on_startButton_clicked() //XXX check validity of inputs QString options = ui->optionsPlainTextEdit->toPlainText(); options.append(" --aircraft=" + ui->aircraftComboBox->currentText()); - mav->enableHilFlightGear(true, options, ui->sensorHilCheckBox->isChecked()); + mav->enableHilFlightGear(true, options, ui->sensorHilCheckBox->isChecked(), this); } void QGCHilFlightGearConfiguration::on_stopButton_clicked() { mav->stopHil(); } + +void QGCHilFlightGearConfiguration::on_barometerOffsetLineEdit_textChanged(const QString& baroOffset) +{ + emit barometerOffsetChanged(baroOffset.toFloat()); +} + diff --git a/src/ui/QGCHilFlightGearConfiguration.h b/src/ui/QGCHilFlightGearConfiguration.h index 9ac353834380bf7b296e0e036f15397f49bfe1a5..7e0e48901380da54c62d39dfc722bfd4a499ee5f 100644 --- a/src/ui/QGCHilFlightGearConfiguration.h +++ b/src/ui/QGCHilFlightGearConfiguration.h @@ -25,9 +25,13 @@ protected: private slots: void on_startButton_clicked(); void on_stopButton_clicked(); + void on_barometerOffsetLineEdit_textChanged(const QString& baroOffset); private: Ui::QGCHilFlightGearConfiguration *ui; + +signals: + void barometerOffsetChanged(float barometerOffsetkPa); }; #endif // QGCHILFLIGHTGEARCONFIGURATION_H diff --git a/src/ui/QGCHilFlightGearConfiguration.ui b/src/ui/QGCHilFlightGearConfiguration.ui index b27ff74a1aef25d39102d4e005d68a8f38aecf5a..fa79fe2613b7ab6dd7f7a22ee65b49856c2166c0 100644 --- a/src/ui/QGCHilFlightGearConfiguration.ui +++ b/src/ui/QGCHilFlightGearConfiguration.ui @@ -32,13 +32,6 @@ 6 - - - - Airframe: - - - @@ -52,14 +45,21 @@ - + <html><head/><body><p>Additional Options:</p></body></html> - + + + + Airframe: + + + + @@ -72,7 +72,7 @@ - + @@ -85,7 +85,7 @@ - + Stop @@ -102,6 +102,20 @@ + + + + Barometer Offset [kPa]: + + + + + + + 0 + + +