From 676e0d02c0132e843424372d980037dc4ae4b498 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Fri, 10 Feb 2012 18:30:43 +0100 Subject: [PATCH] Mission plan: support for pixhawk MAV_CMD_NAV_SWEEP --- qgroundcontrol.pro | 9 +- src/ui/WaypointEditableView.cc | 23 +- src/ui/WaypointEditableView.h | 2 + src/ui/mission/QGCMissionNavSweep.cc | 80 +++++ src/ui/mission/QGCMissionNavSweep.h | 29 ++ src/ui/mission/QGCMissionNavSweep.ui | 470 +++++++++++++++++++++++++++ 6 files changed, 608 insertions(+), 5 deletions(-) create mode 100644 src/ui/mission/QGCMissionNavSweep.cc create mode 100644 src/ui/mission/QGCMissionNavSweep.h create mode 100644 src/ui/mission/QGCMissionNavSweep.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 92c56b841..afac96bb0 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -246,7 +246,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/mission/QGCMissionNavLoiterTime.ui \ src/ui/mission/QGCMissionNavReturnToLaunch.ui \ src/ui/mission/QGCMissionNavLand.ui \ - src/ui/mission/QGCMissionNavTakeoff.ui + src/ui/mission/QGCMissionNavTakeoff.ui \ + src/ui/mission/QGCMissionNavSweep.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -377,7 +378,8 @@ HEADERS += src/MG.h \ src/ui/mission/QGCMissionNavLoiterTime.h \ src/ui/mission/QGCMissionNavReturnToLaunch.h \ src/ui/mission/QGCMissionNavLand.h \ - src/ui/mission/QGCMissionNavTakeoff.h + src/ui/mission/QGCMissionNavTakeoff.h \ + src/ui/mission/QGCMissionNavSweep.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -517,7 +519,8 @@ SOURCES += src/main.cc \ src/ui/mission/QGCMissionNavLoiterTime.cc \ src/ui/mission/QGCMissionNavReturnToLaunch.cc \ src/ui/mission/QGCMissionNavLand.cc \ - src/ui/mission/QGCMissionNavTakeoff.cc + src/ui/mission/QGCMissionNavTakeoff.cc \ + src/ui/mission/QGCMissionNavSweep.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/ui/WaypointEditableView.cc b/src/ui/WaypointEditableView.cc index 24499c12d..49dfbe245 100644 --- a/src/ui/WaypointEditableView.cc +++ b/src/ui/WaypointEditableView.cc @@ -28,6 +28,7 @@ #include "QGCMissionNavReturnToLaunch.h" #include "QGCMissionNavLand.h" #include "QGCMissionNavTakeoff.h" +#include "QGCMissionNavSweep.h" #include "QGCMissionConditionDelay.h" #include "QGCMissionDoJump.h" #include "QGCMissionOther.h" @@ -56,6 +57,7 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) : MissionNavReturnToLaunchWidget = NULL; MissionNavLandWidget = NULL; MissionNavTakeoffWidget = NULL; + MissionNavSweepWidget = NULL; MissionDoJumpWidget = NULL; MissionConditionDelayWidget = NULL; MissionOtherWidget = NULL; @@ -72,7 +74,10 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) : //m_ui->comboBox_action->addItem(tr("NAV: Target"),MAV_CMD_NAV_TARGET); m_ui->comboBox_action->addItem(tr("IF: Delay over"),MAV_CMD_CONDITION_DELAY); //m_ui->comboBox_action->addItem(tr("IF: Yaw angle is"),MAV_CMD_CONDITION_YAW); - m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP); + m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP); +#ifdef MAVLINK_ENABLED_PIXHAWK + m_ui->comboBox_action->addItem(tr("NAV: Sweep"),MAV_CMD_NAV_SWEEP); +#endif m_ui->comboBox_action->addItem(tr("Other"), MAV_CMD_ENUM_END); // add frames @@ -174,6 +179,12 @@ void WaypointEditableView::updateActionView(int action) case MAV_CMD_DO_JUMP: if(MissionDoJumpWidget) MissionDoJumpWidget->show(); break; + #ifdef MAVLINK_ENABLED_PIXHAWK + case MAV_CMD_NAV_SWEEP: + if(MissionNavSweepWidget) MissionNavSweepWidget->show(); + break; + #endif + default: if(MissionOtherWidget) MissionOtherWidget->show(); viewMode = QGC_WAYPOINTEDITABLEVIEW_MODE_DIRECT_EDITING; @@ -276,7 +287,15 @@ void WaypointEditableView::initializeActionView(int actionID) m_ui->customActionWidget->layout()->addWidget(MissionDoJumpWidget); } break; - + #ifdef MAVLINK_ENABLED_PIXHAWK + case MAV_CMD_NAV_SWEEP: + if (!MissionNavSweepWidget) + { + MissionNavSweepWidget = new QGCMissionNavSweep(this); + m_ui->customActionWidget->layout()->addWidget(MissionNavSweepWidget); + } + break; +#endif case MAV_CMD_ENUM_END: default: if (!MissionOtherWidget) diff --git a/src/ui/WaypointEditableView.h b/src/ui/WaypointEditableView.h index 05753c571..3df07554d 100644 --- a/src/ui/WaypointEditableView.h +++ b/src/ui/WaypointEditableView.h @@ -53,6 +53,7 @@ class QGCMissionNavLoiterTime; class QGCMissionNavReturnToLaunch; class QGCMissionNavLand; class QGCMissionNavTakeoff; +class QGCMissionNavSweep; class QGCMissionDoJump; class QGCMissionConditionDelay; class QGCMissionOther; @@ -105,6 +106,7 @@ protected: QGCMissionNavReturnToLaunch* MissionNavReturnToLaunchWidget; QGCMissionNavLand* MissionNavLandWidget; QGCMissionNavTakeoff* MissionNavTakeoffWidget; + QGCMissionNavSweep* MissionNavSweepWidget; QGCMissionDoJump* MissionDoJumpWidget; QGCMissionConditionDelay* MissionConditionDelayWidget; QGCMissionOther* MissionOtherWidget; diff --git a/src/ui/mission/QGCMissionNavSweep.cc b/src/ui/mission/QGCMissionNavSweep.cc new file mode 100644 index 000000000..3d68f6069 --- /dev/null +++ b/src/ui/mission/QGCMissionNavSweep.cc @@ -0,0 +1,80 @@ +#include "QGCMissionNavSweep.h" +#include "ui_QGCMissionNavSweep.h" +#include "WaypointEditableView.h" + +QGCMissionNavSweep::QGCMissionNavSweep(WaypointEditableView* WEV) : + QWidget(WEV), + ui(new Ui::QGCMissionNavSweep) +{ + ui->setupUi(this); + this->WEV = WEV; + + //Using UI to change WP: + connect(this->ui->radSpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam1(double))); + //connect(this->ui->acceptanceSpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam2(double))); + connect(this->ui->posN1SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam3(double)));//NED + connect(this->ui->posE1SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam4(double))); + connect(this->ui->posN2SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam5(double))); + connect(this->ui->posE2SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam6(double))); + connect(this->ui->posDSpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam7(double))); + connect(this->ui->lat1SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam3(double)));//Global + connect(this->ui->lon1SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam4(double))); + connect(this->ui->lat2SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam5(double))); + connect(this->ui->lon2SpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam6(double))); + connect(this->ui->altSpinBox, SIGNAL(valueChanged(double)),WEV,SLOT(changedParam7(double))); + + //Reading WP to update UI: + connect(WEV,SIGNAL(frameBroadcast(MAV_FRAME)),this,SLOT(updateFrame(MAV_FRAME))); + connect(WEV,SIGNAL(param1Broadcast(double)),this->ui->radSpinBox,SLOT(setValue(double))); + //connect(WEV,SIGNAL(param2Broadcast(double)),this->ui->acceptanceSpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param3Broadcast(double)),this->ui->posN1SpinBox,SLOT(setValue(double)));//NED + connect(WEV,SIGNAL(param4Broadcast(double)),this->ui->posE1SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param5Broadcast(double)),this->ui->posN2SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param6Broadcast(double)),this->ui->posE2SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param7Broadcast(double)),this->ui->posDSpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param3Broadcast(double)),this->ui->lat1SpinBox,SLOT(setValue(double)));//Global + connect(WEV,SIGNAL(param4Broadcast(double)),this->ui->lon1SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param5Broadcast(double)),this->ui->lat2SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param6Broadcast(double)),this->ui->lon2SpinBox,SLOT(setValue(double))); + connect(WEV,SIGNAL(param7Broadcast(double)),this->ui->altSpinBox,SLOT(setValue(double))); +} + +void QGCMissionNavSweep::updateFrame(MAV_FRAME frame) +{ + switch(frame) + { + case MAV_FRAME_LOCAL_ENU: + case MAV_FRAME_LOCAL_NED: + this->ui->posN1SpinBox->show(); + this->ui->posE1SpinBox->show(); + this->ui->posN2SpinBox->show(); + this->ui->posE2SpinBox->show(); + this->ui->posDSpinBox->show(); + this->ui->lat1SpinBox->hide(); + this->ui->lon1SpinBox->hide(); + this->ui->lat2SpinBox->hide(); + this->ui->lon2SpinBox->hide(); + this->ui->altSpinBox->hide(); + break; + case MAV_FRAME_GLOBAL: + case MAV_FRAME_GLOBAL_RELATIVE_ALT: + this->ui->posN1SpinBox->hide(); + this->ui->posE1SpinBox->hide(); + this->ui->posN2SpinBox->hide(); + this->ui->posE2SpinBox->hide(); + this->ui->posDSpinBox->hide(); + this->ui->lat1SpinBox->show(); + this->ui->lon1SpinBox->show(); + this->ui->lat2SpinBox->show(); + this->ui->lon2SpinBox->show(); + this->ui->altSpinBox->show(); + break; + default: + break; + } +} + +QGCMissionNavSweep::~QGCMissionNavSweep() +{ + delete ui; +} diff --git a/src/ui/mission/QGCMissionNavSweep.h b/src/ui/mission/QGCMissionNavSweep.h new file mode 100644 index 000000000..dd578acd9 --- /dev/null +++ b/src/ui/mission/QGCMissionNavSweep.h @@ -0,0 +1,29 @@ +#ifndef QGCMISSIONNAVSWEEP_H +#define QGCMISSIONNAVSWEEP_H + +#include +#include "WaypointEditableView.h" + +namespace Ui { + class QGCMissionNavSweep; +} + +class QGCMissionNavSweep : public QWidget +{ + Q_OBJECT + +public: + explicit QGCMissionNavSweep(WaypointEditableView* WEV); + ~QGCMissionNavSweep(); + +public slots: + void updateFrame(MAV_FRAME); + +protected: + WaypointEditableView* WEV; + +private: + Ui::QGCMissionNavSweep *ui; +}; + +#endif // QGCMISSIONNAVSWEEP_H diff --git a/src/ui/mission/QGCMissionNavSweep.ui b/src/ui/mission/QGCMissionNavSweep.ui new file mode 100644 index 000000000..c186e7b27 --- /dev/null +++ b/src/ui/mission/QGCMissionNavSweep.ui @@ -0,0 +1,470 @@ + + + QGCMissionNavSweep + + + + 0 + 0 + 2208 + 37 + + + + + 0 + 0 + + + + + 0 + 0 + + + + Form + + + + + + + 5 + + + 0 + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + X coordinate of the first sweep area corner + + + X coordinate of the first sweep area corner + + + false + + + true + + + true + + + false + + + (1)N + + + m + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.050000000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Y coordinate of the first sweep area corner + + + Y coordinate of the first sweep area corner + + + false + + + (1)E + + + m + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + X coordinate of the second sweep area corner + + + X coordinate of the second sweep area corner + + + false + + + true + + + true + + + false + + + (2)N + + + m + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.050000000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Y coordinate of the second sweep area corner + + + Y coordinate of the second sweep area corner + + + false + + + (2)E + + + m + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Z coordinate (local frame, negative) + + + + + + false + + + D + + + m + + + -10000.000000000000000 + + + 10000.000000000000000 + + + 0.050000000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Latitude of the first sweep area corner + + + Latitude of the first sweep area corner + + + false + + + (1)lat + + + ° + + + 7 + + + -90.000000000000000 + + + 90.000000000000000 + + + 0.000010000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Longitude of the first sweep area corner + + + Longitude of the first sweep area corner + + + false + + + (1)lon + + + ° + + + 7 + + + -180.000000000000000 + + + 180.000000000000000 + + + 0.000010000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Latitude of the second sweep area corner + + + Latitude of the second sweep area corner + + + false + + + (2)lat + + + ° + + + 7 + + + -90.000000000000000 + + + 90.000000000000000 + + + 0.000010000000000 + + + + + + + + 0 + 0 + + + + Qt::WheelFocus + + + Longitude of the second sweep area corner + + + Longitude of the second sweep area corner + + + false + + + (2)lon + + + ° + + + 7 + + + -180.000000000000000 + + + 180.000000000000000 + + + 0.000010000000000 + + + + + + + + 0 + 0 + + + + Altitude + + + Altitude + + + false + + + alt + + + m + + + 2 + + + -100000.000000000000000 + + + 100000.000000000000000 + + + + + + + + 0 + 0 + + + + Radius of the circle under the MAV covered by the camera + + + Radius of the circle under the MAV covered by the camera + + + false + + + m + + + 0.200000000000000 + + + + + + + + -- 2.22.0