修改为使用QLinedit输入型号,偏基础移量测试

This commit is contained in:
2024-09-09 03:09:27 +08:00
parent 2ce0d7b876
commit 431823dd72
24 changed files with 145 additions and 25 deletions
@@ -2,6 +2,7 @@
#include <halconAlgo/Correction.h>
#include <iostream>
#include <simpleTools/eulerCoordinateAlgo.h>
#include <appCore.hpp>
struct CorrectionPoints
{
double OriginZ, OriginX, OriginY;
@@ -339,21 +340,38 @@ void ALGO_Correction(std::shared_ptr <detData> data)
data->writeBack("short", 274, "1");
return;
CorrectionPoints resultPoints;
if (simpleCorrection(&data->laserData, resultPoints) == false)
bool correctionResult = simpleCorrection(&data->laserData, resultPoints);
std::cout << "correctionResult_X" << resultPoints.OriginX << std::endl;
std::cout << "correctionResult_Y" << resultPoints.OriginY << std::endl;
std::cout << "correctionResult_Z" << resultPoints.OriginZ << std::endl;
if (correctionResult == false)
{
data->writeBack("short", 274, "1");
return;
}
Point3d point = getRPY(resultPoints);
auto currentProductConfig = _core._appConfig._switchProductWidgetDataPtr.getCurrentProductData();
//json中记录的基础偏移
double baseOffset_X = currentProductConfig._correctionConfigStruct.baseOffset_X;
double baseOffset_Y = currentProductConfig._correctionConfigStruct.baseOffset_Y;
double baseOffset_Z = currentProductConfig._correctionConfigStruct.baseOffset_Z;
//std::cout << "ox:" << resultPoints.Origin[0] << "oy:" << resultPoints.Origin[1] << "oz:" << resultPoints.Origin[2] << std::endl;
//std::cout << "Rx:" << point.x << "Ry:" << point.y << "Rz:" << point.z << std::endl;
//qDebug() << "productIndex:"<< data->productType <<"ox:" << resultPoints.Origin[0] << "oy : " << resultPoints.Origin[1] << "oz : " << resultPoints.Origin[2];
//qDebug() << "Rx:" << point.x << "Ry:" << point.y << "Rz:" << point.z;
double correction_X = currentProductConfig._correctionConfigStruct.correction_X;
double correction_Y = currentProductConfig._correctionConfigStruct.correction_Y;
double correction_Z = currentProductConfig._correctionConfigStruct.correction_Z;
data->pointsOffsetStruct_.baseOffsetX = data->_productDataStruct.basePos[0] - resultPoints.OriginX;
data->pointsOffsetStruct_.baseOffsetY = data->_productDataStruct.basePos[1] - resultPoints.OriginY;
data->pointsOffsetStruct_.baseOffsetZ = data->_productDataStruct.basePos[2] - resultPoints.OriginZ;
double offsetLimit_X = currentProductConfig._correctionConfigStruct.offsetLimit_X;
double offsetLimit_Y = currentProductConfig._correctionConfigStruct.offsetLimit_Y;
double offsetLimit_Z = currentProductConfig._correctionConfigStruct.offsetLimit_Z;
double correctionFinalResultX = correction_X - resultPoints.OriginX - baseOffset_X;
double correctionFinalResultY = correction_Y - resultPoints.OriginY - baseOffset_Y;
double correctionFinalResultZ = correction_Z - resultPoints.OriginZ - baseOffset_Z;
std::cout << "correctionFinalResultX" << correctionFinalResultX << std::endl;
std::cout << "correctionFinalResultY" << correctionFinalResultY << std::endl;
std::cout << "correctionFinalResultZ" << correctionFinalResultZ << std::endl;
//double offsetRx = data->_productDataStruct.baseRad[0] - point.x;
//double offsetRy = data->_productDataStruct.baseRad[1] - point.y;
@@ -68,6 +68,25 @@ void appConfig::parsingProductData(std::string path)
productData.connectorAmout = res["connectorAmout"];
productData.isBackExist = res["isBackExist"];
productData.backArmIndex = res["backArmIndex"];
if (res["Correction"].empty() == false)
{
productData._correctionConfigStruct.correction_X = res["Correction"]["correction_X"];
productData._correctionConfigStruct.correction_Y = res["Correction"]["correction_Y"];
productData._correctionConfigStruct.correction_Z = res["Correction"]["correction_Z"];
productData._correctionConfigStruct.baseOffset_X = res["Correction"]["baseOffset_X"];
productData._correctionConfigStruct.baseOffset_Y = res["Correction"]["baseOffset_Y"];
productData._correctionConfigStruct.baseOffset_Z = res["Correction"]["baseOffset_Z"];
productData._correctionConfigStruct.offsetLimit_X = res["Correction"]["offsetLimit_X"];
productData._correctionConfigStruct.offsetLimit_Y = res["Correction"]["offsetLimit_Y"];
productData._correctionConfigStruct.offsetLimit_Z = res["Correction"]["offsetLimit_Z"];
}
for (auto it = res["partNumberList"].begin(); it != res["partNumberList"].end(); ++it)
{
productData.partNumberList.push_back(it.value());
}
for (auto it = res["cameraSetting"].begin(); it != res["cameraSetting"].end(); ++it)
{
std::vector<std::string> result = split(it.value(), '/');
+15 -2
View File
@@ -1,5 +1,6 @@
#include <appconfigStruct.h>
#include <sqlAppData.h>
#include <unordered_map>
class appConfig
{
public:
@@ -7,11 +8,23 @@ public:
sqlManager _sqlManager;//储存产品信息用
appConfig()
{
parsingGlobalData();
parsingProductData(productDataPath);
parsingGlobalData();//解析全局参数
parsingProductData(productDataPath);//解析产品配置
parsePartNumberWithIndex();
_sqlManager.initialization(this);
}
void parsePartNumberWithIndex()
{
for (int index = 0 ;index < productDatas.size(); index++)
{
for (auto partNum : productDatas[index].partNumberList)
{
partNumberWithIndex.insert(std::make_pair(partNum, index));
}
}
}
std::unordered_map<std::string, int> partNumberWithIndex;
switchProductWidgetDataPtr _switchProductWidgetDataPtr;
std::string softwareTile;//软件标题
@@ -12,6 +12,18 @@ struct productSignStruct
cv::Rect posRect;
std::string sign;
};
struct correctionConfigStruct
{
double correction_X = 0;
double correction_Y = 0;
double correction_Z = 0;
double baseOffset_X = 0;
double baseOffset_Y = 0;
double baseOffset_Z = 0;
double offsetLimit_X = 3;
double offsetLimit_Y = 3;
double offsetLimit_Z = 3;
};
struct productDataStruct
{
std::string name;
@@ -37,6 +49,8 @@ struct productDataStruct
int codedAlgoIndex = -1;
std::unordered_map<int, productSignStruct> productSign;
std::vector<std::string>partNumberList;//料号list
correctionConfigStruct _correctionConfigStruct;
};
struct perConnector
{
@@ -0,0 +1,5 @@
class productConfigmanager
{
public:
};
+1 -1
View File
@@ -10,7 +10,7 @@
#include <qtimer.h>
#define disableBackEndCheck 0
#define disableBackEndCheck 1
#define disableeAlgo 0
#define enableHideConsle 1
class detGlobalData
+2
View File
@@ -539,7 +539,9 @@ public slots:
currentSn = SN.toStdString();
_triggerManager.sendFinsMsg("write_short_350_" + QString::number(_core._appConfig.productDatas[productTypeIn].indexOfArm));
_triggerManager.sendFinsMsg("write_short_351_1");
qDebug() << "SN:" << SN << "开始运行,型号->" << QString::fromStdString(_core._detGlobalData.productTypeStr);
}
//人工复判按下NG
void uiModuleImageDoubleCheckQdialog_pressNG(int armPos,int type)//1 halcon 2ai
@@ -1,7 +1,7 @@
#include<handleAiModelList.hpp>
#include <handleAiModel.h>
#define enableHandleAiModel 1
#define enableHandleAiModel 0
void handleAiModelManager::handleAiModelManager::run()
{
if (init == true)
@@ -52,13 +52,16 @@ public:
maxValue = getMax(value, maxValue);
minValue = getMin(value, minValue);
currentValue = value;
if((maxValue - minValue) ==0)
if ((maxValue - minValue) == 0)
setProgress(1);
else if (value == 0)
setProgress(0);
else
setProgress( value/(maxValue - minValue));
else
{
double v = (double)((double)(value - minValue) / (double)(maxValue - minValue));
setProgress(v);
}
}
void setProgress(double newProgress)
{
@@ -94,17 +97,17 @@ protected:
painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignHCenter | Qt::AlignTop, QString::number(currentValue) + "ms");
if (maxValue == INT_MIN)
painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignRight | Qt::AlignTop, "0ms");
else
else
painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignRight | Qt::AlignTop, QString::number(maxValue) + "ms");
painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignLeft | Qt::AlignTop, "min");
painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignLeft | Qt::AlignTop, "Min");
painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignHCenter | Qt::AlignTop, title);
painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignRight | Qt::AlignTop, "Max");
int barWidth = rect.width() - 20;
int barHeight = 5;
QRect barRect(10, rect.height() / 2 - barHeight / 2-5, barWidth, barHeight);
QRect barRect(10, rect.height() / 2 - barHeight / 2 - 5, barWidth, barHeight);
// Draw progress in the bar
int progressWidth = static_cast<int>(barRect.width() * progress);
@@ -130,7 +133,7 @@ private:
bool init = false;
QString title;
int maxValue = INT_MIN, minValue = INT_MAX, currentValue = 0;
int frequency =50;
int frequency = 50;
double progress;
};
#pragma once
@@ -29,13 +29,23 @@ public:
QVBoxLayout* layout = new QVBoxLayout(this);
fancyButtonText* switchBtn = new fancyButtonText(100, 60, "修改", "修改当前机型");
QLabel* armHeartBeatSign = new QLabel();
//料号条码输入
QLineEdit* partNumberIntputLine = new QLineEdit();
//运行按钮
fancyButtonText* startBtn;
//SN条码输入
QLineEdit* snIntputLine = new QLineEdit();
//料号显示
QComboBox* productSelect = new QComboBox(this);
QComboBox* productSelect = new QComboBox(this);
QLabel* currentProduct = new QLabel(this);
//料号类型
QComboBox* productNameTypeSwitch = new QComboBox(this);
void clear()
{
partNumberIntputLine->clear();
snIntputLine->clear();
}
switchProductWidget()
{
currentProductIndexPtr = &_core._appConfig._switchProductWidgetDataPtr.currentProductIndex;
@@ -68,19 +78,28 @@ public:
layout->addLayout(switchLayout);
}
snIntputLine->setFixedHeight(50);
snIntputLine->setFont(font);
QHBoxLayout* hBtnLayout2 = new QHBoxLayout();
partNumberIntputLine->setFixedHeight(50);
partNumberIntputLine->setFont(font);
partNumberIntputLine->setPlaceholderText("料号条码输入");
hBtnLayout2->addWidget(partNumberIntputLine);
QHBoxLayout* hBtnLayout = new QHBoxLayout();
startBtn = new fancyButtonText(80, -1, "运行", "运行检测程序");
snIntputLine->setFixedHeight(50);
snIntputLine->setFont(font);
snIntputLine->setPlaceholderText("SN条码输入");
hBtnLayout->addWidget(snIntputLine);
hBtnLayout->addWidget(startBtn);
layout->addLayout(hBtnLayout2);
layout->addLayout(hBtnLayout);
productSelectFresh(0);
connect(startBtn, &QPushButton::clicked, this, [=]()
{
emit startArmProgramSignal(productSelect->currentIndex(), snIntputLine->text());
emit startArmProgramSignal(indexFromPartNumber, snIntputLine->text());
std::cout << "按下按钮" << std::endl;
});
connect(switchBtn, &QPushButton::clicked, this, &switchProductWidget::startSwitch);
@@ -93,6 +112,14 @@ public:
{
productSelectFresh(productNameTypeSwitch->currentIndex());
});
connect(partNumberIntputLine, &QLineEdit::textChanged, this, [=]()
{
partNumberIntputLineSlot(partNumberIntputLine->text().toStdString());
});
currentProduct->setText("请输入料号");
productSelect->hide();
switchBtn->hide();
startBtn->setDisabled(true);
}
void productSelectFresh(int index)
{
@@ -138,7 +165,7 @@ public slots:
if (status == true)
{
startBtn->toDefault();
if(disableTextChange == false)
if (disableTextChange == false)
startBtn->setText("运行");
snIntputLine->setDisabled(false);
std::cout << "按下软件运行" << std::endl;
@@ -156,8 +183,27 @@ signals:
void startArmProgramSignal(int,QString);
void switchProductSignal(int);
private:
int indexFromPartNumber = -1;
int siwtchBtnState = 0;
private slots:
void partNumberIntputLineSlot(std::string partNumber)
{
auto it = _core._appConfig.partNumberWithIndex.find(partNumber);
if(it != _core._appConfig.partNumberWithIndex.end())
{
int index = _core._appConfig.partNumberWithIndex.find(partNumber)->second;
currentProduct->setText(QString::fromStdString(_core._appConfig.productDatas[index].name));
*currentProductIndexPtr = index;
startBtn->setEnabled(true);
indexFromPartNumber = index;
snIntputLine->setFocus();
}
else
{
currentProduct->setText("未找到对应料号!");
startBtn->setDisabled(true);
}
}
void startSwitch()
{
if(siwtchBtnState == 0)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.