From b232d1e1e3e892b9c8d060a08aa729e6494d5e76 Mon Sep 17 00:00:00 2001 From: lm Date: Tue, 7 Dec 2010 15:24:12 +0100 Subject: [PATCH] Cleanup, moved output files, added set home button --- qgroundcontrol.pri | 14 ++++++------- src/uas/UAS.cc | 37 ++++++++++++++++++++++++++++++++++ src/uas/UAS.h | 2 ++ src/uas/UASInterface.h | 2 ++ src/ui/UASControl.ui | 2 +- src/ui/uas/UASControlWidget.cc | 2 ++ 6 files changed, 51 insertions(+), 8 deletions(-) diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 48f48d49d..4028055ad 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -65,7 +65,7 @@ macx { QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.5 - DESTDIR = $$BASEDIR/bin/mac + #DESTDIR = $$BASEDIR/bin/mac INCLUDEPATH += -framework SDL LIBS += -framework IOKit \ @@ -146,12 +146,12 @@ macx { linux-g++ { debug { - DESTDIR = $$BUILDDIR/debug + #DESTDIR = $$BUILDDIR/debug CONFIG += debug } release { - DESTDIR = $$BUILDDIR/release + #DESTDIR = $$BUILDDIR/release } QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/. @@ -214,12 +214,12 @@ linux-g++ { linux-g++-64 { debug { - DESTDIR = $$BUILDDIR/debug + #DESTDIR = $$BUILDDIR/debug CONFIG += debug } release { - DESTDIR = $$BUILDDIR/release + #DESTDIR = $$BUILDDIR/release } QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/. @@ -364,11 +364,11 @@ win32-g++ { debug { - DESTDIR = $$BUILDDIR/debug + #DESTDIR = $$BUILDDIR/debug } release { - DESTDIR = $$BUILDDIR/release + #DESTDIR = $$BUILDDIR/release } RC_FILE = $$BASEDIR/qgroundcontrol.rc diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 1cb2ccc53..baac28f2d 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -421,6 +421,13 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } } break; + case MAVLINK_MSG_ID_GPS_LOCAL_ORIGIN_SET: + { + mavlink_gps_local_origin_set_t pos; + mavlink_msg_gps_local_origin_set_decode(&message, &pos); + // FIXME Emit to other components + } + break; case MAVLINK_MSG_ID_RC_CHANNELS_RAW: { mavlink_rc_channels_raw_t channels; @@ -657,6 +664,36 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) } } +void UAS::setLocalOriginAtCurrentGPSPosition() +{ + + bool result = false; + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText("Setting new World Coordinate Frame Origin"); + msgBox.setInformativeText("Do you want to set a new origin? Waypoints defined in the local frame will be shifted in their physical location"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + int ret = msgBox.exec(); + + // Close the message box shortly after the click to prevent accidental clicks + QTimer::singleShot(5000, &msgBox, SLOT(reject())); + + + if (ret == QMessageBox::Yes) + { + mavlink_message_t msg; + mavlink_msg_action_pack(mavlink->getSystemId(), mavlink->getSystemId(), &msg, this->getUASID(), 0, MAV_ACTION_SET_ORIGIN); + // Send message twice to increase chance that it reaches its goal + sendMessage(msg); + // Wait 5 ms + MG::SLEEP::usleep(5000); + // Send again + sendMessage(msg); + result = true; + } +} + void UAS::setLocalPositionSetpoint(float x, float y, float z, float yaw) { #ifdef MAVLINK_ENABLED_PIXHAWK diff --git a/src/uas/UAS.h b/src/uas/UAS.h index c30c85b27..241e3db6f 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -243,6 +243,8 @@ public slots: /** @brief Update the system state */ void updateState(); + /** @brief Set world frame origin at current GPS position */ + void setLocalOriginAtCurrentGPSPosition(); /** @brief Set local position setpoint */ void setLocalPositionSetpoint(float x, float y, float z, float yaw); /** @brief Add an offset in body frame to the setpoint */ diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index 32825bc5b..9e8403440 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -194,6 +194,8 @@ public slots: //virtual void requestWaypoints() = 0; /** @brief Clear all existing waypoints on the robot */ //virtual void clearWaypointList() = 0; + /** @brief Set world frame origin at current GPS position */ + virtual void setLocalOriginAtCurrentGPSPosition() = 0; /** @brief Request all onboard parameters of all components */ virtual void requestParameters() = 0; /** @brief Write parameter to permanent storage */ diff --git a/src/ui/UASControl.ui b/src/ui/UASControl.ui index ef287b0cc..99f720ddc 100644 --- a/src/ui/UASControl.ui +++ b/src/ui/UASControl.ui @@ -219,7 +219,7 @@ - Set Home + Set Origin diff --git a/src/ui/uas/UASControlWidget.cc b/src/ui/uas/UASControlWidget.cc index ddb5774e2..d638e1cc3 100644 --- a/src/ui/uas/UASControlWidget.cc +++ b/src/ui/uas/UASControlWidget.cc @@ -95,6 +95,7 @@ void UASControlWidget::setUAS(UASInterface* uas) disconnect(ui.liftoffButton, SIGNAL(clicked()), oldUAS, SLOT(launch())); disconnect(ui.landButton, SIGNAL(clicked()), oldUAS, SLOT(home())); disconnect(ui.shutdownButton, SIGNAL(clicked()), oldUAS, SLOT(shutdown())); + connect(ui.setHomeButton, SIGNAL(clicked()), uas, SLOT(setLocalOriginAtCurrentGPSPosition())); disconnect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); disconnect(uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int))); } @@ -104,6 +105,7 @@ void UASControlWidget::setUAS(UASInterface* uas) connect(ui.liftoffButton, SIGNAL(clicked()), uas, SLOT(launch())); connect(ui.landButton, SIGNAL(clicked()), uas, SLOT(home())); connect(ui.shutdownButton, SIGNAL(clicked()), uas, SLOT(shutdown())); + connect(ui.setHomeButton, SIGNAL(clicked()), uas, SLOT(setLocalOriginAtCurrentGPSPosition())); connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString))); connect(uas, SIGNAL(statusChanged(int)), this, SLOT(updateState(int))); -- 2.22.0