1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge remote-tracking branch 'origin/laurent/OP-1622_Ground_config_tab' into next

This commit is contained in:
Fredrik Larsson 2014-12-03 17:49:09 +11:00
commit 16eec9caed
7 changed files with 1697 additions and 688 deletions

View File

@ -6,15 +6,24 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>880</width> <width>801</width>
<height>608</height> <height>652</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -63,14 +72,19 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_41"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="rightMargin"> <property name="topMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="groupBox_7"> <widget class="QGroupBox" name="groupBox_7">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -81,110 +95,50 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title"> <property name="title">
<string>Output channel assignments</string> <string>Output channel assignments</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_5"> <layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0"> <property name="fieldGrowthPolicy">
<widget class="QLabel" name="gvEngineLabel"> <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<property name="minimumSize">
<size>
<width>77</width>
<height>0</height>
</size>
</property> </property>
<property name="text">
<string>Engine</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="gvEngineChannelBox">
<property name="toolTip">
<string>Select output channel for the engine</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="gvAileron1Label">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Aileron 1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="gvAileron1ChannelBox">
<property name="toolTip">
<string>Select output channel for the first aileron (or elevon)</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="gvAileron2Label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Aileron 2</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="gvAileron2ChannelBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select output channel for the second aileron (or elevon)</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="gvMotor1Label"> <widget class="QLabel" name="gvMotor1Label">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>60</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Motor</string> <string>Motor 1</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="gvMotor1ChannelBox"> <widget class="QComboBox" name="gvMotor1ChannelBox">
<property name="toolTip"> <property name="toolTip">
<string>Select output channel for the first motor</string> <string>Select output channel for the first motor</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="3" column="0">
<widget class="QLabel" name="gvMotor2Label"> <widget class="QLabel" name="gvMotor2Label">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>47</width> <width>60</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -193,7 +147,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="gvMotor2ChannelBox"> <widget class="QComboBox" name="gvMotor2ChannelBox">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -203,28 +157,40 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="4" column="0">
<widget class="QLabel" name="gvSteering1Label"> <widget class="QLabel" name="gvSteering1Label">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Front Steering</string> <string>Front Steering</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QComboBox" name="gvSteering1ChannelBox"> <widget class="QComboBox" name="gvSteering1ChannelBox">
<property name="toolTip"> <property name="toolTip">
<string>Select output channel for the first steering actuator</string> <string>Select output channel for the first steering actuator</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="5" column="0">
<widget class="QLabel" name="gvSteering2Label"> <widget class="QLabel" name="gvSteering2Label">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Rear Steering</string> <string>Rear Steering</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="5" column="1">
<widget class="QComboBox" name="gvSteering2ChannelBox"> <widget class="QComboBox" name="gvSteering2ChannelBox">
<property name="toolTip"> <property name="toolTip">
<string>Select output channel for a second steering actuator</string> <string>Select output channel for a second steering actuator</string>
@ -240,7 +206,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -376,14 +342,94 @@ margin:1px;</string>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groundframeBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Vehicle frame</string>
</property>
<layout class="QVBoxLayout" name="vehicleframeBox">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QGraphicsView" name="groundShape">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:transparent</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QGroupBox" name="gvThrottleCurve1GroupBox"> <widget class="QGroupBox" name="gvThrottleCurve1GroupBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>100</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize">
<size>
<width>280</width>
<height>280</height>
</size>
</property>
<property name="title"> <property name="title">
<string>Front throttle curve</string> <string>Front throttle curve</string>
</property> </property>
@ -391,7 +437,7 @@ margin:1px;</string>
<item> <item>
<widget class="MixerCurve" name="groundVehicleThrottle1" native="true"> <widget class="MixerCurve" name="groundVehicleThrottle1" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -425,14 +471,36 @@ margin:1px;</string>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="gvThrottleCurve2GroupBox"> <widget class="QGroupBox" name="gvThrottleCurve2GroupBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize">
<size>
<width>280</width>
<height>280</height>
</size>
</property>
<property name="title"> <property name="title">
<string>Rear throttle curve</string> <string>Rear throttle curve</string>
</property> </property>
@ -440,7 +508,7 @@ margin:1px;</string>
<item> <item>
<widget class="MixerCurve" name="groundVehicleThrottle2" native="true"> <widget class="MixerCurve" name="groundVehicleThrottle2" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -476,18 +544,17 @@ margin:1px;</string>
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer"> <layout class="QGridLayout" name="gridLayout">
<property name="orientation"> <property name="sizeConstraint">
<enum>Qt::Vertical</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="rightMargin">
<size> <number>0</number>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_28"> <layout class="QHBoxLayout" name="horizontalLayout_28">

View File

@ -236,9 +236,11 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
} }
double Throttle2CurveMin = m_aircraft->customThrottle2Curve->getMin();
if (MixerSettings * mxr = qobject_cast<MixerSettings *>(mixer)) { if (MixerSettings * mxr = qobject_cast<MixerSettings *>(mixer)) {
MixerSettings::DataFields mixerSettingsData = mxr->getData(); MixerSettings::DataFields mixerSettingsData = mxr->getData();
if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) { if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE && Throttle2CurveMin >= 0 ) {
m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
} else { } else {
m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);

View File

@ -79,6 +79,9 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
m_aircraft->groundVehicleType->addItems(groundVehicleTypes); m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
m_aircraft->groundShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_aircraft->groundShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// Set default model to "Turnable (car)" // Set default model to "Turnable (car)"
connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)")); m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
@ -97,51 +100,93 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
{ {
// Setup the UI // Setup the UI
m_aircraft->gvEngineChannelBox->setEnabled(false); Q_ASSERT(m_aircraft);
m_aircraft->gvAileron1ChannelBox->setEnabled(false); QSvgRenderer *renderer = new QSvgRenderer();
m_aircraft->gvAileron2ChannelBox->setEnabled(false); renderer->load(QString(":/configgadget/images/ground-shapes.svg"));
m_vehicleImg = new QGraphicsSvgItem();
m_vehicleImg->setSharedRenderer(renderer);
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
Q_ASSERT(system);
QPointer<UAVObjectField> frameTypeSaved = system->getField(QString("AirframeType"));
m_aircraft->differentialSteeringSlider1->setEnabled(false); m_aircraft->differentialSteeringSlider1->setEnabled(false);
m_aircraft->differentialSteeringSlider2->setEnabled(false); m_aircraft->differentialSteeringSlider2->setEnabled(false);
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true);
m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true);
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") { if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") {
// Tank // Tank
m_vehicleImg->setElementId("tank");
setComboCurrentIndex(m_aircraft->groundVehicleType, setComboCurrentIndex(m_aircraft->groundVehicleType,
m_aircraft->groundVehicleType->findText("Differential (tank)")); m_aircraft->groundVehicleType->findText("Differential (tank)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1ChannelBox->setEnabled(true);
m_aircraft->gvMotor2ChannelBox->setEnabled(true); m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(false);
m_aircraft->gvMotor1Label->setText("Left motor"); m_aircraft->gvMotor1Label->setText("Left motor");
m_aircraft->gvMotor2Label->setText("Right motor"); m_aircraft->gvMotor2Label->setText("Right motor");
m_aircraft->gvSteering1ChannelBox->setEnabled(false); m_aircraft->gvSteering1ChannelBox->setEnabled(false);
m_aircraft->gvSteering2ChannelBox->setEnabled(false); m_aircraft->gvSteering2ChannelBox->setEnabled(false);
m_aircraft->gvSteering1Label->setText("Front steering");
m_aircraft->gvSteering2Label->setText("Rear steering"); m_aircraft->gvSteering2Label->setText("Rear steering");
m_aircraft->differentialSteeringSlider1->setEnabled(true); m_aircraft->differentialSteeringSlider1->setEnabled(true);
m_aircraft->differentialSteeringSlider2->setEnabled(true); m_aircraft->differentialSteeringSlider2->setEnabled(true);
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve"); m_aircraft->gvThrottleCurve1GroupBox->setTitle("");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("Throttle curve");
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH);
m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
initMixerCurves(frameType);
// If new setup, set sliders to defaults and set curves values
// Allow forward/reverse 0.8 / -0.8 for Throttle, keep some room
// to allow rotate at full throttle and heading stabilization
if (frameTypeSaved->getValue().toString() != "GroundVehicleDifferential") {
m_aircraft->differentialSteeringSlider1->setValue(100);
m_aircraft->differentialSteeringSlider2->setValue(100);
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0);
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 0.8, -0.8);
}
} else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { } else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") {
// Motorcycle // Motorcycle
m_vehicleImg->setElementId("motorbike");
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle")); setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle"));
m_aircraft->gvMotor1ChannelBox->setEnabled(false); m_aircraft->gvMotor1ChannelBox->setEnabled(false);
m_aircraft->gvMotor2ChannelBox->setEnabled(true); m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(false);
m_aircraft->gvMotor1Label->setText("Front motor");
m_aircraft->gvMotor2Label->setText("Rear motor"); m_aircraft->gvMotor2Label->setText("Rear motor");
m_aircraft->gvSteering1ChannelBox->setEnabled(true); m_aircraft->gvSteering1ChannelBox->setEnabled(true);
m_aircraft->gvSteering2ChannelBox->setEnabled(true); m_aircraft->gvSteering2ChannelBox->setEnabled(true);
m_aircraft->gvSteering1Label->setText("Front steering");
m_aircraft->gvSteering2Label->setText("Balancing"); m_aircraft->gvSteering2Label->setText("Balancing");
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
// Curve range 0 -> +1 (no reverse)
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
initMixerCurves(frameType);
// If new setup, set curves values
if (frameTypeSaved->getValue().toString() != "GroundVehicleMotorCycle") {
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0);
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0);
}
} else { } else {
// Car // Car
m_vehicleImg->setElementId("car");
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)")); setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1ChannelBox->setEnabled(true);
@ -153,11 +198,32 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvSteering1ChannelBox->setEnabled(true); m_aircraft->gvSteering1ChannelBox->setEnabled(true);
m_aircraft->gvSteering2ChannelBox->setEnabled(true); m_aircraft->gvSteering2ChannelBox->setEnabled(true);
m_aircraft->gvSteering1Label->setText("Front steering");
m_aircraft->gvSteering2Label->setText("Rear steering");
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
initMixerCurves(frameType);
// If new setup, set curves values
if (frameTypeSaved->getValue().toString() != "GroundVehicleCar") {
// Curve range 0 -> +1 (no reverse)
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0);
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0);
} }
} }
QGraphicsScene *scene = new QGraphicsScene();
scene->addItem(m_vehicleImg);
scene->setSceneRect(m_vehicleImg->boundingRect());
m_aircraft->groundShape->fitInView(m_vehicleImg, Qt::KeepAspectRatio);
m_aircraft->groundShape->setScene(scene);
}
void ConfigGroundVehicleWidget::enableControls(bool enable) void ConfigGroundVehicleWidget::enableControls(bool enable)
{ {
ConfigTaskWidget::enableControls(enable); ConfigTaskWidget::enableControls(enable);
@ -174,9 +240,6 @@ void ConfigGroundVehicleWidget::registerWidgets(ConfigTaskWidget &parent)
parent.addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget()); parent.addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget());
parent.addWidget(m_aircraft->groundVehicleThrottle2); parent.addWidget(m_aircraft->groundVehicleThrottle2);
parent.addWidget(m_aircraft->groundVehicleType); parent.addWidget(m_aircraft->groundVehicleType);
parent.addWidget(m_aircraft->gvEngineChannelBox);
parent.addWidget(m_aircraft->gvAileron1ChannelBox);
parent.addWidget(m_aircraft->gvAileron2ChannelBox);
parent.addWidget(m_aircraft->gvMotor1ChannelBox); parent.addWidget(m_aircraft->gvMotor1ChannelBox);
parent.addWidget(m_aircraft->gvMotor2ChannelBox); parent.addWidget(m_aircraft->gvMotor2ChannelBox);
parent.addWidget(m_aircraft->gvSteering1ChannelBox); parent.addWidget(m_aircraft->gvSteering1ChannelBox);
@ -198,9 +261,45 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
{ {
setupUI(frameType); setupUI(frameType);
initMixerCurves(frameType);
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings"))); UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer); Q_ASSERT(mixer);
GUIConfigDataUnion config = getConfigData();
// THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
// Retrieve channel setup values
setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1);
setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2);
setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1);
setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2);
if (frameType == "GroundVehicleDifferential") {
// Find the channel number for Motor1
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// If for some reason the actuators were incoherent, we might fail here, hence the check.
m_aircraft->differentialSteeringSlider1->setValue(
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) / 1.27);
}
channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1;
if (channel > -1) {
m_aircraft->differentialSteeringSlider2->setValue(
-getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) / 1.27);
}
}
}
/**
Virtual function to update curve values from board
*/
void ConfigGroundVehicleWidget::initMixerCurves(QString frameType)
{
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
QList<double> curveValues; QList<double> curveValues;
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
@ -218,46 +317,13 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
if (isValidThrottleCurve(&curveValues)) { if (isValidThrottleCurve(&curveValues)) {
m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
} else {
// no, init a straight curve
if (frameType == "GroundVehicleDifferential") {
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 0.8, -0.8);
} else { } else {
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
} }
GUIConfigDataUnion config = getConfigData();
// THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
// Retrieve channel setup values
setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1);
setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2);
setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1);
setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2);
if (frameType == "GroundVehicleDifferential") {
// CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE
// If the vehicle type is "differential", restore the slider setting
// Find the channel number for Motor1
// obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
// Q_ASSERT(obj);
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// If for some reason the actuators were incoherent, we might fail here, hence the check.
m_aircraft->differentialSteeringSlider1->setValue(
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
m_aircraft->differentialSteeringSlider2->setValue(
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
}
} else if (frameType == "GroundVehicleMotorcycle") {
// CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
// obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
// Q_ASSERT(obj);
// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
// if (chMixerNumber >=0) {
// field = obj->getField(mixerVectors.at(chMixerNumber));
// int ti = field->getElementNames().indexOf("Yaw");
// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100);
//
// ti = field->getElementNames().indexOf("Pitch");
// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100);
// }
} }
} }
@ -285,7 +351,7 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
} else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
airframeType = "GroundVehicleDifferential"; airframeType = "GroundVehicleDifferential";
setupGroundVehicleDifferential(airframeType); setupGroundVehicleDifferential(airframeType);
} else { // "Motorcycle" } else {
airframeType = "GroundVehicleMotorcycle"; airframeType = "GroundVehicleMotorcycle";
setupGroundVehicleMotorcycle(airframeType); setupGroundVehicleMotorcycle(airframeType);
} }
@ -310,8 +376,9 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
GUIConfigDataUnion config = getConfigData(); GUIConfigDataUnion config = getConfigData();
resetActuators(&config); resetActuators(&config);
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex();
config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex();
setConfigData(config); setConfigData(config);
@ -369,17 +436,20 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
Q_ASSERT(mixer); Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer); resetMotorAndServoMixers(mixer);
double yawmotor1 = m_aircraft->differentialSteeringSlider1->value() * 1.27;
double yawmotor2 = m_aircraft->differentialSteeringSlider2->value() * 1.27;
// left motor // left motor
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR); setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yawmotor1);
// right motor // right motor
channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR); setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yawmotor2);
// Output success message // Output success message
m_aircraft->gvStatusLabel->setText("Mixer generated"); m_aircraft->gvStatusLabel->setText("Mixer generated");
@ -446,7 +516,7 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
bool error = false; bool error = false;
// Create a red block. All combo boxes are the same size, so any one should do as a model // Create a red block. All combo boxes are the same size, so any one should do as a model
int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize); int size = m_aircraft->gvMotor1ChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size, size); QPixmap pixmap(size, size);
pixmap.fill(QColor("red")); pixmap.fill(QColor("red"));
@ -454,40 +524,22 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
if (airframeType == "GroundVehicleCar") { // Car if (airframeType == "GroundVehicleCar") { // Car
if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" if (m_aircraft->gvMotor1ChannelBox->currentText() == "None"
&& m_aircraft->gvMotor2ChannelBox->currentText() == "None") { && m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
pixmap.fill(QColor("green"));
m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
// m_aircraft->gvMotor1Label->setText("<font color='red'>" + m_aircraft->gvMotor1Label->text() + "</font>");
// m_aircraft->gvMotor2Label->setText("<font color='red'>" + m_aircraft->gvMotor2Label->text() + "</font>");
error = true; error = true;
} else { } else {
m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags.
// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText());
// delete htmlText;
// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags.
// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText());
} }
if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" if (m_aircraft->gvSteering1ChannelBox->currentText() == "None"
&& m_aircraft->gvSteering2ChannelBox->currentText() == "None") { && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
// m_aircraft->gvStatusLabel->setText("<font color='red'>ERROR: check steering channel assignment</font>");
// m_aircraft->gvSteering1Label->setText("<font color='red'>" + m_aircraft->gvSteering1Label->text() + "</font>");
// m_aircraft->gvSteering2Label->setText("<font color='red'>" + m_aircraft->gvSteering2Label->text() + "</font>");
error = true; error = true;
} else { } else {
m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags.
// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText());
// delete htmlText;
// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags.
// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText());
} }
} else if (airframeType == "GroundVehicleDifferential") { // Tank } else if (airframeType == "GroundVehicleDifferential") { // Tank
if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" if (m_aircraft->gvMotor1ChannelBox->currentText() == "None"
@ -504,8 +556,7 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
} else if (airframeType == "GroundVehicleMotorcycle") { // Motorcycle } else if (airframeType == "GroundVehicleMotorcycle") { // Motorcycle
if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" if (m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
&& m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true; error = true;
} else { } else {
@ -530,3 +581,17 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
} }
return error; return error;
} }
void ConfigGroundVehicleWidget::resizeEvent(QResizeEvent *)
{
if (m_vehicleImg) {
m_aircraft->groundShape->fitInView(m_vehicleImg, Qt::KeepAspectRatio);
}
}
void ConfigGroundVehicleWidget::showEvent(QShowEvent *)
{
if (m_vehicleImg) {
m_aircraft->groundShape->fitInView(m_vehicleImg, Qt::KeepAspectRatio);
}
}

View File

@ -50,13 +50,17 @@ public:
~ConfigGroundVehicleWidget(); ~ConfigGroundVehicleWidget();
virtual void refreshWidgetsValues(QString frameType); virtual void refreshWidgetsValues(QString frameType);
virtual void initMixerCurves(QString frameType);
virtual QString updateConfigObjectsFromWidgets(); virtual QString updateConfigObjectsFromWidgets();
protected: protected:
void enableControls(bool enable); void enableControls(bool enable);
void resizeEvent(QResizeEvent *);
void showEvent(QShowEvent *);
private: private:
Ui_GroundConfigWidget *m_aircraft; Ui_GroundConfigWidget *m_aircraft;
QGraphicsSvgItem *m_vehicleImg;
virtual void registerWidgets(ConfigTaskWidget &parent); virtual void registerWidgets(ConfigTaskWidget &parent);
virtual void resetActuators(GUIConfigDataUnion *configData); virtual void resetActuators(GUIConfigDataUnion *configData);

View File

@ -4,6 +4,7 @@
<file>images/ahrs-calib.svg</file> <file>images/ahrs-calib.svg</file>
<file>images/multirotor-shapes.svg</file> <file>images/multirotor-shapes.svg</file>
<file>images/fixedwing-shapes.svg</file> <file>images/fixedwing-shapes.svg</file>
<file>images/ground-shapes.svg</file>
<file>images/ccpm_setup.svg</file> <file>images/ccpm_setup.svg</file>
<file>images/PipXtreme.png</file> <file>images/PipXtreme.png</file>
<file>images/help.png</file> <file>images/help.png</file>

View File

@ -329,7 +329,7 @@ int ConfigVehicleTypeWidget::frameCategory(QString frameType)
return ConfigVehicleTypeWidget::HELICOPTER; return ConfigVehicleTypeWidget::HELICOPTER;
} else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
|| frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
|| frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { || frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") {
return ConfigVehicleTypeWidget::GROUND; return ConfigVehicleTypeWidget::GROUND;
} else { } else {
return ConfigVehicleTypeWidget::CUSTOM; return ConfigVehicleTypeWidget::CUSTOM;

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 329 KiB