1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Change throttle default max value to 0.95 on multis

This commit is contained in:
zedamota 2011-06-08 18:17:14 +01:00
parent b6326b855d
commit dcccae7270
3 changed files with 30 additions and 12 deletions

View File

@ -358,7 +358,7 @@ void ConfigAirframeWidget::resetFwMixer()
{
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
resetMixer(m_aircraft->fixedWingThrottle, field->getNumElements());
resetMixer(m_aircraft->fixedWingThrottle, field->getNumElements(),1);
}
/**
@ -368,7 +368,7 @@ void ConfigAirframeWidget::resetMrMixer()
{
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
resetMixer(m_aircraft->multiThrottleCurve, field->getNumElements());
resetMixer(m_aircraft->multiThrottleCurve, field->getNumElements(),0.95);
}
/**
@ -378,7 +378,7 @@ void ConfigAirframeWidget::resetCt1Mixer()
{
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
resetMixer(m_aircraft->customThrottle1Curve, field->getNumElements());
resetMixer(m_aircraft->customThrottle1Curve, field->getNumElements(),1);
}
/**
@ -388,18 +388,18 @@ void ConfigAirframeWidget::resetCt2Mixer()
{
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
UAVObjectField* field = obj->getField(QString("ThrottleCurve2"));
resetMixer(m_aircraft->customThrottle2Curve, field->getNumElements());
resetMixer(m_aircraft->customThrottle2Curve, field->getNumElements(),1);
}
/**
Resets a mixer curve
*/
void ConfigAirframeWidget::resetMixer(MixerCurveWidget *mixer, int numElements)
void ConfigAirframeWidget::resetMixer(MixerCurveWidget *mixer, int numElements, double maxvalue)
{
QList<double> curveValues;
for (double i=0; i<numElements; i++) {
curveValues.append(i/(numElements-1));
curveValues.append(maxvalue*(i/(numElements-1)));
}
// Setup all Throttle1 curves for all types of airframes
mixer->initCurve(curveValues);
@ -469,19 +469,37 @@ void ConfigAirframeWidget::requestAircraftUpdate()
QList<double> curveValues;
// If the 1st element of the curve is <= -10, then the curve
// is a straight line (that's how the mixer works on the mainboard):
double temp=0; //used to check if default value(all 0s) is being returned
if (field->getValue(0).toInt() <= -10) {
for (double i=0; i<field->getNumElements(); i++) {
curveValues.append(i/(field->getNumElements()-1));
}
} else {
double value;
for (unsigned int i=0; i < field->getNumElements(); i++) {
curveValues.append(field->getValue(i).toDouble());
value=field->getValue(i).toDouble();
temp+=value;
curveValues.append(value);
}
}
// Setup all Throttle1 curves for all types of airframes
m_aircraft->fixedWingThrottle->initCurve(curveValues);
m_aircraft->multiThrottleCurve->initCurve(curveValues);
if(temp==0)
{ curveValues.clear();
for (double i=0; i<field->getNumElements(); i++) {
curveValues.append(0.95*(i/(field->getNumElements()-1)));
}
m_aircraft->multiThrottleCurve->initCurve(curveValues);
curveValues.clear();
for (double i=0; i<field->getNumElements(); i++) {
curveValues.append(i/(field->getNumElements()-1));
}
m_aircraft->fixedWingThrottle->initCurve(curveValues);
}
else
{
m_aircraft->multiThrottleCurve->initCurve(curveValues);
m_aircraft->fixedWingThrottle->initCurve(curveValues);
}
// Load the Settings for fixed wing frames:
if (frameType.startsWith("FixedWing")) {
// Then retrieve how channels are setup

View File

@ -59,7 +59,7 @@ private:
void setupMotors(QList<QString> motorList);
void resetField(UAVObjectField * field);
void resetMixer (MixerCurveWidget *mixer, int numElements);
void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue);
void resetActuators();
//void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector);
void setupQuadMotor(int channel, double roll, double pitch, double yaw);

View File

@ -5,7 +5,7 @@
<field name="FeedForward" units="" type="float" elements="1" defaultvalue="0"/>
<field name="AccelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
<field name="DecelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
<field name="ThrottleCurve1" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
<field name="ThrottleCurve1" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0,0,0,0"/>
<field name="ThrottleCurve2" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
<field name="Mixer1Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
<field name="Mixer1Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>