1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Added conf setting for GPS start position for IL2 simulation

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@991 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
corvus 2010-07-03 09:30:35 +00:00 committed by corvus
parent d007478f02
commit 67a05f948e
9 changed files with 70 additions and 8 deletions

View File

@ -43,6 +43,8 @@ void HITLIL2::loadConfiguration(IUAVGadgetConfiguration* config)
{
HITLIL2Configuration *m = qobject_cast<HITLIL2Configuration*>(config);
m_widget->setIl2HostName( m->il2HostName() );
m_widget->setIl2Latitude( m->il2Latitude() );
m_widget->setIl2Longitude( m->il2Longitude() );
m_widget->setIl2Port( m->il2Port() );
m_widget->setIl2ManualControl( m->il2ManualControl() );
}

View File

@ -30,16 +30,22 @@
HITLIL2Configuration::HITLIL2Configuration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_il2HostName(""), m_il2Port(0), m_il2ManualControl(false)
m_il2Latitude(""), m_il2Longitude(""), m_il2HostName(""), m_il2Port(0), m_il2ManualControl(false)
{
if (state.count() > 0) {
QDataStream stream(state);
QString il2Latitude;
QString il2Longitude;
QString il2HostName;
int il2Port;
bool il2ManualControl;
stream >> il2HostName;
m_il2HostName = il2HostName;
stream >> il2Latitude;
m_il2Latitude = il2Latitude;
stream >> il2Port;
stream >> il2Longitude;
m_il2Longitude = il2Longitude;
m_il2Port = il2Port;
stream >> il2ManualControl;
m_il2ManualControl = il2ManualControl;
@ -50,6 +56,8 @@ IUAVGadgetConfiguration *HITLIL2Configuration::clone()
{
HITLIL2Configuration *m = new HITLIL2Configuration(this->classId());
m->m_il2HostName = m_il2HostName;
m->m_il2Latitude = m_il2Latitude;
m->m_il2Longitude = m_il2Longitude;
m->m_il2Port = m_il2Port;
m->m_il2ManualControl = m_il2ManualControl;
return m;
@ -60,6 +68,8 @@ QByteArray HITLIL2Configuration::saveState() const
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << m_il2HostName;
stream << m_il2Latitude;
stream << m_il2Longitude;
stream << m_il2Port;
stream << m_il2ManualControl;
return bytes;

View File

@ -39,6 +39,8 @@ class HITLIL2Configuration : public IUAVGadgetConfiguration
Q_OBJECT
Q_PROPERTY(QString m_il2HostName READ il2HostName WRITE setIl2HostName)
Q_PROPERTY(QString m_il2Latitude READ il2Latitude WRITE setIl2Latitude)
Q_PROPERTY(QString m_il2Longitude READ il2Longitude WRITE setIl2Longitude)
Q_PROPERTY(int m_il2Port READ il2Port WRITE setIl2Port)
Q_PROPERTY(bool m_il2ManualControl READ il2ManualControl WRITE setIl2ManualControl)
@ -48,6 +50,8 @@ public:
IUAVGadgetConfiguration *clone();
QString il2HostName() const { return m_il2HostName; }
QString il2Latitude() const { return m_il2Latitude; }
QString il2Longitude() const { return m_il2Longitude; }
int il2Port() const { return m_il2Port; }
bool il2ManualControl() const { return m_il2ManualControl; }
@ -55,11 +59,15 @@ signals:
public slots:
void setIl2HostName(QString HostName) { m_il2HostName = HostName; }
void setIl2Latitude(QString Latitude) { m_il2Latitude = Latitude; }
void setIl2Longitude(QString Longitude) { m_il2Longitude = Longitude; }
void setIl2Port(int Port) { m_il2Port = Port; }
void setIl2ManualControl(bool val) { m_il2ManualControl = val; }
private:
QString m_il2HostName;
QString m_il2Latitude;
QString m_il2Longitude;
int m_il2Port;
bool m_il2ManualControl;

View File

@ -47,6 +47,8 @@ QWidget *HITLIL2OptionsPage::createPage(QWidget *parent)
// Restore the contents from the settings:
m_optionsPage->Il2Port->setValue(m_config->il2Port());
m_optionsPage->Il2HostName->setText(m_config->il2HostName());
m_optionsPage->Il2Latitude->setText(m_config->il2Latitude());
m_optionsPage->Il2Longitude->setText(m_config->il2Longitude());
m_optionsPage->il2ManualControl->setChecked(m_config->il2ManualControl());
@ -57,6 +59,8 @@ void HITLIL2OptionsPage::apply()
{
m_config->setIl2Port( m_optionsPage->Il2Port->value());
m_config->setIl2HostName( m_optionsPage->Il2HostName->text());
m_config->setIl2Latitude( m_optionsPage->Il2Latitude->text());
m_config->setIl2Longitude( m_optionsPage->Il2Longitude->text());
m_config->setIl2ManualControl( m_optionsPage->il2ManualControl->isChecked());
}

View File

@ -63,16 +63,36 @@
</property>
</widget>
</item>
<item row="0" column="2">
<item row="2" column="2">
<widget class="QLineEdit" name="Il2HostName"/>
</item>
<item row="0" column="1">
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>IL2 Host Name/Number</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="Il2Longitude"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_1">
<property name="text">
<string>Longitude offset (in degrees)</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="Il2Latitude"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_0">
<property name="text">
<string>Latitude offset (in degrees)</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -58,7 +58,7 @@ void HITLIL2Widget::startButtonClicked()
// Start bridge
qxtLog->info("HITLIL2: Starting bridge, initializing IL2 and Autopilot connections");
il2Bridge = new Il2Bridge(il2HostName,il2Port);
il2Bridge = new Il2Bridge(il2HostName,il2Port,il2Latitude,il2Longitude);
connect(il2Bridge, SIGNAL(autopilotConnected()), this, SLOT(onAutopilotConnect()));
connect(il2Bridge, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()));
connect(il2Bridge, SIGNAL(il2Connected()), this, SLOT(onIl2Connect()));
@ -98,6 +98,16 @@ void HITLIL2Widget::setIl2HostName(QString il2HostName)
this->il2HostName = il2HostName;
}
void HITLIL2Widget::setIl2Latitude(QString il2Latitude)
{
this->il2Latitude = il2Latitude;
}
void HITLIL2Widget::setIl2Longitude(QString il2Longitude)
{
this->il2Longitude = il2Longitude;
}
void HITLIL2Widget::setIl2Port(int il2Port)
{
this->il2Port = il2Port;

View File

@ -42,6 +42,8 @@ public:
~HITLIL2Widget();
void setIl2HostName(QString il2HostName);
void setIl2Latitude(QString il2Latitude);
void setIl2Longitude(QString il2Longitude);
void setIl2Port(int il2Port);
void setIl2ManualControl(bool val);
@ -59,6 +61,8 @@ private:
Ui_HITLIL2Widget* widget;
Il2Bridge* il2Bridge;
QString il2HostName;
QString il2Latitude;
QString il2Longitude;
int il2Port;
bool il2ManualControl;
};

View File

@ -63,7 +63,7 @@
#include "extensionsystem/pluginmanager.h"
#include <math.h>
Il2Bridge::Il2Bridge(QString il2HostName, int il2Port)
Il2Bridge::Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QString il2Longitude)
{
// Init fields
il2Host = QHostAddress(il2HostName);
@ -72,6 +72,8 @@ Il2Bridge::Il2Bridge(QString il2HostName, int il2Port)
il2Timeout = 2000;
autopilotConnectionStatus = false;
il2ConnectionStatus = false;
latitude=il2Latitude.toFloat();
longitude=il2Longitude.toFloat();
// Get required UAVObjects
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
@ -348,8 +350,8 @@ void Il2Bridge::processUpdate(QString& data)
gpsData.Altitude = current.Z;
gpsData.Heading = current.azimuth;
gpsData.Groundspeed = current.groundspeed;
gpsData.Latitude = current.Y * DEG2M;
gpsData.Longitude = current.X * cos(gpsData.Latitude*DEG2RAD) * DEG2M;
gpsData.Latitude = latitude + current.Y * DEG2M;
gpsData.Longitude = longitude + current.X * cos(gpsData.Latitude*DEG2RAD) * DEG2M;
gpsData.Satellites = 7;
gpsData.Status = PositionActual::STATUS_FIX3D;
posActual->setData(gpsData);

View File

@ -80,7 +80,7 @@ class Il2Bridge: public QObject
Q_OBJECT
public:
Il2Bridge(QString il2HostName, int il2Port);
Il2Bridge(QString il2HostName, int il2Port, QString il2Latitude, QString il2Longitude);
~Il2Bridge();
bool isAutopilotConnected();
@ -125,6 +125,8 @@ private:
PositionActual* posActual;
GCSTelemetryStats* telStats;
QHostAddress il2Host;
float latitude;
float longitude;
int outPort;
int updatePeriod;
QTimer* txTimer;