From 1bff0f479cdc99b64204221414fdbb33d390dfe4 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Mon, 19 Dec 2016 14:23:06 +0100 Subject: [PATCH 1/7] LP-454 Add boat and differential boat to the ground tab --- flight/libraries/sanitycheck.c | 2 + .../configgroundvehiclewidget.cpp | 88 +- .../configgroundvehiclewidget.h | 4 +- .../src/plugins/config/configinputwidget.cpp | 20 +- .../config/configvehicletypewidget.cpp | 8 +- .../plugins/config/images/ground-shapes.svg | 1548 ++++++++++++----- ground/gcs/src/share/qml/js/uav.js | 2 +- shared/uavobjectdefinition/systemsettings.xml | 2 +- 8 files changed, 1248 insertions(+), 426 deletions(-) diff --git a/flight/libraries/sanitycheck.c b/flight/libraries/sanitycheck.c index dff5572fb..08d8a67d2 100644 --- a/flight/libraries/sanitycheck.c +++ b/flight/libraries/sanitycheck.c @@ -364,6 +364,8 @@ FrameType_t GetCurrentFrameType() case SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLECAR: case SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: case SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + case SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEBOAT: + case SYSTEMSETTINGS_AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIALBOAT: return FRAME_TYPE_GROUND; case SYSTEMSETTINGS_AIRFRAMETYPE_VTOL: diff --git a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index e2e0099fb..7d2fb783e 100644 --- a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -1,9 +1,9 @@ /** ****************************************************************************** * - * @file configgroundvehiclemwidget.cpp - * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. - * @author K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @file configgroundvehiclewidget.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2016. + * K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin @@ -81,7 +81,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : populateChannelComboBoxes(); QStringList groundVehicleTypes; - groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; + groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle" << "Boat" << "Differential (boat)"; m_aircraft->groundVehicleType->addItems(groundVehicleTypes); m_aircraft->groundShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -126,12 +126,58 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) initMixerCurves(frameType); + if (frameType == "GroundVehicleBoat" || frameType == "Boat") { + // Boat + m_vehicleImg->setElementId("boat"); + setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Boat")); + + m_aircraft->gvMotor1ChannelBox->setEnabled(true); + m_aircraft->gvMotor2ChannelBox->setEnabled(true); + + m_aircraft->gvMotor1Label->setText("First motor"); + m_aircraft->gvMotor2Label->setText("Second motor"); + + m_aircraft->gvSteering1ChannelBox->setEnabled(true); + m_aircraft->gvSteering2ChannelBox->setEnabled(true); + + m_aircraft->gvSteering1Label->setText("First rudder"); + m_aircraft->gvSteering2Label->setText("Second rudder"); + + m_aircraft->gvThrottleCurve2GroupBox->setTitle("Throttle curve2"); + m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true); + m_aircraft->gvThrottleCurve1GroupBox->setTitle("Throttle curve1"); + m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true); + + m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH); + m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); + + initMixerCurves(frameType); + + // If new setup, set curves values + if (frameTypeSaved->getValue().toString() != "GroundVehicleBoat") { + m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0, 0.0); + m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0, 0.0); + } + } else if ((frameType == "GroundVehicleDifferential") || (frameType == "Differential (tank)") || + (frameType == "GroundVehicleDifferentialBoat") || (frameType == "Differential (boat)")) { + bool is_Boat = frameType.contains("oat"); + + if (is_Boat) { + // Boat differential + m_vehicleImg->setElementId("boat_diff"); + setComboCurrentIndex(m_aircraft->groundVehicleType, + m_aircraft->groundVehicleType->findText("Differential (boat)")); + m_aircraft->gvSteering1Label->setText("First rudder"); + m_aircraft->gvSteering2Label->setText("Second rudder"); + } else { + // Tank + m_vehicleImg->setElementId("tank"); + setComboCurrentIndex(m_aircraft->groundVehicleType, + m_aircraft->groundVehicleType->findText("Differential (tank)")); + m_aircraft->gvSteering1Label->setText("Front steering"); + m_aircraft->gvSteering2Label->setText("Rear steering"); + } - if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") { - // Tank - m_vehicleImg->setElementId("tank"); - setComboCurrentIndex(m_aircraft->groundVehicleType, - m_aircraft->groundVehicleType->findText("Differential (tank)")); m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor2ChannelBox->setEnabled(true); @@ -143,9 +189,6 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) m_aircraft->gvSteering1ChannelBox->setEnabled(false); m_aircraft->gvSteering2ChannelBox->setEnabled(false); - m_aircraft->gvSteering1Label->setText("Front steering"); - m_aircraft->gvSteering2Label->setText("Rear steering"); - m_aircraft->differentialSteeringSlider1->setEnabled(true); m_aircraft->differentialSteeringSlider2->setEnabled(true); @@ -158,7 +201,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) initMixerCurves(frameType); // If new setup, set sliders to defaults and set curves values - if (frameTypeSaved->getValue().toString() != "GroundVehicleDifferential") { + if ((!is_Boat && (frameTypeSaved->getValue().toString() != "GroundVehicleDifferential")) || + (is_Boat && (frameTypeSaved->getValue().toString() != "GroundVehicleDifferentialBoat"))) { m_aircraft->differentialSteeringSlider1->setValue(100); m_aircraft->differentialSteeringSlider2->setValue(100); m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0, 0.0); @@ -288,7 +332,7 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1); setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2); - if (frameType == "GroundVehicleDifferential") { + if (frameType.contains("GroundVehicleDifferential")) { // Find the channel number for Motor1 int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; if (channel > -1) { @@ -322,7 +366,7 @@ void ConfigGroundVehicleWidget::initMixerCurves(QString frameType) m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); } else { // no, init a straight curve - if (frameType == "GroundVehicleDifferential") { + if (frameType.contains("GroundVehicleDifferential")) { m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 0.8, 0.0); } else if (frameType == "GroundVehicleCar") { m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0, 0.0); @@ -338,7 +382,7 @@ void ConfigGroundVehicleWidget::initMixerCurves(QString frameType) m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); } else { // no, init a straight curve - if (frameType == "GroundVehicleDifferential") { + if (frameType.contains("GroundVehicleDifferential")) { m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 0.8, 0.0); } else if (frameType == "GroundVehicleCar") { m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0, 0.0); @@ -363,7 +407,13 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve()); // All airframe types must start with "GroundVehicle" - if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { + if (m_aircraft->groundVehicleType->currentText() == "Differential (boat)") { + airframeType = "GroundVehicleDifferentialBoat"; + setupGroundVehicleDifferential(airframeType); + } else if (m_aircraft->groundVehicleType->currentText() == "Boat") { + airframeType = "GroundVehicleBoat"; + setupGroundVehicleCar(airframeType); + } else if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { airframeType = "GroundVehicleCar"; setupGroundVehicleCar(airframeType); } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { @@ -539,7 +589,7 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType) pixmap.fill(QColor("red")); - if (airframeType == "GroundVehicleCar") { // Car + if ((airframeType == "GroundVehicleCar") || (airframeType == "GroundVehicleBoat")) { // Car if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None") { m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes @@ -559,7 +609,7 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType) m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes } - } else if (airframeType == "GroundVehicleDifferential") { // Tank + } else if (airframeType.contains("GroundVehicleDifferential")) { // Tank and differential Boat if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" || m_aircraft->gvMotor2ChannelBox->currentText() == "None") { m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes diff --git a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index b9216665b..5da8e9ae8 100644 --- a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -2,7 +2,8 @@ ****************************************************************************** * * @file configgroundvehiclewidget.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2016. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin @@ -67,6 +68,7 @@ private: bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType); bool setupGroundVehicleMotorcycle(QString airframeType); + bool setupGroundVehicleBoat(QString airframeType); private slots: virtual void setupUI(QString airframeType); diff --git a/ground/gcs/src/plugins/config/configinputwidget.cpp b/ground/gcs/src/plugins/config/configinputwidget.cpp index d0e77a50c..9df7c0906 100644 --- a/ground/gcs/src/plugins/config/configinputwidget.cpp +++ b/ground/gcs/src/plugins/config/configinputwidget.cpp @@ -882,10 +882,18 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step) transmitterType = acro; } else if (wizardUi->typeGround->isChecked()) { transmitterType = ground; - /* Make sure to tell controller, this is really a ground vehicle. */ + systemSettingsData = systemSettingsObj->getData(); - systemSettingsData.AirframeType = SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR; - systemSettingsObj->setData(systemSettingsData); + /* Make sure to tell controller, this is really a ground vehicle. */ + if ((systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR) || + (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL) || + (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE) || + (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEBOAT) || + (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIALBOAT)) { + // Apply default ground vehicle airframe + systemSettingsData.AirframeType = SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR; + systemSettingsObj->setData(systemSettingsData); + } } else { transmitterType = heli; } @@ -1990,7 +1998,11 @@ void ConfigInputWidget::simpleCalibration(bool enable) manualSettingsData = manualSettingsObj->getData(); systemSettingsData = systemSettingsObj->getData(); - if (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR) { + if ((systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR) || + (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL) || + (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE) || + (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEBOAT) || + (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIALBOAT)) { QMessageBox::warning(this, tr("Ground Vehicle"), tr("

Please center throttle control and press OK when ready.

")); diff --git a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp index 69ec26829..a4ccc9b21 100644 --- a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file configvehicletypewidget.cpp - * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2016. * E. Lafargue, K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012 * @addtogroup GCSPlugins GCS Plugins * @{ @@ -99,6 +99,8 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEBOAT: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIALBOAT: // ground channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions(); break; @@ -284,7 +286,9 @@ int ConfigVehicleTypeWidget::frameCategory(QString frameType) return ConfigVehicleTypeWidget::HELICOPTER; } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" - || frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { + || frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle" + || frameType == "GroundVehicleBoat" || frameType == "Boat" + || frameType == "GroundVehicleDifferentialBoat" || frameType == "Differential (boat)") { return ConfigVehicleTypeWidget::GROUND; } else { return ConfigVehicleTypeWidget::CUSTOM; diff --git a/ground/gcs/src/plugins/config/images/ground-shapes.svg b/ground/gcs/src/plugins/config/images/ground-shapes.svg index 730da9a62..d1efcd420 100644 --- a/ground/gcs/src/plugins/config/images/ground-shapes.svg +++ b/ground/gcs/src/plugins/config/images/ground-shapes.svg @@ -14,9 +14,9 @@ id="Layer_1" x="0px" y="0px" - width="665.06097" - height="2346.0632" - viewBox="0 0 665.06097 2346.0632" + width="804.33447" + height="3250.895" + viewBox="0 0 804.33447 3250.895" enable-background="new 0 0 792 1008" xml:space="preserve" inkscape:version="0.91 r13725" @@ -26,7 +26,7 @@ inkscape:export-ydpi="70.479134">image/svg+xml \ No newline at end of file diff --git a/ground/gcs/src/share/qml/js/uav.js b/ground/gcs/src/share/qml/js/uav.js index 967c5f8c7..789a9f52f 100644 --- a/ground/gcs/src/share/qml/js/uav.js +++ b/ground/gcs/src/share/qml/js/uav.js @@ -155,7 +155,7 @@ function isCC3D() { function frameType() { var frameTypeText = ["FixedWing", "FixedWingElevon", "FixedWingVtail", "VTOL", "HeliCP", "QuadX", "QuadP", "Hexa+", "Octo+", "Custom", "HexaX", "HexaH", "OctoV", "OctoCoaxP", "OctoCoaxX", "OctoX", "HexaCoax", - "Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"]; + "Tricopter", "GroundCar", "GroundDiff", "GroundMoto", "GroundBoat", "GroundDiffBoat"]; if (frameTypeText.length != SystemSettings.SystemSettingsConstants.AirframeTypeCount) { console.log("uav.js: frameType() do not match systemSettings.airframeType uavo"); diff --git a/shared/uavobjectdefinition/systemsettings.xml b/shared/uavobjectdefinition/systemsettings.xml index f4f4f540a..0e7279495 100644 --- a/shared/uavobjectdefinition/systemsettings.xml +++ b/shared/uavobjectdefinition/systemsettings.xml @@ -1,7 +1,7 @@ Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand - +