diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 28b9715a1..f34e40900 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -40,22 +40,104 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa { m_stabilization = new Ui_StabilizationWidget(); m_stabilization->setupUi(this); - /* QList * rateGroup=new QList(); - rateGroup->append(0); - addApplySaveButtons(m_stabilization->saveStabilizationToRAM,m_stabilization->saveStabilizationToSD); - addUAVObjectToWidgetRelation("StabilizationSettings","RollRatePID",m_stabilization->rateRollKp,"Kp",1,true,rateGroup); - - addDefaultButton(m_stabilization->defaultButton,0); - addReloadButton(m_stabilization->reloadButton,0); - addWidgetToDefaultReloadGroups(m_stabilization->rateRollKp,rateGroup); - addShadowWidget("StabilizationSettings","RollRatePID",m_stabilization->rateRollKi,0,1,true,rateGroup);*/ autoLoadWidgets(); + realtimeUpdates=new QTimer(this); + connect(m_stabilization->realTimeUpdates_6,SIGNAL(stateChanged(int)),this,SLOT(realtimeUpdatesSlot(int))); + connect(m_stabilization->realTimeUpdates_7,SIGNAL(stateChanged(int)),this,SLOT(realtimeUpdatesSlot(int))); + connect(realtimeUpdates,SIGNAL(timeout()),this,SLOT(apply())); + + connect(m_stabilization->checkBox_7,SIGNAL(stateChanged(int)),this,SLOT(linkCheckBoxes(int))); + connect(m_stabilization->checkBox_2,SIGNAL(stateChanged(int)),this,SLOT(linkCheckBoxes(int))); + connect(m_stabilization->checkBox_8,SIGNAL(stateChanged(int)),this,SLOT(linkCheckBoxes(int))); + connect(m_stabilization->checkBox_3,SIGNAL(stateChanged(int)),this,SLOT(linkCheckBoxes(int))); + + connect(this,SIGNAL(widgetContentsChanged(QWidget*)),this,SLOT(processLinkedWidgets(QWidget*))); } ConfigStabilizationWidget::~ConfigStabilizationWidget() { - // Do nothing + // Do nothing +} + +void ConfigStabilizationWidget::realtimeUpdatesSlot(int value) +{ + m_stabilization->realTimeUpdates_6->setCheckState((Qt::CheckState)value); + m_stabilization->realTimeUpdates_7->setCheckState((Qt::CheckState)value); + if(value==Qt::Checked && !realtimeUpdates->isActive()) + realtimeUpdates->start(300); + else if(value==Qt::Unchecked) + realtimeUpdates->stop(); +} + +void ConfigStabilizationWidget::linkCheckBoxes(int value) +{ + if(sender()== m_stabilization->checkBox_7) + m_stabilization->checkBox_3->setCheckState((Qt::CheckState)value); + else if(sender()== m_stabilization->checkBox_3) + m_stabilization->checkBox_7->setCheckState((Qt::CheckState)value); + else if(sender()== m_stabilization->checkBox_8) + m_stabilization->checkBox_2->setCheckState((Qt::CheckState)value); + else if(sender()== m_stabilization->checkBox_2) + m_stabilization->checkBox_8->setCheckState((Qt::CheckState)value); +} + +void ConfigStabilizationWidget::processLinkedWidgets(QWidget * widget) +{ + if(m_stabilization->checkBox_7->checkState()==Qt::Checked) + { + if(widget== m_stabilization->RateRollKp_2) + { + m_stabilization->RatePitchKp->setValue(m_stabilization->RateRollKp_2->value()); + } + else if(widget== m_stabilization->RateRollKi_2) + { + m_stabilization->RatePitchKi->setValue(m_stabilization->RateRollKi_2->value()); + } + else if(widget== m_stabilization->RateRollILimit_2) + { + m_stabilization->RatePitchILimit->setValue(m_stabilization->RateRollILimit_2->value()); + } + else if(widget== m_stabilization->RatePitchKp) + { + m_stabilization->RateRollKp_2->setValue(m_stabilization->RatePitchKp->value()); + } + else if(widget== m_stabilization->RatePitchKi) + { + m_stabilization->RateRollKi_2->setValue(m_stabilization->RatePitchKi->value()); + } + else if(widget== m_stabilization->RatePitchILimit) + { + m_stabilization->RateRollILimit_2->setValue(m_stabilization->RatePitchILimit->value()); + } + } + if(m_stabilization->checkBox_8->checkState()==Qt::Checked) + { + if(widget== m_stabilization->AttitudeRollKp) + { + m_stabilization->AttitudePitchKp_2->setValue(m_stabilization->AttitudeRollKp->value()); + } + else if(widget== m_stabilization->AttitudeRollKi) + { + m_stabilization->AttitudePitchKi_2->setValue(m_stabilization->AttitudeRollKi->value()); + } + else if(widget== m_stabilization->AttitudeRollILimit) + { + m_stabilization->AttitudePitchILimit_2->setValue(m_stabilization->AttitudeRollILimit->value()); + } + else if(widget== m_stabilization->AttitudePitchKp_2) + { + m_stabilization->AttitudeRollKp->setValue(m_stabilization->AttitudePitchKp_2->value()); + } + else if(widget== m_stabilization->AttitudePitchKi_2) + { + m_stabilization->AttitudeRollKi->setValue(m_stabilization->AttitudePitchKi_2->value()); + } + else if(widget== m_stabilization->AttitudePitchILimit_2) + { + m_stabilization->AttitudeRollILimit->setValue(m_stabilization->AttitudePitchILimit_2->value()); + } + } } diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index ea3a635d2..266b59ae9 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -47,8 +47,11 @@ public: private: Ui_StabilizationWidget *m_stabilization; - + QTimer * realtimeUpdates; private slots: + void realtimeUpdatesSlot(int); + void linkCheckBoxes(int value); + void processLinkedWidgets(QWidget*); }; #endif // ConfigStabilizationWidget_H diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 8921cd55d..52c1e0d38 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -470,7 +470,7 @@ QTabWidget::North - 0 + 1 true @@ -1140,12 +1140,6 @@ 0 - - - button:default - buttongroup:1 - - 81 @@ -1185,6 +1179,12 @@ border-radius: 4; Default + + + button:default + buttongroup:1 + + @@ -1194,13 +1194,7 @@ border-radius: 4; 0 0 - - - - button:help - url:http://wiki.openpilot.org/display/Doc/Stabilization+panel - - + 51 @@ -1240,6 +1234,12 @@ border-radius: 4; Wiki + + + button:help + url:http://wiki.openpilot.org/display/Doc/Stabilization+panel + + @@ -3401,7 +3401,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3433,7 +3433,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3477,7 +3477,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3509,7 +3509,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3553,7 +3553,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3585,7 +3585,7 @@ border-radius: 5; element:Kp haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3648,7 +3648,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3680,7 +3680,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3724,7 +3724,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3756,7 +3756,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3800,7 +3800,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -3832,7 +3832,7 @@ border-radius: 5; element:Ki haslimits:yes scale:0.0001 - buttongroup:1,10 + buttongroup:1,10 @@ -4482,12 +4482,6 @@ border-radius: 5; 0 - - - button:default - buttongroup:2 - - 81 @@ -4524,6 +4518,12 @@ border-radius: 4; Default + + + button:default + buttongroup:2 + + @@ -7129,12 +7129,6 @@ border-radius: 5; 0 - - - button:help - url:http://wiki.openpilot.org/display/Doc/Stabilization+panel - - 51 @@ -7171,6 +7165,12 @@ border-radius: 4; Wiki + + + button:help + url:http://wiki.openpilot.org/display/Doc/Stabilization+panel + + @@ -7815,12 +7815,6 @@ border-radius: 4; 0 - - - button:help - url:http://wiki.openpilot.org/display/Doc/Stabilization+panel - - 51 @@ -7857,6 +7851,12 @@ border-radius: 4; Wiki + + + button:help + url:http://wiki.openpilot.org/display/Doc/Stabilization+panel + + @@ -7867,12 +7867,6 @@ border-radius: 4; 0 - - - button:default - buttongroup:3 - - 81 @@ -7909,6 +7903,12 @@ border-radius: 4; Default + + + button:default + buttongroup:3 + + @@ -10070,13 +10070,13 @@ Angle 25 - + objname:StabilizationSettings fieldname:RollMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10101,13 +10101,13 @@ Angle 50 - + objname:StabilizationSettings fieldname:RollMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10144,13 +10144,13 @@ Angle 25 - + objname:StabilizationSettings fieldname:PitchMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10175,13 +10175,13 @@ Angle 50 - + objname:StabilizationSettings fieldname:PitchMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10218,13 +10218,13 @@ Angle 25 - + objname:StabilizationSettings fieldname:YawMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10249,13 +10249,13 @@ Angle 50 - + objname:StabilizationSettings fieldname:YawMax haslimits:yes scale:1.8 - buttongroup:3,10 + buttongroup:3,10 @@ -10312,14 +10312,14 @@ Rate 25 - + objname:StabilizationSettings fieldname:ManualRate - element:Roll + element:Roll haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10344,14 +10344,14 @@ Rate 50 - + objname:StabilizationSettings fieldname:ManualRate - element:Roll + element:Roll haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10388,14 +10388,14 @@ Rate 25 - + objname:StabilizationSettings fieldname:ManualRate - element:Pitch + element:Pitch haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10420,14 +10420,14 @@ Rate 50 - + objname:StabilizationSettings fieldname:ManualRate - element:Pitch + element:Pitch haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10464,14 +10464,14 @@ Rate 25 - + objname:StabilizationSettings fieldname:ManualRate - element:Yaw + element:Yaw haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10496,14 +10496,14 @@ Rate 50 - + objname:StabilizationSettings fieldname:ManualRate - element:Yaw + element:Yaw haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10560,14 +10560,14 @@ Attitude 25 - + objname:StabilizationSettings fieldname:MaximumRate - element:Roll + element:Roll haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10592,14 +10592,14 @@ Attitude 50 - + objname:StabilizationSettings fieldname:MaximumRate - element:Roll + element:Roll haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10636,14 +10636,14 @@ Attitude 25 - + objname:StabilizationSettings fieldname:MaximumRate - element:Pitch + element:Pitch haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10668,14 +10668,14 @@ Attitude 50 - + objname:StabilizationSettings fieldname:MaximumRate - element:Pitch + element:Pitch haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10712,14 +10712,14 @@ Attitude 25 - + objname:StabilizationSettings fieldname:MaximumRate - element:Yaw + element:Yaw haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -10744,14 +10744,14 @@ Attitude 50 - + objname:StabilizationSettings fieldname:MaximumRate - element:Yaw + element:Yaw haslimits:yes scale:5 - buttongroup:3,10 + buttongroup:3,10 @@ -11377,12 +11377,12 @@ Attitude Zero the integral when throttle is low - - - objname:StabilizationSettings - fieldname:LowThrottleZeroIntegral - - + + + objname:StabilizationSettings + fieldname:LowThrottleZeroIntegral + + @@ -11439,12 +11439,6 @@ automatically every 300ms, which will help for fast tuning. 0 - - - button:help - url:http://wiki.openpilot.org/display/Doc/Stabilization+panel - - 32 @@ -11467,6 +11461,12 @@ automatically every 300ms, which will help for fast tuning. true + + + button:help + url:http://wiki.openpilot.org/display/Doc/Stabilization+panel + + @@ -11477,12 +11477,6 @@ automatically every 300ms, which will help for fast tuning. 0 - - - button:reload - buttongroup:10 - - 120 @@ -11524,6 +11518,12 @@ border-radius: 4; Reload Board Data + + + button:reload + buttongroup:10 + + @@ -11673,8 +11673,8 @@ border-radius: 4; 0 - 0 - 431 + -38 + 626 828 @@ -12315,13 +12315,6 @@ border-radius: 4; 0 - - - objname:StabilizationSettings - button:default - buttongroup:4 - - 81 @@ -12358,6 +12351,13 @@ border-radius: 4; Default + + + objname:StabilizationSettings + button:default + buttongroup:4 + + @@ -14500,16 +14500,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:RollRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14535,6 +14525,16 @@ border-radius: 5; 0.000100000000000 + + + objname:StabilizationSettings + fieldname:RollRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14544,16 +14544,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:PitchRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14576,6 +14566,16 @@ border-radius: 5; 0.000100000000000 + + + objname:StabilizationSettings + fieldname:PitchRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14585,16 +14585,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:YawRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14623,6 +14613,16 @@ You can usually go for higher values for Yaw factors. 0.000100000000000 + + + objname:StabilizationSettings + fieldname:YawRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14667,16 +14667,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:RollRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14703,6 +14693,16 @@ value as YawRate Kp. 0.000100000000000 + + + objname:StabilizationSettings + fieldname:RollRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14728,16 +14728,6 @@ value as YawRate Kp. 0 0 - - - - objname:StabilizationSettings - fieldname:PitchRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14760,6 +14750,16 @@ value as YawRate Kp. 0.000100000000000 + + + objname:StabilizationSettings + fieldname:PitchRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14785,16 +14785,6 @@ value as YawRate Kp. 0 0 - - - - objname:StabilizationSettings - fieldname:YawRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14823,6 +14813,16 @@ You can usually go for higher values for Yaw factors. 0.000100000000000 + + + objname:StabilizationSettings + fieldname:YawRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + @@ -14863,16 +14863,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:RollRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14896,7 +14886,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 1.000000000000000 + + + + objname:StabilizationSettings + fieldname:RollRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:4,20 + @@ -14907,16 +14907,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:PitchRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14937,7 +14927,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 1.000000000000000 + + + + objname:StabilizationSettings + fieldname:PitchRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:4,20 + @@ -14948,16 +14948,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:YawRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:4,20 - @@ -14984,7 +14974,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 1.000000000000000 + + + + objname:StabilizationSettings + fieldname:YawRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:4,20 + @@ -15662,13 +15662,6 @@ You can usually go for higher values for Yaw factors. 0 - - - objname:StabilizationSettings - button:default - buttongroup:5 - - 81 @@ -15705,6 +15698,13 @@ border-radius: 4; Default + + + objname:StabilizationSettings + button:default + buttongroup:5 + + @@ -17847,16 +17847,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:RollPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - @@ -17880,7 +17870,17 @@ border-radius: 5; 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:RollPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + @@ -17891,16 +17891,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:PitchPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - @@ -17921,7 +17911,17 @@ border-radius: 5; 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:PitchPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + @@ -17932,16 +17932,6 @@ border-radius: 5; 0 0 - - - - objname:StabilizationSettings - fieldname:YawPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - @@ -17968,7 +17958,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:YawPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18014,16 +18014,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:RollPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18048,7 +18038,17 @@ value as YawRate Kp. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:RollPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18075,16 +18075,6 @@ value as YawRate Kp. 0 0 - - - - objname:StabilizationSettings - fieldname:PitchPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18105,7 +18095,17 @@ value as YawRate Kp. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:PitchPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18132,16 +18132,6 @@ value as YawRate Kp. 0 0 - - - - objname:StabilizationSettings - fieldname:YawPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18168,7 +18158,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:YawPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18210,16 +18210,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:RollPI - element:ILimit - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18243,7 +18233,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:RollPI + element:ILimit + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18254,16 +18254,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:PitchPI - element:ILimit - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18284,7 +18274,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:PitchPI + element:ILimit + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18295,16 +18295,6 @@ You can usually go for higher values for Yaw factors. 0 0 - - - - objname:StabilizationSettings - fieldname:YawPI - element:ILimit - haslimits:no - scale:1 - buttongroup:5,20 - @@ -18331,7 +18321,17 @@ You can usually go for higher values for Yaw factors. 6 - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:YawPI + element:ILimit + haslimits:no + scale:1 + buttongroup:5,20 + @@ -18964,13 +18964,6 @@ You can usually go for higher values for Yaw factors. 0 - - - objname:StabilizationSettings - button:default - buttongroup:6 - - 81 @@ -19007,6 +19000,13 @@ border-radius: 4; Default + + + objname:StabilizationSettings + button:default + buttongroup:6 + + @@ -21170,10 +21170,22 @@ angle(deg) - 6 + 0 + + + 1000000.000000000000000 - 0.000100000000000 + 1.000000000000000 + + + + objname:StabilizationSettings + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21201,47 +21213,22 @@ angle(deg) - 6 + 0 + + + 1000000.000000000000000 - 0.000100000000000 + 1.000000000000000 - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Slowly raise Kp until you start seeing clear oscillations when you fly. -Then lower the value by 20% or so. - -You can usually go for higher values for Yaw factors. - - - - - - 6 - - - 0.000100000000000 + + + objname:StabilizationSettings + fieldname:PitchMax + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21311,8 +21298,21 @@ value as YawRate Kp. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21358,8 +21358,21 @@ value as YawRate Kp. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:ManualRate + element:Pitch + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21411,8 +21424,21 @@ You can usually go for higher values for Yaw factors. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21477,8 +21503,21 @@ You can usually go for higher values for Yaw factors. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:MaximumRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21508,8 +21547,21 @@ You can usually go for higher values for Yaw factors. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:MaximumRate + element:Pitch + haslimits:no + scale:1 + buttongroup:6,20 + @@ -21545,8 +21597,70 @@ You can usually go for higher values for Yaw factors. 6 + + 1000000.000000000000000 + - 0.000100000000000 + 0.100000000000000 + + + + objname:StabilizationSettings + fieldname:MaximumRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Slowly raise Kp until you start seeing clear oscillations when you fly. +Then lower the value by 20% or so. + +You can usually go for higher values for Yaw factors. + + + + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettings + fieldname:YawMax + haslimits:no + scale:1 + buttongroup:6,20 + @@ -22139,6 +22253,12 @@ You can usually go for higher values for Yaw factors. Zero the integral when throttle is low + + + objname:StabilizationSettings + fieldname:LowThrottleZeroIntegral + + @@ -22198,6 +22318,12 @@ automatically every 300ms, which will help for fast tuning. true + + + button:help + url:http://wiki.openpilot.org/display/Doc/Stabilization+panel + + @@ -22265,6 +22391,11 @@ border-radius: 4; Apply + + + button:apply + + @@ -22319,6 +22450,11 @@ border-radius: 4; Save + + + button:save + + diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp index 6a7c8d02e..bd860a37b 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectfield.cpp @@ -106,11 +106,11 @@ void UAVObjectField::limitsInitialize(const QString &limits) if(limits.isEmpty()) return; QStringList stringPerElement=limits.split(","); + quint32 index=0; foreach (QString str, stringPerElement) { QString _str=str.trimmed(); QStringList valuesPerElement=_str.split(":"); LimitStruct lstruc; - quint32 index=stringPerElement.indexOf(str); bool b1=valuesPerElement.at(0).startsWith("%"); bool b2=(int)(index)<(int)numElements; if(b1 && b2) @@ -157,6 +157,7 @@ void UAVObjectField::limitsInitialize(const QString &limits) } } elementLimits.insert(index,lstruc); + ++index; } else { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 86f5468a6..0ae42faa4 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -136,7 +136,7 @@ ConfigTaskWidget::~ConfigTaskWidget() void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) { - qDebug()<<"ConfigTaskWidget::saveObjectToSD"; + //qDebug()<<"ConfigTaskWidget::saveObjectToSD"; // saveObjectToSD is now handled by the UAVUtils plugin in one // central place (and one central queue) ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -165,6 +165,7 @@ double ConfigTaskWidget::listMean(QList list) void ConfigTaskWidget::onAutopilotDisconnect() { + qDebug()<<"ConfigTaskWidget onAutopilotDisconnect"; isConnected=false; enableControls(false); invalidateObjects(); @@ -172,6 +173,7 @@ void ConfigTaskWidget::onAutopilotDisconnect() void ConfigTaskWidget::onAutopilotConnect() { + qDebug()<<"ConfigTaskWidget onAutopilotConnect"; invalidateObjects(); dirty=false; isConnected=true; @@ -241,13 +243,17 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav if(!smartsave) { smartsave=new smartSaveButton(); - smartsave->addButtons(save,update); connect(smartsave,SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty())); connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates())); connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates())); } - smartsave->addButtons(save,update); + if(update && save) + smartsave->addButtons(save,update); + else if (update) + smartsave->addApplyButton(update); + else if (save) + smartsave->addSaveButton(save); if(objOfInterest.count()>0) { foreach(objectToWidget * oTw,objOfInterest) @@ -255,7 +261,11 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav smartsave->addObject((UAVDataObject*)oTw->object); } } - enableControls(false); + TelemetryManager* telMngr = pm->getObject(); + if(telMngr->isConnected()) + enableControls(true); + else + enableControls(false); } void ConfigTaskWidget::enableControls(bool enable) @@ -269,16 +279,17 @@ void ConfigTaskWidget::enableControls(bool enable) void ConfigTaskWidget::widgetsContentsChanged() { + //qDebug()<objectName()<metaObject()->className(); emit widgetContentsChanged((QWidget*)sender()); double scale; objectToWidget * oTw= shadowsList.value((QWidget*)sender(),NULL); /* - qDebug()<<"sender:"<<(quint32)sender(); + //qDebug()<<"sender:"<<(quint32)sender(); foreach(QWidget * w,shadowsList.keys()) - qDebug()<<"in list:"<<(quint32)w; + //qDebug()<<"in list:"<<(quint32)w; if(oTw) - qDebug()<<"in oTw OK"<<(quint32)oTw->widget; + //qDebug()<<"in oTw OK"<<(quint32)oTw->widget; */ if(oTw) { @@ -286,7 +297,7 @@ void ConfigTaskWidget::widgetsContentsChanged() { scale=oTw->scale; checkWidgetsLimits((QWidget*)sender(),oTw->field,oTw->index,oTw->isLimited,getVariantFromWidget((QWidget*)sender(),oTw->scale),oTw->scale); - qDebug()<<"sender was master"; + //qDebug()<<"sender was master"; } else { @@ -294,26 +305,31 @@ void ConfigTaskWidget::widgetsContentsChanged() { if(sh->widget==(QWidget*)sender()) { + //qDebug()<widget->objectName()<widget->metaObject()->className(); scale=sh->scale; checkWidgetsLimits((QWidget*)sender(),oTw->field,oTw->index,sh->isLimited,getVariantFromWidget((QWidget*)sender(),scale),scale); - qDebug()<<"sender was shadow"; + //qDebug()<<"sender was shadow"; } } } if(oTw->widget!=(QWidget *)sender()) { + //qDebug()<widget->objectName()<widget->metaObject()->className(); disconnectWidgetUpdatesToSlot((QWidget*)oTw->widget,SLOT(widgetsContentsChanged())); checkWidgetsLimits(oTw->widget,oTw->field,oTw->index,oTw->isLimited,getVariantFromWidget((QWidget*)sender(),scale),oTw->scale); setWidgetFromVariant(oTw->widget,getVariantFromWidget((QWidget*)sender(),scale),oTw->scale); - connectWidgetUpdatesToSlot((QWidget*)oTw->widget,SLOT(widgetsContentsChanged())); + emit widgetContentsChanged((QWidget*)oTw->widget); + connectWidgetUpdatesToSlot((QWidget*)oTw->widget,SLOT(widgetsContentsChanged())); } foreach (shadow * sh, oTw->shadowsList) { if(sh->widget!=(QWidget*)sender()) { + //qDebug()<widget->objectName()<widget->metaObject()->className(); disconnectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); checkWidgetsLimits(sh->widget,oTw->field,oTw->index,sh->isLimited,getVariantFromWidget((QWidget*)sender(),scale),sh->scale); setWidgetFromVariant(sh->widget,getVariantFromWidget((QWidget*)sender(),scale),sh->scale); + emit widgetContentsChanged((QWidget*)sh->widget); connectWidgetUpdatesToSlot((QWidget*)sh->widget,SLOT(widgetsContentsChanged())); } } @@ -367,7 +383,7 @@ bool ConfigTaskWidget::allObjectsUpdated() { ret=ret & objectUpdates[obj]; } - qDebug()<<"ALL OBJECTS UPDATE:"<apply(); +} + +void ConfigTaskWidget::save() +{ + if(smartsave) + smartsave->save(); +} + bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited,QList* defaultReloadGroups) { foreach(objectToWidget * oTw,objOfInterest) @@ -405,6 +433,16 @@ bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *w oTw->scale=scale; oTw->widget=widget; } + else if(!qobject_cast(oTw->widget) && qobject_cast(widget)) + { + sh=new shadow; + sh->isLimited=oTw->isLimited; + sh->scale=oTw->scale; + sh->widget=oTw->widget; + oTw->isLimited=isLimited; + oTw->scale=scale; + oTw->widget=widget; + } else { sh=new shadow; @@ -412,8 +450,8 @@ bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *w sh->scale=scale; sh->widget=widget; } + shadowsList.insert(widget,oTw); oTw->shadowsList.append(sh); - shadowsList.insert(sh->widget,oTw); connectWidgetUpdatesToSlot(widget,SLOT(widgetsContentsChanged())); if(defaultReloadGroups) addWidgetToDefaultReloadGroups(widget,defaultReloadGroups); @@ -433,7 +471,7 @@ void ConfigTaskWidget::autoLoadWidgets() QVariant info=widget->property("objrelation"); if(info.isValid()) { - qDebug()<<"processing autoloadwidget"; + //qDebug()<<"processing autoloadwidget"; uiRelationAutomation uiRelation; uiRelation.buttonType=none; uiRelation.scale=1; @@ -495,9 +533,13 @@ void ConfigTaskWidget::autoLoadWidgets() { case save_button: saveButtonWidget=qobject_cast(widget); + if(saveButtonWidget) + addApplySaveButtons(NULL,saveButtonWidget); break; case apply_button: applyButtonWidget=qobject_cast(widget); + if(applyButtonWidget) + addApplySaveButtons(applyButtonWidget,NULL); break; case default_button: button=qobject_cast(widget); @@ -522,18 +564,16 @@ void ConfigTaskWidget::autoLoadWidgets() else { QWidget * wid=qobject_cast(widget); - qDebug()<<"adding widget"<<(quint32)wid; + //qDebug()<<"adding widget"<<(quint32)wid; if(uiRelation.element.isEmpty()) { - qDebug()<<"empty element"; + //qDebug()<<"empty element"; } if(wid) addUAVObjectToWidgetRelation(uiRelation.objname,uiRelation.fieldname,wid,uiRelation.element,uiRelation.scale,uiRelation.haslimits,&uiRelation.buttonGroup); } } } - if(saveButtonWidget && applyButtonWidget) - addApplySaveButtons(applyButtonWidget,saveButtonWidget); refreshWidgetsValues(); } @@ -658,14 +698,14 @@ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget * widget,const char* f } else if(QCheckBox * cb=qobject_cast(widget)) { - connect(cb,SIGNAL(clicked()),this,function); + connect(cb,SIGNAL(stateChanged(int)),this,function); } else if(QPushButton * cb=qobject_cast(widget)) { connect(cb,SIGNAL(clicked()),this,function); } - else - qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); + //else + //qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); } void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget * widget,const char* function) @@ -698,14 +738,14 @@ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget * widget,const char } else if(QCheckBox * cb=qobject_cast(widget)) { - disconnect(cb,SIGNAL(clicked()),this,function); + disconnect(cb,SIGNAL(stateChanged(int)),this,function); } else if(QPushButton * cb=qobject_cast(widget)) { disconnect(cb,SIGNAL(clicked()),this,function); } - else - qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); + //else + //qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); } bool ConfigTaskWidget::setFieldFromWidget(QWidget * widget,UAVObjectField * field,int index,double scale) @@ -719,7 +759,7 @@ bool ConfigTaskWidget::setFieldFromWidget(QWidget * widget,UAVObjectField * fiel return true; } { - qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); + //qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); return false; } } @@ -758,7 +798,6 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, dou } else if(QLabel * cb=qobject_cast(widget)) { - qDebug()<<"SETLABEL "<setText(value.toString()); else @@ -778,7 +817,7 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, dou else if(QSlider * cb=qobject_cast(widget)) { cb->setValue((int)qRound(value.toDouble()/scale)); - qDebug()<<"SETVALUE widgetfromvariant"<(widget)) @@ -807,7 +846,7 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget * widget,UAVObjectField * fiel return true; else { - qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); + //qDebug()<<__FUNCTION__<<"widget to uavobject relation not implemented"<metaObject()->className(); return false; } } @@ -815,7 +854,7 @@ void ConfigTaskWidget::checkWidgetsLimits(QWidget * widget,UAVObjectField * fiel { if(!hasLimits) return; - qDebug()<<"check widget"<accessibleName()<<"value"<isWithinLimits(value,index); + //qDebug()<<"check widget"<objectName()<<"value"<isWithinLimits(value,index); if(!field->isWithinLimits(value,index)) { if(!widget->property("styleBackup").isValid()) @@ -926,12 +965,12 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field, if(field->getMaxLimit(index).isValid()) { cb->setMaximum((int)qRound(field->getMaxLimit(index).toDouble()/scale)); - qDebug()<<"set MAX="<getMaxLimit(index).toDouble()<<"/"<maximum(); + //qDebug()<<"set MAX="<getMaxLimit(index).toDouble()<<"/"<maximum(); } if(field->getMinLimit(index).isValid()) { cb->setMinimum((int)(field->getMinLimit(index).toDouble()/scale)); - qDebug()<< "set MIN="<getMinLimit(index).toDouble()<<"/"<minimum(); + //qDebug()<< "set MIN="<getMinLimit(index).toDouble()<<"/"<minimum(); } } } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index a31fe26f8..8310ac04b 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -119,6 +119,8 @@ public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); void invalidateObjects(); + void apply(); + void save(); signals: void widgetContentsChanged(QWidget * widget); void populateWidgetsRequested(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp index 7279e6def..36da08758 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp @@ -38,6 +38,16 @@ void smartSaveButton::addButtons(QPushButton *save, QPushButton *apply) connect(save,SIGNAL(clicked()),this,SLOT(processClick())); connect(apply,SIGNAL(clicked()),this,SLOT(processClick())); } +void smartSaveButton::addApplyButton(QPushButton *apply) +{ + buttonList.insert(apply,apply_button); + connect(apply,SIGNAL(clicked()),this,SLOT(processClick())); +} +void smartSaveButton::addSaveButton(QPushButton *save) +{ + buttonList.insert(save,save_button); + connect(save,SIGNAL(clicked()),this,SLOT(processClick())); +} void smartSaveButton::processClick() { emit beginOp(); @@ -47,9 +57,18 @@ void smartSaveButton::processClick() return; if(buttonList.value(button)==save_button) save=true; + processOperation(button,save); + +} + +void smartSaveButton::processOperation(QPushButton * button,bool save) +{ emit preProcessOperations(); - button->setEnabled(false); - button->setIcon(QIcon(":/uploader/images/system-run.svg")); + if(button) + { + button->setEnabled(false); + button->setIcon(QIcon(":/uploader/images/system-run.svg")); + } QTimer timer; timer.setSingleShot(true); bool error=false; @@ -109,15 +128,18 @@ void smartSaveButton::processClick() } } } - button->setEnabled(true); + if(button) + button->setEnabled(true); if(!error) { - button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); + if(button) + button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); emit saveSuccessfull(); } else { - button->setIcon(QIcon(":/uploader/images/process-stop.svg")); + if(button) + button->setIcon(QIcon(":/uploader/images/process-stop.svg")); } emit endOp(); } @@ -169,3 +191,15 @@ void smartSaveButton::enableControls(bool value) foreach(QPushButton * button,buttonList.keys()) button->setEnabled(value); } + +void smartSaveButton::apply() +{ + processOperation(NULL,false); +} + +void smartSaveButton::save() +{ + processOperation(NULL,true); +} + + diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h index c96de6717..6931cee92 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h @@ -50,13 +50,19 @@ public: void clearObjects(); void removeObject(UAVDataObject *obj); void removeAllObjects(); + void addApplyButton(QPushButton *apply); + void addSaveButton(QPushButton *save); signals: void preProcessOperations(); void saveSuccessfull(); void beginOp(); void endOp(); +public slots: + void apply(); + void save(); private slots: void processClick(); + void processOperation(QPushButton *button, bool save); void transaction_finished(UAVObject* obj, bool result); void saving_finished(int,bool);