mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Merge remote-tracking branch 'origin/MikeL_ConfigVehicle' into revo
This commit is contained in:
commit
07f8922f2f
@ -25,7 +25,6 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "configccpmwidget.h"
|
#include "configccpmwidget.h"
|
||||||
//#include "mixersettings.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
@ -182,18 +182,16 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
|
|||||||
QString airframeType = "FixedWing";
|
QString airframeType = "FixedWing";
|
||||||
|
|
||||||
// Save the curve (common to all Fixed wing frames)
|
// Save the curve (common to all Fixed wing frames)
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(mixer);
|
||||||
|
|
||||||
// Remove Feed Forward, it is pointless on a plane:
|
// Remove Feed Forward, it is pointless on a plane:
|
||||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
UAVObjectField* field = mixer->getField(QString("FeedForward"));
|
||||||
field->setDouble(0);
|
field->setDouble(0);
|
||||||
|
|
||||||
field = obj->getField("ThrottleCurve1");
|
// Set the throttle curve
|
||||||
QList<double> curve = m_aircraft->fixedWingThrottle->getCurve();
|
setThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve());
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//All airframe types must start with "FixedWing"
|
//All airframe types must start with "FixedWing"
|
||||||
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) {
|
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) {
|
||||||
airframeType = "FixedWing";
|
airframeType = "FixedWing";
|
||||||
@ -229,36 +227,26 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
|||||||
setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
|
setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
|
||||||
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
|
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
|
||||||
|
|
||||||
UAVDataObject* obj;
|
UAVDataObject* mixer= dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
UAVObjectField *field;
|
Q_ASSERT(mixer);
|
||||||
|
|
||||||
|
int channel;
|
||||||
if (frameType == "FixedWingElevon") {
|
if (frameType == "FixedWingElevon") {
|
||||||
// If the airframe is elevon, restore the slider setting
|
// If the airframe is elevon, restore the slider setting
|
||||||
// Find the channel number for Elevon1 (FixedWingRoll1)
|
// Find the channel number for Elevon1 (FixedWingRoll1)
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||||
Q_ASSERT(obj);
|
if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||||
int chMixerNumber = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)*100);
|
||||||
if (chMixerNumber >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
|
||||||
field = obj->getField(mixerVectors.at(chMixerNumber));
|
|
||||||
int ti = field->getElementNames().indexOf("Roll");
|
|
||||||
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (frameType == "FixedWingVtail") {
|
if (frameType == "FixedWingVtail") {
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
||||||
Q_ASSERT(obj);
|
if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||||
int chMixerNumber = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)*100);
|
||||||
if (chMixerNumber >=0) {
|
m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
|
||||||
field = obj->getField(mixerVectors.at(chMixerNumber));
|
}
|
||||||
int ti = field->getElementNames().indexOf("Yaw");
|
}
|
||||||
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "configmultirotorwidget.h"
|
#include "configmultirotorwidget.h"
|
||||||
#include "mixersettings.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -296,12 +295,8 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
|||||||
field = obj->getField(QString("MaxAccel"));
|
field = obj->getField(QString("MaxAccel"));
|
||||||
field->setDouble(m_aircraft->maxAccelSlider->value());
|
field->setDouble(m_aircraft->maxAccelSlider->value());
|
||||||
|
|
||||||
// Curve is also common to all quads:
|
// Curve is also common to all quads:
|
||||||
field = obj->getField("ThrottleCurve1");
|
setThrottleCurve(obj, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
|
||||||
QList<double> curve = m_aircraft->multiThrottleCurve->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
||||||
airframeType = "QuadP";
|
airframeType = "QuadP";
|
||||||
@ -1036,20 +1031,22 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
|||||||
qDebug()<<mixerFactors[5][0]<<" "<<mixerFactors[5][1]<<" "<<mixerFactors[5][2];
|
qDebug()<<mixerFactors[5][0]<<" "<<mixerFactors[5][1]<<" "<<mixerFactors[5][2];
|
||||||
qDebug()<<mixerFactors[6][0]<<" "<<mixerFactors[6][1]<<" "<<mixerFactors[6][2];
|
qDebug()<<mixerFactors[6][0]<<" "<<mixerFactors[6][1]<<" "<<mixerFactors[6][2];
|
||||||
qDebug()<<mixerFactors[7][0]<<" "<<mixerFactors[7][1]<<" "<<mixerFactors[7][2];
|
qDebug()<<mixerFactors[7][0]<<" "<<mixerFactors[7][1]<<" "<<mixerFactors[7][2];
|
||||||
|
|
||||||
UAVObjectField *field;
|
|
||||||
QList<QComboBox*> mmList;
|
QList<QComboBox*> mmList;
|
||||||
mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
|
mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
|
||||||
<< m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
<< m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
||||||
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
// 1. Assign the servo/motor/none for each channel
|
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
// Disable all
|
Q_ASSERT(mixer);
|
||||||
foreach(QString mixer, mixerTypes) {
|
|
||||||
field = obj->getField(mixer);
|
//disable all
|
||||||
Q_ASSERT(field);
|
for (int channel=0; channel<VehicleConfig::CHANNEL_NUMELEM; channel++)
|
||||||
field->setValue("Disabled");
|
{
|
||||||
|
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
|
||||||
|
resetMixerVector(mixer, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and enable only the relevant channels:
|
// and enable only the relevant channels:
|
||||||
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
|
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
|
||||||
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
|
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "ui_airframe.h"
|
#include "ui_airframe.h"
|
||||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||||
|
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||||
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
|
@ -233,6 +233,60 @@ void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, Mixer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VehicleConfig::setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double> curve)
|
||||||
|
{
|
||||||
|
QPointer<UAVObjectField> field;
|
||||||
|
|
||||||
|
switch (curveType)
|
||||||
|
{
|
||||||
|
case MIXER_THROTTLECURVE1:
|
||||||
|
{
|
||||||
|
field = mixer->getField("ThrottleCurve1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MIXER_THROTTLECURVE2:
|
||||||
|
{
|
||||||
|
field = mixer->getField("ThrottleCurve2");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field && field->getNumElements() == curve.length()) {
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double>* curve)
|
||||||
|
{
|
||||||
|
Q_ASSERT(mixer);
|
||||||
|
Q_ASSERT(curve);
|
||||||
|
|
||||||
|
QPointer<UAVObjectField> field;
|
||||||
|
|
||||||
|
switch (curveType)
|
||||||
|
{
|
||||||
|
case MIXER_THROTTLECURVE1:
|
||||||
|
{
|
||||||
|
field = mixer->getField("ThrottleCurve1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MIXER_THROTTLECURVE2:
|
||||||
|
{
|
||||||
|
field = mixer->getField("ThrottleCurve2");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
curve->clear();
|
||||||
|
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||||
|
curve->append(field->getValue(i).toDouble());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reset the contents of a field
|
Reset the contents of a field
|
||||||
*/
|
*/
|
||||||
|
@ -111,6 +111,9 @@ class VehicleConfig: public ConfigTaskWidget
|
|||||||
VehicleConfig(QWidget *parent = 0);
|
VehicleConfig(QWidget *parent = 0);
|
||||||
~VehicleConfig();
|
~VehicleConfig();
|
||||||
|
|
||||||
|
/* Enumeration options for ThrottleCurves */
|
||||||
|
typedef enum { MIXER_THROTTLECURVE1=0, MIXER_THROTTLECURVE2=1 } MixerThrottleCurveElem;
|
||||||
|
|
||||||
/* Enumeration options for field MixerType */
|
/* Enumeration options for field MixerType */
|
||||||
typedef enum { MIXERTYPE_DISABLED=0, MIXERTYPE_MOTOR=1, MIXERTYPE_SERVO=2, MIXERTYPE_CAMERAROLL=3, MIXERTYPE_CAMERAPITCH=4, MIXERTYPE_CAMERAYAW=5, MIXERTYPE_ACCESSORY0=6, MIXERTYPE_ACCESSORY1=7, MIXERTYPE_ACCESSORY2=8, MIXERTYPE_ACCESSORY3=9, MIXERTYPE_ACCESSORY4=10, MIXERTYPE_ACCESSORY5=11 } MixerTypeElem;
|
typedef enum { MIXERTYPE_DISABLED=0, MIXERTYPE_MOTOR=1, MIXERTYPE_SERVO=2, MIXERTYPE_CAMERAROLL=3, MIXERTYPE_CAMERAPITCH=4, MIXERTYPE_CAMERAYAW=5, MIXERTYPE_ACCESSORY0=6, MIXERTYPE_ACCESSORY1=7, MIXERTYPE_ACCESSORY2=8, MIXERTYPE_ACCESSORY3=9, MIXERTYPE_ACCESSORY4=10, MIXERTYPE_ACCESSORY5=11 } MixerTypeElem;
|
||||||
/* Array element names for field MixerVector */
|
/* Array element names for field MixerVector */
|
||||||
@ -127,6 +130,8 @@ class VehicleConfig: public ConfigTaskWidget
|
|||||||
void resetMixerVector(UAVDataObject* mixer, int channel);
|
void resetMixerVector(UAVDataObject* mixer, int channel);
|
||||||
QString getMixerType(UAVDataObject* mixer, int channel);
|
QString getMixerType(UAVDataObject* mixer, int channel);
|
||||||
void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType);
|
void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType);
|
||||||
|
void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double> curve);
|
||||||
|
void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double>* curve);
|
||||||
|
|
||||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||||
virtual QStringList getChannelDescriptions();
|
virtual QStringList getChannelDescriptions();
|
||||||
|
@ -36,10 +36,11 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
#include "systemsettings.h"
|
#include "systemsettings.h"
|
||||||
#include "mixersettings.h"
|
#include "mixersettings.h"
|
||||||
#include "actuatorsettings.h"
|
#include "actuatorsettings.h"
|
||||||
#include <QEventLoop>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper delegate for the custom mixer editor table.
|
Helper delegate for the custom mixer editor table.
|
||||||
@ -781,77 +782,65 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
|||||||
Note: does NOT ask for an object refresh itself!
|
Note: does NOT ask for an object refresh itself!
|
||||||
*/
|
*/
|
||||||
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||||
{
|
{
|
||||||
|
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(mixer);
|
||||||
|
|
||||||
|
VehicleConfig* vconfig = new VehicleConfig();
|
||||||
|
|
||||||
QList<double> curveValues;
|
QList<double> curveValues;
|
||||||
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
// setup throttlecurve 1
|
||||||
Q_ASSERT(obj);
|
vconfig->getThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE1,&curveValues);
|
||||||
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
int total = 0;
|
||||||
if (field)
|
for (int i=0; i<curveValues.length(); i++)
|
||||||
{
|
total += curveValues.at(i);
|
||||||
// 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):
|
if (curveValues.at(0) <= -10 || total == 0) {
|
||||||
if (field->getValue(0).toInt() <= -10) {
|
m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.length(),(double)1);
|
||||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
}
|
||||||
} else {
|
else {
|
||||||
double temp=0;
|
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
||||||
double value;
|
|
||||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
|
||||||
value=field->getValue(i).toDouble();
|
|
||||||
temp+=value;
|
|
||||||
curveValues.append(value);
|
|
||||||
}
|
|
||||||
if(temp==0)
|
|
||||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
else
|
|
||||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curveValues.clear();
|
// setup throttlecurve 2
|
||||||
|
vconfig->getThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE2,&curveValues);
|
||||||
|
|
||||||
field = obj->getField(QString("ThrottleCurve2"));
|
total = 0;
|
||||||
if (field)
|
for (int i=0; i<curveValues.length(); i++)
|
||||||
{
|
total += curveValues.at(i);
|
||||||
// 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):
|
if (curveValues.at(0) <= -10 || total == 0) {
|
||||||
if (field->getValue(0).toInt() <= -10) {
|
m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.length(),(double)1);
|
||||||
m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1);
|
}
|
||||||
} else {
|
else {
|
||||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
||||||
curveValues.append(field->getValue(i).toDouble());
|
|
||||||
}
|
|
||||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the table:
|
|
||||||
for (int i=0; i<8; i++) {
|
// Update the mixer table:
|
||||||
field = obj->getField(mixerTypes.at(i));
|
for (int channel=0; channel<8; channel++) {
|
||||||
|
UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
|
||||||
if (field)
|
if (field)
|
||||||
{
|
{
|
||||||
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,channel);
|
||||||
if (q)
|
if (q)
|
||||||
{
|
{
|
||||||
QString s = field->getValue().toString();
|
QString s = field->getValue().toString();
|
||||||
setComboCurrentIndex(q, q->findText(s));
|
setComboCurrentIndex(q, q->findText(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
field = obj->getField(mixerVectors.at(i));
|
m_aircraft->customMixerTable->item(1,channel)->setText(
|
||||||
if (field)
|
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
|
||||||
{
|
m_aircraft->customMixerTable->item(2,channel)->setText(
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
|
||||||
m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString());
|
m_aircraft->customMixerTable->item(3,channel)->setText(
|
||||||
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
|
||||||
m_aircraft->customMixerTable->item(2,i)->setText(field->getValue(ti).toString());
|
m_aircraft->customMixerTable->item(4,channel)->setText(
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
|
||||||
m_aircraft->customMixerTable->item(3,i)->setText(field->getValue(ti).toString());
|
m_aircraft->customMixerTable->item(5,channel)->setText(
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)));
|
||||||
m_aircraft->customMixerTable->item(4,i)->setText(field->getValue(ti).toString());
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -866,9 +855,6 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
|||||||
*/
|
*/
|
||||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||||
{
|
{
|
||||||
UAVDataObject* obj;
|
|
||||||
UAVObjectField* field;
|
|
||||||
|
|
||||||
QString airframeType = "Custom"; //Sets airframe type default to "Custom"
|
QString airframeType = "Custom"; //Sets airframe type default to "Custom"
|
||||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||||
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
||||||
@ -883,45 +869,42 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
|||||||
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
field = obj->getField(QString("FeedForward"));
|
|
||||||
|
|
||||||
// Curve is also common to all quads:
|
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
field = obj->getField("ThrottleCurve1");
|
Q_ASSERT(mixer);
|
||||||
QList<double> curve = m_aircraft->customThrottle1Curve->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
field = obj->getField("ThrottleCurve2");
|
VehicleConfig* vconfig = new VehicleConfig();
|
||||||
curve.clear();
|
|
||||||
curve = m_aircraft->customThrottle2Curve->getCurve();
|
vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
|
||||||
for (int i=0;i<curve.length();i++) {
|
vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the table:
|
// Update the table:
|
||||||
for (int i=0; i<8; i++) {
|
for (int channel=0; channel<8; channel++) {
|
||||||
field = obj->getField(mixerTypes.at(i));
|
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,channel);
|
||||||
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
|
||||||
field->setValue(q->currentText());
|
vconfig->setMixerType(mixer,channel,
|
||||||
field = obj->getField(mixerVectors.at(i));
|
q->currentText() == "Servo" ? VehicleConfig::MIXERTYPE_SERVO : VehicleConfig::MIXERTYPE_MOTOR);
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(1,i)->text(),ti);
|
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
|
||||||
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
m_aircraft->customMixerTable->item(1,channel)->text().toDouble());
|
||||||
field->setValue(m_aircraft->customMixerTable->item(2,i)->text(),ti);
|
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
m_aircraft->customMixerTable->item(2,channel)->text().toDouble());
|
||||||
field->setValue(m_aircraft->customMixerTable->item(3,i)->text(),ti);
|
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
m_aircraft->customMixerTable->item(3,channel)->text().toDouble());
|
||||||
field->setValue(m_aircraft->customMixerTable->item(4,i)->text(),ti);
|
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
m_aircraft->customMixerTable->item(4,channel)->text().toDouble());
|
||||||
field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti);
|
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
|
||||||
|
m_aircraft->customMixerTable->item(5,channel)->text().toDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the airframe type
|
// set the airframe type
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
UAVDataObject* system = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||||
field = obj->getField(QString("AirframeType"));
|
Q_ASSERT(system);
|
||||||
field->setValue(airframeType);
|
|
||||||
|
QPointer<UAVObjectField> field = system->getField(QString("AirframeType"));
|
||||||
|
if (field)
|
||||||
|
field->setValue(airframeType);
|
||||||
|
|
||||||
updateCustomAirframeUI();
|
updateCustomAirframeUI();
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "cfg_vehicletypes/configfixedwingwidget.h"
|
#include "cfg_vehicletypes/configfixedwingwidget.h"
|
||||||
#include "cfg_vehicletypes/configmultirotorwidget.h"
|
#include "cfg_vehicletypes/configmultirotorwidget.h"
|
||||||
#include "cfg_vehicletypes/configgroundvehiclewidget.h"
|
#include "cfg_vehicletypes/configgroundvehiclewidget.h"
|
||||||
|
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
Loading…
Reference in New Issue
Block a user