#ifndef IVRCONFIG_H #define IVRCONFIG_H #include #include #include #include #include #include #include "VrCommonConfig.h" #include "VrHandEyeCalibConfig.h" struct VrRansacPlaneSegmentationParam { double distanceThreshold = 0.5; int maxIterations = 500; int minPlanePoints = 100; int maxPlanes = 5; double growthZThreshold = 1.0; double minPlaneRatio = 0.1; double maxNormalAngleDeg = 30.0; double maxDistFromPlane = 1.0; }; struct VrHoleDetectionParam { double angleThresholdPos = 50.0; double angleThresholdNeg = -50.0; double angleSearchDistance = 2.0; double minPitDepth = 1.0; double minRadius = 2.0; double maxRadius = 50.0; int expansionSize1 = 5; int expansionSize2 = 10; int minVTransitionPoints = 1; double jumpThresholdResidual = 0.0; double gapJumpThresholdResidual = 0.0; int maxGapPointsInLine = 12; double minFeatureSpan = 2.0; int residualSmoothWindow = 5; double slopeAngleThreshold = 3.0; double edgeBoundaryFilterDist = 0.0; }; struct VrHoleFilterParam { double maxEccentricity = 0.99995; double minAngularCoverage = 10.0; double maxRadiusFitRatio = 1.0; double minQualityScore = 0.0; double maxPlaneResidual = 10.0; double maxAngularGap = 90.0; double minInlierRatio = 0.0; double minHoleDepth = 2.5; }; enum VrHoleSortMode { HOLE_SORT_NONE = 0, HOLE_SORT_BY_RADIUS = 1, HOLE_SORT_BY_DEPTH = 2, HOLE_SORT_BY_QUALITY = 3 }; enum VrPoseOutputOrder { POSE_ORDER_RPY = 0, POSE_ORDER_RYP = 1, POSE_ORDER_PRY = 2, POSE_ORDER_PYR = 3, POSE_ORDER_YRP = 4, POSE_ORDER_YPR = 5 }; enum VrDirVectorInvert { DIR_INVERT_NONE = 0, DIR_INVERT_XY = 1, DIR_INVERT_XZ = 2, DIR_INVERT_YZ = 3 }; struct VrPlcRobotServerConfig { int tcpServerPort = 7800; 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; }; struct VrAlgorithmParams { VrRansacPlaneSegmentationParam ransacParam; VrHoleDetectionParam detectionParam; VrHoleFilterParam filterParam; int sortMode = HOLE_SORT_NONE; VrPlaneCalibParam planeCalibParam; VrAlgorithmParams& operator=(const VrAlgorithmParams& other) { if (this != &other) { ransacParam = other.ransacParam; detectionParam = other.detectionParam; filterParam = other.filterParam; sortMode = other.sortMode; planeCalibParam = other.planeCalibParam; } return *this; } VrAlgorithmParams(const VrAlgorithmParams& other) : ransacParam(other.ransacParam) , detectionParam(other.detectionParam) , filterParam(other.filterParam) , sortMode(other.sortMode) , planeCalibParam(other.planeCalibParam) { } VrAlgorithmParams() = default; }; struct ConfigResult { std::vector cameraList; std::vector deviceList; VrAlgorithmParams algorithmParams; std::vector 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; }; 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 }; 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_H