diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index 09d6fa96e433c92f897eb3217a73dc7da13a142f..71efcfe33a742bbc593336dd8931432732226cfb 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -64,7 +64,8 @@ SerialLink::SerialLink(QString portname, BaudRateType baudrate, FlowType flow, P // Set the port name if (porthandle == "") { - name = tr("serial link ") + QString::number(getId()) + tr(" (unconfigured)"); +// name = tr("serial link ") + QString::number(getId()) + tr(" (unconfigured)"); + name = tr("Serial Link ") + QString::number(getId()); } else { diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 3e6be1561c53f1b42ebb25778a105cebeed5311c..0cc31a7c6ae09adcb4ce1a17ac68d1610ecf02aa 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -184,6 +184,8 @@ void MainWindow::buildWidgets() slugsPIDControlWidget = new QDockWidget(tr("PID Control"), this); slugsPIDControlWidget->setWidget(new SlugsPIDControl(this)); + slugsHilSimWidget = new QDockWidget(tr("Slugs Hil Sim"), this); + slugsHilSimWidget->setWidget( new SlugsHilSim(this)); } @@ -218,9 +220,14 @@ void MainWindow::connectWidgets() // it notifies that a waypoint global goes to do create and a map graphic too connect(waypointsDockWidget->widget(), SIGNAL(createWaypointAtMap(QPointF)), mapWidget, SLOT(createWaypointGraphAtMap(QPointF))); - // it notifies that a waypoint global change it´s position by spinBox on Widget WaypointView + // it notifies that a waypoint global change itÂ¥s position by spinBox on Widget WaypointView connect(waypointsDockWidget->widget(), SIGNAL(changePositionWPGlobalBySpinBox(int,float,float)), mapWidget, SLOT(changeGlobalWaypointPositionBySpinBox(int,float,float))); } + + if (slugsHilSimWidget->widget()){ + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), dynamic_cast(slugsHilSimWidget->widget()), SLOT(activeUasSet(UASInterface*)) ); + } + } void MainWindow::arrangeCenterStack() @@ -543,15 +550,13 @@ void MainWindow::UASCreated(UASInterface* uas) // Check which type this UAS is of PxQuadMAV* mav = dynamic_cast(uas); if (mav) loadPixhawkView(); + SlugsMAV* mav2 = dynamic_cast(uas); if (mav2) { - SlugsDataSensorView* slugDataView = dynamic_cast(slugsDataWidget->widget()); - if(slugDataView) - { - slugDataView->addUAS(uas); - } - loadSlugsView(); + dynamic_cast(slugsDataWidget->widget())->addUAS(uas); + loadSlugsView(); + } @@ -642,17 +647,6 @@ void MainWindow::loadSlugsView() infoDockWidget->show(); } - // HORIZONTAL SITUATION INDICATOR - if (hsiDockWidget) - { - HSIDisplay* hsi = dynamic_cast( hsiDockWidget->widget() ); - if (hsi) - { - hsi->start(); - addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget); - hsiDockWidget->show(); - } - } // WAYPOINT LIST if (waypointsDockWidget) @@ -675,6 +669,12 @@ void MainWindow::loadSlugsView() slugsDataWidget->show(); } + // Slugs Data View + if (slugsHilSimWidget) + { + addDockWidget(Qt::LeftDockWidgetArea, slugsHilSimWidget); + slugsHilSimWidget->show(); + } this->show(); } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 473074369f937a7e770e882c3e8d6c3fe501b586..15371a0bc7efaabc6c7f7575154317b22ab2ebb7 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -66,8 +66,12 @@ This file is part of the QGROUNDCONTROL project #include "QMap3DWidget.h" #include "SlugsDataSensorView.h" #include "LogCompressor.h" + #include "SlugsPIDControl.h" +#include "slugshilsim.h" + + /** * @brief Main Application Window @@ -181,7 +185,9 @@ protected: QPointer hsiDockWidget; QPointer rcViewDockWidget; QPointer slugsDataWidget; - QPointer slugsPIDControlWidget; + QPointer slugsPIDControlWidget; + QPointer slugsHilSimWidget; + // Popup widgets JoystickWidget* joystickWidget; diff --git a/src/ui/SlugsPIDControl.cpp b/src/ui/SlugsPIDControl.cpp index 462b83f51e42db0bbd150b67478b24110d47e43e..23a2a284a218b4ba70a94dbb0c54c5095300319e 100644 --- a/src/ui/SlugsPIDControl.cpp +++ b/src/ui/SlugsPIDControl.cpp @@ -12,10 +12,11 @@ SlugsPIDControl::SlugsPIDControl(QWidget *parent) : { ui->setupUi(this); setRedColorStyle(); -// setGreenColorStyle(); + setGreenColorStyle(); - //ORIGINcolorStyle = ui->AirSpeedHold_groupBox->styleSheet(); - //connectButtons(); + + connect_set_pushButtons(); + connect_AirSpeed_LineEdit(); } @@ -26,7 +27,7 @@ SlugsPIDControl::~SlugsPIDControl() } /** - * Set the background color RED of the GroupBox PID based on the send Slugs PID message + * Set the background color RED style for the GroupBox PID when change lineEdit information * */ void SlugsPIDControl::setRedColorStyle() @@ -45,7 +46,7 @@ void SlugsPIDControl::setRedColorStyle() } /** - * Set the background color GREEN of the GroupBox PID based on the send Slugs PID message + * Set the background color GREEN style for the GroupBox PID when change lineEdit information * */ void SlugsPIDControl::setGreenColorStyle() @@ -63,24 +64,33 @@ void SlugsPIDControl::setGreenColorStyle() } /** - * Connection Signal and Slot of the set and get buttons on the widget - * + * Connection Signal and Slot of the set buttons on the widget */ -void SlugsPIDControl::connectButtons() +void SlugsPIDControl::connect_set_pushButtons() { //ToDo connect buttons set and get. Before create the slots + connect(ui->dT_PID_set_pushButton, SIGNAL(clicked(bool)),this,SLOT(changeColor_GREEN_AirSpeed_groupBox())); + } void SlugsPIDControl::connect_AirSpeed_LineEdit() { - connect(ui->dT_P_set,SIGNAL(editingFinished()),this, SLOT(changeColor_AirSpeed_groupBox())); + connect(ui->dT_P_set,SIGNAL(textChanged(QString)),this,SLOT(changeColor_RED_AirSpeed_groupBox(QString))); + connect(ui->dT_I_set,SIGNAL(textChanged(QString)),this,SLOT(changeColor_RED_AirSpeed_groupBox(QString))); + connect(ui->dT_D_set,SIGNAL(textChanged(QString)),this,SLOT(changeColor_RED_AirSpeed_groupBox(QString))); } -void SlugsPIDControl::changeColor_AirSpeed_groupBox() +void SlugsPIDControl::changeColor_RED_AirSpeed_groupBox(QString text) { + Q_UNUSED(text); ui->AirSpeedHold_groupBox->setStyleSheet(REDcolorStyle); } +void SlugsPIDControl::changeColor_GREEN_AirSpeed_groupBox() +{ + ui->AirSpeedHold_groupBox->setStyleSheet(GREENcolorStyle); +} + diff --git a/src/ui/SlugsPIDControl.h b/src/ui/SlugsPIDControl.h index 71e06e253fa89bd1e0e43ae6419755f64daa19db..20349df29b5625cc87053bed9f833317e737ac66 100644 --- a/src/ui/SlugsPIDControl.h +++ b/src/ui/SlugsPIDControl.h @@ -21,11 +21,22 @@ public slots: void setRedColorStyle(); void setGreenColorStyle(); - void changeColor_AirSpeed_groupBox(); - void connectButtons(); + void changeColor_RED_AirSpeed_groupBox(QString text); + void changeColor_GREEN_AirSpeed_groupBox(); + /** + * @brief Connects the SIGNALS from the editline to SLOT changeColor_RED_AirSpeed_groupBox() + * + * @param + */ void connect_AirSpeed_LineEdit(); + + + + + void connect_set_pushButtons(); + private: Ui::SlugsPIDControl *ui; bool change_dT; diff --git a/src/ui/SlugsPIDControl.ui b/src/ui/SlugsPIDControl.ui index 8535251a403c53434b2e0ce341e4e67fae07dfa4..35e7cd35f96b79aa8ffa1dfc003a9bb40e9af7c2 100644 --- a/src/ui/SlugsPIDControl.ui +++ b/src/ui/SlugsPIDControl.ui @@ -81,6 +81,9 @@ dT_P_get + + true + @@ -95,6 +98,9 @@ dT_I_get + + true + @@ -109,6 +115,9 @@ dT_D_get + + true + @@ -235,6 +244,9 @@ dE_P_get + + true + @@ -249,6 +261,9 @@ dE_I_get + + true + @@ -263,6 +278,9 @@ dE_D_get + + true + @@ -389,6 +407,9 @@ dA_P_get + + true + @@ -403,6 +424,9 @@ dA_I_get + + true + @@ -417,6 +441,9 @@ dA_D_get + + true + @@ -520,6 +547,9 @@ HELPComm_P_get + + true + @@ -534,6 +564,9 @@ HELPComm_I_get + + true + @@ -615,6 +648,9 @@ HELPComm_FF_get + + true + @@ -741,6 +777,9 @@ dR_P_get + + true + @@ -755,6 +794,9 @@ dR_I_get + + true + @@ -769,6 +811,9 @@ dR_D_get + + true + @@ -867,6 +912,9 @@ P2dT_FF_get + + true + diff --git a/src/ui/slugshilsim.cc b/src/ui/slugshilsim.cc index 8a8272d1e05edf04a505323ed53a8b31f5807906..ea25c865cd5a9d8e80f2f4c505e52b10b0dd18c0 100644 --- a/src/ui/slugshilsim.cc +++ b/src/ui/slugshilsim.cc @@ -1,3 +1,33 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2010 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief Configuration Window for Slugs' HIL Simulator + * @author Mariano Lizarraga + */ + + #include "slugshilsim.h" #include "ui_slugshilsim.h" #include "LinkManager.h" @@ -7,8 +37,15 @@ SlugsHilSim::SlugsHilSim(QWidget *parent) : ui(new Ui::SlugsHilSim) { ui->setupUi(this); - linkAdded(); + rxSocket = new QUdpSocket(this); + txSocket = new QUdpSocket(this); + + connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addToCombo(LinkInterface*))); + connect(ui->bt_startHil, SIGNAL(clicked()), this, SLOT(putInHilMode())); + connect(rxSocket, SIGNAL(readyRead()), this, SLOT(readDatagram())); + + linksAvailable.clear(); } SlugsHilSim::~SlugsHilSim() @@ -18,12 +55,74 @@ SlugsHilSim::~SlugsHilSim() void SlugsHilSim::linkAdded(void){ - ui->cb_mavlinkLinks->clear(); +// ui->cb_mavlinkLinks->clear(); + +// QList linkList; +// linkList.append(LinkManager::instance()->getLinks()) ; + +// for (int i = 0; i< linkList.size(); i++){ +// ui->cb_mavlinkLinks->addItem((linkList.takeFirst())->getName()); +// } + +} + +void SlugsHilSim::addToCombo(LinkInterface* theLink){ + + ui->cb_mavlinkLinks->addItem(theLink->getName()); + linksAvailable.insert(ui->cb_mavlinkLinks->count(),theLink); +} - QList linkList = LinkManager::instance()->getLinks() ; +void SlugsHilSim::putInHilMode(void){ - for (int i = 0; i< linkList.size(); i++){ - ui->cb_mavlinkLinks->addItem((linkList.takeFirst())->getName()); + bool sw_enableControls = !(ui->bt_startHil->isChecked()); + QString buttonCaption= ui->bt_startHil->isChecked()? "Stop Slugs HIL Mode": "Set Slugs in HIL Mode"; + + if (ui->bt_startHil->isChecked()){ + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("You are about to put SLUGS in HIL Mode."); + msgBox.setInformativeText("It will stop reading the actual sensor readings. Do you wish to continue?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + + if(msgBox.exec() == QMessageBox::Yes) + { + rxSocket->bind(QHostAddress::Any, ui->ed_rxPort->text().toInt()); + txSocket->bind(QHostAddress::Broadcast, ui->ed_txPort->text().toInt()); + + ui->ed_ipAdress->setEnabled(sw_enableControls); + ui->ed_rxPort->setEnabled(sw_enableControls); + ui->ed_txPort->setEnabled(sw_enableControls); + ui->cb_mavlinkLinks->setEnabled(sw_enableControls); + + ui->bt_startHil->setText(buttonCaption); + + + } else { + ui->bt_startHil->setChecked(false); + } + } else { + ui->ed_ipAdress->setEnabled(sw_enableControls); + ui->ed_rxPort->setEnabled(sw_enableControls); + ui->ed_txPort->setEnabled(sw_enableControls); + ui->cb_mavlinkLinks->setEnabled(sw_enableControls); + + ui->bt_startHil->setText(buttonCaption); } + + + +} + +void SlugsHilSim::readDatagram(void){ + +} + + +void SlugsHilSim::activeUasSet(UASInterface* uas){ + + if (uas != NULL) { + //activeUas = uas; + } } diff --git a/src/ui/slugshilsim.h b/src/ui/slugshilsim.h index bad370635aa7d8951040fdd74463d1f3015d633c..18c9560b2efaf98f43973cfbe370a55625c5b927 100644 --- a/src/ui/slugshilsim.h +++ b/src/ui/slugshilsim.h @@ -1,10 +1,42 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2010 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief Definition of the configuration Window for Slugs' HIL Simulator + * @author Mariano Lizarraga + */ + #ifndef SLUGSHILSIM_H #define SLUGSHILSIM_H #include #include #include +#include + #include "LinkInterface.h" +#include "UAS.h" namespace Ui { @@ -24,13 +56,56 @@ protected: QHostAddress* simulinkIp; QUdpSocket* txSocket; QUdpSocket* rxSocket; + UAS* activeUas; public slots: - void linkAdded(); + void linkAdded (void); + + /** + * @brief Adds a link to the combo box listing so the user can select a link + * + * Populates the Combo box that allows the user to select the link with which Slugs will + * receive the simulated sensor data from Simulink + * + * @param theLink the link that is being added to the combo box + */ + void addToCombo(LinkInterface* theLink); + + /** + * @brief Puts Slugs in HIL Mode + * + * Sends the required messages through the main communication link to set Slugs in HIL Mode + * + */ + void putInHilMode(void); + + /** + * @brief Receives a datagram from Simulink containing the sensor data. + * + * Receives a datagram from Simulink containing the simulated sensor data. This data is then + * forwarded to Slugs to use as input to the attitude estimation and navigation algorithms. + * + */ + void readDatagram(void); + + /** + * @brief Called when the a new UAS is set to active. + * + * Called when the a new UAS is set to active. + * + * @param uas The new active UAS + */ + void activeUasSet(UASInterface* uas); + + +public slots: + private: Ui::SlugsHilSim *ui; + QHash linksAvailable; + }; #endif // SLUGSHILSIM_H diff --git a/src/ui/slugshilsim.ui b/src/ui/slugshilsim.ui index 2281b4683f91c73f9d8599c4e8ac7c4e3ad52f29..caae1a9aaf31d8c2f51ecbd78f9be49897261927 100644 --- a/src/ui/slugshilsim.ui +++ b/src/ui/slugshilsim.ui @@ -6,19 +6,19 @@ 0 0 - 256 + 325 191 - 256 + 320 191 - 367 + 450 229 @@ -45,7 +45,7 @@ - Qt::RightToLeft + Qt::LeftToRight IP Address @@ -91,7 +91,7 @@ - Qt::RightToLeft + Qt::LeftToRight Receive Port @@ -124,7 +124,7 @@ - Qt::RightToLeft + Qt::LeftToRight Send Port @@ -132,7 +132,7 @@ - + 60 @@ -165,8 +165,8 @@ - - + + @@ -179,12 +179,32 @@ Qt::RightToLeft - Slugs HIL Sim Serial Link + Slugs HIL Link - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 171 + 26 + + + @@ -206,7 +226,10 @@ - Set in HIL Mode + Set Slugs in HIL Mode + + + true