Commit f0d81866 authored by pixhawk's avatar pixhawk

Pushed implementation of parameter settings, almost done. Added many new...

Pushed implementation of parameter settings, almost done. Added many new MAVLink messages needed for interaction with IMU
parent 460aef7a
# Include QMapControl map library # Include QMapControl map library
# prefer version from external directory / # prefer version from external directory /
# from http://github.com/pixhawk/qmapcontrol/ # from http://github.com/pixhawk/qmapcontrol/
# over bundled version in lib directory # over bundled version in lib directory
# Version from GIT repository is preferred # Version from GIT repository is preferred
#include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{ # include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary # Include bundled version if necessary
include(lib/QMapControl/QMapControl.pri) include(lib/QMapControl/QMapControl.pri)
message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows") message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
#}
# }
# Include general settings for MAVGround # Include general settings for MAVGround
# necessary as last include to override any non-acceptable settings # necessary as last include to override any non-acceptable settings
# done by the plugins above # done by the plugins above
include(qgroundcontrol.pri) include(qgroundcontrol.pri)
# QWT plot and QExtSerial depend on paths set by qgroundcontrol.pri # QWT plot and QExtSerial depend on paths set by qgroundcontrol.pri
# Include serial port library # Include serial port library
include(src/lib/qextserialport/qextserialport.pri) include(src/lib/qextserialport/qextserialport.pri)
# Include QWT plotting library # Include QWT plotting library
include(src/lib/qwt/qwt.pri) include(src/lib/qwt/qwt.pri)
DEPENDPATH += . \ DEPENDPATH += . \
lib/QMapControl \ lib/QMapControl \
lib/QMapControl/src lib/QMapControl/src
...@@ -64,7 +59,8 @@ INCLUDEPATH += src \ ...@@ -64,7 +59,8 @@ INCLUDEPATH += src \
include/ui \ include/ui \
src/input \ src/input \
src/lib/qmapcontrol \ src/lib/qmapcontrol \
src/ui/mavlink src/ui/mavlink \
src/ui/param
HEADERS += src/MG.h \ HEADERS += src/MG.h \
src/Core.h \ src/Core.h \
src/uas/UASInterface.h \ src/uas/UASInterface.h \
...@@ -114,7 +110,9 @@ HEADERS += src/MG.h \ ...@@ -114,7 +110,9 @@ HEADERS += src/MG.h \
src/ui/MAVLinkSettingsWidget.h \ src/ui/MAVLinkSettingsWidget.h \
src/ui/AudioOutputWidget.h \ src/ui/AudioOutputWidget.h \
src/GAudioOutput.h \ src/GAudioOutput.h \
src/LogCompressor.h src/LogCompressor.h \
src/ui/param/ParamTreeItem.h \
src/ui/param/ParamTreeModel.h
SOURCES += src/main.cc \ SOURCES += src/main.cc \
src/Core.cc \ src/Core.cc \
src/uas/UASManager.cc \ src/uas/UASManager.cc \
...@@ -159,5 +157,7 @@ SOURCES += src/main.cc \ ...@@ -159,5 +157,7 @@ SOURCES += src/main.cc \
src/ui/MAVLinkSettingsWidget.cc \ src/ui/MAVLinkSettingsWidget.cc \
src/ui/AudioOutputWidget.cc \ src/ui/AudioOutputWidget.cc \
src/GAudioOutput.cc \ src/GAudioOutput.cc \
src/LogCompressor.cc src/LogCompressor.cc \
src/ui/param/ParamTreeItem.cc \
src/ui/param/ParamTreeModel.cc
RESOURCES = mavground.qrc RESOURCES = mavground.qrc
...@@ -78,8 +78,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) : ...@@ -78,8 +78,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) :
this->setMinimumWidth(100); this->setMinimumWidth(100);
// Refresh timer // Refresh timer
refreshTimer->setInterval(100); refreshTimer->setInterval(150); // 200 Hz/5 ms
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(update())); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(triggerUpdate()));
//connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintGL())); //connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintGL()));
fontDatabase = QFontDatabase(); fontDatabase = QFontDatabase();
...@@ -101,11 +101,18 @@ HDDisplay::~HDDisplay() ...@@ -101,11 +101,18 @@ HDDisplay::~HDDisplay()
delete m_ui; delete m_ui;
} }
void HDDisplay::triggerUpdate()
{
// Only repaint the regions necessary
QRect r = geometry();
update(r);
}
void HDDisplay::paintEvent(QPaintEvent * event) void HDDisplay::paintEvent(QPaintEvent * event)
{ {
//paintGL(); //paintGL();
static quint64 interval = 0; static quint64 interval = 0;
//qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__; qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
interval = MG::TIME::getGroundTimeNow(); interval = MG::TIME::getGroundTimeNow();
paintDisplay(); paintDisplay();
} }
......
...@@ -59,9 +59,10 @@ public slots: ...@@ -59,9 +59,10 @@ public slots:
void stop(); void stop();
void setActiveUAS(UASInterface* uas); void setActiveUAS(UASInterface* uas);
protected slots: protected slots:
void paintGL(); void paintGL();
void paintDisplay(); void paintDisplay();
void triggerUpdate();
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
......
...@@ -23,7 +23,7 @@ This file is part of the PIXHAWK project ...@@ -23,7 +23,7 @@ This file is part of the PIXHAWK project
/** /**
* @file * @file
* @brief Implementation of main application window * @brief Implementation of class MainWindow
* @author Lorenz Meier <mavteam@student.ethz.ch> * @author Lorenz Meier <mavteam@student.ethz.ch>
* *
*/ */
...@@ -208,8 +208,9 @@ void MainWindow::startVideoCapture() ...@@ -208,8 +208,9 @@ void MainWindow::startVideoCapture()
.arg(format)); .arg(format));
delete videoTimer; delete videoTimer;
videoTimer = new QTimer(this); videoTimer = new QTimer(this);
videoTimer->setInterval(40); //videoTimer->setInterval(40);
connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen())); //connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
//videoTimer->stop();
} }
void MainWindow::stopVideoCapture() void MainWindow::stopVideoCapture()
...@@ -391,7 +392,6 @@ void MainWindow::loadPilotView() ...@@ -391,7 +392,6 @@ void MainWindow::loadPilotView()
headDown1->start(); headDown1->start();
headDown2->start(); headDown2->start();
this->show(); this->show();
} }
......
#include <QTreeWidget>
#include "ParameterInterface.h" #include "ParameterInterface.h"
#include "ParamTreeModel.h"
#include "UASManager.h" #include "UASManager.h"
#include "ui_ParameterInterface.h" #include "ui_ParameterInterface.h"
...@@ -8,6 +11,19 @@ ParameterInterface::ParameterInterface(QWidget *parent) : ...@@ -8,6 +11,19 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
// FIXME Testing TODO
QString testData = "IMU\n ROLL_K_P\t0.527\n ROLL_K_I\t1.255\n PITCH_K_P\t0.621\n PITCH_K_I\t2.5545\n";
ParamTreeModel* model = new ParamTreeModel(testData);
QTreeView* tree = new QTreeView();
tree->setModel(model);
QStackedWidget* stack = m_ui->stackedWidget;
stack->addWidget(tree);
stack->setCurrentWidget(tree);
} }
ParameterInterface::~ParameterInterface() ParameterInterface::~ParameterInterface()
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>349</width> <width>350</width>
<height>545</height> <height>545</height>
</rect> </rect>
</property> </property>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Extended Output</string> <string>Activate Extended Output</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="margin"> <property name="margin">
...@@ -37,13 +37,27 @@ ...@@ -37,13 +37,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Send RC-values</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Send raw controller outputs</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>Calibration</string> <string>Calibration Wizards</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <property name="margin">
...@@ -52,7 +66,7 @@ ...@@ -52,7 +66,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="gyroCalButton"> <widget class="QPushButton" name="gyroCalButton">
<property name="text"> <property name="text">
<string>Start gyro calibration</string> <string>Start dynamic calibration</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -66,7 +80,7 @@ ...@@ -66,7 +80,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="magCalButton"> <widget class="QPushButton" name="magCalButton">
<property name="text"> <property name="text">
<string>Start mag. calibration</string> <string>Start static calibration</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -77,20 +91,6 @@ ...@@ -77,20 +91,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QPushButton" name="accCalButton">
<property name="text">
<string>Start ACC calibration</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="accCalLabel">
<property name="text">
<string>Date unknown</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -113,49 +113,35 @@ ...@@ -113,49 +113,35 @@
<item row="0" column="2" colspan="2"> <item row="0" column="2" colspan="2">
<widget class="QComboBox" name="vehicleComboBox"/> <widget class="QComboBox" name="vehicleComboBox"/>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Component</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QComboBox" name="componentComboBox"/>
</item>
<item row="2" column="0" colspan="4">
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="readParamsButton"> <widget class="QPushButton" name="readParamsButton">
<property name="text"> <property name="text">
<string>Read</string> <string>Read</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="2" column="1" colspan="2">
<widget class="QPushButton" name="writeParamsButton"> <widget class="QPushButton" name="writeParamsButton">
<property name="text"> <property name="text">
<string>Write permanently</string> <string>Write permanently</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="2" column="3">
<widget class="QPushButton" name="backupParamsButton"> <widget class="QPushButton" name="backupParamsButton">
<property name="text"> <property name="text">
<string>Backup</string> <string>Backup</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="4">
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of class MainWindow
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include <QStringList>
#include "ParamTreeItem.h"
ParamTreeItem::ParamTreeItem(const QList<QVariant> &data, ParamTreeItem *parent)
{
parentItem = parent;
itemData = data;
}
ParamTreeItem::~ParamTreeItem()
{
qDeleteAll(childItems);
}
void ParamTreeItem::appendChild(ParamTreeItem *item)
{
childItems.append(item);
}
ParamTreeItem *ParamTreeItem::child(int row)
{
return childItems.value(row);
}
int ParamTreeItem::childCount() const
{
return childItems.count();
}
int ParamTreeItem::columnCount() const
{
return itemData.count();
}
QVariant ParamTreeItem::data(int column) const
{
return itemData.value(column);
}
ParamTreeItem *ParamTreeItem::parent()
{
return parentItem;
}
int ParamTreeItem::row() const
{
if (parentItem)
return parentItem->childItems.indexOf(const_cast<ParamTreeItem*>(this));
return 0;
}
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of class ParamTreeItem
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef PARAMTREEITEM_H
#define PARAMTREEITEM_H
#include <QList>
#include <QVariant>
/**
* @brief One item in the onboard parameter tree
*/
class ParamTreeItem
{
public:
ParamTreeItem(const QList<QVariant> &data, ParamTreeItem *parent = 0);
~ParamTreeItem();
void appendChild(ParamTreeItem *child);
ParamTreeItem *child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
ParamTreeItem *parent();
private:
QList<ParamTreeItem*> childItems;
QList<QVariant> itemData;
ParamTreeItem *parentItem;
};
#endif // PARAMTREEITEM_H
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of class ParamTreeModel
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include <QtGui>
#include "ParamTreeItem.h"
#include "ParamTreeModel.h"
ParamTreeModel::ParamTreeModel(const QString &data, QObject *parent)
: QAbstractItemModel(parent)
{
QList<QVariant> rootData;
rootData << tr("Parameter") << tr("Value");
rootItem = new ParamTreeItem(rootData);
setupModelData(data.split(QString("\n")), rootItem);
}
ParamTreeModel::~ParamTreeModel()
{
delete rootItem;
}
int ParamTreeModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return static_cast<ParamTreeItem*>(parent.internalPointer())->columnCount();
else
return rootItem->columnCount();
}
QVariant ParamTreeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
ParamTreeItem *item = static_cast<ParamTreeItem*>(index.internalPointer());
return item->data(index.column());
}
Qt::ItemFlags ParamTreeModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant ParamTreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return rootItem->data(section);
return QVariant();
}
QModelIndex ParamTreeModel::index(int row, int column, const QModelIndex &parent)
const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
ParamTreeItem *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<ParamTreeItem*>(parent.internalPointer());
ParamTreeItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
else
return QModelIndex();
}
QModelIndex ParamTreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
ParamTreeItem *childItem = static_cast<ParamTreeItem*>(index.internalPointer());
ParamTreeItem *parentItem = childItem->parent();
if (parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
}
int ParamTreeModel::rowCount(const QModelIndex &parent) const
{
ParamTreeItem *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<ParamTreeItem*>(parent.internalPointer());
return parentItem->childCount();
}
void ParamTreeModel::setupModelData(const QStringList &lines, ParamTreeItem *parent)
{
QList<ParamTreeItem*> parents;
QList<int> indentations;
parents << parent;
indentations << 0;
int number = 0;
while (number < lines.count()) {
int position = 0;
while (position < lines[number].length()) {
if (lines[number].mid(position, 1) != " ")
break;
position++;
}
QString lineData = lines[number].mid(position).trimmed();
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
QList<QVariant> columnData;
for (int column = 0; column < columnStrings.count(); ++column)
columnData << columnStrings[column];
if (position > indentations.last()) {
// The last child of the current parent is now the new parent
// unless the current parent has no children.
if (parents.last()->childCount() > 0) {
parents << parents.last()->child(parents.last()->childCount()-1);
indentations << position;
}
} else {
while (position < indentations.last() && parents.count() > 0) {
parents.pop_back();
indentations.pop_back();
}
}