1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-04-11 03:02:20 +02:00

OP-1769 Ground support: Align wizard to flight side code implementation

This commit is contained in:
abeck70 2015-03-11 22:07:57 +11:00
parent dd2733d73f
commit 1d7059d4d7

View File

@ -116,7 +116,6 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true); m_aircraft->gvThrottleCurve1GroupBox->setEnabled(true);
m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true); m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true);
// Default Curve2 range -1 -> +1, allow forward/reverse (Car and Tank)
m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); m_aircraft->groundVehicleThrottle1->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH); m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH);
@ -154,13 +153,11 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
initMixerCurves(frameType); initMixerCurves(frameType);
// If new setup, set sliders to defaults and set curves values // 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") { if (frameTypeSaved->getValue().toString() != "GroundVehicleDifferential") {
m_aircraft->differentialSteeringSlider1->setValue(100); m_aircraft->differentialSteeringSlider1->setValue(100);
m_aircraft->differentialSteeringSlider2->setValue(100); m_aircraft->differentialSteeringSlider2->setValue(100);
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0); m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0, 0.0);
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 0.8, -0.8); m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0, 0.0);
} }
} else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { } else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") {
// Motorcycle // Motorcycle
@ -184,7 +181,6 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvThrottleCurve2GroupBox->setTitle(""); m_aircraft->gvThrottleCurve2GroupBox->setTitle("");
m_aircraft->gvThrottleCurve2GroupBox->setEnabled(false); m_aircraft->gvThrottleCurve2GroupBox->setEnabled(false);
// Curve range 0 -> +1 (no reverse)
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);
@ -192,8 +188,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
// If new setup, set curves values // If new setup, set curves values
if (frameTypeSaved->getValue().toString() != "GroundVehicleMotorCycle") { if (frameTypeSaved->getValue().toString() != "GroundVehicleMotorCycle") {
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0); m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0, 0.0);
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0); m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0, 0.0);
} }
} else { } else {
// Car // Car
@ -213,9 +209,9 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvSteering2Label->setText("Rear steering"); m_aircraft->gvSteering2Label->setText("Rear steering");
// Curve2 for Car // Curve2 for Car
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Throttle curve"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("");
m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true); m_aircraft->gvThrottleCurve2GroupBox->setEnabled(true);
m_aircraft->gvThrottleCurve1GroupBox->setTitle(""); m_aircraft->gvThrottleCurve1GroupBox->setTitle("Throttle curve");
m_aircraft->gvThrottleCurve1GroupBox->setEnabled(false); m_aircraft->gvThrottleCurve1GroupBox->setEnabled(false);
m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH); m_aircraft->groundVehicleThrottle2->setMixerType(MixerCurve::MIXERCURVE_PITCH);
@ -225,11 +221,10 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
// If new setup, set curves values // If new setup, set curves values
if (frameTypeSaved->getValue().toString() != "GroundVehicleCar") { if (frameTypeSaved->getValue().toString() != "GroundVehicleCar") {
m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0); m_aircraft->groundVehicleThrottle1->initLinearCurve(5, 1.0, 0.0);
// Set curve2 range from -0.926 to 1 (forward / reverse) // Set curve2 range from 0 to 1.
// Take in account 4% offset in Throttle input after calibration // The curve is applied to both forward and reverse
// 0.5 / 0.54 = 0.926 m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0, 0.0);
m_aircraft->groundVehicleThrottle2->initLinearCurve(5, 1.0, -0.926);
} }
} }
@ -325,7 +320,7 @@ void ConfigGroundVehicleWidget::initMixerCurves(QString frameType)
m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); m_aircraft->groundVehicleThrottle1->initCurve(&curveValues);
} else { } else {
// no, init a straight curve // no, init a straight curve
m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0, 0.0);
} }
// Setup all Throttle2 curves for all types of airframes // Setup all Throttle2 curves for all types of airframes
@ -336,11 +331,11 @@ void ConfigGroundVehicleWidget::initMixerCurves(QString frameType)
} else { } else {
// no, init a straight curve // no, init a straight curve
if (frameType == "GroundVehicleDifferential") { if (frameType == "GroundVehicleDifferential") {
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 0.8, -0.8); m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0, 0.0);
} else if (frameType == "GroundVehicleCar") { } else if (frameType == "GroundVehicleCar") {
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0, -1.0); m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0, 0.0);
} else { } else {
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0, 0.0);
} }
} }
} }
@ -513,11 +508,11 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; channel = m_aircraft->gvMotor1ChannelBox->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_THROTTLECURVE1, 127);
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_THROTTLECURVE1, 127);
// Output success message // Output success message
m_aircraft->gvStatusLabel->setText("Mixer generated"); m_aircraft->gvStatusLabel->setText("Mixer generated");