1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-454 Allow dual motor curves for Car - Cleanup names and motorcycle motor issue

This commit is contained in:
Laurent Lalanne 2016-12-20 14:48:26 +01:00
parent f27be15c62
commit 86932443af
3 changed files with 21 additions and 17 deletions

View File

@ -81,7 +81,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
populateChannelComboBoxes(); populateChannelComboBoxes();
QStringList groundVehicleTypes; QStringList groundVehicleTypes;
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle" << "Boat" << "Differential (boat)"; groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle" << "Turnable (boat)" << "Differential (boat)";
m_aircraft->groundVehicleType->addItems(groundVehicleTypes); m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
m_aircraft->groundShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_aircraft->groundShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -126,10 +126,10 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
initMixerCurves(frameType); initMixerCurves(frameType);
if (frameType == "GroundVehicleBoat" || frameType == "Boat") { if (frameType == "GroundVehicleBoat" || frameType == "Turnable (boat)") {
// Boat // Boat
m_vehicleImg->setElementId("boat"); m_vehicleImg->setElementId("boat");
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Boat")); setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (boat)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1ChannelBox->setEnabled(true);
m_aircraft->gvMotor2ChannelBox->setEnabled(true); m_aircraft->gvMotor2ChannelBox->setEnabled(true);
@ -214,8 +214,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_vehicleImg->setElementId("motorbike"); 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(true); m_aircraft->gvMotor1ChannelBox->setEnabled(false);
m_aircraft->gvMotor2ChannelBox->setEnabled(false); m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvMotor2Label->setText("Rear motor"); m_aircraft->gvMotor2Label->setText("Rear motor");
@ -258,10 +258,10 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvSteering1Label->setText("Front steering"); m_aircraft->gvSteering1Label->setText("Front steering");
m_aircraft->gvSteering2Label->setText("Rear steering"); m_aircraft->gvSteering2Label->setText("Rear steering");
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Throttle curve1"); m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front Motor Throttle curve");
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true); m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true);
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Throttle curve2"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear Motor Throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setEnabled(false); m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true);
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
@ -411,12 +411,12 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
if (m_aircraft->groundVehicleType->currentText() == "Differential (boat)") { if (m_aircraft->groundVehicleType->currentText() == "Differential (boat)") {
airframeType = "GroundVehicleDifferentialBoat"; airframeType = "GroundVehicleDifferentialBoat";
setupGroundVehicleDifferential(airframeType); setupGroundVehicleDifferential(airframeType);
} else if (m_aircraft->groundVehicleType->currentText() == "Boat") { } else if (m_aircraft->groundVehicleType->currentText() == "Turnable (boat)") {
airframeType = "GroundVehicleBoat"; airframeType = "GroundVehicleBoat";
setupGroundVehicleCar(airframeType); setupGroundVehicleTurnable(airframeType);
} else if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { } else if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") {
airframeType = "GroundVehicleCar"; airframeType = "GroundVehicleCar";
setupGroundVehicleCar(airframeType); setupGroundVehicleTurnable(airframeType);
} else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
airframeType = "GroundVehicleDifferential"; airframeType = "GroundVehicleDifferential";
setupGroundVehicleDifferential(airframeType); setupGroundVehicleDifferential(airframeType);
@ -531,7 +531,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
Returns False if impossible to create the mixer. Returns False if impossible to create the mixer.
*/ */
bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) bool ConfigGroundVehicleWidget::setupGroundVehicleTurnable(QString airframeType)
{ {
// Check coherence: // Check coherence:
// Show any config errors in GUI // Show any config errors in GUI
@ -568,8 +568,13 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
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_THROTTLECURVE1, 127); if (airframeType == "GroundVehicleCar") {
// Car: Throttle2 curve for 2nd motor
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
} else {
// Boat: Throttle1 curve for both motors
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
}
// Output success message // Output success message
m_aircraft->gvStatusLabel->setText("Mixer generated"); m_aircraft->gvStatusLabel->setText("Mixer generated");

View File

@ -65,10 +65,9 @@ private:
virtual void registerWidgets(ConfigTaskWidget &parent); virtual void registerWidgets(ConfigTaskWidget &parent);
virtual void resetActuators(GUIConfigDataUnion *configData); virtual void resetActuators(GUIConfigDataUnion *configData);
bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleTurnable(QString airframeType);
bool setupGroundVehicleDifferential(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType);
bool setupGroundVehicleMotorcycle(QString airframeType); bool setupGroundVehicleMotorcycle(QString airframeType);
bool setupGroundVehicleBoat(QString airframeType);
private slots: private slots:
virtual void setupUI(QString airframeType); virtual void setupUI(QString airframeType);

View File

@ -287,7 +287,7 @@ int ConfigVehicleTypeWidget::frameCategory(QString frameType)
} 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 == "GroundVehicleMotorcycle" || frameType == "Motorcycle" || frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"
|| frameType == "GroundVehicleBoat" || frameType == "Boat" || frameType == "GroundVehicleBoat" || frameType == "Turnable (boat)"
|| frameType == "GroundVehicleDifferentialBoat" || frameType == "Differential (boat)") { || frameType == "GroundVehicleDifferentialBoat" || frameType == "Differential (boat)") {
return ConfigVehicleTypeWidget::GROUND; return ConfigVehicleTypeWidget::GROUND;
} else { } else {