Commit 017c02df authored by lm's avatar lm

Implemented moving the home location

parent c7d4fcae
...@@ -23,12 +23,17 @@ var lastAlt = 0; ...@@ -23,12 +23,17 @@ var lastAlt = 0;
var currLat = 47.3769; var currLat = 47.3769;
var currLon = 8.549444; var currLon = 8.549444;
var currAlt = 470; var currAlt = 470;
var currentCameraLatitude = 0;
var currentCameraLongitude = 0;
var currentCameraAltitude = 0;
var currFollowHeading = 0.0; var currFollowHeading = 0.0;
var homeLat = 0; var homeLat = 0;
var homeLon = 0; var homeLon = 0;
var homeAlt = 0; var homeAlt = 0;
var homeViewRange = 500; var homeViewRange = 800;
var homeLocation = null; var homeLocation = null;
var homeGroundLevel = 0; var homeGroundLevel = 0;
...@@ -85,6 +90,8 @@ var newWaypointLongitude = 0; ...@@ -85,6 +90,8 @@ var newWaypointLongitude = 0;
var newWaypointAltitude = 0; var newWaypointAltitude = 0;
var newWaypointPending = false; var newWaypointPending = false;
var clickMode = 0;
var homePlacemark = null; var homePlacemark = null;
function getGlobal(variable) function getGlobal(variable)
...@@ -107,6 +114,28 @@ function setDraggingAllowed(allowed) ...@@ -107,6 +114,28 @@ function setDraggingAllowed(allowed)
draggingAllowed = allowed; draggingAllowed = allowed;
} }
function sampleCurrentPosition()
{
var thisView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
currentCameraLatitude = thisView.getLatitude();
currentCameraLongitude = thisView.getLongitude();
currentCameraGroundAltitude = ge.getGlobe().getGroundAltitude(currentCameraLatitude, currentCameraLongitude);
}
function enableSetHomeMode()
{
clickMode = 1;
}
function setLookAtLatLon(lat, lon)
{
// Keep the current altitude above ground, just move the position
currView = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
currView.setLatitude(lat);
currView.setLongitude(lon);
ge.getView().setAbstractView(currView);
}
function setNewWaypointPending(pending) function setNewWaypointPending(pending)
{ {
newWaypointPending = pending; newWaypointPending = pending;
...@@ -140,16 +169,35 @@ function enableEventListener() ...@@ -140,16 +169,35 @@ function enableEventListener()
// listen for mousedown on the window (look specifically for point placemarks) // listen for mousedown on the window (look specifically for point placemarks)
google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event) google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event)
{ {
if (clickMode == 1)
{
// Set home mode
dragWaypointIndex = 'HOME';
document.getElementById('JScript_dragWaypointIndex').setAttribute('value',dragWaypointIndex);
dragWaypointLatitude = event.getLatitude();
dragWaypointLongitude = event.getLongitude();
dragWaypointAltitude = ge.getGlobe().getGroundAltitude(dragWaypointLatitude, dragWaypointLongitude);
dragWaypointPending = true;
document.getElementById('JScript_dragWaypointLatitude').setAttribute('value',dragWaypointLatitude);
document.getElementById('JScript_dragWaypointLongitude').setAttribute('value',dragWaypointLongitude);
document.getElementById('JScript_dragWaypointAltitude').setAttribute('value',dragWaypointAltitude);
document.getElementById('JScript_dragWaypointPending').setAttribute('value',true);
setGCSHome(dragWaypointLatitude, dragWaypointLongitude, dragWaypointAltitude);
}
if (event.getTarget().getType() == 'KmlPlacemark' && if (event.getTarget().getType() == 'KmlPlacemark' &&
event.getTarget().getGeometry().getType() == 'KmlPoint') { event.getTarget().getGeometry().getType() == 'KmlPoint') {
var placemark = event.getTarget(); var placemark = event.getTarget();
event.preventDefault(); event.preventDefault();
if (draggingAllowed) if (draggingAllowed)
{ {
if (clickMode == 0)
{
dragInfo = { dragInfo = {
placemark: event.getTarget(), placemark: event.getTarget(),
dragged: false dragged: false
}; };
}
} }
} }
}); });
...@@ -157,7 +205,7 @@ google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event) ...@@ -157,7 +205,7 @@ google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event)
// listen for mousemove on the globe // listen for mousemove on the globe
google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event) google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
{ {
if (draggingAllowed) if (draggingAllowed && (clickMode == 0))
{ {
if (dragInfo) { if (dragInfo) {
event.preventDefault(); event.preventDefault();
...@@ -182,7 +230,7 @@ google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event) ...@@ -182,7 +230,7 @@ google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event)
// listen for mouseup on the window // listen for mouseup on the window
google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event) google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event)
{ {
if (draggingAllowed) if (draggingAllowed && (clickMode == 0))
{ {
if (dragInfo) { if (dragInfo) {
if (dragInfo.dragged) if (dragInfo.dragged)
...@@ -206,6 +254,7 @@ google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event) ...@@ -206,6 +254,7 @@ google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event)
dragInfo = null; dragInfo = null;
} }
} }
clickMode = 0;
}); });
// Listen for wp creation request on the globe // Listen for wp creation request on the globe
...@@ -235,6 +284,9 @@ function setCurrAircraft(id) ...@@ -235,6 +284,9 @@ function setCurrAircraft(id)
function setGCSHome(lat, lon, alt) function setGCSHome(lat, lon, alt)
{ {
// Only update if position actually changed
if (lat != homeLat || lon != homeLon || alt != homeAlt)
{
homeLat = lat; homeLat = lat;
homeLon = lon; homeLon = lon;
homeAlt = alt; homeAlt = alt;
...@@ -265,12 +317,15 @@ function setGCSHome(lat, lon, alt) ...@@ -265,12 +317,15 @@ function setGCSHome(lat, lon, alt)
} }
else else
{ {
var location = ge.createPoint(''); var location = ge.createPoint('');
location.setLatitude(lat); if (location.getLatitude() != lat || location.getLongitude() != lon || location.getAltitude() != alt)
location.setLongitude(lon); {
location.setAltitude(alt); location.setLatitude(lat);
homePlacemark.setGeometry(location); location.setLongitude(lon);
homePlacemark.setDescription('HOME'); location.setAltitude(alt);
homePlacemark.setGeometry(location);
homePlacemark.setDescription('HOME');
}
} }
homeGroundLevel = ge.getGlobe().getGroundAltitude(lat,lon); homeGroundLevel = ge.getGlobe().getGroundAltitude(lat,lon);
...@@ -278,6 +333,7 @@ function setGCSHome(lat, lon, alt) ...@@ -278,6 +333,7 @@ function setGCSHome(lat, lon, alt)
{ {
homeGroundLevel = alt; homeGroundLevel = alt;
} }
}
} }
function updateWaypointListLength(id, len) function updateWaypointListLength(id, len)
...@@ -560,14 +616,8 @@ function setViewMode(mode) ...@@ -560,14 +616,8 @@ function setViewMode(mode)
{ {
lastTilt = currView.getTilt(); lastTilt = currView.getTilt();
lastHeading = currView.getHeading(); lastHeading = currView.getHeading();
//var lastLat2 = currView.getLatitude();
//var lastLon2 = currView.getLongitude();
//var lastAlt2 = currView.getAltitude();
currView.setTilt(0); currView.setTilt(0);
currView.setHeading(0); currView.setHeading(0);
//currView.setLatitude(lastLat2);
//currView.setLongitude(lastLon2);
//currView.setAltitude(lastAlt2);
} }
viewMode = mode; viewMode = mode;
...@@ -628,5 +678,8 @@ function failureCallback(object) ...@@ -628,5 +678,8 @@ function failureCallback(object)
<input type="hidden" id="JScript_newWaypointLongitude" value="0" /> <input type="hidden" id="JScript_newWaypointLongitude" value="0" />
<input type="hidden" id="JScript_newWaypointAltitude" value="0" /> <input type="hidden" id="JScript_newWaypointAltitude" value="0" />
<input type="hidden" id="JScript_newWaypointPending" value="false" /> <input type="hidden" id="JScript_newWaypointPending" value="false" />
<input type="hidden" id="JScript_currentCameraLatitude" value="0" />
<input type="hidden" id="JScript_currentCameraLongitude" value="0" />
<input type="hidden" id="JScript_currentCameraGroundAltitude" value="0" />
</body> </body>
</html> </html>
...@@ -1042,6 +1042,20 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -1042,6 +1042,20 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
} }
} }
void UAS::setHomePosition(double lat, double lon, double alt)
{
// Send new home position to UAS
mavlink_gps_set_global_origin_t home;
home.target_system = uasId;
home.target_component = 0; // ALL components
home.latitude = lat*1E7;
home.longitude = lon*1E7;
home.altitude = alt*1000;
mavlink_message_t msg;
mavlink_msg_gps_set_global_origin_encode(mavlink->getSystemId(), mavlink->getComponentId(), &msg, &home);
sendMessage(msg);
}
void UAS::setLocalOriginAtCurrentGPSPosition() void UAS::setLocalOriginAtCurrentGPSPosition()
{ {
...@@ -1061,7 +1075,7 @@ void UAS::setLocalOriginAtCurrentGPSPosition() ...@@ -1061,7 +1075,7 @@ void UAS::setLocalOriginAtCurrentGPSPosition()
if (ret == QMessageBox::Yes) if (ret == QMessageBox::Yes)
{ {
mavlink_message_t msg; mavlink_message_t msg;
mavlink_msg_action_pack(mavlink->getSystemId(), mavlink->getSystemId(), &msg, this->getUASID(), 0, MAV_ACTION_SET_ORIGIN); mavlink_msg_action_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), 0, MAV_ACTION_SET_ORIGIN);
// Send message twice to increase chance that it reaches its goal // Send message twice to increase chance that it reaches its goal
sendMessage(msg); sendMessage(msg);
// Wait 5 ms // Wait 5 ms
......
...@@ -309,6 +309,8 @@ public slots: ...@@ -309,6 +309,8 @@ public slots:
/** @brief Set world frame origin at current GPS position */ /** @brief Set world frame origin at current GPS position */
void setLocalOriginAtCurrentGPSPosition(); void setLocalOriginAtCurrentGPSPosition();
/** @brief Set world frame origin / home position at this GPS position */
void setHomePosition(double lat, double lon, double alt);
/** @brief Set local position setpoint */ /** @brief Set local position setpoint */
void setLocalPositionSetpoint(float x, float y, float z, float yaw); void setLocalPositionSetpoint(float x, float y, float z, float yaw);
/** @brief Add an offset in body frame to the setpoint */ /** @brief Add an offset in body frame to the setpoint */
......
...@@ -224,6 +224,8 @@ public slots: ...@@ -224,6 +224,8 @@ public slots:
//virtual void clearWaypointList() = 0; //virtual void clearWaypointList() = 0;
/** @brief Set world frame origin at current GPS position */ /** @brief Set world frame origin at current GPS position */
virtual void setLocalOriginAtCurrentGPSPosition() = 0; virtual void setLocalOriginAtCurrentGPSPosition() = 0;
/** @brief Set world frame origin / home position at this GPS position */
virtual void setHomePosition(double lat, double lon, double alt) = 0;
/** @brief Request all onboard parameters of all components */ /** @brief Request all onboard parameters of all components */
virtual void requestParameters() = 0; virtual void requestParameters() = 0;
/** @brief Request one specific onboard parameter */ /** @brief Request one specific onboard parameter */
......
...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QTimer>
#include <QSettings>
#include "UAS.h" #include "UAS.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "UASManager.h" #include "UASManager.h"
...@@ -50,19 +51,64 @@ UASManager* UASManager::instance() ...@@ -50,19 +51,64 @@ UASManager* UASManager::instance()
return _instance; return _instance;
} }
void UASManager::storeSettings()
{
QSettings settings;
settings.beginGroup("QGC_UASMANAGER");
settings.setValue("HOMELAT", homeLat);
settings.setValue("HOMELON", homeLon);
settings.setValue("HOMEALT", homeAlt);
settings.endGroup();
settings.sync();
}
void UASManager::loadSettings()
{
QSettings settings;
settings.sync();
settings.beginGroup("QGC_UASMANAGER");
setHomePosition(settings.value("HOMELAT", homeLat).toDouble(),
settings.value("HOMELON", homeLon).toDouble(),
settings.value("HOMEALT", homeAlt).toDouble());
settings.endGroup();
}
void UASManager::setHomePosition(double lat, double lon, double alt)
{
// Checking for NaN and infitiny
if (lat == lat && lon == lon && alt == alt && !std::isinf(lat) && !std::isinf(lon) && !std::isinf(alt))
{
bool changed = false;
if (homeLat != lat) changed = true;
if (homeLon != lon) changed = true;
if (homeAlt != alt) changed = true;
homeLat = lat;
homeLon = lon;
homeAlt = alt;
if (changed) emit homePositionChanged(homeLat, homeLon, homeAlt);
}
}
/** /**
* @brief Private singleton constructor * @brief Private singleton constructor
* *
* This class implements the singleton design pattern and has therefore only a private constructor. * This class implements the singleton design pattern and has therefore only a private constructor.
**/ **/
UASManager::UASManager() : UASManager::UASManager() :
activeUAS(NULL) activeUAS(NULL),
homeLat(47.3769),
homeLon(8.549444),
homeAlt(470.0)
{ {
start(QThread::LowPriority); start(QThread::LowPriority);
loadSettings();
} }
UASManager::~UASManager() UASManager::~UASManager()
{ {
storeSettings();
// Delete all systems // Delete all systems
foreach (UASInterface* mav, systems) foreach (UASInterface* mav, systems)
{ {
...@@ -99,6 +145,7 @@ void UASManager::addUAS(UASInterface* uas) ...@@ -99,6 +145,7 @@ void UASManager::addUAS(UASInterface* uas)
{ {
systems.append(uas); systems.append(uas);
connect(uas, SIGNAL(destroyed(QObject*)), this, SLOT(removeUAS(QObject*))); connect(uas, SIGNAL(destroyed(QObject*)), this, SLOT(removeUAS(QObject*)));
connect(this, SIGNAL(homePositionChanged(double,double,double)), uas, SLOT(setHomePosition(double,double,double)));
emit UASCreated(uas); emit UASCreated(uas);
} }
......
...@@ -70,6 +70,12 @@ public: ...@@ -70,6 +70,12 @@ public:
UASInterface* getUASForId(int id); UASInterface* getUASForId(int id);
QList<UASInterface*> getUASList(); QList<UASInterface*> getUASList();
/** @brief Get home position latitude */
double getHomeLatitude() const { return homeLat; }
/** @brief Get home position longitude */
double getHomeLongitude() const { return homeLon; }
/** @brief Get home position altitude */
double getHomeAltitude() const { return homeAlt; }
public slots: public slots:
...@@ -162,12 +168,23 @@ public slots: ...@@ -162,12 +168,23 @@ public slots:
/** @brief Shut down the onboard operating system down */ /** @brief Shut down the onboard operating system down */
bool shutdownActiveUAS(); bool shutdownActiveUAS();
/** @brief Set the current home position */
void setHomePosition(double lat, double lon, double alt);
/** @brief Load settings */
void loadSettings();
/** @brief Store settings */
void storeSettings();
protected: protected:
UASManager(); UASManager();
QList<UASInterface*> systems; QList<UASInterface*> systems;
UASInterface* activeUAS; UASInterface* activeUAS;
QMutex activeUASMutex; QMutex activeUASMutex;
double homeLat;
double homeLon;
double homeAlt;
signals: signals:
void UASCreated(UASInterface* UAS); void UASCreated(UASInterface* UAS);
...@@ -181,6 +198,8 @@ signals: ...@@ -181,6 +198,8 @@ signals:
void activeUASStatusChanged(UASInterface* UAS, bool active); void activeUASStatusChanged(UASInterface* UAS, bool active);
/** @brief The UAS currently under main operator control changed */ /** @brief The UAS currently under main operator control changed */
void activeUASStatusChanged(int systemId, bool active); void activeUASStatusChanged(int systemId, bool active);
/** @brief Current home position changed */
void homePositionChanged(double lat, double lon, double alt);
}; };
......
...@@ -939,6 +939,7 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -939,6 +939,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
storeSettings(); storeSettings();
aboutToCloseFlag = true; aboutToCloseFlag = true;
mavlink->storeSettings(); mavlink->storeSettings();
UASManager::instance()->storeSettings();
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <QDir> #include <QDir>
#include <QShowEvent> #include <QShowEvent>
#include <QSettings> #include <QSettings>
#include <QInputDialog>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
...@@ -88,6 +89,8 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : ...@@ -88,6 +89,8 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
connect(ui->clearTrailsButton, SIGNAL(clicked()), this, SLOT(clearTrails())); connect(ui->clearTrailsButton, SIGNAL(clicked()), this, SLOT(clearTrails()));
connect(ui->atmosphereCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableAtmosphere(bool))); connect(ui->atmosphereCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableAtmosphere(bool)));
connect(ui->daylightCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableDaylight(bool))); connect(ui->daylightCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableDaylight(bool)));
connect(UASManager::instance(), SIGNAL(homePositionChanged(double,double,double)), this, SLOT(setHome(double,double,double)));
} }
QGCGoogleEarthView::~QGCGoogleEarthView() QGCGoogleEarthView::~QGCGoogleEarthView()
...@@ -355,9 +358,43 @@ void QGCGoogleEarthView::goHome() ...@@ -355,9 +358,43 @@ void QGCGoogleEarthView::goHome()
void QGCGoogleEarthView::setHome(double lat, double lon, double alt) void QGCGoogleEarthView::setHome(double lat, double lon, double alt)
{ {
qDebug() << "SETTING GCS HOME IN GOOGLE MAPS" << lat << lon << alt;
javaScript(QString("setGCSHome(%1,%2,%3);").arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15)); javaScript(QString("setGCSHome(%1,%2,%3);").arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
} }
void QGCGoogleEarthView::setHome()
{
javaScript(QString("enableSetHomeMode();"));
}
void QGCGoogleEarthView::moveToPosition()
{
bool ok;
javaScript("sampleCurrentPosition();");
double latitude = documentElement("currentCameraLatitude").toDouble();
double longitude = documentElement("currentCameraLongitude").toDouble();
QString text = QInputDialog::getText(this, tr("Please enter coordinates"),
tr("Coordinates (Lat,Lon):"), QLineEdit::Normal,
QString("%1,%2").arg(latitude).arg(longitude), &ok);
if (ok && !text.isEmpty())
{
QStringList split = text.split(",");
if (split.length() == 2)
{
bool convert;
double latitude = split.first().toDouble(&convert);
ok &= convert;
double longitude = split.last().toDouble(&convert);
ok &= convert;
if (ok)
{
javaScript(QString("setLookAtLatLon(%1,%2);").arg(latitude, 0, 'f', 15).arg(longitude, 0, 'f', 15));
}
}
}
}
void QGCGoogleEarthView::hideEvent(QHideEvent* event) void QGCGoogleEarthView::hideEvent(QHideEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
...@@ -441,80 +478,47 @@ QVariant QGCGoogleEarthView::documentElement(QString name) ...@@ -441,80 +478,47 @@ QVariant QGCGoogleEarthView::documentElement(QString name)
if(!jScriptInitialized) if(!jScriptInitialized)
{ {
qDebug() << "TOO EARLY JAVASCRIPT CALL, ABORTING"; qDebug() << "TOO EARLY JAVASCRIPT CALL, ABORTING";
return QVariant(false);
} }
else else
{ {
// QVariantList params; if (documentWin)
// QString javaScript("getGlobal(%1)"); {
// params.append(javaScript.arg(name)); QString resultString;
// params.append("JScript");
// QVariant result = jScriptWin->dynamicCall("execScript(QString, QString)", params); // Get HTMLElement object
// qDebug() << "JScript result: " << result << result.toDouble(); QVariantList params;
if (documentWin) IHTMLDocument3* doc;
{ documentWin->queryInterface( IID_IHTMLDocument3, (void**)&doc);
QString resultString; params.append(name);
IHTMLElement* element = NULL;
// Get HTMLElement object // Append alias
QVariantList params; name.prepend("JScript_");
IHTMLDocument3* doc; HRESULT res = doc->getElementById(QStringToBSTR(name), &element);
documentWin->queryInterface( IID_IHTMLDocument3, (void**)&doc); //BSTR elemString;
params.append(name); if (element)
IHTMLElement* element = NULL; {
// Append alias //element->get_innerHTML(&elemString);
name.prepend("JScript_"); VARIANT var;
HRESULT res = doc->getElementById(QStringToBSTR(name), &element); var.vt = VT_BSTR;
//BSTR elemString; HRESULT res = element->getAttribute(L"value", 0, &var);
if (element) if (SUCCEEDED(res) && (var.vt != VT_NULL))
{ {
//element->get_innerHTML(&elemString); QByteArray typeName;
VARIANT var; QVariant qtValue = VARIANTToQVariant(var,typeName);
var.vt = VT_BSTR; return qtValue;
HRESULT res = element->getAttribute(L"value", 0, &var); }
if (SUCCEEDED(res) && (var.vt != VT_NULL)) else
{ {
//VariantChangeType(&var, &var, 0, VT_BSTR); qDebug() << __FILE__ << __LINE__ << "JAVASCRIPT ATTRIBUTE" << name << "NOT FOUND";
//qDebug() << "GOT ATTRIBUTE"; }
//_bstr_t bstrHello(var.bstrVal); // passing true means }
// you should not call else
// SysFreeString {
qDebug() << __FILE__ << __LINE__ << "DID NOT GET HTML ELEMENT" << name;
//qDebug() << "BSTR:" << LPCSTR(bstrHello); }
} }
else
{
qDebug() << "JAVASCRIPT ATTRIBUTE" << name << "NOT FOUND";
}
QByteArray typeName;
QVariant qtValue = VARIANTToQVariant(var,typeName);
return qtValue;
//element->toString(&elemString);
//_bstr_t bstrHello(elemString, true); // passing true means
// you should not call
// SysFreeString
//qDebug() << "BSTR:" << LPCSTR(bstrHello);
//QAxObject* elementWin = new QAxObject(element, documentWin);
//if (elementWin)
//{
// QVariant result = elementWin->dynamicCall("toString()");
// qDebug() << "GOT RESULT" << result << result.toString();
//}
//else
//{
// qDebug() << "CREATING HTML ELEMENT FAILED";
//}
}
else
{
qDebug() << "DID NOT GET HTML ELEMENT";
}
return QVariant(0);//QVariant(result);
}
} }
return QVariant(0);
#endif #endif
} }
...@@ -529,22 +533,18 @@ void QGCGoogleEarthView::initializeGoogleEarth() ...@@ -529,22 +533,18 @@ void QGCGoogleEarthView::initializeGoogleEarth()
QAxObject* doc = webViewWin->querySubObject("Document()"); QAxObject* doc = webViewWin->querySubObject("Document()");
//IDispatch* Disp; //IDispatch* Disp;
IDispatch* winDoc = NULL; IDispatch* winDoc = NULL;
IHTMLDocument2* document = NULL; IHTMLDocument2* document = NULL;
//332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2 //332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2
//25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument //25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument
doc->queryInterface(QUuid("{332C4425-26CB-11D0-B483-00C04FD90119}"), (void**)(&winDoc)); doc->queryInterface(QUuid("{332C4425-26CB-11D0-B483-00C04FD90119}"), (void**)(&winDoc));
if (winDoc) if (winDoc)
{ {
// Security:
// CoInternetSetFeatureEnabled
// (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE);
//
document = NULL; document = NULL;
winDoc->QueryInterface( IID_IHTMLDocument2, (void**)&document ); winDoc->QueryInterface( IID_IHTMLDocument2, (void**)&document );
IHTMLWindow2 *window = NULL; IHTMLWindow2 *window = NULL;
document->get_parentWindow( &window ); document->get_parentWindow( &window );
documentWin = new QAxObject(document, webViewWin); documentWin = new QAxObject(document, webViewWin);
jScriptWin = new QAxObject(window, webViewWin); jScriptWin = new QAxObject(window, webViewWin);
connect(jScriptWin, SIGNAL(exception(int,QString,QString,QString)), this, SLOT(printWinException(int,QString,QString,QString))); connect(jScriptWin, SIGNAL(exception(int,QString,QString,QString)), this, SLOT(printWinException(int,QString,QString,QString)));
jScriptInitialized = true; jScriptInitialized = true;
...@@ -570,10 +570,7 @@ void QGCGoogleEarthView::initializeGoogleEarth() ...@@ -570,10 +570,7 @@ void QGCGoogleEarthView::initializeGoogleEarth()
gEarthInitialized = true; gEarthInitialized = true;
// Set home location // Set home location
setHome(47.3769, 8.549444, 500); setHome(UASManager::instance()->getHomeLatitude(), UASManager::instance()->getHomeLongitude(), UASManager::instance()->getHomeAltitude());
// Move to home location
goHome();
// Add all MAVs // Add all MAVs
QList<UASInterface*> mavs = UASManager::instance()->getUASList(); QList<UASInterface*> mavs = UASManager::instance()->getUASList();
...@@ -601,6 +598,15 @@ void QGCGoogleEarthView::initializeGoogleEarth() ...@@ -601,6 +598,15 @@ void QGCGoogleEarthView::initializeGoogleEarth()
// Go home // Go home
connect(ui->goHomeButton, SIGNAL(clicked()), this, SLOT(goHome())); connect(ui->goHomeButton, SIGNAL(clicked()), this, SLOT(goHome()));
// Set home
connect(ui->setHomeButton, SIGNAL(clicked()), this, SLOT(setHome()));
// Visibility of set home button
connect(ui->editButton, SIGNAL(clicked(bool)), ui->setHomeButton, SLOT(setVisible(bool)));
ui->setHomeButton->setVisible(ui->editButton->isChecked());
// To Lat/Lon button
connect(ui->toLatLonButton, SIGNAL(clicked()), this, SLOT(moveToPosition()));
// Cam distance slider // Cam distance slider
connect(ui->camDistanceSlider, SIGNAL(valueChanged(int)), this, SLOT(setViewRangeScaledInt(int)), Qt::UniqueConnection); connect(ui->camDistanceSlider, SIGNAL(valueChanged(int)), this, SLOT(setViewRangeScaledInt(int)), Qt::UniqueConnection);
...@@ -624,6 +630,9 @@ void QGCGoogleEarthView::initializeGoogleEarth() ...@@ -624,6 +630,9 @@ void QGCGoogleEarthView::initializeGoogleEarth()
enableAtmosphere(ui->atmosphereCheckBox->isChecked()); enableAtmosphere(ui->atmosphereCheckBox->isChecked());
enableDaylight(ui->daylightCheckBox->isChecked()); enableDaylight(ui->daylightCheckBox->isChecked());
follow(this->followCamera); follow(this->followCamera);
// Move to home location
goHome();
} }
} }
} }
...@@ -723,7 +732,9 @@ void QGCGoogleEarthView::updateState() ...@@ -723,7 +732,9 @@ void QGCGoogleEarthView::updateState()
QString idText = documentElement("dragWaypointIndex").toString(); QString idText = documentElement("dragWaypointIndex").toString();
if (idText == "HOME") if (idText == "HOME")
{ {
setHome(latitude, longitude, altitude); qDebug() << "HOME UPDATED!";
UASManager::instance()->setHomePosition(latitude, longitude, altitude);
ui->setHomeButton->setChecked(false);
} }
else else
{ {
......
...@@ -104,6 +104,10 @@ public slots: ...@@ -104,6 +104,10 @@ public slots:
void goHome(); void goHome();
/** @brief Set the home location */ /** @brief Set the home location */
void setHome(double lat, double lon, double alt); void setHome(double lat, double lon, double alt);
/** @brief Set the home location interactively in the UI */
void setHome();
/** @brief Move the view to a latitude / longitude position */
void moveToPosition();
/** @brief Allow waypoint editing */ /** @brief Allow waypoint editing */
void enableEditMode(bool mode); void enableEditMode(bool mode);
/** @brief Enable daylight/night */ /** @brief Enable daylight/night */
......
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1089</width> <width>1409</width>
<height>302</height> <height>302</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,10,10,10,10,5,1,100,10,10,10,10,10,5,2,2"> <layout class="QGridLayout" name="gridLayout" columnstretch="1,10,10,10,10,5,10,1000,10,10,10,10,10,5,2,2,0,0">
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>8</number> <number>4</number>
</property> </property>
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>2</number> <number>2</number>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<property name="margin"> <property name="margin">
<number>2</number> <number>2</number>
</property> </property>
<item row="0" column="0" colspan="16"> <item row="0" column="0" colspan="18">
<layout class="QVBoxLayout" name="webViewLayout"/> <layout class="QVBoxLayout" name="webViewLayout"/>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
...@@ -38,11 +38,37 @@ ...@@ -38,11 +38,37 @@
<string>Go to home location</string> <string>Go to home location</string>
</property> </property>
<property name="text"> <property name="text">
<string>Home</string> <string>To Home</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QPushButton" name="setHomeButton">
<property name="text">
<string>Set Home</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="editButton">
<property name="toolTip">
<string>Enable waypoint and home location edit mode</string>
</property>
<property name="statusTip">
<string>Enable waypoint and home location edit mode</string>
</property>
<property name="text">
<string>Edit</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="trailCheckbox"> <widget class="QCheckBox" name="trailCheckbox">
<property name="toolTip"> <property name="toolTip">
<string>Show MAV trajectories</string> <string>Show MAV trajectories</string>
...@@ -58,21 +84,35 @@ ...@@ -58,21 +84,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="13"> <item row="1" column="5">
<spacer name="horizontalSpacer"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType"> </widget>
<enum>QSizePolicy::Expanding</enum> </item>
<item row="1" column="6">
<widget class="QComboBox" name="camDistanceComboBox">
<property name="toolTip">
<string>Select the MAV to chase</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="statusTip">
<size> <string>Select the MAV to chase</string>
<width>5</width>
<height>20</height>
</size>
</property> </property>
</spacer> <property name="whatsThis">
<string>Select the MAV to chase</string>
</property>
<item>
<property name="text">
<string>MAV Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Ground Distance</string>
</property>
</item>
</widget>
</item> </item>
<item row="1" column="7"> <item row="1" column="7">
<widget class="QSlider" name="camDistanceSlider"> <widget class="QSlider" name="camDistanceSlider">
...@@ -115,50 +155,20 @@ ...@@ -115,50 +155,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="5"> <item row="1" column="9">
<widget class="QComboBox" name="camDistanceComboBox"> <widget class="QPushButton" name="changeViewButton">
<property name="toolTip"> <property name="text">
<string>Select the MAV to chase</string> <string>Overhead</string>
</property>
<property name="statusTip">
<string>Select the MAV to chase</string>
</property>
<property name="whatsThis">
<string>Select the MAV to chase</string>
</property> </property>
<item>
<property name="text">
<string>MAV Distance</string>
</property>
</item>
<item>
<property name="text">
<string>Ground Distance</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="10">
<widget class="Line" name="line"> <widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="12">
<widget class="QPushButton" name="resetButton">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="9">
<widget class="QPushButton" name="changeViewButton">
<property name="text">
<string>Overhead</string>
</property>
</widget>
</item>
<item row="1" column="11"> <item row="1" column="11">
<widget class="QPushButton" name="clearTrailsButton"> <widget class="QPushButton" name="clearTrailsButton">
<property name="toolTip"> <property name="toolTip">
...@@ -175,28 +185,28 @@ ...@@ -175,28 +185,28 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="10"> <item row="1" column="12">
<widget class="Line" name="line_2"> <widget class="QPushButton" name="resetButton">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Reset</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="13">
<widget class="QPushButton" name="editButton"> <spacer name="horizontalSpacer">
<property name="toolTip"> <property name="orientation">
<string>Enable waypoint and home location edit mode</string> <enum>Qt::Horizontal</enum>
</property>
<property name="statusTip">
<string>Enable waypoint and home location edit mode</string>
</property> </property>
<property name="text"> <property name="sizeType">
<string>Edit</string> <enum>QSizePolicy::MinimumExpanding</enum>
</property> </property>
<property name="checkable"> <property name="sizeHint" stdset="0">
<bool>true</bool> <size>
<width>10</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item row="1" column="14"> <item row="1" column="14">
<widget class="QCheckBox" name="atmosphereCheckBox"> <widget class="QCheckBox" name="atmosphereCheckBox">
...@@ -224,6 +234,13 @@ ...@@ -224,6 +234,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QPushButton" name="toLatLonButton">
<property name="text">
<string>To Lat/Lon</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment