mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Added simulator support for AirspeedActual UAVO.
This commit is contained in:
parent
034b366578
commit
b9fe954d87
@ -64,23 +64,30 @@ HITLConfiguration::HITLConfiguration(QString classId, QSettings* qSettings, QObj
|
|||||||
settings.manualControlEnabled= false;
|
settings.manualControlEnabled= false;
|
||||||
settings.minOutputPeriod = 100;
|
settings.minOutputPeriod = 100;
|
||||||
|
|
||||||
|
settings.airspeedActualEnabled= false;
|
||||||
|
settings.airspeedActualRate = 100;
|
||||||
|
|
||||||
|
|
||||||
// if a saved configuration exists load it, and overwrite defaults
|
// if a saved configuration exists load it, and overwrite defaults
|
||||||
if (qSettings != 0) {
|
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.binPath = qSettings->value("binPath").toString();
|
||||||
settings.dataPath = qSettings->value("dataPath").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.latitude = qSettings->value("latitude").toString();
|
||||||
settings.longitude = qSettings->value("longitude").toString();
|
settings.longitude = qSettings->value("longitude").toString();
|
||||||
settings.startSim = qSettings->value("startSim").toBool();
|
settings.startSim = qSettings->value("startSim").toBool();
|
||||||
settings.addNoise = qSettings->value("noiseCheckBox").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.attRawEnabled = qSettings->value("attRawEnabled").toBool();
|
||||||
settings.attRawRate = qSettings->value("attRawRate").toInt();
|
settings.attRawRate = qSettings->value("attRawRate").toInt();
|
||||||
|
|
||||||
@ -99,9 +106,10 @@ HITLConfiguration::HITLConfiguration(QString classId, QSettings* qSettings, QObj
|
|||||||
settings.groundTruthRate = qSettings->value("groundTruthRate").toInt();
|
settings.groundTruthRate = qSettings->value("groundTruthRate").toInt();
|
||||||
|
|
||||||
settings.inputCommand = qSettings->value("inputCommand").toBool();
|
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.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("inputCommand", settings.inputCommand);
|
||||||
qSettings->setValue("minOutputPeriod", settings.minOutputPeriod);
|
qSettings->setValue("minOutputPeriod", settings.minOutputPeriod);
|
||||||
|
|
||||||
|
qSettings->setValue("airspeedActualEnabled", settings.airspeedActualEnabled);
|
||||||
|
qSettings->setValue("airspeedActualRate", settings.airspeedActualRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ Noise HitlNoiseGeneration::generateNoise(){
|
|||||||
noise.accelData.y=0;
|
noise.accelData.y=0;
|
||||||
noise.accelData.z=0;
|
noise.accelData.z=0;
|
||||||
|
|
||||||
noise.baroAirspeed.CalibratedAirspeed=0;
|
noise.airspeedActual.CalibratedAirspeed=0;
|
||||||
|
|
||||||
return noise;
|
return noise;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ struct Noise{
|
|||||||
Accels::DataFields accelData;
|
Accels::DataFields accelData;
|
||||||
AttitudeActual::DataFields attActualData;
|
AttitudeActual::DataFields attActualData;
|
||||||
BaroAltitude::DataFields baroAltData;
|
BaroAltitude::DataFields baroAltData;
|
||||||
BaroAirspeed::DataFields baroAirspeed;
|
AirspeedActual::DataFields airspeedActual;
|
||||||
GPSPosition::DataFields gpsPosData;
|
GPSPosition::DataFields gpsPosData;
|
||||||
GPSVelocity::DataFields gpsVelData;
|
GPSVelocity::DataFields gpsVelData;
|
||||||
Gyros::DataFields gyroData;
|
Gyros::DataFields gyroData;
|
||||||
|
@ -113,6 +113,8 @@ QWidget *HITLOptionsPage::createPage(QWidget *parent)
|
|||||||
m_optionsPage->attActCalc->setChecked(config->Settings().attActCalc);
|
m_optionsPage->attActCalc->setChecked(config->Settings().attActCalc);
|
||||||
m_optionsPage->attActSim->setChecked(config->Settings().attActSim);
|
m_optionsPage->attActSim->setChecked(config->Settings().attActSim);
|
||||||
|
|
||||||
|
m_optionsPage->airspeedActualCheckbox->setChecked(config->Settings().airspeedActualEnabled);
|
||||||
|
m_optionsPage->airspeedRateSpinbox->setValue(config->Settings().airspeedActualRate);
|
||||||
|
|
||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
}
|
}
|
||||||
@ -160,6 +162,10 @@ void HITLOptionsPage::apply()
|
|||||||
settings.attActSim = m_optionsPage->attActSim->isChecked();
|
settings.attActSim = m_optionsPage->attActSim->isChecked();
|
||||||
settings.attActCalc = m_optionsPage->attActCalc->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);
|
config->setSimulatorSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget1">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
@ -829,6 +829,50 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</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>
|
<item>
|
||||||
<widget class="QGroupBox" name="baroAltitudeCheckbox">
|
<widget class="QGroupBox" name="baroAltitudeCheckbox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -912,7 +956,7 @@
|
|||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>50</number>
|
<number>250</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -69,6 +69,7 @@ Simulator::Simulator(const SimulatorSettings& params) :
|
|||||||
gcsRcvrTime = currentTime;
|
gcsRcvrTime = currentTime;
|
||||||
attRawTime = currentTime;
|
attRawTime = currentTime;
|
||||||
baroAltTime = currentTime;
|
baroAltTime = currentTime;
|
||||||
|
airspeedActualTime=currentTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ void Simulator::onStart()
|
|||||||
velActual = VelocityActual::GetInstance(objManager);
|
velActual = VelocityActual::GetInstance(objManager);
|
||||||
posActual = PositionActual::GetInstance(objManager);
|
posActual = PositionActual::GetInstance(objManager);
|
||||||
baroAlt = BaroAltitude::GetInstance(objManager);
|
baroAlt = BaroAltitude::GetInstance(objManager);
|
||||||
baroAirspeed = BaroAirspeed::GetInstance(objManager);
|
airspeedActual = AirspeedActual::GetInstance(objManager);
|
||||||
attActual = AttitudeActual::GetInstance(objManager);
|
attActual = AttitudeActual::GetInstance(objManager);
|
||||||
attSettings = AttitudeSettings::GetInstance(objManager);
|
attSettings = AttitudeSettings::GetInstance(objManager);
|
||||||
accels = Accels::GetInstance(objManager);
|
accels = Accels::GetInstance(objManager);
|
||||||
@ -267,6 +268,9 @@ void Simulator::setupObjects()
|
|||||||
else
|
else
|
||||||
setupWatchedObject(attActual, 100); //Hardcoded? Bleh.
|
setupWatchedObject(attActual, 100); //Hardcoded? Bleh.
|
||||||
|
|
||||||
|
if(settings.airspeedActualEnabled)
|
||||||
|
setupOutputObject(airspeedActual, settings.airspeedActualRate);
|
||||||
|
|
||||||
if(settings.baroAltitudeEnabled)
|
if(settings.baroAltitudeEnabled)
|
||||||
setupOutputObject(baroAlt, settings.baroAltRate);
|
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
|
// Update raw attitude sensors
|
||||||
if (settings.attRawEnabled) {
|
if (settings.attRawEnabled) {
|
||||||
if (attRawTime.msecsTo(currentTime) >= settings.attRawRate) {
|
if (attRawTime.msecsTo(currentTime) >= settings.attRawRate) {
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "actuatordesired.h"
|
#include "actuatordesired.h"
|
||||||
#include "attitudeactual.h"
|
#include "attitudeactual.h"
|
||||||
#include "attitudesettings.h"
|
#include "attitudesettings.h"
|
||||||
#include "baroairspeed.h"
|
#include "airspeedactual.h"
|
||||||
#include "baroaltitude.h"
|
#include "baroaltitude.h"
|
||||||
#include "flightstatus.h"
|
#include "flightstatus.h"
|
||||||
#include "gcsreceiver.h"
|
#include "gcsreceiver.h"
|
||||||
@ -140,6 +140,9 @@ typedef struct _CONNECTION
|
|||||||
bool manualControlEnabled;
|
bool manualControlEnabled;
|
||||||
quint16 minOutputPeriod;
|
quint16 minOutputPeriod;
|
||||||
|
|
||||||
|
bool airspeedActualEnabled;
|
||||||
|
quint16 airspeedActualRate;
|
||||||
|
|
||||||
} SimulatorSettings;
|
} SimulatorSettings;
|
||||||
|
|
||||||
|
|
||||||
@ -260,7 +263,7 @@ protected:
|
|||||||
ManualControlCommand* manCtrlCommand;
|
ManualControlCommand* manCtrlCommand;
|
||||||
FlightStatus* flightStatus;
|
FlightStatus* flightStatus;
|
||||||
BaroAltitude* baroAlt;
|
BaroAltitude* baroAlt;
|
||||||
BaroAirspeed* baroAirspeed;
|
AirspeedActual* airspeedActual;
|
||||||
AttitudeActual* attActual;
|
AttitudeActual* attActual;
|
||||||
AttitudeSettings* attSettings;
|
AttitudeSettings* attSettings;
|
||||||
VelocityActual* velActual;
|
VelocityActual* velActual;
|
||||||
@ -297,6 +300,7 @@ private:
|
|||||||
QTime groundTruthTime;
|
QTime groundTruthTime;
|
||||||
QTime baroAltTime;
|
QTime baroAltTime;
|
||||||
QTime gcsRcvrTime;
|
QTime gcsRcvrTime;
|
||||||
|
QTime airspeedActualTime;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QString simulatorId;
|
QString simulatorId;
|
||||||
|
Loading…
Reference in New Issue
Block a user