fix:修复拆包协议,调平后重新读取文件,空托盘检测

This commit is contained in:
yiyi 2025-12-14 09:37:36 +08:00
parent 4d9e24e62a
commit 4904661d1e
23 changed files with 264 additions and 51 deletions

View File

@ -1,16 +1,16 @@
TEMPLATE = subdirs
# 拆包项目
# SUBDIRS += ./GrabBag/GrabBag.pro
SUBDIRS += ./GrabBag/GrabBag.pro
# 撕裂项目
SUBDIRS += ./BeltTearing/BeltTearing.pro
# SUBDIRS += ./BeltTearing/BeltTearing.pro
#焊接
# SUBDIRS += ./LapWeld/LapWeld.pro
#工件定位
SUBDIRS += ./Workpiece/Workpiece.pro
# SUBDIRS += ./Workpiece/Workpiece.pro
# 颗粒尺寸检测
# SUBDIRS += ./ParticleSize/ParticleSize.pro

View File

@ -322,10 +322,12 @@ void BeltTearingPresenter::sendSimulationData()
// 使用成员变量(开流时会清除)
m_simulationCallCount++;
m_simulationTearIdCounter = 2629344;
// 固定生成2个撕裂长度逐渐增大
for (int i = 0; i < 2; i++) {
SSG_beltTearingInfo tear;
tear.tearID = ++m_simulationTearIdCounter;
tear.tearID = m_simulationTearIdCounter + i;
tear.tearStatus = keSG_tearStatus_Growing;
// 撕裂长度:基础长度 + 调用次数 * 10

View File

@ -17,5 +17,8 @@
4、视觉拍出多个袋子一次只给一个位置数据因为下次抓包前还需再次拍照。
四、通讯协议:
1、机械臂-->视觉:@,视觉号,视觉模版号,启动信息,$:如@13Trig$触发1号视觉拍照调用3号视觉模版发出Trig拍照
2、视觉-->机械臂:@1XYZU0/1$(有无包),如有包时:@,1XYZU1$;无包时:@100000$。
2、视觉-->机械臂:@1XYZU0/1/2$(有无包/错误),
如有包时:@,1XYZU1$
无包时: @,100000$。
错误是: @,100002$。
3、@为帧头,$为结束符。

View File

@ -30,11 +30,13 @@ int DetectPresenter::DetectBag(std::vector<SVzNL3DLaserLine>& detectionDataCache
// 3. 调用算法检测接口(使用当前相机的调平参数)
std::vector<SSG_peakRgnInfo> objOps;
sg_getBagPosition(static_cast<SVzNL3DLaserLine*>(detectionDataCache.data()), detectionDataCache.size(), algoParam, cameraCalibParam, objOps);
int nErr = 0;
sg_getBagPosition(static_cast<SVzNL3DLaserLine*>(detectionDataCache.data()), detectionDataCache.size(), algoParam, cameraCalibParam, objOps, &nErr);
// 从点云数据生成投影图像
detectionResult.image = PointCloudImageUtils::GeneratePointCloudImage(static_cast<SVzNL3DLaserLine*>(detectionDataCache.data()),
detectionDataCache.size(), objOps);
detectionResult.errorCode = nErr;
// 转换检测结果为UI显示格式使用机械臂坐标系数据
for (size_t i = 0; i < objOps.size(); i++) {

View File

@ -452,7 +452,7 @@ void GrabBagPresenter::onTcpDataReceivedFromCallback(const TCPClient* pClient, c
std::string receivedData(pData, nLen);
QString qData = QString::fromStdString(receivedData).trimmed();
LOG_INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
LOG_INFO("TCP data received from client %p: %s\n", pClient, qData.toStdString().c_str());
if (m_pStatus) {
@ -1425,7 +1425,7 @@ int GrabBagPresenter::_DetectTask()
m_pParameterManager->GetRgbColorPattern(),
m_pParameterManager->GetFrontColorTemplate(),
m_pParameterManager->GetBackColorTemplate(), detectionResult);
LOG_INFO("[Algo Thread] DetectBag returned: %d\n", nRet);
LOG_INFO("[Algo Thread] DetectBag return: %d\n", nRet);
} catch (const std::exception& e) {
LOG_ERROR("[Algo Thread] Exception in DetectBag: %s\n", e.what());
if (m_pStatus) {
@ -1450,7 +1450,7 @@ int GrabBagPresenter::_DetectTask()
LOG_INFO("[Algo Thread] algo detected %zu objects time : %.2f ms\n", detectionResult.positions.size(), oTimeUtils.GetElapsedTimeInMilliSec());
// 8. 返回检测结果
detectionResult.cameraIndex = m_currentCameraIndex;
detectionResult.cameraIndex = m_currentExecutionParams.cameraIndex;
// 调用检测结果回调函数
m_pStatus->OnDetectionResult(detectionResult);
@ -1459,7 +1459,7 @@ int GrabBagPresenter::_DetectTask()
m_pStatus->OnStatusUpdate(statusMsg.toStdString());
// 更新机械臂协议状态(发送转换后的目标位置数据)
_SendDetectionResultToRobot(detectionResult, m_currentCameraIndex);
_SendDetectionResultToRobot(detectionResult, m_currentExecutionParams.cameraIndex);
// 9. 检测完成后,将工作状态更新为"完成"
if (m_pStatus) {
@ -1469,8 +1469,7 @@ int GrabBagPresenter::_DetectTask()
// 设置机械臂工作状态为相应相机工作完成相机ID从1开始
if (m_pRobotProtocol) {
uint16_t workStatus = (m_currentCameraIndex == 1) ?
RobotProtocol::WORK_STATUS_CAMERA1_DONE : RobotProtocol::WORK_STATUS_CAMERA2_DONE;
uint16_t workStatus = (m_currentExecutionParams.cameraIndex == 1) ? RobotProtocol::WORK_STATUS_CAMERA1_DONE : RobotProtocol::WORK_STATUS_CAMERA2_DONE;
m_pRobotProtocol->SetWorkStatus(workStatus);
}
@ -1542,7 +1541,7 @@ void GrabBagPresenter::_SendDetectionResultToRobot(const DetectionResult& detect
}
}
} else {
LOG_WARNING("Robot TCP protocol not available\n");
LOG_WARNING("ModbusTCP protocol not available\n");
}
// 发送到串口
@ -1585,20 +1584,18 @@ void GrabBagPresenter::_SendDetectionResultToRobot(const DetectionResult& detect
tcpipSent = true;
}else {
// 无包裹时:@,1,0,0,0,0,0,$
result.append("0,0,0,0,0,$"); // 协议尾
result.append("0,0,0,0,"); // 协议尾
if(detectionResult.errorCode == SX_BAG_TRAY_EMPTY){
result.append("0,$");
}else{
result.append("2,$");
}
tcpipSent = true;
}
m_pTcpServer->SendAllData(result.c_str(), result.length());
}
// 总结发送状态
if (robotSent || serialSent) {
LOG_INFO("Detection result sent successfully (Robot TCP: %s, Serial: %s)\n",
robotSent ? "Yes" : "No", serialSent ? "Yes" : "No");
} else {
LOG_WARNING("Failed to send detection result via any protocol\n");
LOG_WARNING("TCP server not available\n");
}
}
@ -2124,8 +2121,7 @@ void GrabBagPresenter::_UpdateCurrentExecutionParams()
// 5.1 设置包裹参数(从包裹配置中获取)
m_currentExecutionParams.bagParam = currentPackage->bagParam;
LOG_INFO("Using bag parameters: L=%.1f, W=%.1f, H=%.1f\n",
currentPackage->bagParam.bagL, currentPackage->bagParam.bagW, currentPackage->bagParam.bagH);
LOG_INFO("Using bag parameters: L=%.1f, W=%.1f, H=%.1f\n", currentPackage->bagParam.bagL, currentPackage->bagParam.bagW, currentPackage->bagParam.bagH);
// 6. 设置调平参数(从相机配置中获取)
if (currentCamera->planeCalibParam.isCalibrated &&
@ -2136,11 +2132,9 @@ void GrabBagPresenter::_UpdateCurrentExecutionParams()
m_currentExecutionParams.planeCalibParam.invRMatrix[i] = currentCamera->planeCalibParam.invRMatrix[i];
}
m_currentExecutionParams.planeCalibParam.planeHeight = currentCamera->planeCalibParam.planeHeight;
LOG_INFO("Using calibrated plane parameters from camera %s (height=%.3f)\n",
currentCamera->cameraName.c_str(), currentCamera->planeCalibParam.planeHeight);
LOG_INFO("Using calibrated plane parameters from camera %s (height=%.3f)\n", currentCamera->cameraName.c_str(), currentCamera->planeCalibParam.planeHeight);
} else {
LOG_INFO("Camera %s is not calibrated, using identity matrix for plane calibration\n",
currentCamera->cameraName.c_str());
LOG_INFO("Camera %s is not calibrated, using identity matrix for plane calibration\n", currentCamera->cameraName.c_str());
}
// 7. 设置手眼标定参数(从相机配置中获取)
@ -2152,8 +2146,7 @@ void GrabBagPresenter::_UpdateCurrentExecutionParams()
}
LOG_INFO("Using calibrated hand-eye matrix from camera %s\n", currentCamera->cameraName.c_str());
} else {
LOG_INFO("Camera %s hand-eye is not calibrated, using identity matrix\n",
currentCamera->cameraName.c_str());
LOG_INFO("Camera %s hand-eye is not calibrated, using identity matrix\n", currentCamera->cameraName.c_str());
}
LOG_INFO("Current execution parameters updated successfully\n");
@ -2162,10 +2155,7 @@ void GrabBagPresenter::_UpdateCurrentExecutionParams()
LOG_INFO(" Package: %s\n", currentPackage->name.c_str());
// 更新 ParameterManager 的当前执行参数
m_pParameterManager->SetCurrentExecutionParams(
m_currentExecutionParams.planeCalibParam,
m_currentExecutionParams.handEyeCalibMatrix
);
m_pParameterManager->SetCurrentExecutionParams(m_currentExecutionParams.planeCalibParam, m_currentExecutionParams.handEyeCalibMatrix);
}
// 重载版本:直接使用配置指针更新执行参数

View File

@ -2,9 +2,9 @@
#define VERSION_H
#define GRABBAG_VERSION_STRING "1.3.3"
#define GRABBAG_VERSION_STRING "1.3.4"
#define GRABBAG_BUILD_STRING "0"
#define GRABBAG_FULL_VERSION_STRING "V1.3.3_0"
#define GRABBAG_FULL_VERSION_STRING "V1.3.4_0"
// 获取版本信息的便捷函数
inline const char* GetGrabBagVersion() {

View File

@ -1,9 +1,15 @@
#1.3.3
# 1.3.4
## build_0 2025-12-14
1. 修复协议对接使用相机参数错误
2. 修复调平后重新读取参数文件
3. 更新算法:空托盘的判断
# 1.3.3
## build_0 2025-12-10
1. 更新算法增加outputMode参数
#1.3.2
# 1.3.2
## build_2 2025-11-23
1. config 修改默认数据

View File

@ -958,16 +958,22 @@ void DialogConfigTree::onCameraLevelClicked()
int x = parentGeometry.left() + (parentGeometry.width() - dlg.width()) / 2;
int y = parentGeometry.top() + (parentGeometry.height() - dlg.height()) / 2;
dlg.move(x, y);
#if 0
if (dlg.exec() == QDialog::Accepted) {
// 调平成功后,刷新相机配置显示
showCameraConfig(m_currentWorkPos, m_currentCamera);
}
#else
dlg.exec();
showCameraConfig(m_currentWorkPos, m_currentCamera);
#endif
dlg.exec();
// 对话框关闭后,重新加载配置文件
IVrConfig* vrConfig = m_presenter->GetConfig();
if (vrConfig) {
ConfigResult newConfig = vrConfig->LoadConfig(PathManager::GetInstance().GetConfigFilePath().toStdString());
*m_configResult = newConfig;
}
// 遍历所有工位的所有相机,刷新配置显示
for (auto& wp : m_configResult->workPositions) {
for (auto& cam : wp.cameras) {
showCameraConfig(&wp, &cam);
}
}
}
void DialogConfigTree::displayHandEyeCalibInline()

View File

@ -89,6 +89,7 @@ struct DetectionResultData {
QImage image;
std::vector<PositionType> positions;
int cameraIndex = 1; // 相机索引默认为1第一个相机
int errorCode = 0; // 结果错误码0表示成功非0表示错误
// 默认构造函数
DetectionResultData() = default;

View File

@ -4,6 +4,11 @@
#include <functional>
#ifdef VR_EYE_DEBUG_MODE
#include "LaserDataLoader.h"
#include <chrono>
#endif
CVrEyeDevice::CVrEyeDevice()
: m_pHandle(nullptr)
{
@ -11,6 +16,15 @@ CVrEyeDevice::CVrEyeDevice()
CVrEyeDevice::~CVrEyeDevice()
{
#ifdef VR_EYE_DEBUG_MODE
// 停止debug线程
if (m_debugRunning) {
m_debugRunning = false;
if (m_debugThread.joinable()) {
m_debugThread.join();
}
}
#endif
// 确保设备被正确关闭
if (m_pHandle) {
CloseDevice();
@ -24,10 +38,15 @@ int CVrEyeDevice::InitDevice()
int CVrEyeDevice::SetStatusCallback(VzNL_OnNotifyStatusCBEx fNotify, void *param)
{
#ifdef VR_EYE_DEBUG_MODE
m_debugStatusCallback = fNotify;
m_debugStatusCallbackParam = param;
LOG_DEBUG("VR_EYE_DEBUG_MODE: Status callback stored\n");
return SUCCESS;
#endif
// 如果设备已经打开,立即设置回调
if (m_pHandle) {
VzNL_SetDeviceStatusNotifyEx(m_pHandle, fNotify, param);
LOG_DEBUG("Status callback set for opened device\n");
} else {
LOG_DEBUG("Status callback stored, will be set when device opens\n");
}
@ -37,6 +56,10 @@ int CVrEyeDevice::SetStatusCallback(VzNL_OnNotifyStatusCBEx fNotify, void *param
int CVrEyeDevice::OpenDevice(const char* sIP, bool bRGBD, bool bSwing, bool bFillLaser)
{
#ifdef VR_EYE_DEBUG_MODE
LOG_DEBUG("VR_EYE_DEBUG_MODE: OpenDevice success\n");
return SUCCESS;
#endif
int nErrCode = SUCCESS;
// 搜索设备
VzNL_ResearchDevice(keSearchDeviceFlag_EthLaserRobotEye);
@ -136,12 +159,21 @@ int CVrEyeDevice::OpenDevice(const char* sIP, bool bRGBD, bool bSwing, bool bFil
int CVrEyeDevice::GetVersion(SVzNLVersionInfo &sVersionInfo)
{
#ifdef VR_EYE_DEBUG_MODE
strcpy(sVersionInfo.szSDKVersion, "DEBUG_MODE_1.0.0");
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetVersion(m_pHandle, &sVersionInfo);
}
int CVrEyeDevice::GetDevInfo(SVzNLEyeDeviceInfoEx &sDeviceInfo)
{
#ifdef VR_EYE_DEBUG_MODE
memset(&sDeviceInfo, 0, sizeof(SVzNLEyeDeviceInfoEx));
strcpy(sDeviceInfo.sEyeCBInfo.byServerIP, "192.168.1.100");
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
memcpy(&sDeviceInfo, &m_sEeyCBDeviceInfo, sizeof(SVzNLEyeDeviceInfoEx));
return SUCCESS;
@ -149,6 +181,10 @@ int CVrEyeDevice::GetDevInfo(SVzNLEyeDeviceInfoEx &sDeviceInfo)
int CVrEyeDevice::CloseDevice()
{
#ifdef VR_EYE_DEBUG_MODE
LOG_DEBUG("VR_EYE_DEBUG_MODE: CloseDevice success\n");
return SUCCESS;
#endif
int nErrCode = SUCCESS;
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
VzNL_EndDetectLaser(m_pHandle);
@ -162,6 +198,15 @@ int CVrEyeDevice::CloseDevice()
int CVrEyeDevice::StartDetect(VzNL_AutoOutputLaserLineExCB fCallFunc, EVzResultDataType eDataType, void *param)
{
#ifdef VR_EYE_DEBUG_MODE
LOG_DEBUG("VR_EYE_DEBUG_MODE: StartDetect\n");
m_debugCallback = fCallFunc;
m_debugCallbackParam = param;
m_debugDataType = eDataType;
m_debugRunning = true;
m_debugThread = std::thread(&CVrEyeDevice::DebugThreadFunc, this);
return SUCCESS;
#endif
int nErrCode = SUCCESS;
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
VzNL_SetLaserLight(m_pHandle, VzTrue);
@ -177,6 +222,14 @@ bool CVrEyeDevice::IsDetectIng()
int CVrEyeDevice::StopDetect()
{
#ifdef VR_EYE_DEBUG_MODE
LOG_DEBUG("VR_EYE_DEBUG_MODE: StopDetect\n");
m_debugRunning = false;
if (m_debugThread.joinable()) {
m_debugThread.join();
}
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_StopAutoDetect(m_pHandle);
}
@ -199,12 +252,19 @@ int CVrEyeDevice::GetDetectROI(SVzNLRect &leftROI, SVzNLRect &rightROI)
int CVrEyeDevice::SetEyeExpose(unsigned int &exposeTime)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_ConfigEyeExpose(m_pHandle, keVzNLExposeMode_Fix, exposeTime);
}
int CVrEyeDevice::GetEyeExpose(unsigned int &exposeTime)
{
#ifdef VR_EYE_DEBUG_MODE
exposeTime = 1000;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
EVzNLExposeMode peExposeMode;
return VzNL_GetConfigEyeExpose(m_pHandle, &peExposeMode, &exposeTime);
@ -212,6 +272,9 @@ int CVrEyeDevice::GetEyeExpose(unsigned int &exposeTime)
int CVrEyeDevice::SetEyeGain(unsigned int &gain)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
int nRet = VzNL_SetCameraGain(m_pHandle, keEyeSensorType_Left, gain);
nRet |= VzNL_SetCameraGain(m_pHandle, keEyeSensorType_Right, gain);
@ -220,24 +283,38 @@ int CVrEyeDevice::SetEyeGain(unsigned int &gain)
int CVrEyeDevice::GetEyeGain(unsigned int &gain)
{
#ifdef VR_EYE_DEBUG_MODE
gain = 100;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetCameraGain(m_pHandle, keEyeSensorType_Left, reinterpret_cast<unsigned short *>(&gain));
}
int CVrEyeDevice::SetFrame(int &frame)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_SetFrameRate(m_pHandle, frame);
}
int CVrEyeDevice::GetFrame(int &frame)
{
#ifdef VR_EYE_DEBUG_MODE
frame = 30;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetFrameRate(m_pHandle, reinterpret_cast<int *>(&frame));
}
bool CVrEyeDevice::IsSupport()
{
#ifdef VR_EYE_DEBUG_MODE
return true;
#endif
if(!m_pHandle) return false;
int nRet = 0;
@ -247,12 +324,19 @@ bool CVrEyeDevice::IsSupport()
int CVrEyeDevice::SetRGBDExposeThres(float &value)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_SetRGBAutoExposeThres(m_pHandle, value);
}
int CVrEyeDevice::GetRGBDExposeThres(float &value)
{
#ifdef VR_EYE_DEBUG_MODE
value = 128.0f;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
int nRet = 0;
value = VzNL_GetRGBAutoExposeThres(m_pHandle, &nRet);
@ -261,48 +345,78 @@ int CVrEyeDevice::GetRGBDExposeThres(float &value)
int CVrEyeDevice::SetFilterHeight(double &dHeight)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_ConfigLaserLineFilterHeight(m_pHandle, dHeight);
}
int CVrEyeDevice::GetFilterHeight(double &dHeight)
{
#ifdef VR_EYE_DEBUG_MODE
dHeight = 100.0;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetLaserLineFilterHeight(m_pHandle, &dHeight);
}
int CVrEyeDevice::GetSwingSpeed(float &fSpeed)
{
#ifdef VR_EYE_DEBUG_MODE
fSpeed = 10.0f;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetSwingAngleSpeed(m_pHandle, &fSpeed);
}
int CVrEyeDevice::SetSwingSpeed(float &fSpeed)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_SetSwingAngleSpeed(m_pHandle, fSpeed);
}
int CVrEyeDevice::SetSwingAngle(float &fMin, float &fMax)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_SetSwingMotorAngle(m_pHandle, fMin, fMax);
}
int CVrEyeDevice::GetSwingAngle(float &fMin, float &fMax)
{
#ifdef VR_EYE_DEBUG_MODE
fMin = -30.0f;
fMax = 30.0f;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetSwingMotorAngle(m_pHandle, &fMin, &fMax);
}
int CVrEyeDevice::SetWorkRange(double &nMin, double &nMax)
{
#ifdef VR_EYE_DEBUG_MODE
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_SetSwingMotorWorkRange(m_pHandle, nMin, nMax);
}
int CVrEyeDevice::GetWorkRange(double &dMin, double &dMax)
{
#ifdef VR_EYE_DEBUG_MODE
dMin = 500.0;
dMax = 1500.0;
return SUCCESS;
#endif
if(!m_pHandle) return ERRCODE(DEV_NO_OPEN);
return VzNL_GetSwingMotorWorkRange(m_pHandle, &dMin, &dMax);
}
@ -314,3 +428,50 @@ int IVrEyeDevice::CreateObject(IVrEyeDevice** ppEyeDevice)
*ppEyeDevice = p;
return 0;
}
#ifdef VR_EYE_DEBUG_MODE
void CVrEyeDevice::DebugThreadFunc()
{
// 固定的点云文件路径
const std::string debugFilePath = "C:\\project\\QT\\GrabBag\\TestData\\LapWeld\\scanData_ground_1.txt";
LaserDataLoader loader;
std::vector<std::pair<EVzResultDataType, SVzLaserLineData>> laserLines;
int lineNum = 0;
float scanSpeed = 0.0f;
int maxTimeStamp = 0;
int clockPerSecond = 0;
// 加载点云文件
int ret = loader.LoadLaserScanData(debugFilePath, laserLines, lineNum, scanSpeed, maxTimeStamp, clockPerSecond);
if (ret != SUCCESS) {
LOG_DEBUG("VR_EYE_DEBUG_MODE: Failed to load laser data from %s, error: %s\n",debugFilePath.c_str(), loader.GetLastError().c_str());
m_debugRunning = false;
return;
}
LOG_DEBUG("VR_EYE_DEBUG_MODE: Loaded %d laser lines from %s\n", lineNum, debugFilePath.c_str());
int currentIndex = 0;
// 循环读取并回调
while (m_debugRunning && currentIndex < lineNum) {
if (m_debugCallback && currentIndex < lineNum) {
auto& dataPair = laserLines[currentIndex];
m_debugCallback(dataPair.first, &dataPair.second, m_debugCallbackParam);
}
currentIndex++;
// 模拟采集间隔约30ms
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
if (m_debugStatusCallback) {
m_debugStatusCallback(keDeviceWorkStatus_Device_Swing_Finish, nullptr, 0, m_debugStatusCallbackParam);
m_debugStatusCallback(keDeviceWorkStatus_Device_Auto_Stop, nullptr, 0, m_debugStatusCallbackParam);
}
// 释放数据
loader.FreeLaserScanData(laserLines);
LOG_DEBUG("VR_EYE_DEBUG_MODE: Debug thread stopped\n");
}
#endif

View File

@ -64,6 +64,15 @@ win32:CONFIG(debug, debug|release) {
LIBS += -L../../VrUtils -lVrUtils
}
INCLUDEPATH += $$PWD/../../AppUtils/CloudUtils/Inc
win32:CONFIG(debug, debug|release) {
LIBS += -L../../AppUtils/CloudUtils/debug -lCloudUtils
}else:win32:CONFIG(release, debug|release){
LIBS += -L../../AppUtils/CloudUtils/release -lCloudUtils
}else:unix:!macx {
LIBS += -L../../AppUtils/CloudUtils -lCloudUtils
}
# 添加libmodbus依赖
win32 {
LIBS += -lws2_32

View File

@ -1,6 +1,11 @@
#ifndef CVREYEDEVICE_H
#define CVREYEDEVICE_H
#ifdef _WIN32
// Debug模式开关 - 修改此处开启/关闭debug功能
#define VR_EYE_DEBUG_MODE
#endif
#include "IVrEyeDevice.h"
#include "IVzDeviceCoreDataReader.h"
#include "VrEyeCommon.h"
@ -13,6 +18,13 @@
#include "VZNL_RGBConfig.h"
#include "VZNL_DetectLaser.h"
#ifdef VR_EYE_DEBUG_MODE
#include <thread>
#include <atomic>
#include <mutex>
#include <vector>
#endif
class CVrEyeDevice : public IVrEyeDevice
{
public:
@ -152,6 +164,20 @@ private:
VZNLHANDLE m_pHandle = nullptr;
SVzNLEyeDeviceInfoEx m_sEeyCBDeviceInfo;
#ifdef VR_EYE_DEBUG_MODE
// Debug模式相关成员
VzNL_AutoOutputLaserLineExCB m_debugCallback = nullptr;
void* m_debugCallbackParam = nullptr;
EVzResultDataType m_debugDataType;
std::atomic<bool> m_debugRunning{false};
std::thread m_debugThread;
std::mutex m_debugMutex;
VzNL_OnNotifyStatusCBEx m_debugStatusCallback = nullptr;
void* m_debugStatusCallbackParam = nullptr;
void DebugThreadFunc();
#endif
};
#endif // CVREYEDEVICE_H

View File

@ -71,7 +71,8 @@ SG_APISHARED_EXPORT void sg_getBagPosition(
//std::vector<std::vector<int>>& noisePts,
const SG_bagPositionParam algoParam,
const SSG_planeCalibPara poseCalibPara,
std::vector<SSG_peakRgnInfo>& objOps);
std::vector<SSG_peakRgnInfo>& objOps,
int* errCode);
SG_APISHARED_EXPORT void sg_getBagPositionAndOrientation(
SVzNLXYZRGBDLaserLine* laser3DPoints,

View File

@ -478,3 +478,9 @@ typedef struct
int markID;
SVzNL3DPoint mark3D;
}SWD_charuco3DMark;
typedef struct
{
SVzNL3DPoint pt1;
SVzNL3DPoint pt2;
}SWD_3DPointPair;

View File

@ -20,3 +20,6 @@
//¶¨×Óץȡ
#define SX_ERR_INVLID_CUTTING_Z -2101
#define SX_ERR_ZERO_OBJ -2102
//뀔관
#define SX_BAG_TRAY_EMPTY -2201