1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

Added simulator support for AirspeedActual UAVO.

This commit is contained in:
Kenz Dale 2012-08-29 16:28:02 +02:00
parent 034b366578
commit b9fe954d87
7 changed files with 94 additions and 15 deletions

View File

@ -64,23 +64,30 @@ HITLConfiguration::HITLConfiguration(QString classId, QSettings* qSettings, QObj
settings.manualControlEnabled= false;
settings.minOutputPeriod = 100;
settings.airspeedActualEnabled= false;
settings.airspeedActualRate = 100;
// if a saved configuration exists load it, and overwrite defaults
if (qSettings != 0) {
settings.simulatorId = qSettings->value("simulatorId").toString();
settings.hostAddress = qSettings->value("hostAddress").toString();
settings.inPort = qSettings->value("inPort").toInt();
settings.remoteAddress = qSettings->value("remoteAddress").toString();
settings.outPort = qSettings->value("outPort").toInt();
settings.simulatorId = qSettings->value("simulatorId").toString();
settings.binPath = qSettings->value("binPath").toString();
settings.dataPath = qSettings->value("dataPath").toString();
settings.hostAddress = qSettings->value("hostAddress").toString();
settings.remoteAddress = qSettings->value("remoteAddress").toString();
settings.outPort = qSettings->value("outPort").toInt();
settings.inPort = qSettings->value("inPort").toInt();
settings.latitude = qSettings->value("latitude").toString();
settings.longitude = qSettings->value("longitude").toString();
settings.startSim = qSettings->value("startSim").toBool();
settings.addNoise = qSettings->value("noiseCheckBox").toBool();
settings.gcsReceiverEnabled = qSettings->value("gcsReceiverEnabled").toBool();
settings.manualControlEnabled= qSettings->value("manualControlEnabled").toBool();
settings.attRawEnabled = qSettings->value("attRawEnabled").toBool();
settings.attRawRate = qSettings->value("attRawRate").toInt();
@ -99,9 +106,10 @@ HITLConfiguration::HITLConfiguration(QString classId, QSettings* qSettings, QObj
settings.groundTruthRate = qSettings->value("groundTruthRate").toInt();
settings.inputCommand = qSettings->value("inputCommand").toBool();
settings.gcsReceiverEnabled = qSettings->value("gcsReceiverEnabled").toBool();
settings.manualControlEnabled= qSettings->value("manualControlEnabled").toBool();
settings.minOutputPeriod = qSettings->value("minOutputPeriod").toInt();
settings.airspeedActualEnabled=qSettings->value("airspeedActualEnabled").toBool();
settings.airspeedActualRate = qSettings->value("airspeedActualRate").toInt();
}
}
@ -150,6 +158,7 @@ void HITLConfiguration::saveConfig(QSettings* qSettings) const {
qSettings->setValue("inputCommand", settings.inputCommand);
qSettings->setValue("minOutputPeriod", settings.minOutputPeriod);
qSettings->setValue("airspeedActualEnabled", settings.airspeedActualEnabled);
qSettings->setValue("airspeedActualRate", settings.airspeedActualRate);
}

View File

@ -72,7 +72,7 @@ Noise HitlNoiseGeneration::generateNoise(){
noise.accelData.y=0;
noise.accelData.z=0;
noise.baroAirspeed.CalibratedAirspeed=0;
noise.airspeedActual.CalibratedAirspeed=0;
return noise;
}

View File

@ -40,7 +40,7 @@ struct Noise{
Accels::DataFields accelData;
AttitudeActual::DataFields attActualData;
BaroAltitude::DataFields baroAltData;
BaroAirspeed::DataFields baroAirspeed;
AirspeedActual::DataFields airspeedActual;
GPSPosition::DataFields gpsPosData;
GPSVelocity::DataFields gpsVelData;
Gyros::DataFields gyroData;

View File

@ -113,6 +113,8 @@ QWidget *HITLOptionsPage::createPage(QWidget *parent)
m_optionsPage->attActCalc->setChecked(config->Settings().attActCalc);
m_optionsPage->attActSim->setChecked(config->Settings().attActSim);
m_optionsPage->airspeedActualCheckbox->setChecked(config->Settings().airspeedActualEnabled);
m_optionsPage->airspeedRateSpinbox->setValue(config->Settings().airspeedActualRate);
return optionsPageWidget;
}
@ -160,6 +162,10 @@ void HITLOptionsPage::apply()
settings.attActSim = m_optionsPage->attActSim->isChecked();
settings.attActCalc = m_optionsPage->attActCalc->isChecked();
settings.airspeedActualEnabled=m_optionsPage->airspeedActualCheckbox->isChecked();
settings.airspeedActualRate=m_optionsPage->airspeedRateSpinbox->value();
//Write settings to file
config->setSimulatorSettings(settings);
}

View File

@ -154,7 +154,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="layoutWidget1">
<property name="geometry">
<rect>
<x>10</x>
@ -829,6 +829,50 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="airspeedActualCheckbox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>AirspeedActual</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Refresh rate:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="airspeedRateSpinbox">
<property name="toolTip">
<string>0 - update once, or every N seconds</string>
</property>
<property name="suffix">
<string>ms</string>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="baroAltitudeCheckbox">
<property name="enabled">
@ -912,7 +956,7 @@
<number>10</number>
</property>
<property name="value">
<number>50</number>
<number>250</number>
</property>
</widget>
</item>

View File

@ -69,6 +69,7 @@ Simulator::Simulator(const SimulatorSettings& params) :
gcsRcvrTime = currentTime;
attRawTime = currentTime;
baroAltTime = currentTime;
airspeedActualTime=currentTime;
}
@ -143,7 +144,7 @@ void Simulator::onStart()
velActual = VelocityActual::GetInstance(objManager);
posActual = PositionActual::GetInstance(objManager);
baroAlt = BaroAltitude::GetInstance(objManager);
baroAirspeed = BaroAirspeed::GetInstance(objManager);
airspeedActual = AirspeedActual::GetInstance(objManager);
attActual = AttitudeActual::GetInstance(objManager);
attSettings = AttitudeSettings::GetInstance(objManager);
accels = Accels::GetInstance(objManager);
@ -267,6 +268,9 @@ void Simulator::setupObjects()
else
setupWatchedObject(attActual, 100); //Hardcoded? Bleh.
if(settings.airspeedActualEnabled)
setupOutputObject(airspeedActual, settings.airspeedActualRate);
if(settings.baroAltitudeEnabled)
setupOutputObject(baroAlt, settings.baroAltRate);
@ -674,6 +678,18 @@ void Simulator::updateUAVOs(Output2Hardware out){
}
}
// Update AirspeedActual object
if (settings.airspeedActualEnabled){
if (airspeedActualTime.msecsTo(currentTime) >= settings.airspeedActualRate) {
AirspeedActual::DataFields airspeedActualData;
memset(&airspeedActualData, 0, sizeof(AirspeedActual::DataFields));
airspeedActualData.CalibratedAirspeed = out.calibratedAirspeed + noise.airspeedActual.CalibratedAirspeed;
airspeedActual->setData(airspeedActualData);
airspeedActualTime=airspeedActualTime.addMSecs(settings.airspeedActualRate);
}
}
// Update raw attitude sensors
if (settings.attRawEnabled) {
if (attRawTime.msecsTo(currentTime) >= settings.attRawRate) {

View File

@ -43,7 +43,7 @@
#include "actuatordesired.h"
#include "attitudeactual.h"
#include "attitudesettings.h"
#include "baroairspeed.h"
#include "airspeedactual.h"
#include "baroaltitude.h"
#include "flightstatus.h"
#include "gcsreceiver.h"
@ -140,6 +140,9 @@ typedef struct _CONNECTION
bool manualControlEnabled;
quint16 minOutputPeriod;
bool airspeedActualEnabled;
quint16 airspeedActualRate;
} SimulatorSettings;
@ -260,7 +263,7 @@ protected:
ManualControlCommand* manCtrlCommand;
FlightStatus* flightStatus;
BaroAltitude* baroAlt;
BaroAirspeed* baroAirspeed;
AirspeedActual* airspeedActual;
AttitudeActual* attActual;
AttitudeSettings* attSettings;
VelocityActual* velActual;
@ -297,6 +300,7 @@ private:
QTime groundTruthTime;
QTime baroAltTime;
QTime gcsRcvrTime;
QTime airspeedActualTime;
QString name;
QString simulatorId;