GrabBag/Module/HandEyeCalib/Inc/IHandEyeCalib.h

248 lines
8.8 KiB
C
Raw Normal View History

2026-03-17 22:27:58 +08:00
#ifndef IHANDEYECALIB_H
#define IHANDEYECALIB_H
#include <vector>
#include "HandEyeCalib_global.h"
#include "HandEyeCalibTypes.h"
/**
* @brief
* SVD分解的手眼标定算法使Eigen库实现
* OpenCV
*/
class IHandEyeCalib
{
public:
virtual ~IHandEyeCalib() = default;
/**
* @brief ()
* 使SVD分解方法计算两组对应点之间的刚体变换
* @param eyePoints
* @param robotPoints
* @param result (R, T, )
* @return 0
*/
virtual int CalculateRT(
const std::vector<HECPoint3D>& eyePoints,
const std::vector<HECPoint3D>& robotPoints,
HECCalibResult& result) = 0;
/**
* @brief (使)
* @param pointPairs
* @param result
* @return 0
*/
virtual int CalculateRT(
const std::vector<HECCalibPointPair>& pointPairs,
HECCalibResult& result) = 0;
/**
* @brief 使RT矩阵变换点 (: R*p + T)
* @param R
* @param T
* @param srcPoint
* @param dstPoint
*/
virtual void TransformPoint(
const HECRotationMatrix& R,
const HECTranslationVector& T,
const HECPoint3D& srcPoint,
HECPoint3D& dstPoint) = 0;
/**
* @brief 使RT矩阵变换点 ()
* : dstPoint = R * (srcPoint - srcCenter) + dstCenter
* @param R
* @param T
* @param srcCenter
* @param dstCenter
* @param srcPoint
* @param dstPoint
*/
virtual void TransformPointWithCenter(
const HECRotationMatrix& R,
const HECTranslationVector& T,
const HECPoint3D& srcCenter,
const HECPoint3D& dstCenter,
const HECPoint3D& srcPoint,
HECPoint3D& dstPoint) = 0;
/**
* @brief 使 ()
* @param R
* @param srcPoint
* @param dstPoint
*/
virtual void RotatePoint(
const HECRotationMatrix& R,
const HECPoint3D& srcPoint,
HECPoint3D& dstPoint) = 0;
/**
* @brief (ZYX顺序)
* @param R
* @param angles ()
*/
virtual void RotationMatrixToEulerZYX(
const HECRotationMatrix& R,
HECEulerAngles& angles) = 0;
/**
* @brief ()
* @param R
* @param order
* @param angles ()
*/
virtual void RotationMatrixToEuler(
const HECRotationMatrix& R,
HECEulerOrder order,
HECEulerAngles& angles) = 0;
/**
* @brief (ZYX顺序)
* @param angles ()
* @param R
*/
virtual void EulerZYXToRotationMatrix(
const HECEulerAngles& angles,
HECRotationMatrix& R) = 0;
/**
* @brief ()
* @param angles ()
* @param order
* @param R
*/
virtual void EulerToRotationMatrix(
const HECEulerAngles& angles,
HECEulerOrder order,
HECRotationMatrix& R) = 0;
/**
* @brief 姿 ( + 姿)
* 姿
* @param calibResult
* @param eyePoint
* @param eyeDirVectors (X, Y, Z轴方向)
* @param invertYZ Y轴和Z轴方向取反 ()
* @param poseResult 姿
*/
virtual void TransformPose(
const HECCalibResult& calibResult,
const HECPoint3D& eyePoint,
const std::vector<HECPoint3D>& eyeDirVectors,
bool invertYZ,
HECPoseResult& poseResult) = 0;
/**
* @brief Convert eye-frame center + XZ seed directions to robot-frame pose.
*
* Builds a right-handed frame from xSeed (X axis) and zSeed (Z axis),
* applies the dirVectorInvert flip, transforms position and orientation through
* the hand-eye calibration, and returns the result in degrees.
*
* @param calibResult Hand-eye calibration result (R, T)
* @param eyeCenter Object center in eye (camera) frame
* @param xSeed X-axis seed direction in eye frame
* @param zSeed Z-axis seed direction in eye frame
* @param dirVectorInvert Axis-flip mode: 0=none, 1=flip XY, 2=flip XZ, 3=flip YZ
* @param eulerOrder Euler angle decomposition order
* @param poseResult Output robot-frame position (mm) and Euler angles (degrees)
* @return true if the seed vectors form a valid frame, false otherwise
*/
virtual bool TransformPose(
const HECCalibResult& calibResult,
const HECPoint3D& eyeCenter,
const HECPoint3D& longAxisDir,
const HECPoint3D& normalDir,
int dirVectorInvert,
HECEulerOrder eulerOrder,
HECLongAxisDir longAxisMapping,
HECPoseResult& poseResult) = 0;
2026-03-17 22:27:58 +08:00
/**
* @brief
* @param eyePoints
* @param robotPoints
* @param calibResult
* @return (mm)
*/
virtual double CalculateError(
const std::vector<HECPoint3D>& eyePoints,
const std::vector<HECPoint3D>& robotPoints,
const HECCalibResult& calibResult) = 0;
/**
* @brief (Eye-In-Hand)
*
*
* P_base
* P_base = T_end * T_cam * P_cam
* T_end 姿T_cam
*
* AX=XB
*
* @param calibData 姿
* @param result ()
* @return 0
*/
virtual int CalculateEyeInHand(
const std::vector<HECEyeInHandData>& calibData,
HECCalibResult& result) = 0;
/**
* @brief - 使
* 使
*
* @param calibData
* @param targetInBase
* @param result
* @return 0
*/
virtual int CalculateEyeInHandWithTarget(
const std::vector<HECEyeInHandData>& calibData,
const HECPoint3D& targetInBase,
HECCalibResult& result) = 0;
/**
* @brief TCP 3-DOF 6-DOF
* @param data TCP
* @return TCP
*/
virtual HECTCPCalibResult CalculateTCP(const HECTCPCalibData& data) = 0;
/**
* @brief Eye-To-Hand 使姿 - Park
*
*
* 使 Park/Tsai-Lenz 姿+姿
* AX=XB
* A = T_end_i^{-1} * T_end_j (姿)
* B = T_board_i^{-1} * T_board_j ()
* X = T_cam_to_base ()
*
* @param calibData 姿姿
* @param result
* @return 0
*/
virtual int CalculateEyeToHandWithPose(
const std::vector<HECEyeToHandData>& calibData,
HECCalibResult& result) = 0;
};
/**
* @brief
* @return
*/
IHandEyeCalib* CreateHandEyeCalibInstance();
/**
* @brief
* @param instance
*/
void DestroyHandEyeCalibInstance(IHandEyeCalib* instance);
#endif // IHANDEYECALIB_H