1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

OP-532 Updated GUI config data definition, UI, and implemented three

sliders in mixer generation code
This commit is contained in:
Andrew Thoms 2011-06-16 00:09:27 -04:00
parent 22269b658d
commit 5c5a07b101
4 changed files with 119 additions and 39 deletions

View File

@ -75,7 +75,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="BasicTab"> <widget class="QWidget" name="BasicTab">
<attribute name="title"> <attribute name="title">
@ -1585,7 +1585,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="ccpmCollectivesScaleBox"> <widget class="QSpinBox" name="ccpmCollectiveScaleBox">
<property name="maximum"> <property name="maximum">
<number>100</number> <number>100</number>
</property> </property>
@ -3823,7 +3823,7 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>ccpmCollectivesScaleBox</sender> <sender>ccpmCollectiveScaleBox</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>
<receiver>ccpmCollectiveScale</receiver> <receiver>ccpmCollectiveScale</receiver>
<slot>setValue(int)</slot> <slot>setValue(int)</slot>
@ -3841,7 +3841,7 @@
<connection> <connection>
<sender>ccpmCollectiveScale</sender> <sender>ccpmCollectiveScale</sender>
<signal>sliderMoved(int)</signal> <signal>sliderMoved(int)</signal>
<receiver>ccpmCollectivesScaleBox</receiver> <receiver>ccpmCollectiveScaleBox</receiver>
<slot>setValue(int)</slot> <slot>setValue(int)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">

View File

@ -739,17 +739,42 @@ void ConfigccpmWidget::ccpmSwashplateUpdate()
void ConfigccpmWidget::UpdateMixer() void ConfigccpmWidget::UpdateMixer()
{ {
int i,j,Type,ThisEnable[6]; bool useCCPM;
float CollectiveConstant,CorrectionAngle,ThisAngle[6]; bool useCyclic;
int i,j,ThisEnable[6];
float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6];
//QTableWidgetItem *newItem;// = new QTableWidgetItem(); //QTableWidgetItem *newItem;// = new QTableWidgetItem();
QString Channel; QString Channel;
Type = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; //Type = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
CollectiveConstant=m_ccpm->ccpmCollectiveSlider->value()/100.0; //CollectiveConstant=m_ccpm->ccpmCollectiveSlider->value()/100.0;
CorrectionAngle=m_ccpm->ccpmCorrectionAngle->value(); //CorrectionAngle=m_ccpm->ccpmCorrectionAngle->value();
UpdatCCPMOptionsFromUI();
useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState);
useCyclic = GUIConfigData.heli.ccpmLinkRollState;
if (Type>0) CollectiveConstant = (float)GUIConfigData.heli.SliderValue0 / 100.00;
if (useCCPM)
{//cyclic = 1 - collective
PitchConstant = 1-CollectiveConstant;
RollConstant = PitchConstant;
}
else
{
PitchConstant = (float)GUIConfigData.heli.SliderValue1 / 100.00;;
if (useCyclic)
{
RollConstant = PitchConstant;
}
else
{
RollConstant = (float)GUIConfigData.heli.SliderValue2 / 100.00;;
}
}
if (GUIConfigData.heli.SwasplateType>0)
{//not advanced settings {//not advanced settings
//get the channel data from the ui //get the channel data from the ui
MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex(); MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex();
@ -813,8 +838,8 @@ void ConfigccpmWidget::UpdateMixer()
{//Swashplate {//Swashplate
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(1-CollectiveConstant)*sin((180+CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(1-CollectiveConstant)*cos((CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
} }
@ -859,6 +884,9 @@ void ConfigccpmWidget::UpdateMixer()
*/ */
void ConfigccpmWidget::UpdatCCPMOptionsFromUI() void ConfigccpmWidget::UpdatCCPMOptionsFromUI()
{ {
bool useCCPM;
bool useCyclic;
if (updatingFromHardware) return; if (updatingFromHardware) return;
//get the user options //get the user options
//swashplate config //swashplate config
@ -869,12 +897,36 @@ void ConfigccpmWidget::UpdatCCPMOptionsFromUI()
GUIConfigData.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); GUIConfigData.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked();
GUIConfigData.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); GUIConfigData.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked();
GUIConfigData.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); GUIConfigData.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked();
useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState);
useCyclic = GUIConfigData.heli.ccpmLinkRollState;
//correction angle //correction angle
GUIConfigData.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value(); GUIConfigData.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value();
//CollectiveChannel //CollectiveChannel
GUIConfigData.heli.CollectiveChannel = m_ccpm->ccpmCollectiveChannel->currentIndex(); GUIConfigData.heli.CollectiveChannel = m_ccpm->ccpmCollectiveChannel->currentIndex();
//update sliders
if (useCCPM)
{
GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value();
}
else
{
GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value();
}
if (useCyclic)
{
GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value();
}
else
{
GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value();
}
GUIConfigData.heli.SliderValue2 = m_ccpm->ccpmRollScale->value();
//GUIConfigData.heli.RevoSlider = m_ccpm->ccpmREVOScale->value();
} }
void ConfigccpmWidget::UpdatCCPMUIFromOptions() void ConfigccpmWidget::UpdatCCPMUIFromOptions()
{ {
@ -893,6 +945,18 @@ void ConfigccpmWidget::UpdatCCPMUIFromOptions()
//CollectiveChannel //CollectiveChannel
m_ccpm->ccpmCollectiveChannel->setCurrentIndex(GUIConfigData.heli.CollectiveChannel); m_ccpm->ccpmCollectiveChannel->setCurrentIndex(GUIConfigData.heli.CollectiveChannel);
//update sliders
m_ccpm->ccpmCollectiveScale->setValue(GUIConfigData.heli.SliderValue0);
m_ccpm->ccpmCollectiveScaleBox->setValue(GUIConfigData.heli.SliderValue0);
m_ccpm->ccpmCyclicScale->setValue(GUIConfigData.heli.SliderValue1);
m_ccpm->ccpmCyclicScaleBox->setValue(GUIConfigData.heli.SliderValue1);
m_ccpm->ccpmPitchScale->setValue(GUIConfigData.heli.SliderValue1);
m_ccpm->ccpmPitchScaleBox->setValue(GUIConfigData.heli.SliderValue1);
m_ccpm->ccpmRollScale->setValue(GUIConfigData.heli.SliderValue2);
m_ccpm->ccpmRollScaleBox->setValue(GUIConfigData.heli.SliderValue2);
m_ccpm->ccpmCollectiveSlider->setValue(GUIConfigData.heli.SliderValue0);
m_ccpm->ccpmCollectivespinBox->setValue(GUIConfigData.heli.SliderValue0);
//m_ccpm->ccpmREVOScale->setValue(GUIConfigData.heli.RevoSlider);
} }
@ -952,7 +1016,8 @@ void ConfigccpmWidget::requestccpmUpdate()
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings"))); obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
field = obj->getField(QString("GUIConfigData")); field = obj->getField(QString("GUIConfigData"));
GUIConfigData.UAVObject=field->getValue().toUInt(); GUIConfigData.UAVObject[0]=field->getValue(0).toUInt();
GUIConfigData.UAVObject[1]=field->getValue(1).toUInt();
UpdatCCPMUIFromOptions(); UpdatCCPMUIFromOptions();
@ -1040,6 +1105,7 @@ void ConfigccpmWidget::requestccpmUpdate()
//just call it user angles for now.... //just call it user angles for now....
/*
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - User Angles")); m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - User Angles"));
if (NumServos>1) if (NumServos>1)
@ -1072,7 +1138,9 @@ void ConfigccpmWidget::requestccpmUpdate()
} }
HeadRotation=0; HeadRotation=0;
//calculate the angles
HeadRotation=m_ccpm->ccpmSingleServo->currentIndex();
//calculate the angles
for(j=0;j<NumServos;j++) for(j=0;j<NumServos;j++)
{ {
//MixerDataFromHeli[i][2]=(127.0*(1-CollectiveConstant)*sin((CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll //MixerDataFromHeli[i][2]=(127.0*(1-CollectiveConstant)*sin((CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
@ -1088,7 +1156,7 @@ void ConfigccpmWidget::requestccpmUpdate()
} }
//set the head rotation //set the head rotation
m_ccpm->ccpmSingleServo->setCurrentIndex(HeadRotation); //m_ccpm->ccpmSingleServo->setCurrentIndex(HeadRotation);
//calculate the un rotated angles //calculate the un rotated angles
for(j=0;j<NumServos;j++) for(j=0;j<NumServos;j++)
@ -1108,15 +1176,19 @@ void ConfigccpmWidget::requestccpmUpdate()
} }
m_ccpm->ccpmAngleW->setValue(ServoAngles[SortAngles[0]]); //m_ccpm->ccpmAngleW->setValue(ServoAngles[SortAngles[0]]);
m_ccpm->ccpmAngleX->setValue(ServoAngles[SortAngles[1]]); //m_ccpm->ccpmAngleX->setValue(ServoAngles[SortAngles[1]]);
m_ccpm->ccpmAngleY->setValue(ServoAngles[SortAngles[2]]); //m_ccpm->ccpmAngleY->setValue(ServoAngles[SortAngles[2]]);
m_ccpm->ccpmAngleZ->setValue(ServoAngles[SortAngles[3]]); //m_ccpm->ccpmAngleZ->setValue(ServoAngles[SortAngles[3]]);
m_ccpm->ccpmServoWChannel->setCurrentIndex(ServoChannels[SortAngles[0]]); //m_ccpm->ccpmServoWChannel->setCurrentIndex(ServoChannels[SortAngles[0]]);
m_ccpm->ccpmServoXChannel->setCurrentIndex(ServoChannels[SortAngles[1]]); //m_ccpm->ccpmServoXChannel->setCurrentIndex(ServoChannels[SortAngles[1]]);
m_ccpm->ccpmServoYChannel->setCurrentIndex(ServoChannels[SortAngles[2]]); //m_ccpm->ccpmServoYChannel->setCurrentIndex(ServoChannels[SortAngles[2]]);
m_ccpm->ccpmServoZChannel->setCurrentIndex(ServoChannels[SortAngles[3]]); //m_ccpm->ccpmServoZChannel->setCurrentIndex(ServoChannels[SortAngles[3]]);
m_ccpm->ccpmServoWChannel->setCurrentIndex(ServoChannels[0]);
m_ccpm->ccpmServoXChannel->setCurrentIndex(ServoChannels[1]);
m_ccpm->ccpmServoYChannel->setCurrentIndex(ServoChannels[2]);
m_ccpm->ccpmServoZChannel->setCurrentIndex(ServoChannels[3]);
//Types << "CCPM 2 Servo 90º" << "CCPM 3 Servo 120º" << "CCPM 3 Servo 140º" << "FP 2 Servo 90º" << "Custom - User Angles" << "Custom - Advanced Settings" ; //Types << "CCPM 2 Servo 90º" << "CCPM 3 Servo 120º" << "CCPM 3 Servo 140º" << "FP 2 Servo 90º" << "Custom - User Angles" << "Custom - Advanced Settings" ;
@ -1182,7 +1254,7 @@ void ConfigccpmWidget::requestccpmUpdate()
{ {
} }
*/
@ -1204,7 +1276,7 @@ void ConfigccpmWidget::requestccpmUpdate()
updatingFromHardware=FALSE; updatingFromHardware=FALSE;
UpdatCCPMUIFromOptions();
ccpmSwashplateUpdate(); ccpmSwashplateUpdate();
} }
@ -1220,17 +1292,21 @@ void ConfigccpmWidget::sendccpmUpdate()
UAVDataObject* obj; UAVDataObject* obj;
if (SwashLvlConfigurationInProgress)return; if (SwashLvlConfigurationInProgress)return;
ShowDisclaimer(1); //ShowDisclaimer(1);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UpdatCCPMOptionsFromUI();
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings"))); obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
field = obj->getField(QString("GUIConfigData")); field = obj->getField(QString("GUIConfigData"));
field->setValue(GUIConfigData.UAVObject); field->setValue(GUIConfigData.UAVObject[0],0);
field->setValue(GUIConfigData.UAVObject[1],1);
obj->updated(); obj->updated();
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("MixerSettings"))); obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("MixerSettings")));
Q_ASSERT(obj); Q_ASSERT(obj);
@ -1299,6 +1375,8 @@ void ConfigccpmWidget::sendccpmUpdate()
obj->updated(); obj->updated();
} }
/** /**

View File

@ -56,14 +56,16 @@ typedef struct {
uint ccpmCollectivePassthroughState:1; uint ccpmCollectivePassthroughState:1;
uint ccpmLinkCyclicState:1; uint ccpmLinkCyclicState:1;
uint ccpmLinkRollState:1; uint ccpmLinkRollState:1;
uint CollectiveChannel:3; uint CollectiveChannel:3;//20bits
uint padding:12; uint SliderValue0:7;
uint padding2:32; uint SliderValue1:7;
uint SliderValue2:7;//41bits
uint padding:23;
} __attribute__((packed)) heliGUISettingsStruct; } __attribute__((packed)) heliGUISettingsStruct;
typedef union typedef union
{ {
uint UAVObject; uint UAVObject[2];
heliGUISettingsStruct heli; heliGUISettingsStruct heli;
} GUIConfigDataUnion; } GUIConfigDataUnion;

View File

@ -2,7 +2,7 @@
<object name="SystemSettings" singleinstance="true" settings="true"> <object name="SystemSettings" singleinstance="true" settings="true">
<description>Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand</description> <description>Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand</description>
<field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,FixedWingVtail,VTOL,HeliCP,QuadX,QuadP,Hexa,Octo,Custom,HexaX,OctoV,OctoCoaxP,OctoCoaxX,HexaCoax,Tri" defaultvalue="FixedWing"/> <field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,FixedWingVtail,VTOL,HeliCP,QuadX,QuadP,Hexa,Octo,Custom,HexaX,OctoV,OctoCoaxP,OctoCoaxX,HexaCoax,Tri" defaultvalue="FixedWing"/>
<field name="GUIConfigData" units="bits" type="uint32" elements="1" defaultvalue="0"/> <field name="GUIConfigData" units="bits" type="uint32" elements="2" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/> <access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/> <telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/> <telemetryflight acked="true" updatemode="onchange" period="0"/>