#ifndef IVRCONFIG_H #define IVRCONFIG_H #include #include #include // 包含公共配置结构体 #include "VrCommonConfig.h" #include "VrHandEyeCalibConfig.h" /** * @brief 钢筋直径/长度参数 */ struct VrRodParam { double rodDiameter = 16.0; // 钢筋直径 (mm) double rodLen = 50.0; // 钢筋长度 (mm) }; /** * @brief 焊缝搜索参数 */ struct VrWeldSeamParam { double weldSeamRangeMin = 0.0; // 焊缝距钢筋交叉点的最小距离 (mm) double weldSeamRangeMax = 100.0; // 焊缝距钢筋交叉点的最大距离 (mm) int weldingCategory = 2; // 1=每根钢筋都有支点,2=仅上层钢筋有支点 }; /** * @brief 角点检测参数 */ struct VrCornerParam { double minEndingGap = 20.0; double minEndingGap_z = 5.0; double scale = 4.0; double cornerTh = 60.0; double jumpCornerTh_1 = 15.0; double jumpCornerTh_2 = 60.0; }; /** * @brief 离群点滤波参数 */ struct VrOutlierFilterParam { double continuityTh = 4.0; // meanK double outlierTh = 4.0; // stddevMul }; /** * @brief 区域生长参数 */ struct VrTreeGrowParam { double yDeviation_max = 5.0; double zDeviation_max = 3.0; int maxLineSkipNum = 5; double maxSkipDistance = 20.0; double minLTypeTreeLen = 50.0; double minVTypeTreeLen = 50.0; }; /** * @brief 算法参数配置结构(RodWeldSeam 专用) */ struct VrAlgorithmParams { VrRodParam rodParam; VrWeldSeamParam weldSeamParam; VrCornerParam cornerParam; VrOutlierFilterParam filterParam; VrTreeGrowParam growParam; VrPlaneCalibParam planeCalibParam; }; /** * @brief 配置加载结果 */ struct ConfigResult { std::vector cameraList; // 相机设备列表 VrDebugParam debugParam; // 调试参数 SerialConfig serialConfig; // 串口配置 VrAlgorithmParams algorithmParams; // 算法参数 std::vector handEyeCalibMatrixList; // 多相机手眼标定矩阵列表 int eulerOrder = 11; // Euler order, default: extrinsic ZYX int dirVectorInvert = 0; // Direction-vector inversion mode int byteOrder = 0; // 0=big endian, 1=little endian int longAxisDir = 0; // 0=X axis, 1=Y axis int poseOutputOrder = 0; // Robot A/B/C field order int tcpPort = 7800; // Text TCP server port ConfigResult& operator=(const ConfigResult& other) { if (this != &other) { cameraList = other.cameraList; debugParam = other.debugParam; serialConfig = other.serialConfig; algorithmParams = other.algorithmParams; handEyeCalibMatrixList = other.handEyeCalibMatrixList; eulerOrder = other.eulerOrder; dirVectorInvert = other.dirVectorInvert; byteOrder = other.byteOrder; longAxisDir = other.longAxisDir; poseOutputOrder = other.poseOutputOrder; tcpPort = other.tcpPort; } return *this; } ConfigResult(const ConfigResult& other) : cameraList(other.cameraList) , debugParam(other.debugParam) , serialConfig(other.serialConfig) , algorithmParams(other.algorithmParams) , handEyeCalibMatrixList(other.handEyeCalibMatrixList) , eulerOrder(other.eulerOrder) , dirVectorInvert(other.dirVectorInvert) , byteOrder(other.byteOrder) , longAxisDir(other.longAxisDir) , poseOutputOrder(other.poseOutputOrder) , tcpPort(other.tcpPort) { } 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: /** * @brief 虚析构函数 */ virtual ~IVrConfig() {} /** * @brief 创建实例 * @return 实例 */ static bool CreateInstance(IVrConfig** ppVrConfig); /** * @brief 加载配置文件 * @param filePath 配置文件路径 * @param configResult 输出参数,加载的配置结果 * @return 错误代码 (LoadConfigErrorCode): 0=成功, 负值表示错误 */ virtual int LoadConfig(const std::string& filePath, ConfigResult& configResult) = 0; /** * @brief 保存配置文件 * @param filePath 配置文件路径 * @param configResult 配置结果 * @return 是否保存成功 */ virtual bool SaveConfig(const std::string& filePath, ConfigResult& configResult) = 0; /** * @brief 设置配置改变通知回调 * @param notify 通知接口指针 */ virtual void SetConfigChangeNotify(IVrConfigChangeNotify* notify) = 0; }; #endif // IVRCONFIG_H