1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge branch 'next' of ssh://git.openpilot.org/OpenPilot into next

This commit is contained in:
sambas 2011-08-06 08:57:53 +03:00
commit 0ba697af5b
4 changed files with 78 additions and 211 deletions

View File

@ -37,6 +37,9 @@
#include <math.h> #include <math.h>
#include <QMessageBox> #include <QMessageBox>
#include "mixersettings.h"
#include "systemsettings.h"
#define Pi 3.14159265358979323846 #define Pi 3.14159265358979323846
@ -1179,7 +1182,7 @@ void ConfigccpmWidget::requestccpmUpdate()
{ {
#define MaxAngleError 2 #define MaxAngleError 2
int MixerDataFromHeli[8][5]; int MixerDataFromHeli[8][5];
QString MixerOutputType[8]; quint8 MixerOutputType[8];
int EngineChannel,TailRotorChannel,ServoChannels[4],ServoAngles[4],SortAngles[4],CalcAngles[4],ServoCurve2[4]; int EngineChannel,TailRotorChannel,ServoChannels[4],ServoAngles[4],SortAngles[4],CalcAngles[4],ServoCurve2[4];
int NumServos=0; int NumServos=0;
double Collective=0.0; double Collective=0.0;
@ -1191,39 +1194,45 @@ void ConfigccpmWidget::requestccpmUpdate()
if (updatingToHardware)return; if (updatingToHardware)return;
updatingFromHardware=TRUE; updatingFromHardware=TRUE;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
int i,j; int i,j;
UAVObjectField *field;
UAVDataObject* obj;
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings"))); SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
field = obj->getField(QString("GUIConfigData")); SystemSettings::DataFields systemSettingsData = systemSettings->getData();
GUIConfigData.UAVObject[0]=field->getValue(0).toUInt();
GUIConfigData.UAVObject[1]=field->getValue(1).toUInt(); Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
(sizeof(GUIConfigData.UAVObject) / sizeof(GUIConfigData.UAVObject[0])));
for(i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++)
GUIConfigData.UAVObject[i]=systemSettingsData.GUIConfigData[i];
UpdatCCPMUIFromOptions(); UpdatCCPMUIFromOptions();
// Get existing mixer settings
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("MixerSettings"))); MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager());
Q_ASSERT(obj); MixerSettings::DataFields mixerSettingsData = mixerSettings->getData();
//go through the user data and update the mixer matrix //go through the user data and update the mixer matrix
for (i=0;i<8;i++)
{
field = obj->getField(tr( "Mixer%1Vector" ).arg(i+1));
//config the vector
for (j=0;j<5;j++) for (j=0;j<5;j++)
{ {
MixerDataFromHeli[i][j] = field->getValue(j).toInt(); MixerDataFromHeli[0][j] = mixerSettingsData.Mixer1Vector[j];
//field->setValue(m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(),j); MixerDataFromHeli[1][j] = mixerSettingsData.Mixer2Vector[j];
} MixerDataFromHeli[2][j] = mixerSettingsData.Mixer3Vector[j];
} MixerDataFromHeli[3][j] = mixerSettingsData.Mixer4Vector[j];
for (i=0;i<8;i++) MixerDataFromHeli[4][j] = mixerSettingsData.Mixer5Vector[j];
{ MixerDataFromHeli[5][j] = mixerSettingsData.Mixer6Vector[j];
field = obj->getField(tr( "Mixer%1Type" ).arg(i+1)); MixerDataFromHeli[6][j] = mixerSettingsData.Mixer7Vector[j];
MixerOutputType[i] = field->getValue().toString(); MixerDataFromHeli[7][j] = mixerSettingsData.Mixer8Vector[j];
} }
MixerOutputType[0] = mixerSettingsData.Mixer1Type;
MixerOutputType[1] = mixerSettingsData.Mixer2Type;
MixerOutputType[2] = mixerSettingsData.Mixer3Type;
MixerOutputType[3] = mixerSettingsData.Mixer4Type;
MixerOutputType[4] = mixerSettingsData.Mixer5Type;
MixerOutputType[5] = mixerSettingsData.Mixer6Type;
MixerOutputType[6] = mixerSettingsData.Mixer7Type;
MixerOutputType[7] = mixerSettingsData.Mixer8Type;
EngineChannel =-1; EngineChannel =-1;
TailRotorChannel =-1; TailRotorChannel =-1;
for (j=0;j<5;j++) for (j=0;j<5;j++)
@ -1239,7 +1248,7 @@ void ConfigccpmWidget::requestccpmUpdate()
for (i=0;i<8;i++) for (i=0;i<8;i++)
{ {
//check if this is the engine... Throttle only //check if this is the engine... Throttle only
if ((MixerOutputType[i].compare("Motor")==0)&& if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_MOTOR)&&
(MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1 (MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1
(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
(MixerDataFromHeli[i][2]==0)&&//Roll (MixerDataFromHeli[i][2]==0)&&//Roll
@ -1251,7 +1260,7 @@ void ConfigccpmWidget::requestccpmUpdate()
} }
//check if this is the tail rotor... REVO and YAW //check if this is the tail rotor... REVO and YAW
if ((MixerOutputType[i].compare("Servo")==0)&& if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&&
//(MixerDataFromHeli[i][0]!=0)&&//ThrottleCurve1 //(MixerDataFromHeli[i][0]!=0)&&//ThrottleCurve1
(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
(MixerDataFromHeli[i][2]==0)&&//Roll (MixerDataFromHeli[i][2]==0)&&//Roll
@ -1264,7 +1273,7 @@ void ConfigccpmWidget::requestccpmUpdate()
m_ccpm->ccpmREVOspinBox->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 //check if this is a swashplate servo... Throttle is zero
if ((MixerOutputType[i].compare("Servo")==0)&& if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&&
(MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1 (MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1
//(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 //(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
//(MixerDataFromHeli[i][2]==0)&&//Roll //(MixerDataFromHeli[i][2]==0)&&//Roll
@ -1275,193 +1284,23 @@ void ConfigccpmWidget::requestccpmUpdate()
ServoCurve2[NumServos]=MixerDataFromHeli[i][1];//record the ThrottleCurve2 contribution to 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 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++; NumServos++;
} }
} }
//just call it user angles for now....
/*
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - User Angles"));
if (NumServos>1)
{
if((ServoCurve2[0]==0)&&(ServoCurve2[1]==0)&&(ServoCurve2[2]==0)&&(ServoCurve2[3]==0))
{
//fixed pitch heli
isCCPM=0;
m_ccpm->ccpmCollectiveSlider->setValue(0);
Collective = 0.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
isCCPM=1;
Collective = ((double)ServoCurve2[0]*100.00)/127.00;
m_ccpm->ccpmCollectiveSlider->setValue((int)Collective);
m_ccpm->ccpmCollectivespinBox->setValue((int)Collective);
}
}
}
}
else
{//must be a custom config... "Custom - Advanced Settings"
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("Custom - Advanced Settings"));
}
HeadRotation=0;
HeadRotation=m_ccpm->ccpmSingleServo->currentIndex();
//calculate the angles
for(j=0;j<NumServos;j++)
{
//MixerDataFromHeli[i][2]=(127.0*(1-CollectiveConstant)*sin((CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
//MixerDataFromHeli[i][3]=(127.0*(1-CollectiveConstant)*cos((CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
a1=((double)MixerDataFromHeli[ServoChannels[j]][2]/(1.27*(100.0-Collective)));
a2=((double)MixerDataFromHeli[ServoChannels[j]][3]/(1.27*(100.0-Collective)));
ServoAngles[j]=fmod(360.0+atan2(-a1,a2)/(Pi/180.00),360.0);
//check the angles for one being a multiple of 90deg
if (fmod(ServoAngles[j],90)<MaxAngleError)
{
HeadRotation=ServoAngles[j]/90;
}
}
//set the head rotation
//m_ccpm->ccpmSingleServo->setCurrentIndex(HeadRotation);
//calculate the un rotated angles
for(j=0;j<NumServos;j++)
{
CalcAngles[j] = fmod(360.0+ServoAngles[j]-(double)HeadRotation*90.0,360.0);
}
//sort the calc angles do the smallest is first...brute force...
for(i=0;i<5;i++)
for(j=0;j<NumServos-1;j++)
{
if (CalcAngles[SortAngles[j]] > CalcAngles[SortAngles[j+1]])
{//swap the sorted angles
temp = SortAngles[j];
SortAngles[j]=SortAngles[j+1];
SortAngles[j+1]=temp;
}
}
//m_ccpm->ccpmAngleW->setValue(ServoAngles[SortAngles[0]]);
//m_ccpm->ccpmAngleX->setValue(ServoAngles[SortAngles[1]]);
//m_ccpm->ccpmAngleY->setValue(ServoAngles[SortAngles[2]]);
//m_ccpm->ccpmAngleZ->setValue(ServoAngles[SortAngles[3]]);
//m_ccpm->ccpmServoWChannel->setCurrentIndex(ServoChannels[SortAngles[0]]);
//m_ccpm->ccpmServoXChannel->setCurrentIndex(ServoChannels[SortAngles[1]]);
//m_ccpm->ccpmServoYChannel->setCurrentIndex(ServoChannels[SortAngles[2]]);
//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" ;
//check this against known combinations
if (NumServos==2)
{
if ((fabs(CalcAngles[SortAngles[0]])<MaxAngleError)&&
(fabs(CalcAngles[SortAngles[1]]-90)<MaxAngleError))
{// two servo 90º
if (isCCPM)
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("CCPM 2 Servo 90º"));
UpdateType();
}
else
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("FP 2 Servo 90º"));
UpdateType();
}
}
}
if (NumServos==3)
{
if ((fabs(CalcAngles[SortAngles[0]])<MaxAngleError)&&
(fabs(CalcAngles[SortAngles[1]]-120)<MaxAngleError)&&
(fabs(CalcAngles[SortAngles[2]]-240)<MaxAngleError))
{// three servo 120º
if (isCCPM)
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("CCPM 3 Servo 120º"));
UpdateType();
}
else
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("FP 3 Servo 120º"));
UpdateType();
}
}
else if ((fabs(CalcAngles[SortAngles[0]])<MaxAngleError)&&
(fabs(CalcAngles[SortAngles[1]]-140)<MaxAngleError)&&
(fabs(CalcAngles[SortAngles[2]]-220)<MaxAngleError))
{// three servo 140º
if (isCCPM)
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("CCPM 3 Servo 140º"));
UpdateType();
}
else
{
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->findText("FP 3 Servo 140º"));
UpdateType();
}
}
}
if (NumServos==4)
{
}
*/
//get the settings for the curve from the mixer settings //get the settings for the curve from the mixer settings
field = obj->getField(QString("ThrottleCurve1"));
for (i=0;i<5;i++) for (i=0;i<5;i++)
{ {
m_ccpm->CurveSettings->item(i, 0)->setText(QString().sprintf("%.3f",field->getValue(i).toDouble())); m_ccpm->CurveSettings->item(i, 0)->setText(QString().sprintf("%.3f",
//m_ccpm->CurveSettings->item(i, 0)->setText(field->getValue(i).toString()); mixerSettingsData.ThrottleCurve1[i]));
m_ccpm->CurveSettings->item(i, 1)->setText(QString().sprintf("%.3f",
mixerSettingsData.ThrottleCurve2[i]));
} }
field = obj->getField(QString("ThrottleCurve2"));
for (i=0;i<5;i++)
{
m_ccpm->CurveSettings->item(i, 1)->setText(QString().sprintf("%.3f",field->getValue(i).toDouble()));
//m_ccpm->CurveSettings->item(i, 1)->setText(field->getValue(i).toString());
}
updatingFromHardware=FALSE; updatingFromHardware=FALSE;
UpdatCCPMUIFromOptions(); UpdatCCPMUIFromOptions();
ccpmSwashplateUpdate(); ccpmSwashplateUpdate();
} }
@ -1499,7 +1338,7 @@ void ConfigccpmWidget::sendccpmUpdate()
//clear the output types //clear the output types
for (i=0;i<8;i++) for (i=0;i<8;i++)
{ {
field = obj->getField(tr( "Mixer%1Type" ).arg( i+1 )); field = obj->getField( QString( "Mixer%1Type" ).arg( i+1 ));
//clear the mixer type //clear the mixer type
field->setValue("Disabled"); field->setValue("Disabled");
} }
@ -1520,7 +1359,7 @@ void ConfigccpmWidget::sendccpmUpdate()
if (MixerChannelData[i]<8) if (MixerChannelData[i]<8)
{ {
//select the correct mixer for this config element //select the correct mixer for this config element
field = obj->getField(tr( "Mixer%1Type" ).arg( MixerChannelData[i]+1 )); field = obj->getField(QString( "Mixer%1Type" ).arg( MixerChannelData[i]+1 ));
//set the mixer type //set the mixer type
if (i==0) if (i==0)
{ {
@ -1532,7 +1371,7 @@ void ConfigccpmWidget::sendccpmUpdate()
} }
//select the correct mixer for this config element //select the correct mixer for this config element
field = obj->getField(tr( "Mixer%1Vector" ).arg( MixerChannelData[i]+1 )); field = obj->getField(QString( "Mixer%1Vector" ).arg( MixerChannelData[i]+1 ));
//config the vector //config the vector
for (j=0;j<5;j++) for (j=0;j<5;j++)
{ {

Binary file not shown.

View File

@ -3,7 +3,12 @@
APP="${1?}" APP="${1?}"
PLUGINS="${APP}/Contents/Plugins" PLUGINS="${APP}/Contents/Plugins"
OP_PLUGINS="${APP}/Contents/Plugins/OpenPilot" OP_PLUGINS="${APP}/Contents/Plugins/OpenPilot"
QT_LIBS="QtGui QtCore QtSvg QtSql QtOpenGL QtNetwork QtXml QtDBus QtScript phonon SDL" QT_LIBS="QtGui QtTest QtCore QtSvg QtSql QtOpenGL QtNetwork QtXml QtDBus QtScript phonon"
QT_DIR=$(otool -L "${APP}/Contents/MacOS/OpenPilot GCS" | sed -n -e 's/\/QtCore\.framework.*//p' | sed -n -E 's:^.::p')
QT_EXTRA="accessible/libqtaccessiblewidgets.dylib bearer/libqgenericbearer.dylib codecs/libqcncodecs.dylib codecs/libqjpcodecs.dylib codecs/libqkrcodecs.dylib codecs/libqtwcodecs.dylib graphicssystems/libqtracegraphicssystem.dylib imageformats/libqgif.dylib imageformats/libqico.dylib imageformats/libqjpeg.dylib imageformats/libqmng.dylib imageformats/libqtiff.dylib qmltooling/libqmldbg_inspector.dylib qmltooling/libqmldbg_tcp.dylib"
echo "Qt library directory is \"${QT_DIR}\""
echo "Processing Qt libraries in $1" echo "Processing Qt libraries in $1"
macdeployqt "${APP}" macdeployqt "${APP}"
@ -13,7 +18,7 @@ do
for g in $QT_LIBS for g in $QT_LIBS
do do
install_name_tool -change \ install_name_tool -change \
${g}.framework/Versions/4/${g} \ "${QT_DIR}/${g}.framework/Versions/4/${g}" \
@executable_path/../Frameworks/${g}.framework/Versions/4/${g} \ @executable_path/../Frameworks/${g}.framework/Versions/4/${g} \
"${f}" "${f}"
done done
@ -24,23 +29,41 @@ done
for f in ${QT_LIBS} for f in ${QT_LIBS}
do do
echo "Copying ${f}" echo "Copying ${f}"
cp -r /Library/Frameworks/${f}.framework "${APP}/Contents/Frameworks/" cp -r "${QT_DIR}/${f}.framework" "${APP}/Contents/Frameworks/"
echo "Changing package identification of ${f}" echo "Changing package identification of ${f}"
install_name_tool -id \ install_name_tool -id \
@executable_path/../Frameworks/${f}.framework/Versions/4/QtCore \ @executable_path/../Frameworks/${f}.framework/Versions/4/${f} \
"${APP}/Contents/Frameworks/${f}.framework/Versions/4/${f}" "${APP}/Contents/Frameworks/${f}.framework/Versions/4/${f}"
rm "${APP}/Contents/Frameworks/${f}.framework/${f}"
echo "Changing package linkages" echo "Changing package linkages"
for g in $QT_LIBS for g in $QT_LIBS
do do
install_name_tool -change \ install_name_tool -change \
${g}.framework/Versions/4/${g} \ "${QT_DIR}/${g}.framework/Versions/4/${g}" \
@executable_path/../Frameworks/${g}.framework/Versions/4/${g} \ @executable_path/../Frameworks/${g}.framework/Versions/4/${g} \
"${APP}/Contents/Frameworks/${f}.framework/Versions/4/${f}" "${APP}/Contents/Frameworks/${f}.framework/Versions/4/${f}"
done done
done done
for f in ${QT_EXTRA}
do
echo "Changing package identification of ${f}"
install_name_tool -id \
@executable_path/../Plugins/${f} \
"${PLUGINS}/${f}"
done
echo "Copying SDL"
cp -r "/Library/Frameworks/SDL.framework" "${APP}/Contents/Frameworks/"
echo "Changing package identification of SDL"
install_name_tool -id \
@executable_path/../Frameworks/SDL.framework/Versions/A/SDL \
"${APP}/Contents/Frameworks/SDL.framework/Versions/A/SDL"
# deleting unnecessary files # deleting unnecessary files
echo "Deleting unnecessary files" echo "Deleting unnecessary files"
find "${APP}/Contents/Frameworks" -iname "current" -exec rm -rf \{\} \; find "${APP}/Contents/Frameworks" -iname "current" -exec rm -rf \{\} \;

View File

@ -23,10 +23,15 @@ cp -r "${APP_PATH}" "/Volumes/${VOL_NAME}"
#cp -r "${FW_DIR}" "/Volumes/${VOL_NAME}/firmware" #cp -r "${FW_DIR}" "/Volumes/${VOL_NAME}/firmware"
cp "${FW_DIR}/fw_coptercontrol-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/firmware" cp "${FW_DIR}/fw_coptercontrol-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/firmware"
cp "${ROOT_DIR}/HISTORY.txt" "/Volumes/${VOL_NAME}"
"${ROOT_DIR}/package/osx/libraries" \ "${ROOT_DIR}/package/osx/libraries" \
"/Volumes/${VOL_NAME}/OpenPilot GCS.app" || exit 1 "/Volumes/${VOL_NAME}/OpenPilot GCS.app" || exit 1
hdiutil detach ${device} hdiutil detach ${device}
echo "Resizing dmg"
hdiutil resize -size 250m ${TEMP_FILE}
hdiutil convert "${TEMP_FILE}" -format UDZO -o "${OUT_FILE}" hdiutil convert "${TEMP_FILE}" -format UDZO -o "${OUT_FILE}"
# cleanup # cleanup