Commit ef51e33a authored by Alejandro's avatar Alejandro

Add widget UASControlParameters

parent bf89851b
This diff is collapsed.
......@@ -335,6 +335,14 @@ void MainWindow::buildCommonWidgets()
addToToolsMenu (controlDockWidget, tr("Control"), SLOT(showToolWidget(bool)), MENU_UAS_CONTROL, Qt::LeftDockWidgetArea);
}
if (!controlParameterWidget)
{
controlParameterWidget = new QDockWidget(tr("Control Parameters"), this);
controlParameterWidget->setObjectName("UNMANNED_SYSTEM_CONTROL_PARAMETERWIDGET");
controlParameterWidget->setWidget( new UASControlParameters(this) );
addToToolsMenu (controlParameterWidget, tr("Control Parameters"), SLOT(showToolWidget(bool)), MENU_UAS_CONTROL_PARAM, Qt::LeftDockWidgetArea);
}
if (!listDockWidget)
{
listDockWidget = new QDockWidget(tr("Unmanned Systems"), this);
......@@ -818,7 +826,7 @@ void MainWindow::showToolWidget(bool visible)
else
{
removeDockWidget(dockWidget);
}
}
QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext())
......@@ -1007,10 +1015,11 @@ void MainWindow::connectCommonWidgets()
//
connect(waypointsDockWidget->widget(), SIGNAL(changePointList()), mapWidget, SLOT(clearWaypoints()));
}
if(controlDockWidget && controlParameterWidget)
{
connect(controlDockWidget->widget(), SIGNAL(changedMode(int)), controlParameterWidget->widget(), SLOT(changedMode(int)));
}
//TODO temporaly debug
......@@ -1018,6 +1027,11 @@ void MainWindow::connectCommonWidgets()
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
slugsHilSimWidget->widget(), SLOT(activeUasSet(UASInterface*)));
}
if (controlParameterWidget && controlParameterWidget->widget()){
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
controlParameterWidget->widget(), SLOT(activeUasSet(UASInterface*)));
}
}
void MainWindow::createCustomWidget()
......@@ -1064,6 +1078,8 @@ void MainWindow::connectSlugsWidgets()
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
slugsPIDControlWidget->widget(), SLOT(activeUasSet(UASInterface*)));
}
}
void MainWindow::arrangeCommonCenterStack()
......
......@@ -75,7 +75,7 @@ This file is part of the QGROUNDCONTROL project
#include "SlugsHilSim.h"
#include "SlugsVideoCamControl.h"
#include "UASControlParameters.h"
/**
* @brief Main Application Window
......@@ -212,6 +212,7 @@ protected:
// FIXME: DO NOT PUT CUSTOM VALUES IN THIS ENUM since it is iterated over
// this will be fixed in a future release.
typedef enum _TOOLS_WIDGET_NAMES {
MENU_UAS_CONTROL_PARAM,
MENU_UAS_CONTROL,
MENU_UAS_INFO,
MENU_CAMERA,
......@@ -381,6 +382,7 @@ protected:
#endif
// Dock widgets
QPointer<QDockWidget> controlDockWidget;
QPointer<QDockWidget> controlParameterWidget;
QPointer<QDockWidget> infoDockWidget;
QPointer<QDockWidget> cameraDockWidget;
QPointer<QDockWidget> listDockWidget;
......
......@@ -191,7 +191,11 @@ void QGCRemoteControlView::redraw()
progressBars.at(i)->setValue(vv);
}
// Update RSSI
rssiBar->setValue(rssi*100);
if(rssi>0)
{
rssiBar->setValue(rssi*100);
}
updated = false;
}
}
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>392</width>
<width>495</width>
<height>671</height>
</rect>
</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UASControlParameters</class>
<widget class="QWidget" name="UASControlParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>228</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>267</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbMode">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>----</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height (m)</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbHeight">
<property name="maximum">
<double>1500.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Airspeed (m/s)</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAirSpeed">
<property name="maximum">
<double>500.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Turn Rate (rad/s)</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbTurnRate">
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btSetCommands">
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btGetCommands">
<property name="text">
<string>Get</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "src\ui\uas\UASControlParameters.h"
#include "ui_UASControlParameters.h"
#define CONTROL_MODE_LOCKED "MODE LOCKED"
#define CONTROL_MODE_MANUAL "MODE MANUAL"
#define CONTROL_MODE_GUIDED "MODE GUIDED"
#define CONTROL_MODE_AUTO "MODE AUTO"
#define CONTROL_MODE_TEST1 "MODE TEST1"
#define CONTROL_MODE_TEST2 "MODE TEST2"
#define CONTROL_MODE_TEST3 "MODE TEST3"
#define CONTROL_MODE_READY "MODE TEST3"
#define CONTROL_MODE_RC_TRAINING "RC SIMULATION"
#define CONTROL_MODE_LOCKED_INDEX 1
#define CONTROL_MODE_MANUAL_INDEX 2
#define CONTROL_MODE_GUIDED_INDEX 3
#define CONTROL_MODE_AUTO_INDEX 4
#define CONTROL_MODE_TEST1_INDEX 5
#define CONTROL_MODE_TEST2_INDEX 6
#define CONTROL_MODE_TEST3_INDEX 7
#define CONTROL_MODE_READY_INDEX 8
#define CONTROL_MODE_RC_TRAINING_INDEX 9
UASControlParameters::UASControlParameters(QWidget *parent) :
QWidget(parent),
ui(new Ui::UASControlParameters)
{
ui->setupUi(this);
//this->mode = "MAV_MODE_UNKNOWN";
//connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(activeUasSet(UASInterface*)));
connect(ui->btGetCommands, SIGNAL(clicked()), this, SLOT(getCommands()));
//QColor groupColor = QColor(231,72,28);
//QString borderColor = "#FA4A4F";
//groupColor = groupColor.darker(475);
}
UASControlParameters::~UASControlParameters()
{
delete ui;
}
void UASControlParameters::changedMode(int mode)
{
QString modeTemp;
if (mode == CONTROL_MODE_LOCKED_INDEX)
{
modeTemp= CONTROL_MODE_LOCKED;
}
else if (mode == CONTROL_MODE_MANUAL_INDEX)
{
modeTemp= CONTROL_MODE_MANUAL;
}
else if (mode == CONTROL_MODE_GUIDED_INDEX)
{
modeTemp= CONTROL_MODE_GUIDED;
}
else if (mode == CONTROL_MODE_AUTO_INDEX)
{
modeTemp= CONTROL_MODE_AUTO;
}
else if (mode == CONTROL_MODE_TEST1_INDEX)
{
modeTemp= CONTROL_MODE_TEST1;
}
else if (mode == CONTROL_MODE_TEST2_INDEX)
{
modeTemp= CONTROL_MODE_TEST2;
}
else if (mode == CONTROL_MODE_TEST3_INDEX)
{
modeTemp= CONTROL_MODE_TEST3;
}
else if (mode == CONTROL_MODE_RC_TRAINING_INDEX)
{
modeTemp= CONTROL_MODE_RC_TRAINING;
}
if( static_cast<QString>(modeTemp) != this->mode)
{
ui->lbMode->setStyleSheet("background-color: rgb(255, 0, 0)");
}
else
{
ui->lbMode->setStyleSheet("");
}
}
void UASControlParameters::activeUasSet(UASInterface *uas)
{
connect(uas, SIGNAL(globalPositionChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateGlobalPosition(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(speedChanged(UASInterface*,double,double,double,quint64)), this, SLOT(speedChanged(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(attitudeChanged(UASInterface*,double,double,double,quint64)), this, SLOT(updateAttitude(UASInterface*,double,double,double,quint64)));
connect(uas, SIGNAL(modeChanged(int,QString,QString)), this, SLOT(updateMode(int,QString,QString)));
activeUAS= uas;
}
void UASControlParameters::updateGlobalPosition(UASInterface * a, double b, double c, double aa, quint64 ab)
{
//ui->sbHeight->setValue(aa);
this->altitude=aa;
}
void UASControlParameters::speedChanged(UASInterface* uas, double vx, double vy, double vz, quint64 time)
{
this->speed = sqrt(pow(vx, 2.0) + pow(vy, 2.0) + pow(vz, 2.0));
//ui->sbAirSpeed->setValue(speed);
}
void UASControlParameters::updateAttitude(UASInterface *uas, double roll, double pitch, double yaw, quint64 time)
{
Q_UNUSED(uas);
Q_UNUSED(time);
//ui->sbTurnRate->setValue(roll);
this->roll = roll;
}
void UASControlParameters::setCommands()
{}
void UASControlParameters::getCommands()
{
ui->sbAirSpeed->setValue(this->speed);
ui->sbHeight->setValue(this->altitude);
ui->sbTurnRate->setValue(this->roll);
}
void UASControlParameters::updateMode(int uas,QString mode,QString description)
{
Q_UNUSED(uas);
Q_UNUSED(description);
this->mode = mode;
ui->lbMode->setText(this->mode);
}
#ifndef UASCONTROLPARAMETERS_H
#define UASCONTROLPARAMETERS_H
#include <QWidget>
#include "UASManager.h"
#include "SlugsMAV.h"
#include <QTimer>
#include <QTabWidget>
namespace Ui {
class UASControlParameters;
}
class UASControlParameters : public QWidget
{
Q_OBJECT
public:
explicit UASControlParameters(QWidget *parent = 0);
~UASControlParameters();
public slots:
void changedMode(int mode);
void activeUasSet(UASInterface* uas);
void updateGlobalPosition(UASInterface*,double,double,double,quint64);
void speedChanged(UASInterface*,double,double,double,quint64);
void updateAttitude(UASInterface* uas, double roll, double pitch, double yaw, quint64 time);
void setCommands();
void getCommands();
void updateMode(int uas,QString mode,QString description);
private:
Ui::UASControlParameters *ui;
QTimer* refreshTimerGet;
UASInterface* activeUAS;
double speed;
double roll;
double altitude;
QString mode;
QString REDcolorStyle;
};
#endif // UASCONTROLPARAMETERS_H
......@@ -249,6 +249,8 @@ void UASControlWidget::setMode(int mode)
qDebug() << "SET MODE REQUESTED" << uasMode;
emit changedMode(mode);
}
void UASControlWidget::transmitMode()
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of class UASControlWidget
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASCONTROLWIDGET_H_
#define _UASCONTROLWIDGET_H_
#include <QWidget>
#include <QLineEdit>
#include <QString>
#include <QPushButton>
#include <ui_UASControl.h>
#include <UASInterface.h>
/**
* @brief Widget controlling one MAV
*/
class UASControlWidget : public QWidget
{
Q_OBJECT
public:
UASControlWidget(QWidget *parent = 0);
~UASControlWidget();
public slots:
/** @brief Set the system this widget controls */
void setUAS(UASInterface* uas);
/** @brief Trigger next context action */
void cycleContextButton();
/** @brief Set the operation mode of the MAV */
void setMode(int mode);
/** @brief Transmit the operation mode */
void transmitMode();
/** @brief Update the mode */
void updateMode(int uas,QString mode,QString description);
/** @brief Update state */
void updateState(int state);
/** @brief Update internal state machine */
void updateStatemachine();
protected slots:
/** @brief Set the background color for the widget */
void setBackgroundColor(QColor color);
protected:
int uas; ///< Reference to the current uas
unsigned int uasMode; ///< Current uas mode
bool engineOn; ///< Engine state
private:
Ui::uasControl ui;
};
#endif // _UASCONTROLWIDGET_H_
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of class UASControlWidget
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASCONTROLWIDGET_H_
#define _UASCONTROLWIDGET_H_
#include <QWidget>
#include <QLineEdit>
#include <QString>
#include <QPushButton>
#include <ui_UASControl.h>
#include <UASInterface.h>
/**
* @brief Widget controlling one MAV
*/
class UASControlWidget : public QWidget
{
Q_OBJECT
public:
UASControlWidget(QWidget *parent = 0);
~UASControlWidget();
public slots:
/** @brief Set the system this widget controls */
void setUAS(UASInterface* uas);
/** @brief Trigger next context action */
void cycleContextButton();
/** @brief Set the operation mode of the MAV */
void setMode(int mode);
/** @brief Transmit the operation mode */
void transmitMode();
/** @brief Update the mode */
void updateMode(int uas,QString mode,QString description);
/** @brief Update state */
void updateState(int state);
/** @brief Update internal state machine */
void updateStatemachine();
signals:
void changedMode(int);
protected slots:
/** @brief Set the background color for the widget */
void setBackgroundColor(QColor color);
protected:
int uas; ///< Reference to the current uas
unsigned int uasMode; ///< Current uas mode
bool engineOn; ///< Engine state
private:
Ui::uasControl ui;
};
#endif // _UASCONTROLWIDGET_H_
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