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
# prefer version from external directory /
# from http://github.com/pixhawk/qmapcontrol/
# over bundled version in lib directory
# Version from GIT repository is preferred
#include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary
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")
#}
# include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary
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")
# }
# Include general settings for MAVGround
# necessary as last include to override any non-acceptable settings
# done by the plugins above
include(qgroundcontrol.pri)
# QWT plot and QExtSerial depend on paths set by qgroundcontrol.pri
# Include serial port library
include(src/lib/qextserialport/qextserialport.pri)
# Include QWT plotting library
include(src/lib/qwt/qwt.pri)
DEPENDPATH += . \
lib/QMapControl \
lib/QMapControl/src
......@@ -64,7 +59,8 @@ INCLUDEPATH += src \
include/ui \
src/input \
src/lib/qmapcontrol \
src/ui/mavlink
src/ui/mavlink \
src/ui/param
HEADERS += src/MG.h \
src/Core.h \
src/uas/UASInterface.h \
......@@ -114,7 +110,9 @@ HEADERS += src/MG.h \
src/ui/MAVLinkSettingsWidget.h \
src/ui/AudioOutputWidget.h \
src/GAudioOutput.h \
src/LogCompressor.h
src/LogCompressor.h \
src/ui/param/ParamTreeItem.h \
src/ui/param/ParamTreeModel.h
SOURCES += src/main.cc \
src/Core.cc \
src/uas/UASManager.cc \
......@@ -159,5 +157,7 @@ SOURCES += src/main.cc \
src/ui/MAVLinkSettingsWidget.cc \
src/ui/AudioOutputWidget.cc \
src/GAudioOutput.cc \
src/LogCompressor.cc
src/LogCompressor.cc \
src/ui/param/ParamTreeItem.cc \
src/ui/param/ParamTreeModel.cc
RESOURCES = mavground.qrc
......@@ -78,8 +78,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QWidget *parent) :
this->setMinimumWidth(100);
// Refresh timer
refreshTimer->setInterval(100);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(update()));
refreshTimer->setInterval(150); // 200 Hz/5 ms
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(triggerUpdate()));
//connect(refreshTimer, SIGNAL(timeout()), this, SLOT(paintGL()));
fontDatabase = QFontDatabase();
......@@ -101,11 +101,18 @@ HDDisplay::~HDDisplay()
delete m_ui;
}
void HDDisplay::triggerUpdate()
{
// Only repaint the regions necessary
QRect r = geometry();
update(r);
}
void HDDisplay::paintEvent(QPaintEvent * event)
{
//paintGL();
static quint64 interval = 0;
//qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
interval = MG::TIME::getGroundTimeNow();
paintDisplay();
}
......
......@@ -59,9 +59,10 @@ public slots:
void stop();
void setActiveUAS(UASInterface* uas);
protected slots:
protected slots:
void paintGL();
void paintDisplay();
void triggerUpdate();
protected:
void changeEvent(QEvent *e);
......
......@@ -23,7 +23,7 @@ This file is part of the PIXHAWK project
/**
* @file
* @brief Implementation of main application window
* @brief Implementation of class MainWindow
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
......@@ -208,8 +208,9 @@ void MainWindow::startVideoCapture()
.arg(format));
delete videoTimer;
videoTimer = new QTimer(this);
videoTimer->setInterval(40);
connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
//videoTimer->setInterval(40);
//connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
//videoTimer->stop();
}
void MainWindow::stopVideoCapture()
......@@ -391,7 +392,6 @@ void MainWindow::loadPilotView()
headDown1->start();
headDown2->start();
this->show();
}
......
#include <QTreeWidget>
#include "ParameterInterface.h"
#include "ParamTreeModel.h"
#include "UASManager.h"
#include "ui_ParameterInterface.h"
......@@ -8,6 +11,19 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
{
m_ui->setupUi(this);
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()
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>349</width>
<width>350</width>
<height>545</height>
</rect>
</property>
......@@ -17,7 +17,7 @@
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Extended Output</string>
<string>Activate Extended Output</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
......@@ -37,13 +37,27 @@
</property>
</widget>
</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>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Calibration</string>
<string>Calibration Wizards</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
......@@ -52,7 +66,7 @@
<item row="0" column="0">
<widget class="QPushButton" name="gyroCalButton">
<property name="text">
<string>Start gyro calibration</string>
<string>Start dynamic calibration</string>
</property>
</widget>
</item>
......@@ -66,7 +80,7 @@
<item row="1" column="0">
<widget class="QPushButton" name="magCalButton">
<property name="text">
<string>Start mag. calibration</string>
<string>Start static calibration</string>
</property>
</widget>
</item>
......@@ -77,20 +91,6 @@
</property>
</widget>
</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>
</widget>
</item>
......@@ -113,49 +113,35 @@
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="vehicleComboBox"/>
</item>
<item row="1" column="0" colspan="2">
<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">
<item row="2" column="0">
<widget class="QPushButton" name="readParamsButton">
<property name="text">
<string>Read</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="writeParamsButton">
<property name="text">
<string>Write permanently</string>
</property>
</widget>
</item>
<item row="3" column="3">
<item row="2" column="3">
<widget class="QPushButton" name="backupParamsButton">
<property name="text">
<string>Backup</string>
</property>
</widget>
</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>
</widget>
</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();
}
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new ParamTreeItem(columnData, parents.last()));
}
number++;
}
}
/*=====================================================================
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 ParamParamTreeModel
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef PARAMTREEMODEL_H
#define PARAMTREEMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
class ParamTreeItem;
class ParamTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
ParamTreeModel(const QString &data, QObject *parent = 0);
~ParamTreeModel();
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
private:
void setupModelData(const QStringList &lines, ParamTreeItem *parent);
ParamTreeItem *rootItem;
};
#endif // PARAMParamTreeModel_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