diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 7b645d1b799eccaea1e8c28660aec34092e66e9a..9d39bdfb413a9573bf6cf223b7d6d25aec146ab6 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -299,7 +299,6 @@ HEADERS += src/MG.h \ src/ui/uas/QGCUnconnectedInfoWidget.h \ src/ui/designer/QGCToolWidget.h \ src/ui/designer/QGCParamSlider.h \ - src/ui/designer/QGCActionButton.h \ src/ui/designer/QGCCommandButton.h \ src/ui/designer/QGCToolWidgetItem.h \ src/ui/QGCMAVLinkLogPlayer.h \ @@ -425,7 +424,6 @@ SOURCES += src/main.cc \ src/ui/uas/QGCUnconnectedInfoWidget.cc \ src/ui/designer/QGCToolWidget.cc \ src/ui/designer/QGCParamSlider.cc \ - src/ui/designer/QGCActionButton.cc \ src/ui/designer/QGCCommandButton.cc \ src/ui/designer/QGCToolWidgetItem.cc \ src/ui/QGCMAVLinkLogPlayer.cc \ diff --git a/src/Waypoint.cc b/src/Waypoint.cc index 2fd5a7099fd5c1ff1c793d72c90c712fbdeba3e6..bfcde0c4c194806facc8fc51af292dd21f98dbf6 100644 --- a/src/Waypoint.cc +++ b/src/Waypoint.cc @@ -109,7 +109,8 @@ void Waypoint::setId(quint16 id) void Waypoint::setX(double x) { - if (this->x != x && (this->frame == MAV_FRAME_LOCAL)) { + if (!isinf(x) && !isnan(x) && ((this->frame == MAV_FRAME_LOCAL_NED) || (this->frame == MAV_FRAME_LOCAL_ENU))) + { this->x = x; emit changed(this); } @@ -117,7 +118,8 @@ void Waypoint::setX(double x) void Waypoint::setY(double y) { - if (this->y != y && (this->frame == MAV_FRAME_LOCAL)) { + if (!isinf(y) && !isnan(y) && ((this->frame == MAV_FRAME_LOCAL_NED) || (this->frame == MAV_FRAME_LOCAL_ENU))) + { this->y = y; emit changed(this); } @@ -125,7 +127,8 @@ void Waypoint::setY(double y) void Waypoint::setZ(double z) { - if (this->z != z && (this->frame == MAV_FRAME_LOCAL)) { + if (!isinf(z) && !isnan(z) && ((this->frame == MAV_FRAME_LOCAL_NED) || (this->frame == MAV_FRAME_LOCAL_ENU))) + { this->z = z; emit changed(this); } @@ -133,7 +136,8 @@ void Waypoint::setZ(double z) void Waypoint::setLatitude(double lat) { - if (this->x != lat && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) { + if (this->x != lat && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) + { this->x = lat; emit changed(this); } @@ -141,7 +145,8 @@ void Waypoint::setLatitude(double lat) void Waypoint::setLongitude(double lon) { - if (this->y != lon && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) { + if (this->y != lon && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) + { this->y = lon; emit changed(this); } @@ -149,7 +154,8 @@ void Waypoint::setLongitude(double lon) void Waypoint::setAltitude(double altitude) { - if (this->z != altitude && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) { + if (this->z != altitude && ((this->frame == MAV_FRAME_GLOBAL) || (this->frame == MAV_FRAME_GLOBAL_RELATIVE_ALT))) + { this->z = altitude; emit changed(this); } @@ -157,7 +163,8 @@ void Waypoint::setAltitude(double altitude) void Waypoint::setYaw(int yaw) { - if (this->yaw != yaw) { + if (this->yaw != yaw) + { this->yaw = yaw; emit changed(this); } @@ -165,7 +172,8 @@ void Waypoint::setYaw(int yaw) void Waypoint::setYaw(double yaw) { - if (this->yaw != yaw) { + if (this->yaw != yaw) + { this->yaw = yaw; emit changed(this); } @@ -173,7 +181,8 @@ void Waypoint::setYaw(double yaw) void Waypoint::setAction(int action) { - if (this->action != (MAV_CMD)action) { + if (this->action != (MAV_CMD)action) + { this->action = (MAV_CMD)action; emit changed(this); } @@ -205,7 +214,8 @@ void Waypoint::setAutocontinue(bool autoContinue) void Waypoint::setCurrent(bool current) { - if (this->current != current) { + if (this->current != current) + { this->current = current; emit changed(this); } @@ -213,7 +223,8 @@ void Waypoint::setCurrent(bool current) void Waypoint::setAcceptanceRadius(double radius) { - if (this->param2 != radius) { + if (this->param2 != radius) + { this->param2 = radius; emit changed(this); } @@ -223,7 +234,8 @@ void Waypoint::setParam1(double param1) { //qDebug() << "SENDER:" << QObject::sender(); //qDebug() << "PARAM1 SET REQ:" << param1; - if (this->param1 != param1) { + if (this->param1 != param1) + { this->param1 = param1; emit changed(this); } @@ -231,7 +243,8 @@ void Waypoint::setParam1(double param1) void Waypoint::setParam2(double param2) { - if (this->param2 != param2) { + if (this->param2 != param2) + { this->param2 = param2; emit changed(this); } diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 69ee72af4d437d2e56a7eee212d545e22eb9ac3b..098fe65ffa9f7104b63146cab1bc469d8acefe78 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -395,7 +395,7 @@ void MAVLinkProtocol::sendHeartbeat() { if (m_heartbeatsEnabled) { mavlink_message_t beat; - mavlink_msg_heartbeat_pack(getSystemId(), getComponentId(),&beat, OCU, MAV_AUTOPILOT_GENERIC); + mavlink_msg_heartbeat_pack(getSystemId(), getComponentId(),&beat, MAV_TYPE_OCU, MAV_CLASS_INVALID); sendMessage(beat); } if (m_authEnabled) { diff --git a/src/ui/HSIDisplay.cc b/src/ui/HSIDisplay.cc index 27f40b8498561284b41b4e838c9437ba589b4e92..bc3e193d3a6c28b2745f58c27128471d7f3d1043 100644 --- a/src/ui/HSIDisplay.cc +++ b/src/ui/HSIDisplay.cc @@ -792,7 +792,8 @@ void HSIDisplay::drawWaypoints(QPainter& painter) for (int i = 0; i < list.size(); i++) { QPointF in; - if (list.at(i)->getFrame() == MAV_FRAME_LOCAL) { + if (list.at(i)->getFrame() == MAV_FRAME_LOCAL_NED) + { // Do not transform in = QPointF(list.at(i)->getX(), list.at(i)->getY()); } else { diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 1f39e4a270f82bdce497007c098cc9a21cd91032..14d8c4c2ad5b865737ba770f477a03e486a819a4 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -1629,7 +1629,7 @@ void MainWindow::UASCreated(UASInterface* uas) } switch (uas->getAutopilotType()) { - case (MAV_AUTOPILOT_SLUGS): { + case (MAV_CLASS_SLUGS): { // Build Slugs Widgets buildSlugsWidgets(); @@ -1667,9 +1667,9 @@ void MainWindow::UASCreated(UASInterface* uas) } break; default: - case (MAV_AUTOPILOT_GENERIC): - case (MAV_AUTOPILOT_ARDUPILOTMEGA): - case (MAV_AUTOPILOT_PIXHAWK): { + case (MAV_CLASS_GENERIC): + case (MAV_CLASS_ARDUPILOTMEGA): + case (MAV_CLASS_PIXHAWK): { // Build Pixhawk Widgets buildPxWidgets(); diff --git a/src/ui/RadioCalibration/RadioCalibrationWindow.cc b/src/ui/RadioCalibration/RadioCalibrationWindow.cc index 21ae680661abd5d9749f5d3d9ec372fa16037fe8..5933f7e3dfc50c5215dbdfdf7ac10faa55f4afd5 100644 --- a/src/ui/RadioCalibration/RadioCalibrationWindow.cc +++ b/src/ui/RadioCalibration/RadioCalibrationWindow.cc @@ -270,13 +270,14 @@ void RadioCalibrationWindow::send() void RadioCalibrationWindow::request() { - qDebug() << __FILE__ << __LINE__ << "READ FROM UAV"; - UAS *uas = dynamic_cast(UASManager::instance()->getUASForId(uasId)); - if (uas) { - mavlink_message_t msg; - mavlink_msg_action_pack(uasId, 0, &msg, 0, 0, ::MAV_ACTION_CALIBRATE_RC); - uas->sendMessage(msg); - } + // FIXME MAVLINKV10PORTINGNEEDED +// qDebug() << __FILE__ << __LINE__ << "READ FROM UAV"; +// UAS *uas = dynamic_cast(UASManager::instance()->getUASForId(uasId)); +// if (uas) { +// mavlink_message_t msg; +// mavlink_msg_action_pack(uasId, 0, &msg, 0, 0, ::MAV_ACTION_CALIBRATE_RC); +// uas->sendMessage(msg); +// } } void RadioCalibrationWindow::receive(const QPointer& radio) diff --git a/src/ui/WaypointView.cc b/src/ui/WaypointView.cc index 9d157ca142c2dd5ee323bb0f2d1ece6323ba4007..516b68e3f56887a261ba2cc41254ebe656828167 100644 --- a/src/ui/WaypointView.cc +++ b/src/ui/WaypointView.cc @@ -52,7 +52,7 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) : // add frames m_ui->comboBox_frame->addItem("Abs. Alt/Global",MAV_FRAME_GLOBAL); m_ui->comboBox_frame->addItem("Rel. Alt/Global", MAV_FRAME_GLOBAL_RELATIVE_ALT); - m_ui->comboBox_frame->addItem("Local/Abs. Alt.",MAV_FRAME_LOCAL); + m_ui->comboBox_frame->addItem("Local/Abs. Alt.",MAV_FRAME_LOCAL_NED); m_ui->comboBox_frame->addItem("Mission",MAV_FRAME_MISSION); // Initialize view correctly @@ -322,7 +322,7 @@ void WaypointView::updateFrameView(int frame) m_ui->comboBox_frame->show(); m_ui->customActionWidget->hide(); break; - case MAV_FRAME_LOCAL: + case MAV_FRAME_LOCAL_NED: m_ui->lonSpinBox->hide(); m_ui->latSpinBox->hide(); m_ui->altSpinBox->hide(); @@ -386,7 +386,7 @@ void WaypointView::updateValues() updateFrameView(frame); } switch(frame) { - case MAV_FRAME_LOCAL: { + case MAV_FRAME_LOCAL_NED: { if (m_ui->posNSpinBox->value() != wp->getX()) { m_ui->posNSpinBox->setValue(wp->getX()); } diff --git a/src/ui/designer/QGCActionButton.cc b/src/ui/designer/QGCActionButton.cc deleted file mode 100644 index 72753e91ff1f804369e3aa76b1ad29a91c3b6ab6..0000000000000000000000000000000000000000 --- a/src/ui/designer/QGCActionButton.cc +++ /dev/null @@ -1,136 +0,0 @@ -#include "QGCActionButton.h" -#include "ui_QGCActionButton.h" - -#include "MAVLinkProtocol.h" -#include "UASManager.h" - -const char* kActionLabels[MAV_ACTION_NB] = { - "HOLD", - "START MOTORS", - "LAUNCH", - "RETURN", - "EMERGENCY LAND", - "EMERGENCY KILL", - "CONFIRM KILL", - "CONTINUE", - "STOP MOTORS", - "HALT", - "SHUTDOWN", - "REBOOT", - "SET MANUAL", - "SET AUTO", - "READ STORAGE", - "WRITE STORAGE", - "CALIBRATE RC", - "CALIBRATE GYRO", - "CALIBRATE MAG", - "CALIBRATE ACC", - "CALIBRATE PRESSURE", - "START REC", - "PAUSE REC", - "STOP REC", - "TAKEOFF", - "NAVIGATE", - "LAND", - "LOITER", - "SET ORIGIN", - "RELAY ON", -//"RELAY OFF", -//"GET IMAGE", -//"START VIDEO", -//"STOP VIDEO", - "RESET MAP", - "RESET PLAN" -}; - -QGCActionButton::QGCActionButton(QWidget *parent) : - QGCToolWidgetItem("Button", parent), - ui(new Ui::QGCActionButton), - uas(NULL) -{ - ui->setupUi(this); - - connect(ui->actionButton, SIGNAL(clicked()), this, SLOT(sendAction())); - connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode())); - connect(ui->editButtonName, SIGNAL(textChanged(QString)), this, SLOT(setActionButtonName(QString))); - connect(ui->editActionComboBox, SIGNAL(currentIndexChanged(QString)), ui->nameLabel, SLOT(setText(QString))); - - // Hide all edit items - ui->editActionComboBox->hide(); - ui->editActionsRefreshButton->hide(); - ui->editFinishButton->hide(); - ui->editNameLabel->hide(); - ui->editButtonName->hide(); - - // add action labels to combobox - for (int i = 0; i < MAV_ACTION_NB; i++) { - ui->editActionComboBox->addItem(kActionLabels[i]); - } -} - -QGCActionButton::~QGCActionButton() -{ - delete ui; -} - -void QGCActionButton::sendAction() -{ - if (QGCToolWidgetItem::uas) { - MAV_ACTION action = static_cast( - ui->editActionComboBox->currentIndex()); - - QGCToolWidgetItem::uas->setAction(action); - } else { - qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING"; - } -} - -void QGCActionButton::setActionButtonName(QString text) -{ - ui->actionButton->setText(text); -} - -void QGCActionButton::startEditMode() -{ - ui->editActionComboBox->show(); - ui->editActionsRefreshButton->show(); - ui->editFinishButton->show(); - ui->editNameLabel->show(); - ui->editButtonName->show(); - isInEditMode = true; -} - -void QGCActionButton::endEditMode() -{ - ui->editActionComboBox->hide(); - ui->editActionsRefreshButton->hide(); - ui->editFinishButton->hide(); - ui->editNameLabel->hide(); - ui->editButtonName->hide(); - - // Write to settings - emit editingFinished(); - - isInEditMode = false; -} - -void QGCActionButton::writeSettings(QSettings& settings) -{ - settings.setValue("TYPE", "BUTTON"); - settings.setValue("QGC_ACTION_BUTTON_DESCRIPTION", ui->nameLabel->text()); - settings.setValue("QGC_ACTION_BUTTON_BUTTONTEXT", ui->actionButton->text()); - settings.setValue("QGC_ACTION_BUTTON_ACTIONID", ui->editActionComboBox->currentIndex()); - settings.sync(); -} - -void QGCActionButton::readSettings(const QSettings& settings) -{ - ui->editNameLabel->setText(settings.value("QGC_ACTION_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); - ui->editButtonName->setText(settings.value("QGC_ACTION_BUTTON_BUTTONTEXT", "UNKNOWN").toString()); - ui->editActionComboBox->setCurrentIndex(settings.value("QGC_ACTION_BUTTON_ACTIONID", 0).toInt()); - - ui->nameLabel->setText(settings.value("QGC_ACTION_BUTTON_DESCRIPTION", "ERROR LOADING BUTTON").toString()); - ui->actionButton->setText(settings.value("QGC_ACTION_BUTTON_BUTTONTEXT", "UNKNOWN").toString()); - ui->editActionComboBox->setCurrentIndex(settings.value("QGC_ACTION_BUTTON_ACTIONID", 0).toInt()); - qDebug() << "DONE READING SETTINGS"; -} diff --git a/src/ui/designer/QGCActionButton.h b/src/ui/designer/QGCActionButton.h deleted file mode 100644 index a145e9a00be5c3d947eff113c293296a0ccb82ec..0000000000000000000000000000000000000000 --- a/src/ui/designer/QGCActionButton.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef QGCACTIONBUTTON_H -#define QGCACTIONBUTTON_H - -#include "QGCToolWidgetItem.h" - -namespace Ui -{ -class QGCActionButton; -} - -class UASInterface; - -class QGCActionButton : public QGCToolWidgetItem -{ - Q_OBJECT - -public: - explicit QGCActionButton(QWidget *parent = 0); - ~QGCActionButton(); - -public slots: - void sendAction(); - void setActionButtonName(QString text); - void startEditMode(); - void endEditMode(); - void writeSettings(QSettings& settings); - void readSettings(const QSettings& settings); - -private: - Ui::QGCActionButton *ui; - UASInterface* uas; -}; - -#endif // QGCACTIONBUTTON_H diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index 6a0f7678ca8519bc49c6ece7ee6f84c1c2088ae3..9a3fb8ec26545aac87a753bbb5f2a673209d74e0 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -11,7 +11,6 @@ #include #include "QGCParamSlider.h" -#include "QGCActionButton.h" #include "QGCCommandButton.h" #include "UASManager.h" @@ -129,10 +128,7 @@ void QGCToolWidget::loadSettings(QSettings& settings) QString type = settings.value("TYPE", "UNKNOWN").toString(); if (type != "UNKNOWN") { QGCToolWidgetItem* item = NULL; - if (type == "BUTTON") { - item = new QGCActionButton(this); - qDebug() << "CREATED BUTTON"; - } else if (type == "COMMANDBUTTON") { + if (type == "COMMANDBUTTON") { item = new QGCCommandButton(this); qDebug() << "CREATED COMMANDBUTTON"; } else if (type == "SLIDER") { @@ -303,17 +299,6 @@ void QGCToolWidget::addParam() slider->startEditMode(); } -void QGCToolWidget::addAction() -{ - QGCActionButton* button = new QGCActionButton(this); - if (ui->hintLabel) { - ui->hintLabel->deleteLater(); - ui->hintLabel = NULL; - } - toolLayout->addWidget(button); - button->startEditMode(); -} - void QGCToolWidget::addCommand() { QGCCommandButton* button = new QGCCommandButton(this); diff --git a/src/ui/designer/QGCToolWidget.h b/src/ui/designer/QGCToolWidget.h index 7d8b74dadc8dad24494ff8d495f81f4706f79270..81c9cf4eb10edaff9bdb5026359aa48892500714 100644 --- a/src/ui/designer/QGCToolWidget.h +++ b/src/ui/designer/QGCToolWidget.h @@ -82,8 +82,6 @@ protected: protected slots: void addParam(); - /** @deprecated */ - void addAction(); void addCommand(); void setTitle(); void setTitle(QString title);