Commit 4d5aa0df authored by Lorenz Meier's avatar Lorenz Meier

Fixed RC mapping check

parent 1f76bbed
This diff is collapsed.
......@@ -180,6 +180,8 @@
<file>files/images/px4/menu/plane.png</file>
<file>files/images/px4/menu/remote.png</file>
<file>files/images/px4/menu/cogwheels.png</file>
<file>files/images/px4/rc/cessna_back.png</file>
<file>files/images/px4/rc/cessna_side.png</file>
</qresource>
<qresource prefix="/general">
<file alias="vera.ttf">files/styles/Vera.ttf</file>
......
......@@ -60,6 +60,8 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
#ifdef QUPGRADE_SUPPORT
firmwareDialog(NULL),
#endif
planeBack(":/files/images/px4/rc/cessna_back.png"),
planeSide(":/files/images/px4/rc/cessna_side.png"),
ui(new Ui::QGCPX4VehicleConfig)
{
doneLoadingConfig = false;
......@@ -142,6 +144,15 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
connect(ui->advancedCheckBox, SIGNAL(clicked(bool)), ui->advancedGroupBox, SLOT(setVisible(bool)));
ui->advancedGroupBox->setVisible(false);
connect(ui->advancedCheckBox, SIGNAL(clicked(bool)), ui->graphicsView, SLOT(setHidden(bool)));
ui->graphicsView->setScene(&scene);
scene.addPixmap(planeBack);
scene.addPixmap(planeSide);
// XXX hide while WIP
ui->graphicsView->hide();
ui->rcCalibrationButton->setCheckable(true);
connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool)));
......@@ -209,6 +220,7 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
rcMappedMin[i] = 1000;
rcMappedMax[i] = 2000;
rcMappedValue[i] = UINT16_MAX;
rcMappedValueRev[i] = UINT16_MAX;
rcMappedNormalizedValue[i] = 0.0f;
}
......@@ -217,6 +229,7 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
rcMappedMin[i] = 1000;
rcMappedMax[i] = 2000;
rcMappedValue[i] = UINT16_MAX;
rcMappedValueRev[i] = UINT16_MAX;
rcMappedNormalizedValue[i] = 0.0f;
}
......@@ -1184,13 +1197,12 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval)
}
// Raw value
float mappedVal = rcMappedValue[rcToFunctionMapping[chan]];
float deltaRaw = fabsf(fval - rcValue[chan]);
float delta = fabsf(fval - mappedVal);
float delta = fabsf(fval - rcMappedValue[rcToFunctionMapping[chan]]);
if (!configEnabled && !calibrationEnabled &&
(deltaRaw < 12.0f && delta < 12.0f && rcValue[chan] > 800 && rcValue[chan] < 2200))
{
//ignore tiny jitter values
// ignore tiny jitter values
return;
}
else {
......@@ -1281,17 +1293,13 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval)
normalized = (rcRev[chan]) ? -1.0f*normalized : normalized;
// Find correct mapped channel
for (unsigned int i = 0; i < chanCount; i++) {
if (chan == rcMapping[i]) {
rcMappedValue[i] = (rcRev[chan]) ? rcMax[chan] - (fval - rcMin[chan]) : fval;
rcMappedValueRev[rcToFunctionMapping[chan]] = (rcRev[chan]) ? rcMax[chan] - (fval - rcMin[chan]) : fval;
rcMappedValue[rcToFunctionMapping[chan]] = fval;
// Copy min / max
rcMappedMin[i] = rcMin[chan];
rcMappedMax[i] = rcMax[chan];
rcMappedNormalizedValue[i] = normalized;
}
}
// Copy min / max
rcMappedMin[rcToFunctionMapping[chan]] = rcMin[chan];
rcMappedMax[rcToFunctionMapping[chan]] = rcMax[chan];
rcMappedNormalizedValue[rcToFunctionMapping[chan]] = normalized;
if (chan == rcMapping[0]) {
rcRoll = normalized;
......
......@@ -8,6 +8,7 @@
#include <QPushButton>
#include <QStringList>
#include <QMessageBox>
#include <QGraphicsScene>
#include "QGCToolWidget.h"
#include "UASInterface.h"
......@@ -285,10 +286,11 @@ protected:
float rcScaling[chanMax]; ///< Scaling of channel input to control commands
bool rcRev[chanMax]; ///< Channel reverse
int rcValue[chanMax]; ///< Last values, RAW
float rcValueReversed[chanMax]; ///< Last values, accounted for reverse
float rcMappedMin[chanMappedMax]; ///< Mapped channels in default order
float rcMappedMax[chanMappedMax]; ///< Mapped channels in default order
float rcMappedValue[chanMappedMax]; ///< Mapped channels in default order
int rcValueReversed[chanMax]; ///< Last values, accounted for reverse
int rcMappedMin[chanMappedMax]; ///< Mapped channels in default order
int rcMappedMax[chanMappedMax]; ///< Mapped channels in default order
int rcMappedValue[chanMappedMax]; ///< Mapped channels in default order
int rcMappedValueRev[chanMappedMax];
float rcMappedNormalizedValue[chanMappedMax]; ///< Mapped channels in default order
int channelWanted; ///< During channel assignment search the requested default index
int channelReverseStateWanted;
......@@ -323,8 +325,11 @@ protected:
QGCPX4AirframeConfig* px4AirframeConfig;
DialogBare* firmwareDialog;
QPixmap planeBack;
QPixmap planeSide;
QGCPX4SensorCalibration* px4SensorCalibration;
QMessageBox msgBox;
QGraphicsScene scene;
QPushButton* skipActionButton;
private:
......
......@@ -42,7 +42,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="firmwareTab">
<layout class="QVBoxLayout" name="firmwareLayout"/>
......@@ -205,6 +205,9 @@
</property>
</widget>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item>
<widget class="QGroupBox" name="advancedGroupBox">
<property name="title">
......@@ -819,8 +822,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>21</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
......@@ -856,8 +859,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>21</width>
<height>16</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
......@@ -907,8 +910,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>16</width>
<height>16</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
......
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