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

Fixed RC mapping check

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