2026-03-28 10:49:55 +08:00

211 lines
6.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef IVRCONFIG_HOLEPITPOSITION_H
#define IVRCONFIG_HOLEPITPOSITION_H
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstring>
// 包含公共配置结构体
#include "VrCommonConfig.h"
#include "VrHandEyeCalibConfig.h"
/**
* @brief 线段参数(对应 SSG_lineSegParam
*/
struct VrLineSegParam
{
double distScale = 25.0; // 距离缩放
double segGapTh_y = 25.0; // y方向分段间隔阈值
double segGapTh_z = 0.0; // z方向分段间隔阈值
};
/**
* @brief 角点参数(对应 SSG_cornerParam
*/
struct VrCornerParam
{
double cornerTh = 60.0; // 角度阈值
double scale = 4.0; // 方向角计算窗口比例
double minEndingGap = 10.0; // y方向端点最小间距
double minEndingGap_z = 5.0; // z方向端点最小间距
double jumpCornerTh_1 = 15.0; // 跳变角度阈值1水平角度小于此视为水平
double jumpCornerTh_2 = 60.0; // 跳变角度阈值2
};
/**
* @brief 噪声滤除参数(对应 SSG_outlierFilterParam
*/
struct VrOutlierFilterParam
{
double continuityTh = 20.0; // 连续性阈值z跳变大于此阈值时检查噪声
double outlierTh = 5.0; // 噪声判定阈值(点数小于此阈值视为噪声)
};
/**
* @brief 树生长参数(对应 SSG_treeGrowParam
*/
struct VrTreeGrowParam
{
int maxLineSkipNum = 2; // 最大跳行数
double yDeviation_max = 4.0; // Y方向最大偏差
double maxSkipDistance = 0.0; // 最大跳跃距离
double zDeviation_max = 10.0; // Z方向最大偏差
double minLTypeTreeLen = 1.0; // L型最小树长(mm)
double minVTypeTreeLen = 1.0; // V型最小树长(mm)
};
/**
* @brief 姿态输出顺序枚举
*/
enum VrPoseOutputOrder
{
POSE_ORDER_RPY = 0, // Roll, Pitch, Yaw默认
POSE_ORDER_RYP = 1, // Roll, Yaw, Pitch
POSE_ORDER_PRY = 2, // Pitch, Roll, Yaw
POSE_ORDER_PYR = 3, // Pitch, Yaw, Roll
POSE_ORDER_YRP = 4, // Yaw, Roll, Pitch
POSE_ORDER_YPR = 5 // Yaw, Pitch, Roll
};
/**
* @brief 方向向量反向配置枚举
*/
enum VrDirVectorInvert
{
DIR_INVERT_NONE = 0, // 不反向
DIR_INVERT_XY = 1, // X和Y方向反向
DIR_INVERT_XZ = 2, // X和Z方向反向
DIR_INVERT_YZ = 3 // Y和Z方向反向默认
};
/**
* @brief TCP协议和坐标输出配置
*/
struct VrPlcRobotServerConfig
{
int tcpServerPort = 7800; // TCP协议服务端口
int poseOutputOrder = POSE_ORDER_RPY; // 姿态输出顺序
int dirVectorInvert = DIR_INVERT_YZ; // 方向向量反向配置
VrPlcRobotServerConfig& operator=(const VrPlcRobotServerConfig& other) {
if (this != &other) {
tcpServerPort = other.tcpServerPort;
poseOutputOrder = other.poseOutputOrder;
dirVectorInvert = other.dirVectorInvert;
}
return *this;
}
VrPlcRobotServerConfig(const VrPlcRobotServerConfig& other)
: tcpServerPort(other.tcpServerPort)
, poseOutputOrder(other.poseOutputOrder)
, dirVectorInvert(other.dirVectorInvert) {
}
VrPlcRobotServerConfig() = default;
};
/**
* @brief 算法参数配置结构
*/
struct VrAlgorithmParams
{
VrLineSegParam lineSegParam; // 线段参数
VrCornerParam cornerParam; // 角点参数
VrOutlierFilterParam outlierFilterParam; // 噪声滤除参数
VrTreeGrowParam treeGrowParam; // 树生长参数
VrPlaneCalibParam planeCalibParam; // 平面校准参数
VrAlgorithmParams& operator=(const VrAlgorithmParams& other) {
if (this != &other) {
lineSegParam = other.lineSegParam;
cornerParam = other.cornerParam;
outlierFilterParam = other.outlierFilterParam;
treeGrowParam = other.treeGrowParam;
planeCalibParam = other.planeCalibParam;
}
return *this;
}
VrAlgorithmParams(const VrAlgorithmParams& other)
: lineSegParam(other.lineSegParam)
, cornerParam(other.cornerParam)
, outlierFilterParam(other.outlierFilterParam)
, treeGrowParam(other.treeGrowParam)
, planeCalibParam(other.planeCalibParam) {
}
VrAlgorithmParams() = default;
};
/**
* @brief 配置加载结果
*/
struct ConfigResult
{
std::vector<DeviceInfo> cameraList;
std::vector<DeviceInfo> deviceList;
VrAlgorithmParams algorithmParams;
std::vector<VrHandEyeCalibMatrix> handEyeCalibMatrixList;
VrDebugParam debugParam;
SerialConfig serialConfig;
VrPlcRobotServerConfig plcRobotServerConfig;
ConfigResult& operator=(const ConfigResult& other) {
if (this != &other) {
cameraList = other.cameraList;
deviceList = other.deviceList;
algorithmParams = other.algorithmParams;
handEyeCalibMatrixList = other.handEyeCalibMatrixList;
debugParam = other.debugParam;
serialConfig = other.serialConfig;
plcRobotServerConfig = other.plcRobotServerConfig;
}
return *this;
}
ConfigResult(const ConfigResult& other)
: cameraList(other.cameraList)
, deviceList(other.deviceList)
, algorithmParams(other.algorithmParams)
, handEyeCalibMatrixList(other.handEyeCalibMatrixList)
, debugParam(other.debugParam)
, serialConfig(other.serialConfig)
, plcRobotServerConfig(other.plcRobotServerConfig) {
}
ConfigResult() = default;
};
/**
* @brief 配置加载错误代码
*/
enum LoadConfigErrorCode
{
LOAD_CONFIG_SUCCESS = 0,
LOAD_CONFIG_FILE_NOT_FOUND = -1,
LOAD_CONFIG_PARSE_ERROR = -2,
LOAD_CONFIG_INVALID_FORMAT = -3,
LOAD_CONFIG_UNKNOWN_ERROR = -99
};
/**
* @brief VrConfig接口类
*/
class IVrConfig
{
public:
virtual ~IVrConfig() {}
static bool CreateInstance(IVrConfig** ppVrConfig);
virtual int LoadConfig(const std::string& filePath, ConfigResult& configResult) = 0;
virtual bool SaveConfig(const std::string& filePath, ConfigResult& configResult) = 0;
virtual void SetConfigChangeNotify(IVrConfigChangeNotify* notify) = 0;
};
#endif // IVRCONFIG_HOLEPITPOSITION_H