3 Commits
36 ... 38

Author SHA1 Message Date
a492baea18 fix:惯导进入full nav才开始采集高光谱; 2023-09-01 15:38:16 +08:00
096df8075c 修改:
记录上次设置的帧率和曝光时间,打开时,将上次的帧率和曝光时间设置为当前参数;
2023-08-29 13:46:40 +08:00
ba1b01bccc fix bug:解析sbg的sulution mode; 2023-08-18 16:01:22 +08:00
6 changed files with 251 additions and 57 deletions

View File

@ -45,6 +45,29 @@ public:
bool createConfigFile();
bool updateConfigFile();
private:
string m_configfilePath;
Config cfg;
};
class ParameterConfigfile
{
public:
ParameterConfigfile();
void setConfigfilePath(string configfilePath);
bool isConfigfileExist();
bool parseConfigfile();
bool getFrameRate(int &frameRate);
bool setFrameRate(int frameRate);
bool getExposeTime(float &exposeTime);
bool setExposeTime(float exposeTime);
bool createConfigFile();
// bool updateConfigFile();
bool writeConfig2File();
private:
string m_configfilePath;
Config cfg;

View File

@ -130,7 +130,7 @@ public:
void setFramerate(double framerate);
double getFramerate();
double setExposureTime(float exposureTime);
double setExposureTime(float exposureTime_in_us);
int wrapSetExposureTime(float exposureTime_in_us);
double getExposureTime();
double autoExposure();
@ -188,6 +188,7 @@ private:
}
Configfile m_configfile;
ParameterConfigfile m_parameterConfigfile;

View File

@ -468,3 +468,172 @@ bool Configfile::updateConfigFile()
return true;
}
ParameterConfigfile::ParameterConfigfile()
{
}
void ParameterConfigfile::setConfigfilePath(string configfilePath)
{
m_configfilePath = configfilePath;
}
bool ParameterConfigfile::isConfigfileExist()
{
QFileInfo info(QString::fromStdString(m_configfilePath));
return info.exists();
}
bool ParameterConfigfile::parseConfigfile()
{
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile(m_configfilePath);
return true;
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return false;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
return false;
}
}
bool ParameterConfigfile::createConfigFile()
{
using namespace std;
using namespace libconfig;
Config cfg;
Setting &root = cfg.getRoot();
// Add some settings to the configuration.
// Setting &SN = root.add("SN", Setting::TypeString) = "0098";
// Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
// Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
Setting &ximeaParam = root.add("ximeaParam", Setting::TypeGroup);
ximeaParam.add("frameRate", Setting::TypeInt) = 100;
ximeaParam.add("exposeTime", Setting::TypeFloat) = 10.0;
// Write out the new configuration.
try
{
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
bool ret = createDir(fileInfo[0]);
cfg.writeFile(m_configfilePath.c_str());
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
}
catch(const FileIOException &fioex)
{
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
return true;
}
return true;
}
bool ParameterConfigfile::getFrameRate(int &frameRate)
{
const Setting& root = cfg.getRoot();
try
{
const Setting &ximeaParam = root["ximeaParam"];
frameRate = ximeaParam.lookup("frameRate");
std::cout << "----------------"<< frameRate<<std::endl;
return true;
}
catch(const SettingNotFoundException &nfex)
{
cerr << "No 'frameRate' setting in configuration file." << endl;
return false;
}
}
bool ParameterConfigfile::setFrameRate(int frameRate)
{
const Setting& root = cfg.getRoot();
try
{
Setting &frameRate2 = root["ximeaParam"]["frameRate"];
frameRate2 = frameRate;
writeConfig2File();
return true;
}
catch(const SettingNotFoundException &nfex)
{
cerr << "No 'frameRate' setting in configuration file." << endl;
return false;
}
}
bool ParameterConfigfile::getExposeTime(float &exposeTime)
{
const Setting& root = cfg.getRoot();
try
{
const Setting &ximeaParam = root["ximeaParam"];
exposeTime = ximeaParam.lookup("exposeTime");
std::cout << "----------------"<< exposeTime<<std::endl;
return true;
}
catch(const SettingNotFoundException &nfex)
{
cerr << "No 'exposeTime' setting in configuration file." << endl;
return false;
}
}
bool ParameterConfigfile::setExposeTime(float exposeTime)
{
const Setting& root = cfg.getRoot();
try
{
Setting &frameRate2 = root["ximeaParam"]["exposeTime"];
frameRate2 = exposeTime;
writeConfig2File();
return true;
}
catch(const SettingNotFoundException &nfex)
{
cerr << "No 'exposeTime' setting in configuration file." << endl;
return false;
}
}
bool ParameterConfigfile::writeConfig2File()
{
try
{
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
bool ret = createDir(fileInfo[0]);
cfg.writeFile(m_configfilePath.c_str());
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
}
catch(const FileIOException &fioex)
{
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
return false;
}
return true;
}

View File

@ -3,7 +3,7 @@
int main(int argc, char *argv[])
{
std::cout<<"ximeaAirborneSystem 版本:"<< "36." <<std::endl;
std::cout<<"ximeaAirborneSystem 版本:"<< "38." <<std::endl;
QCoreApplication a(argc, argv);
//UdpServer* x=new UdpServer();

View File

@ -608,42 +608,18 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
//判断模式是否为: NAV_POSITION
if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
{
m_iSolutionModeCounter++;//
m_iSolutionModeCounter++;
uint32_t status=logData.ekfEulerData.status;
uint32_t mode=status>>24;//?????????????????????????????????????
// uint32_t mode=status;//这是错的
uint32_t mode=status & 0xf;
//一秒钟发射一次mode
if(m_iSolutionModeCounter%200 == 0)
{
emit sbgSolutionModeSignal(mode);
// std::cout << "logData.ekfEulerData.status: " << status << std::endl;
switch (mode)
{
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
// std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
break;
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
// std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
break;
case SBG_ECOM_SOL_MODE_AHRS:
// std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
break;
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
// std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
break;
case SBG_ECOM_SOL_MODE_NAV_POSITION:
// std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
break;
default:
break;
}
}
switch (mode)
{
switch (mode) {
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
// std::cout << "此刻模式为: " << "UNINITIALIZED" << std::endl;
m_bIsNAV_POSITION_MODE = false;
@ -669,6 +645,7 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
break;
}
}
}
else if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_GPS1_POS)
{
float maximal=0;
@ -687,6 +664,10 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
// std::cout<<"纬度精度为:"<<maximal<<std::endl;
// std::cout<<"numSvUsed"<<satelliteCounter<<std::endl;
//
// std::cout<<"latitude"<<logData.gpsPosData.latitude<<std::endl;
// std::cout<<"longitude"<<logData.gpsPosData.longitude<<std::endl;
// std::cout<<"altitude"<<logData.gpsPosData.altitude<<std::endl;
emit sbgAccuracySignal(static_cast<int>(maximal), satelliteCounter);
@ -727,7 +708,7 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
//控制开始采集高光谱影像,m_bIsNAV_POSITION_MODE &&
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_UTC_TIME)
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && m_bIsNAV_POSITION_MODE)
{
m_baseFileName=getFileNameBaseOnTime();
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);

View File

@ -28,6 +28,11 @@ XimeaImager::XimeaImager()
std::cout<<"ximea.cfg 错误bin1 波段数小于 bin2 波段数的 2 倍!"<<std::endl;
}
QString ximeaParamCfgFile = "/media/nvme/300TC/config/ximeaParam.cfg";
m_parameterConfigfile.setConfigfilePath(ximeaParamCfgFile.toStdString());
if(!m_parameterConfigfile.isConfigfileExist())
m_parameterConfigfile.createConfigFile();
m_parameterConfigfile.parseConfigfile();
m_recordTempThread=new QThread();
m_ximeaTemperature = new RecordXimeaTemperature(&m_imager);
@ -121,7 +126,20 @@ void XimeaImager::openImger()
m_imager.setAcqBufferSize(acqBufferSize);
}
if (m_parameterConfigfile.isConfigfileExist())
{
int frameRate;
m_parameterConfigfile.getFrameRate(frameRate);
setFramerate(frameRate);
float exposeTime;
m_parameterConfigfile.getExposeTime(exposeTime);
wrapSetExposureTime(exposeTime);
}
else
{
setFramerate(100);
}
//经验证frameSizeManual和frameSizeAuto相等
int frameSizeManual = m_imager.get_band_count()*m_imager.get_sample_count()*2;
@ -186,14 +204,16 @@ void XimeaImager::setFramerate(double framerate)
{
m_imager.set_framerate(framerate);
int maxExposureTimeInUs=1/framerate*1000000*0.01;
setExposureTime(maxExposureTimeInUs);
int maxExposureTimeInUs=1/framerate*1000000;
// setExposureTime(maxExposureTimeInUs);
// setExposureTime(1000);
m_iImagerState=102;
emit ximeaImageStatus(m_iImagerState);
emit frameRateSignal(framerate);
m_parameterConfigfile.setFrameRate(framerate);
}
catch(int xiApiErrorCodes)
{
@ -240,6 +260,7 @@ double XimeaImager::setExposureTime(float exposureTime_in_us)
//返回设置的积分时间
integrationTime2Return=m_imager.get_integration_time();
m_parameterConfigfile.setExposeTime(integrationTime2Return);
return integrationTime2Return;
}
@ -528,8 +549,7 @@ void XimeaImager::startRecord(double TimeDifferenceBetweensOSAndSbg,QString base
{
if(m_iImagerState <= 99 || m_iImagerState==100 || m_iImagerState==104)
{
emit ximeaImageStatus(m_iImagerState);
printf("已经开始采集----------------------------!\n");
return;
}