From 593c947f5ecca9c5825cfcf12b92c58b02a4777d Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Oct 2010 14:05:51 +0000 Subject: [PATCH] minor modifications to UI for ccpm mixing. better integration into config gadget (now only one set of buttons) this has not been tested with hardware in it's current form. Still need to make UI small screen friendly. Use at own risk! git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1963 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/config/ccpm.ui | 583 +++++++++++------- .../plugins/config/configairframewidget.cpp | 7 +- .../src/plugins/config/configccpmwidget.cpp | 155 ++++- ground/src/plugins/config/configccpmwidget.h | 7 +- 4 files changed, 517 insertions(+), 235 deletions(-) diff --git a/ground/src/plugins/config/ccpm.ui b/ground/src/plugins/config/ccpm.ui index c38e0f9b5..4549f571b 100644 --- a/ground/src/plugins/config/ccpm.ui +++ b/ground/src/plugins/config/ccpm.ui @@ -6,22 +6,49 @@ 0 0 - 821 - 606 + 730 + 500 + + + 0 + 0 + + + + + 500 + 500 + + Form + + false + - 10 - 10 - 791 - 551 + 0 + 30 + 731 + 470 + + + 0 + 0 + + + + + 692 + 419 + + 0 @@ -29,47 +56,16 @@ Basic settings - + - 110 + 0 10 - 551 - 21 - - - - - 10 - - - - Select aircraft type here - - - - - - 10 - 10 - 91 - 21 - - - - Swashplate config: - - - - - - 11 - 60 - 764 + 721 427 - + @@ -486,136 +482,284 @@ - - - true - - - CCPM Mixing - - - - - - Qt::Vertical + + + + + true + + + + 0 + 0 + + + + + 50 + 250 + + + + + 50 + 250 + + + + + 8 + + + + CCPM + + + Qt::AlignCenter + + + + + 0 + 20 + 48 + 218 + - - - true - - - Collective - - - Qt::AlignCenter - - - - - true - - - - 0 - 0 - - - - 100 - - - 5 - - - 50 - - - Qt::Vertical - - - - - true - - - Cyclic - - - Qt::AlignCenter - - + + + + + true + + + Collective + + + true + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 150 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + true + + + Cyclic + + + Qt::AlignCenter + + + + + + + 100 + + + 5 + + + 50 + + + + - - - - - 100 - - - 5 - - - 50 + splitter_2 + ccpmCollectivespinBox + ccpmCollectiveSlider + label_15 + ccpmCollectivespinBox + label_16 + + + + + + + + 0 + 0 + + + + + 50 + 250 + + + + + 50 + 250 + + + + REVO + + + + + 0 + 20 + 47 + 218 + + + + + + false + + + 100% + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + false + + + + 0 + 150 + + + + 100 + + + 5 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + false + + + 0% + + + Qt::AlignCenter + + + + + + + - - - - - - - - REVO Mixing - - - - - - Qt::Vertical - - - - false - - - 100% - - - Qt::AlignCenter - - - - - false - - - 100 - - - 5 - - - Qt::Vertical - - - - - false - - - 0% - - - Qt::AlignCenter - - - - - - - - - + + + @@ -713,6 +857,19 @@ + + + + Qt::Horizontal + + + + 5 + 20 + + + + @@ -1667,53 +1824,39 @@ - + - 10 - 570 - 93 - 27 + 170 + 0 + 421 + 26 - - Retrieve settings from OpenPilot - - - Get Current - - - - - - 510 - 570 - 93 - 27 - - - - Send to OpenPilot but don't write in SD. - - - Save to RAM - - - - - - 620 - 570 - 93 - 27 - - - - Applies and Saves all settings to SD - - - Save to SD - + + + 0 + + + + + Swashplate config: + + + + + + + + 10 + + + + Select aircraft type here + + + + @@ -1739,14 +1882,10 @@ ccpmAngleY ccpmAngleZ ccpmCorrectionAngle - ccpmCollectiveSlider ccpmCollectivespinBox ccpmRevoSlider ccpmREVOspinBox SwashplateImage - getccpmCurrent - saveccpmToRAM - saveccpmToSD CurveType NumCurvePoints CurveValue1 @@ -1772,8 +1911,8 @@ 309 - 228 - 501 + 259 + 467 @@ -1784,8 +1923,8 @@ setValue(int) - 247 - 496 + 259 + 467 243 @@ -1800,8 +1939,8 @@ setValue(int) - 320 - 498 + 344 + 467 326 @@ -1820,8 +1959,8 @@ 222 - 308 - 496 + 344 + 467 diff --git a/ground/src/plugins/config/configairframewidget.cpp b/ground/src/plugins/config/configairframewidget.cpp index 0db57aab6..9d9b191e7 100644 --- a/ground/src/plugins/config/configairframewidget.cpp +++ b/ground/src/plugins/config/configairframewidget.cpp @@ -546,8 +546,10 @@ void ConfigAirframeWidget::requestAircraftUpdate() Q_ASSERT(field); m_aircraft->maxAccelSlider->setValue(field->getDouble()); + } else if (frameType == "HeliCP") { + m_aircraft->widget_3->requestccpmUpdate(); + m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Helicopter"));//"Helicopter" } - } /** @@ -1352,6 +1354,9 @@ void ConfigAirframeWidget::sendAircraftUpdate() // Now reflect those settings in the "Custom" panel as well updateCustomAirframeUI(); + } else if (m_aircraft->aircraftType->currentText() == "Helicopter") { + airframeType = "HeliCP"; + m_aircraft->widget_3->sendccpmUpdate(); } else { airframeType = "Custom"; } diff --git a/ground/src/plugins/config/configccpmwidget.cpp b/ground/src/plugins/config/configccpmwidget.cpp index d644d5dbd..e2c481139 100644 --- a/ground/src/plugins/config/configccpmwidget.cpp +++ b/ground/src/plugins/config/configccpmwidget.cpp @@ -140,9 +140,9 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) UpdateType(); - connect(m_ccpm->saveccpmToSD, SIGNAL(clicked()), this, SLOT(saveccpmUpdate())); - connect(m_ccpm->saveccpmToRAM, SIGNAL(clicked()), this, SLOT(sendccpmUpdate())); - connect(m_ccpm->getccpmCurrent, SIGNAL(clicked()), this, SLOT(requestccpmUpdate())); + //connect(m_ccpm->saveccpmToSD, SIGNAL(clicked()), this, SLOT(saveccpmUpdate())); + //connect(m_ccpm->saveccpmToRAM, SIGNAL(clicked()), this, SLOT(sendccpmUpdate())); + //connect(m_ccpm->getccpmCurrent, SIGNAL(clicked()), this, SLOT(requestccpmUpdate())); connect(m_ccpm->ccpmGenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve())); connect(m_ccpm->NumCurvePoints, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurveSettings())); connect(m_ccpm->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCurveSettings())); @@ -437,6 +437,7 @@ void ConfigccpmWidget::ccpmSwashplateUpdate() //m_ccpm->SwashplateImage->centerOn (CenterX, CenterY); + //m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio); UpdateMixer(); @@ -553,15 +554,151 @@ void ConfigccpmWidget::UpdateMixer() */ void ConfigccpmWidget::requestccpmUpdate() { - //ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - //UAVObjectManager *objManager = pm->getObject(); + int MixerDataFromHeli[8][5]; + QString MixerOutputType[8]; + int EngineChannel,TailRotorChannel,ServoChannels[4],ServoAngles[4],ServoCurve2[4]; + int NumServos=0; + double Collective=0.0; + + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + int i,j; + UAVObjectField *field; + UAVDataObject* obj; + obj = dynamic_cast(objManager->getObject(QString("MixerSettings"))); + Q_ASSERT(obj); + + //go through the user data and update the mixer matrix + for (i=0;i<8;i++) + { + field = obj->getField(tr( "Mixer%1Vector" ).arg(i)); + //config the vector + for (j=0;j<5;j++) + { + MixerDataFromHeli[i][j] = field->getValue(j).toInt(); + //field->setValue(m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(),j); + } + } + for (i=0;i<8;i++) + { + field = obj->getField(tr( "Mixer%1Type" ).arg(i)); + MixerOutputType[i] = field->getValue().toString(); + } + + EngineChannel =-1; + TailRotorChannel =-1; + for (j=0;j<5;j++) + { + ServoChannels[j]=8; + ServoCurve2[j]=0; + ServoAngles[j]=350; + } + + NumServos=0; + //process the data from Heli and try to figure out the settings... + for (i=0;i<8;i++) + { + //check if this is the engine... Throttle only + if ((MixerOutputType[i].compare("Motor")==0)&& + (MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1 + (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 + (MixerDataFromHeli[i][2]==0)&&//Roll + (MixerDataFromHeli[i][3]==0)&&//Pitch + (MixerDataFromHeli[i][4]==0))//Yaw + { + EngineChannel = i; + m_ccpm->ccpmEngineChannel->setCurrentIndex(i); + + } + //check if this is the tail rotor... REVO and YAW + if ((MixerOutputType[i].compare("Servo")==0)&& + //(MixerDataFromHeli[i][0]!=0)&&//ThrottleCurve1 + (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 + (MixerDataFromHeli[i][2]==0)&&//Roll + (MixerDataFromHeli[i][3]==0)&&//Pitch + (MixerDataFromHeli[i][4]!=0))//Yaw + { + TailRotorChannel = i; + m_ccpm->ccpmTailChannel->setCurrentIndex(i); + m_ccpm->ccpmRevoSlider->setValue((MixerDataFromHeli[i][0]*100)/127); + m_ccpm->ccpmREVOspinBox->setValue((MixerDataFromHeli[i][0]*100)/127); + } + //check if this is a swashplate servo... Throttle is zero + if ((MixerOutputType[i].compare("Servo")==0)&& + (MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1 + //(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 + //(MixerDataFromHeli[i][2]==0)&&//Roll + //(MixerDataFromHeli[i][3]==0)&&//Pitch + (MixerDataFromHeli[i][4]==0))//Yaw + { + ServoChannels[NumServos] = i;//record the channel for this servo + ServoCurve2[NumServos]=MixerDataFromHeli[i][1];//record the ThrottleCurve2 contribution to this servo + ServoAngles[NumServos]=NumServos*45;//make this 0 for the final version + + //if (NumServos==0)m_ccpm->ccpmServoWChannel->setCurrentIndex(i); + //if (NumServos==1)m_ccpm->ccpmServoXChannel->setCurrentIndex(i); + //if (NumServos==2)m_ccpm->ccpmServoYChannel->setCurrentIndex(i); + //if (NumServos==3)m_ccpm->ccpmServoZChannel->setCurrentIndex(i); + NumServos++; + } + + } + m_ccpm->ccpmServoWChannel->setCurrentIndex(ServoChannels[0]); + m_ccpm->ccpmServoXChannel->setCurrentIndex(ServoChannels[1]); + m_ccpm->ccpmServoYChannel->setCurrentIndex(ServoChannels[2]); + m_ccpm->ccpmServoZChannel->setCurrentIndex(ServoChannels[3]); + + m_ccpm->ccpmAngleW->setValue(ServoAngles[0]); + m_ccpm->ccpmAngleX->setValue(ServoAngles[1]); + m_ccpm->ccpmAngleY->setValue(ServoAngles[2]); + m_ccpm->ccpmAngleZ->setValue(ServoAngles[3]); + + if (NumServos>1) + { + if((ServoCurve2[0]==0)&&(ServoCurve2[1]==0)&&(ServoCurve2[2]==0)&&(ServoCurve2[3]==0)) + { + //fixed pitch heli + m_ccpm->ccpmCollectiveSlider->setValue(0); + } + if(ServoCurve2[0]==ServoCurve2[1]) + { + if ((NumServos<3)||(ServoCurve2[1]==ServoCurve2[2])) + { + if ((NumServos<4)||(ServoCurve2[2]==ServoCurve2[3])) + {//all the servos have the same ThrottleCurve2 setting so this must be a CCPM config + Collective = ((double)ServoCurve2[0]*100.00)/127.00; + m_ccpm->ccpmCollectiveSlider->setValue((int)Collective); + m_ccpm->ccpmCollectivespinBox->setValue((int)Collective); + + //just call it user angles for now.... + m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - User Angles")); + } + } + } + } + else + {//must be a custom config... "Custom - Advanced Settings" + m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - Advanced Settings")); + } - //UAVObjectField *field; - //QTableWidgetItem *newItem;// = new QTableWidgetItem(); + + //get the settings for the curve from the mixer settings + field = obj->getField(QString("ThrottleCurve1")); + for (i=0;i<5;i++) + { + m_ccpm->CurveSettings->item(i, 0)->setText(field->getValue(i).toString()); + //field->setValue(m_ccpm->CurveSettings->item(i, 0)->text().toDouble(),i); + } + field = obj->getField(QString("ThrottleCurve2")); + for (i=0;i<5;i++) + { + m_ccpm->CurveSettings->item(i, 1)->setText(field->getValue(i).toString()); + //field->setValue(m_ccpm->CurveSettings->item(i, 1)->text().toDouble(),i); + } + - //not doing anything yet ccpmSwashplateUpdate(); @@ -617,7 +754,7 @@ void ConfigccpmWidget::sendccpmUpdate() //config the vector for (j=0;j<5;j++) { - //field->setValue(j,m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt()); + field->setValue(m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(),j); } } diff --git a/ground/src/plugins/config/configccpmwidget.h b/ground/src/plugins/config/configccpmwidget.h index f9dc270f0..f7534e83f 100644 --- a/ground/src/plugins/config/configccpmwidget.h +++ b/ground/src/plugins/config/configccpmwidget.h @@ -63,14 +63,15 @@ private: int MixerChannelData[6]; private slots: - void requestccpmUpdate(); - void sendccpmUpdate(); - void saveccpmUpdate(); void ccpmSwashplateUpdate(); void UpdateCurveSettings(); void GenerateCurve(); void UpdateMixer(); void UpdateType(); + public slots: + void requestccpmUpdate(); + void sendccpmUpdate(); + void saveccpmUpdate(); };