mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge remote-tracking branch 'origin/next' into outputchannelform
Conflicts: ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp
This commit is contained in:
commit
ea5caa24d5
@ -41,12 +41,18 @@
|
||||
#include <QUrl>
|
||||
#include "actuatorcommand.h"
|
||||
#include "systemalarms.h"
|
||||
#include "uavsettingsimportexport/uavsettingsimportexportfactory.h"
|
||||
|
||||
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent),wasItMe(false)
|
||||
{
|
||||
m_config = new Ui_OutputWidget();
|
||||
m_config->setupUi(this);
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
UAVSettingsImportExportFactor * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>();
|
||||
connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests()));
|
||||
|
||||
setupButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
|
||||
addUAVObject("ActuatorSettings");
|
||||
|
||||
@ -77,6 +83,12 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
addWidget(m_config->outputRate1);
|
||||
|
||||
addWidget(m_config->spinningArmed);
|
||||
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVObject* obj = objManager->getObject(QString("ActuatorCommand"));
|
||||
if(obj->getMetadata().gcsTelemetryUpdateMode == UAVObject::UPDATEMODE_ONCHANGE)
|
||||
this->setEnabled(false);
|
||||
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(disableIfNotMe(UAVObject*)));
|
||||
}
|
||||
|
||||
ConfigOutputWidget::~ConfigOutputWidget()
|
||||
@ -127,6 +139,7 @@ void ConfigOutputWidget::runChannelTests(bool state)
|
||||
UAVObject::Metadata mdata = obj->getMetadata();
|
||||
if (state)
|
||||
{
|
||||
wasItMe=true;
|
||||
accInitialData = mdata;
|
||||
mdata.flightAccess = UAVObject::ACCESS_READONLY;
|
||||
mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
||||
@ -136,9 +149,11 @@ void ConfigOutputWidget::runChannelTests(bool state)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasItMe=false;
|
||||
mdata = accInitialData; // Restore metadata
|
||||
}
|
||||
obj->setMetadata(mdata);
|
||||
obj->updated();
|
||||
|
||||
}
|
||||
|
||||
@ -334,4 +349,18 @@ void ConfigOutputWidget::openHelp()
|
||||
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Output+Configuration", QUrl::StrictMode) );
|
||||
}
|
||||
|
||||
void ConfigOutputWidget::stopTests()
|
||||
{
|
||||
m_config->channelOutTest->setChecked(false);
|
||||
}
|
||||
|
||||
void ConfigOutputWidget::disableIfNotMe(UAVObject* obj)
|
||||
{
|
||||
if(obj->getMetadata().gcsTelemetryUpdateMode == UAVObject::UPDATEMODE_ONCHANGE)
|
||||
{
|
||||
if(!wasItMe)
|
||||
this->setEnabled(false);
|
||||
}
|
||||
else
|
||||
this->setEnabled(true);
|
||||
}
|
||||
|
@ -64,8 +64,10 @@ private:
|
||||
|
||||
bool firstUpdate;
|
||||
|
||||
|
||||
bool wasItMe;
|
||||
private slots:
|
||||
void stopTests();
|
||||
void disableIfNotMe(UAVObject *obj);
|
||||
virtual void refreshWidgetsValues();
|
||||
void updateObjectsFromWidgets();
|
||||
void runChannelTests(bool state);
|
||||
|
@ -1,58 +1,65 @@
|
||||
function [] = OPLogConvert()
|
||||
%% Define indices and arrays of structures to hold data
|
||||
%% Define indices and arrays of structures to hold data
|
||||
% THIS FILE IS AUTOMATICALLY GENERATED.
|
||||
$(ALLOCATIONCODE)
|
||||
|
||||
%% Open file
|
||||
%fid = fopen('log.opl');
|
||||
[FileName,PathName,FilterIndex] = uigetfile('*.opl');
|
||||
logfile = strcat(PathName,FileName);
|
||||
fid = fopen(logfile);
|
||||
|
||||
while (1)
|
||||
%% Read logging header
|
||||
timestamp = fread(fid, 1, 'uint32');
|
||||
if (feof(fid)); break; end
|
||||
datasize = fread(fid, 1, 'int64');
|
||||
|
||||
|
||||
%% Read message header
|
||||
% get sync field (0x3C, 1 byte)
|
||||
sync = fread(fid, 1, 'uint8');
|
||||
if sync ~= hex2dec('3C')
|
||||
disp ('Wrong sync byte');
|
||||
return
|
||||
end
|
||||
% get msg type (quint8 1 byte ) should be 0x20, ignore the rest?
|
||||
msgType = fread(fid, 1, 'uint8');
|
||||
if msgType ~= hex2dec('20')
|
||||
disp ('Wrong msgType');
|
||||
return
|
||||
end
|
||||
% get msg size (quint16 2 bytes) excludes crc, include msg header and data payload
|
||||
msgSize = fread(fid, 1, 'uint16');
|
||||
% get obj id (quint32 4 bytes)
|
||||
objID = fread(fid, 1, 'uint32');
|
||||
|
||||
|
||||
%% Read object
|
||||
switch objID
|
||||
$(SWITCHCODE)
|
||||
otherwise
|
||||
disp('Unknown object ID');
|
||||
msgBytesLeft = datasize - 1 - 1 - 2 - 4;
|
||||
fread(fid, msgBytesLeft, 'uint8');
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
%% Clean Up and Save mat file
|
||||
fclose(fid);
|
||||
|
||||
matfile = strrep(logfile,'opl','mat');
|
||||
save(matfile $(SAVEOBJECTSCODE));
|
||||
|
||||
|
||||
%% Open log file
|
||||
% [FileName,PathName,FilterIndex] = uigetfile('*.opl');
|
||||
|
||||
FileName='OP-2011-10-22_22-27-09.opl';
|
||||
PathName='/Users/kenz/Movies/brisk_videos/rover_test_1/';
|
||||
FilterIndex=1;
|
||||
|
||||
|
||||
logfile = fullfile(PathName,FileName);
|
||||
fid = fopen(logfile);
|
||||
|
||||
% Parse log file, entry by entry
|
||||
while (1)
|
||||
%% Read logging header
|
||||
timestamp = fread(fid, 1, 'uint32');
|
||||
if (feof(fid)); break; end
|
||||
datasize = fread(fid, 1, 'int64');
|
||||
|
||||
|
||||
%% Read message header
|
||||
% get sync field (0x3C, 1 byte)
|
||||
sync = fread(fid, 1, 'uint8');
|
||||
if sync ~= hex2dec('3C')
|
||||
disp ('Wrong sync byte');
|
||||
return
|
||||
end
|
||||
% get msg type (quint8 1 byte ) should be 0x20, ignore the rest?
|
||||
msgType = fread(fid, 1, 'uint8');
|
||||
if msgType ~= hex2dec('20')
|
||||
disp ('Wrong msgType');
|
||||
return
|
||||
end
|
||||
% get msg size (quint16 2 bytes) excludes crc, include msg header and data payload
|
||||
msgSize = fread(fid, 1, 'uint16');
|
||||
% get obj id (quint32 4 bytes)
|
||||
objID = fread(fid, 1, 'uint32');
|
||||
|
||||
|
||||
%% Read object
|
||||
switch objID
|
||||
$(SWITCHCODE)
|
||||
otherwise
|
||||
disp(['Unknown object ID: 0x' dec2hex(objID)]);
|
||||
msgBytesLeft = datasize - 1 - 1 - 2 - 4;
|
||||
fread(fid, msgBytesLeft, 'uint8');
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
%% Clean Up and Save mat file
|
||||
fclose(fid);
|
||||
|
||||
matfile = strrep(logfile,'opl','mat');
|
||||
save(matfile $(SAVEOBJECTSCODE));
|
||||
|
||||
|
||||
|
||||
|
||||
%% Object reading functions
|
||||
$(FUNCTIONSCODE)
|
||||
|
@ -1017,3 +1017,43 @@ int DFUObject::receiveData(void * data,int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define BOARD_ID_MB 1
|
||||
#define BOARD_ID_INS 2
|
||||
#define BOARD_ID_PIP 3
|
||||
#define BOARD_ID_CC 4
|
||||
//#define BOARD_ID_PRO ?
|
||||
|
||||
/**
|
||||
Gets the type of board connected
|
||||
*/
|
||||
OP_DFU::eBoardType DFUObject::GetBoardType(int boardNum)
|
||||
{
|
||||
OP_DFU::eBoardType brdType = eBoardUnkwn;
|
||||
|
||||
// First of all, check what Board type we are talking to
|
||||
int board = devices[boardNum].ID;
|
||||
qDebug() << "Board model: " << board;
|
||||
switch (board >> 8) {
|
||||
case BOARD_ID_MB: // Mainboard family
|
||||
brdType = eBoardMainbrd;
|
||||
break;
|
||||
case BOARD_ID_INS: // Inertial Nav
|
||||
brdType = eBoardINS;
|
||||
break;
|
||||
case BOARD_ID_PIP: // PIP RF Modem
|
||||
brdType = eBoardPip;
|
||||
break;
|
||||
case BOARD_ID_CC: // CopterControl family
|
||||
brdType = eBoardCC;
|
||||
break;
|
||||
#if 0 // Someday ;-)
|
||||
case BOARD_ID_PRO: // Pro board
|
||||
brdType = eBoardPro;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return brdType;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,6 +92,16 @@ namespace OP_DFU {
|
||||
|
||||
};
|
||||
|
||||
enum eBoardType
|
||||
{
|
||||
eBoardUnkwn = 0,
|
||||
eBoardMainbrd = 1,
|
||||
eBoardINS,
|
||||
eBoardPip,
|
||||
eBoardCC,
|
||||
eBoardPro,
|
||||
};
|
||||
|
||||
struct device
|
||||
{
|
||||
int ID;
|
||||
@ -154,6 +164,7 @@ namespace OP_DFU {
|
||||
// Helper functions:
|
||||
QString StatusToString(OP_DFU::Status const & status);
|
||||
static quint32 CRC32WideFast(quint32 Crc, quint32 Size, quint32 *Buffer);
|
||||
OP_DFU::eBoardType GetBoardType(int boardNum);
|
||||
|
||||
|
||||
|
||||
|
@ -480,7 +480,7 @@ void UploaderGadgetWidget::systemRescue()
|
||||
m_config->rescueButton->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if(QMessageBox::question(this,tr("OpenPilot Uploader"),tr("If you want to search for other boards connect power now and press Yes"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||
if ((eBoardCC != dfu->GetBoardType(0)) && (QMessageBox::question(this,tr("OpenPilot Uploader"),tr("If you want to search for other boards connect power now and press Yes"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes))
|
||||
{
|
||||
log("\nWaiting...");
|
||||
QTimer::singleShot(3000, &m_eventloop, SLOT(quit()));
|
||||
|
@ -50,7 +50,7 @@ bool UAVObjectGeneratorMatlab::generate(UAVObjectParser* parser,QString template
|
||||
}
|
||||
|
||||
matlabCodeTemplate.replace( QString("$(ALLOCATIONCODE)"), matlabAllocationCode);
|
||||
matlabCodeTemplate.replace( QString("$(SWITCHCODE)"), matlabSwithCode);
|
||||
matlabCodeTemplate.replace( QString("$(SWITCHCODE)"), matlabSwitchCode);
|
||||
matlabCodeTemplate.replace( QString("$(SAVEOBJECTSCODE)"), matlabSaveObjectsCode);
|
||||
matlabCodeTemplate.replace( QString("$(FUNCTIONSCODE)"), matlabFunctionsCode);
|
||||
|
||||
@ -71,6 +71,7 @@ bool UAVObjectGeneratorMatlab::process_object(ObjectInfo* info)
|
||||
if (info == NULL)
|
||||
return false;
|
||||
|
||||
//Declare variables
|
||||
QString objectName(info->name);
|
||||
// QString objectTableName(objectName + "Objects");
|
||||
QString objectTableName(objectName);
|
||||
@ -80,39 +81,71 @@ bool UAVObjectGeneratorMatlab::process_object(ObjectInfo* info)
|
||||
QString objectID(QString().setNum(info->id));
|
||||
QString isSingleInst = boolTo01String( info->isSingleInst );
|
||||
|
||||
// Generate allocation code (will replace the $(ALLOCATIONCODE) tag)
|
||||
matlabAllocationCode.append("\n " + tableIdxName + " = 1;\n");
|
||||
matlabAllocationCode.append(" " + objectTableName + ".timestamp = 0;\n");
|
||||
QString type;
|
||||
QString allocfields;
|
||||
for (int n = 0; n < info->fields.length(); ++n) {
|
||||
// Determine type
|
||||
type = fieldTypeStrMatlab[info->fields[n]->type];
|
||||
// Append field
|
||||
if ( info->fields[n]->numElements > 1 )
|
||||
allocfields.append(" " + objectTableName + "(1)." + info->fields[n]->name + " = zeros(1," + QString::number(info->fields[n]->numElements, 10) + ");\n");
|
||||
else
|
||||
allocfields.append(" " + objectTableName + "(1)." + info->fields[n]->name + " = 0;\n");
|
||||
}
|
||||
|
||||
//===================================================================//
|
||||
// Generate allocation code (will replace the $(ALLOCATIONCODE) tag) //
|
||||
//===================================================================//
|
||||
// matlabSwitchCode.append("\t\tcase " + objectID + "\n");
|
||||
matlabAllocationCode.append("\n\t" + tableIdxName + " = 1;\n");
|
||||
QString type;
|
||||
QString allocfields;
|
||||
if (0){
|
||||
matlabAllocationCode.append("\t" + objectTableName + ".timestamp = 0;\n");
|
||||
for (int n = 0; n < info->fields.length(); ++n) {
|
||||
// Determine type
|
||||
type = fieldTypeStrMatlab[info->fields[n]->type];
|
||||
// Append field
|
||||
if ( info->fields[n]->numElements > 1 )
|
||||
allocfields.append("\t" + objectTableName + "(1)." + info->fields[n]->name + " = zeros(1," + QString::number(info->fields[n]->numElements, 10) + ");\n");
|
||||
else
|
||||
allocfields.append("\t" + objectTableName + "(1)." + info->fields[n]->name + " = 0;\n");
|
||||
}
|
||||
}
|
||||
else{
|
||||
matlabAllocationCode.append("\t" + objectTableName + "=struct('timestamp', 0");
|
||||
for (int n = 0; n < info->fields.length(); ++n) {
|
||||
// Determine type
|
||||
type = fieldTypeStrMatlab[info->fields[n]->type];
|
||||
// Append field
|
||||
if ( info->fields[n]->numElements > 1 )
|
||||
allocfields.append(",...\n\t\t '" + info->fields[n]->name + "', zeros(1," + QString::number(info->fields[n]->numElements, 10) + ")");
|
||||
else
|
||||
allocfields.append(",...\n\t\t '" + info->fields[n]->name + "', 0");
|
||||
}
|
||||
allocfields.append(");\n");
|
||||
}
|
||||
matlabAllocationCode.append(allocfields);
|
||||
matlabAllocationCode.append("\t" + objectTableName.toUpper() + "_OBJID=" + objectID + ";\n");
|
||||
|
||||
// Generate 'swith:' code (will replace the $(SWITCHCODE) tag)
|
||||
matlabSwithCode.append(" case " + objectID + "\n");
|
||||
matlabSwithCode.append(" " + objectTableName + "(" + tableIdxName +") = " + functionCall + ";\n");
|
||||
matlabSwithCode.append(" " + tableIdxName + " = " + tableIdxName +" + 1;\n");
|
||||
|
||||
// Generate objects saving code code (will replace the $(SAVEOBJECTSCODE) tag)
|
||||
//=============================================================//
|
||||
// Generate 'Switch:' code (will replace the $(SWITCHCODE) tag) //
|
||||
//=============================================================//
|
||||
matlabSwitchCode.append("\t\tcase " + objectTableName.toUpper() + "_OBJID\n");
|
||||
matlabSwitchCode.append("\t\t\t" + objectTableName + "(" + tableIdxName +") = " + functionCall + ";\n");
|
||||
matlabSwitchCode.append("\t\t\t" + tableIdxName + " = " + tableIdxName +" + 1;\n");
|
||||
|
||||
|
||||
//=============================================================================//
|
||||
// Generate objects saving code code (will replace the $(SAVEOBJECTSCODE) tag) //
|
||||
//=============================================================================//
|
||||
matlabSaveObjectsCode.append(",'"+objectTableName+"'");
|
||||
|
||||
// Generate functions code (will replace the $(FUNCTIONSCODE) tag)
|
||||
matlabFunctionsCode.append("%%\n% " + objectName + " read function\n");
|
||||
|
||||
|
||||
//=================================================================//
|
||||
// Generate functions code (will replace the $(FUNCTIONSCODE) tag) //
|
||||
//=================================================================//
|
||||
//Generate function description comment
|
||||
matlabFunctionsCode.append("function [" + objectName + "] = " + functionCall + "\n");
|
||||
matlabFunctionsCode.append(" if " + isSingleInst + "\n");
|
||||
matlabFunctionsCode.append(" headerSize = 8;\n");
|
||||
matlabFunctionsCode.append(" else\n");
|
||||
matlabFunctionsCode.append(" " + objectName + ".instanceID = fread(fid, 1, 'uint16');\n");
|
||||
matlabFunctionsCode.append(" headerSize = 10;\n");
|
||||
matlabFunctionsCode.append(" end\n\n");
|
||||
matlabFunctionsCode.append(" " + objectName + ".timestamp = timestamp;\n");
|
||||
matlabFunctionsCode.append("\tif " + isSingleInst + "\n");
|
||||
matlabFunctionsCode.append("\t\theaderSize = 8;\n");
|
||||
matlabFunctionsCode.append("\telse\n");
|
||||
matlabFunctionsCode.append("\t\t" + objectName + ".instanceID = fread(fid, 1, 'uint16');\n");
|
||||
matlabFunctionsCode.append("\t\theaderSize = 10;\n");
|
||||
matlabFunctionsCode.append("\tend\n\n");
|
||||
matlabFunctionsCode.append("\t" + objectName + ".timestamp = timestamp;\n");
|
||||
|
||||
// Generate functions code, actual fields of the object
|
||||
QString funcfields;
|
||||
@ -122,16 +155,16 @@ bool UAVObjectGeneratorMatlab::process_object(ObjectInfo* info)
|
||||
type = fieldTypeStrMatlab[info->fields[n]->type];
|
||||
// Append field
|
||||
if ( info->fields[n]->numElements > 1 )
|
||||
funcfields.append(" " + objectName + "." + info->fields[n]->name + " = double(fread(fid, " + QString::number(info->fields[n]->numElements, 10) + ", '" + type + "'));\n");
|
||||
funcfields.append("\t" + objectName + "." + info->fields[n]->name + " = double(fread(fid, " + QString::number(info->fields[n]->numElements, 10) + ", '" + type + "'));\n");
|
||||
else
|
||||
funcfields.append(" " + objectName + "." + info->fields[n]->name + " = double(fread(fid, 1, '" + type + "'));\n");
|
||||
funcfields.append("\t" + objectName + "." + info->fields[n]->name + " = double(fread(fid, 1, '" + type + "'));\n");
|
||||
}
|
||||
matlabFunctionsCode.append(funcfields);
|
||||
|
||||
matlabFunctionsCode.append(" % read CRC\n");
|
||||
matlabFunctionsCode.append(" fread(fid, 1, 'uint8');\n");
|
||||
matlabFunctionsCode.append("\t% read CRC\n");
|
||||
matlabFunctionsCode.append("\tfread(fid, 1, 'uint8');\n");
|
||||
|
||||
matlabFunctionsCode.append("end\n\n");
|
||||
matlabFunctionsCode.append("\n\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
private:
|
||||
bool process_object(ObjectInfo* info);
|
||||
QString matlabAllocationCode;
|
||||
QString matlabSwithCode;
|
||||
QString matlabSwitchCode;
|
||||
QString matlabSaveObjectsCode;
|
||||
QString matlabFunctionsCode;
|
||||
QStringList fieldTypeStrMatlab;
|
||||
|
Loading…
Reference in New Issue
Block a user