Commit a47b16fb authored by Bryan Godbolt's avatar Bryan Godbolt

laid out all widgets needed for radio calibration window

parent bec9e278
...@@ -76,8 +76,7 @@ FORMS += src/ui/MainWindow.ui \ ...@@ -76,8 +76,7 @@ FORMS += src/ui/MainWindow.ui \
src/ui/QGCPxImuFirmwareUpdate.ui \ src/ui/QGCPxImuFirmwareUpdate.ui \
src/ui/QGCDataPlot2D.ui \ src/ui/QGCDataPlot2D.ui \
src/ui/QGCRemoteControlView.ui \ src/ui/QGCRemoteControlView.ui \
src/ui/WaypointGlobalView.ui \ src/ui/WaypointGlobalView.ui
src/ui/QGCRadioCalibration.ui
INCLUDEPATH += src \ INCLUDEPATH += src \
src/ui \ src/ui \
src/ui/linechart \ src/ui/linechart \
...@@ -162,7 +161,10 @@ HEADERS += src/MG.h \ ...@@ -162,7 +161,10 @@ HEADERS += src/MG.h \
src/ui/QGCRemoteControlView.h \ src/ui/QGCRemoteControlView.h \
src/WaypointGlobal.h \ src/WaypointGlobal.h \
src/ui/WaypointGlobalView.h \ src/ui/WaypointGlobalView.h \
src/ui/RadioCalibration/RadioCalibrationWindow.h src/ui/RadioCalibration/RadioCalibrationWindow.h \
src/ui/RadioCalibration/AirfoilServoCalibrator.h \
src/ui/RadioCalibration/SwitchCalibrator.h \
src/ui/RadioCalibration/CurveCalibrator.h
SOURCES += src/main.cc \ SOURCES += src/main.cc \
src/Core.cc \ src/Core.cc \
src/uas/UASManager.cc \ src/uas/UASManager.cc \
...@@ -229,7 +231,10 @@ SOURCES += src/main.cc \ ...@@ -229,7 +231,10 @@ SOURCES += src/main.cc \
src/ui/QGCRemoteControlView.cc \ src/ui/QGCRemoteControlView.cc \
src/WaypointGlobal.cpp \ src/WaypointGlobal.cpp \
src/ui/WaypointGlobalView.cpp \ src/ui/WaypointGlobalView.cpp \
src/ui/RadioCalibration/RadioCalibrationWindow.cc src/ui/RadioCalibration/RadioCalibrationWindow.cc \
src/ui/RadioCalibration/AirfoilServoCalibrator.cc \
src/ui/RadioCalibration/SwitchCalibrator.cc \
src/ui/RadioCalibration/CurveCalibrator.cc
RESOURCES = mavground.qrc RESOURCES = mavground.qrc
# Include RT-LAB Library # Include RT-LAB Library
......
...@@ -76,7 +76,7 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) : ...@@ -76,7 +76,7 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) :
calibrateButtonLayout->addWidget(calibrate, 0, Qt::AlignHCenter); calibrateButtonLayout->addWidget(calibrate, 0, Qt::AlignHCenter);
layout->addItem(calibrateButtonLayout, 3, 0, 1, 2); layout->addItem(calibrateButtonLayout, 3, 0, 1, 2);
calibrationWindow = new QWidget(this, Qt::Window); calibrationWindow = new RadioCalibrationWindow(this);
connect(calibrate, SIGNAL(clicked()), calibrationWindow, SLOT(show())); connect(calibrate, SIGNAL(clicked()), calibrationWindow, SLOT(show()));
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(setUASId(int))); connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(setUASId(int)));
...@@ -108,6 +108,7 @@ void QGCRemoteControlView::setUASId(int id) ...@@ -108,6 +108,7 @@ void QGCRemoteControlView::setUASId(int id)
// New UAS exists, connect // New UAS exists, connect
nameLabel->setText(QString("RC Input of %1").arg(newUAS->getUASName())); nameLabel->setText(QString("RC Input of %1").arg(newUAS->getUASName()));
connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), this, SLOT(setChannel(int,float,float))); connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), this, SLOT(setChannel(int,float,float)));
connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), calibrationWindow, SLOT(setChannel(int,float,float)));
connect(newUAS, SIGNAL(remoteControlRSSIChanged(float)), this, SLOT(setRemoteRSSI(float))); connect(newUAS, SIGNAL(remoteControlRSSIChanged(float)), this, SLOT(setRemoteRSSI(float)));
} }
} }
......
...@@ -34,6 +34,8 @@ This file is part of the QGROUNDCONTROL project ...@@ -34,6 +34,8 @@ This file is part of the QGROUNDCONTROL project
#include <QVector> #include <QVector>
#include <QPushButton> #include <QPushButton>
#include "RadioCalibration/RadioCalibrationWindow.h"
namespace Ui { namespace Ui {
class QGCRemoteControlView; class QGCRemoteControlView;
} }
...@@ -70,7 +72,7 @@ protected: ...@@ -70,7 +72,7 @@ protected:
QProgressBar* rssiBar; QProgressBar* rssiBar;
QLabel* nameLabel; QLabel* nameLabel;
QPushButton *calibrate; QPushButton *calibrate;
QWidget *calibrationWindow; RadioCalibrationWindow *calibrationWindow;
private: private:
Ui::QGCRemoteControlView *ui; Ui::QGCRemoteControlView *ui;
......
#include "AirfoilServoCalibrator.h"
AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent) :
QWidget(parent)
{
QGridLayout *grid = new QGridLayout(this);
/* Add title */
QHBoxLayout *titleLayout = new QHBoxLayout();
QLabel *title;
if (type == AILERON)
{
title = new QLabel(tr("Aileron"));
}
else if (type == ELEVATOR)
{
title = new QLabel(tr("Elevator"));
}
else if (type == RUDDER)
{
title = new QLabel(tr("Rudder"));
}
titleLayout->addWidget(title);
grid->addLayout(titleLayout, 0, 0, 1, 3, Qt::AlignHCenter);
/* Add current Pulse Width Display */
QLabel *pulseWidthTitle = new QLabel(tr("Pulse Width (us)"));
pulseWidth = new QLabel();
QHBoxLayout *pulseLayout = new QHBoxLayout();
pulseLayout->addWidget(pulseWidthTitle);
pulseLayout->addWidget(pulseWidth);
grid->addLayout(pulseLayout, 1, 0, 1, 3);
this->setLayout(grid);
}
void AirfoilServoCalibrator::channelChanged(float raw)
{
pulseWidth->setText(QString::number(static_cast<double>(raw)));
}
#ifndef AIRFOILSERVOCALIBRATOR_H
#define AIRFOILSERVOCALIBRATOR_H
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVector>
#include <QGridLayout>
#include <QHBoxLayout>
class AirfoilServoCalibrator : public QWidget
{
Q_OBJECT
public:
enum AirfoilType
{
AILERON,
ELEVATOR,
RUDDER
};
explicit AirfoilServoCalibrator(AirfoilType type = AILERON, QWidget *parent = 0);
signals:
void highSetpointChanged(float);
void centerSetpointChanged(float);
void lowSetpointChanged(float);
public slots:
void channelChanged(float raw);
protected:
QLabel *pulseWidth;
QPushButton *highButton;
QPushButton *centerButton;
QPushButton *lowButton;
float high;
float center;
float low;
QVector<float> log;
};
#endif // AIRFOILSERVOCALIBRATOR_H
#include "CurveCalibrator.h"
CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
QWidget(parent),
setpoints(QVector<double>(5)),
positions(QVector<double>())
{
QGridLayout *grid = new QGridLayout(this);
QLabel *title = new QLabel(titleString);
grid->addWidget(title, 0, 0, 1, 5, Qt::AlignHCenter);
QLabel *pulseWidthTitle = new QLabel(tr("Pulse Width (us)"));
pulseWidth = new QLabel();
QHBoxLayout *pulseLayout = new QHBoxLayout();
pulseLayout->addWidget(pulseWidthTitle);
pulseLayout->addWidget(pulseWidth);
grid->addLayout(pulseLayout, 1, 0, 1, 5, Qt::AlignHCenter);
for (int i=0; i<=100; i=i+100/4)
positions.append(static_cast<double>(i));
setpoints.fill(1500);
plot = new QwtPlot();
grid->addWidget(plot, 2, 0, 1, 5, Qt::AlignHCenter);
plot->setAxisScale(QwtPlot::yLeft, 1000, 2000, 200);
curve = new QwtPlotCurve();
curve->setData(positions, setpoints);
curve->attach(plot);
plot->replot();
this->setLayout(grid);
}
void CurveCalibrator::channelChanged(float raw)
{
pulseWidth->setText(QString::number(static_cast<double>(raw)));
}
#ifndef CURVECALIBRATOR_H
#define CURVECALIBRATOR_H
#include <QWidget>
#include <QVector>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
class CurveCalibrator : public QWidget
{
Q_OBJECT
public:
explicit CurveCalibrator(QString title = QString(), QWidget *parent = 0);
signals:
void setpointChanged(float[5]);
public slots:
void channelChanged(float raw);
protected:
QVector<double> setpoints;
QVector<double> positions;
QwtPlot *plot;
QwtPlotCurve *curve;
QLabel *pulseWidth;
};
#endif // CURVECALIBRATOR_H
...@@ -3,4 +3,56 @@ ...@@ -3,4 +3,56 @@
RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) : RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) :
QWidget(parent, Qt::Window) QWidget(parent, Qt::Window)
{ {
QGridLayout *grid = new QGridLayout();
aileron = new AirfoilServoCalibrator(AirfoilServoCalibrator::AILERON);
grid->addWidget(aileron, 0, 0, 1, 1, Qt::AlignTop);
elevator = new AirfoilServoCalibrator(AirfoilServoCalibrator::ELEVATOR);
grid->addWidget(elevator, 0, 1, 1, 1, Qt::AlignTop);
rudder = new AirfoilServoCalibrator(AirfoilServoCalibrator::RUDDER);
grid->addWidget(rudder, 0, 2, 1, 1, Qt::AlignTop);
gyro = new SwitchCalibrator(tr("Gyro Mode/Gain"));
grid->addWidget(gyro, 0, 3, 1, 1, Qt::AlignTop);
pitch = new CurveCalibrator(tr("Collective Pitch"));
grid->addWidget(pitch, 1, 0, 1, 2);
throttle = new CurveCalibrator(tr("Throttle"));
grid->addWidget(throttle, 1, 2, 1, 2);
this->setLayout(grid);
}
void RadioCalibrationWindow::setChannel(int ch, float raw, float normalized)
{
/** this expects a particular channel to function mapping
\todo allow run-time channel mapping
*/
switch (ch)
{
case 0:
aileron->channelChanged(raw);
break;
case 1:
elevator->channelChanged(raw);
break;
case 2:
throttle->channelChanged(raw);
break;
case 3:
rudder->channelChanged(raw);
break;
case 4:
gyro->channelChanged(raw);
break;
case 5:
pitch->channelChanged(raw);
break;
}
} }
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
#include <QGroupBox> #include <QGroupBox>
#include <QPushButton> #include <QPushButton>
#include <QVector> #include <QVector>
#include <QGridLayout>
#include "AirfoilServoCalibrator.h"
#include "SwitchCalibrator.h"
#include "CurveCalibrator.h"
class RadioCalibrationWindow : public QWidget class RadioCalibrationWindow : public QWidget
{ {
...@@ -16,34 +21,15 @@ public: ...@@ -16,34 +21,15 @@ public:
signals: signals:
public slots: public slots:
void setChannel(int ch, float raw, float normalized);
protected: protected:
class AirfoilServoCalibrator : public QWidget AirfoilServoCalibrator *aileron;
{ AirfoilServoCalibrator *elevator;
Q_OBJECT AirfoilServoCalibrator *rudder;
public: SwitchCalibrator *gyro;
explicit AirfoilServoCalibrator(QWidget *parent=0); CurveCalibrator *pitch;
CurveCalibrator *throttle;
signals:
void highSetpointChanged(float);
void centerSetpointChanged(float);
void lowSetpointChanged(float);
public slots:
void channelChanged(float raw);
protected:
QLabel *pulseWidth;
QPushButton *highButton;
QPushButton *centerButton;
QPushButton *lowButton;
float high;
float center;
float low;
QVector<float> log;
};
}; };
......
#include "SwitchCalibrator.h"
SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
QWidget(parent)
{
/* Add title label*/
QLabel *title = new QLabel(titleString);
QGridLayout *grid = new QGridLayout();
grid->addWidget(title, 0, 0, 1, 3);
/* Add current Pulse Width Display */
QLabel *pulseWidthTitle = new QLabel(tr("Pulse Width (us)"));
pulseWidth = new QLabel();
QHBoxLayout *pulseLayout = new QHBoxLayout();
pulseLayout->addWidget(pulseWidthTitle);
pulseLayout->addWidget(pulseWidth);
grid->addLayout(pulseLayout, 1, 0, 1, 3);
this->setLayout(grid);
}
void SwitchCalibrator::channelChanged(float raw)
{
pulseWidth->setText(QString::number(static_cast<double>(raw)));
}
#ifndef SWITCHCALIBRATOR_H
#define SWITCHCALIBRATOR_H
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVector>
#include <QGridLayout>
#include <QHBoxLayout>
class SwitchCalibrator : public QWidget
{
Q_OBJECT
public:
explicit SwitchCalibrator(QString title=QString(), QWidget *parent = 0);
signals:
void defaultSetpointChanged(float);
void toggledSetpointChanged(float);
public slots:
void channelChanged(float raw);
protected:
QLabel *pulseWidth;
QPushButton *defaultButton;
QPushButton *toggledButton;
float defaultPos;
float toggled;
QVector<float> log;
};
#endif // SWITCHCALIBRATOR_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