GrabBag/Tools/CalibView/Inc/CalibDataWidget.h

225 lines
5.4 KiB
C
Raw Normal View History

2026-02-22 00:10:46 +08:00
#ifndef CALIBDATAWIDGET_H
#define CALIBDATAWIDGET_H
#include <QWidget>
#include <QTableWidget>
#include <QPushButton>
#include <QComboBox>
#include <QGroupBox>
#include <QSpinBox>
#include <QDoubleSpinBox>
2026-03-17 22:27:58 +08:00
#include "../../Module/HandEyeCalib/Inc/IHandEyeCalib.h"
2026-02-22 00:10:46 +08:00
#include <QLabel>
#include <vector>
#include "HandEyeCalibTypes.h"
/**
* @brief 标定数据输入控件
* 支持 Eye-To-Hand、Eye-In-Hand 和 TCP 三种模式的数据输入
*/
class CalibDataWidget : public QWidget
{
Q_OBJECT
public:
explicit CalibDataWidget(QWidget* parent = nullptr);
~CalibDataWidget() override;
/**
* @brief 获取 Eye-To-Hand 标定数据
*/
void getEyeToHandData(std::vector<HECPoint3D>& eyePoints,
std::vector<HECPoint3D>& robotPoints) const;
2026-03-17 22:27:58 +08:00
/**
* @brief 获取 Eye-To-Hand 完整位姿数据(用于 Park 方法)
*/
void getEyeToHandPoseData(std::vector<HECEyeToHandData>& calibData) const;
2026-02-22 00:10:46 +08:00
/**
* @brief 获取 Eye-In-Hand 标定数据
*/
void getEyeInHandData(std::vector<HECEyeInHandData>& calibData) const;
/**
* @brief 获取当前标定模式
*/
HECCalibrationType getCalibType() const;
/**
* @brief 获取当前标定模式索引 (0=EyeToHand, 1=EyeInHand, 2=TCP)
*/
int getCalibTypeIndex() const;
2026-03-17 22:27:58 +08:00
/**
* @brief 获取当前选择的欧拉角顺序
*/
HECEulerOrder getEulerOrder() const;
2026-02-22 00:10:46 +08:00
/**
* @brief 清除所有数据
*/
void clearAll();
/**
* @brief 供外部设置机械臂数据到输入框(根据当前模式自动填充)
*/
void setRobotInput(double x, double y, double z, double rx, double ry, double rz);
/**
* @brief 供外部设置相机数据到输入框(Eye-To-Hand 模式)
*/
void setCameraInput(double x, double y, double z, double rx, double ry, double rz);
/**
* @brief 获取 TCP 标定输入数据
*/
HECTCPCalibData getTCPCalibData() const;
/**
* @brief 将当前模式的标定数据保存到 INI 文件
*/
void saveCalibData(const QString& filePath) const;
/**
* @brief 从 INI 文件加载标定数据到表格
*/
void loadCalibData(const QString& filePath);
signals:
/**
* @brief 标定模式改变信号
*/
void calibTypeChanged(HECCalibrationType type);
/**
* @brief 请求 Eye-To-Hand 标定
*/
void requestEyeToHandCalib();
/**
* @brief 请求 Eye-In-Hand 标定
*/
void requestEyeInHandCalib();
/**
* @brief 请求 TCP 标定
*/
void requestTCPCalib();
private slots:
/**
* @brief 标定模式切换
*/
void onCalibTypeChanged(int index);
/**
* @brief TCP 模式切换(3-DOF / 6-DOF)
*/
void onTCPModeChanged(int index);
/**
* @brief TCP 添加行
*/
void onTCPAddRow();
/**
* @brief TCP 删除行
*/
void onTCPRemoveRow();
private:
/**
* @brief 初始化界面
*/
void setupUI();
/**
2026-03-17 22:27:58 +08:00
* @brief 创建手眼标定数据表格(Eye-To-Hand 和 Eye-In-Hand 共用)
2026-02-22 00:10:46 +08:00
*/
2026-03-17 22:27:58 +08:00
QWidget* createHandEyeGroup();
2026-02-22 00:10:46 +08:00
/**
* @brief 创建 TCP 标定数据组
*/
QWidget* createTCPCalibGroup();
/**
* @brief 更新表格显示
*/
void updateTableVisibility();
/**
* @brief 根据当前模式和角度单位更新表格列头
*/
void updateTableHeaders();
2026-02-22 00:10:46 +08:00
// 标定模式选择
QComboBox* m_cbCalibType;
2026-03-17 22:27:58 +08:00
// 欧拉角顺序选择
QComboBox* m_cbEulerOrder;
2026-02-22 00:10:46 +08:00
2026-03-17 22:27:58 +08:00
// 手眼标定通用数据表格(Eye-To-Hand 和 Eye-In-Hand 共用)
QTableWidget* m_tableHandEye;
QWidget* m_groupHandEye;
2026-02-22 00:10:46 +08:00
2026-03-17 22:27:58 +08:00
// 手眼标定内联按钮
QPushButton* m_btnHandEyeAddRow;
QPushButton* m_btnHandEyeDeleteRow;
QPushButton* m_btnHandEyeCalib;
2026-02-22 00:10:46 +08:00
// TCP 标定相关
QWidget* m_groupTCPCalib;
QTableWidget* m_tableTCP;
QComboBox* m_tcpModeCombo;
QComboBox* m_tcpEulerOrderCombo;
QSpinBox* m_tcpRefPoseIndex;
QDoubleSpinBox* m_tcpWorldRx;
QDoubleSpinBox* m_tcpWorldRy;
QDoubleSpinBox* m_tcpWorldRz;
QGroupBox* m_tcpOrientationGroup;
QPushButton* m_tcpAddRowBtn;
QPushButton* m_tcpRemoveRowBtn;
QPushButton* m_btnTCPCalib;
2026-03-17 22:27:58 +08:00
// 手眼标定通用输入框
2026-02-22 00:10:46 +08:00
QDoubleSpinBox* m_inputCamX;
QDoubleSpinBox* m_inputCamY;
QDoubleSpinBox* m_inputCamZ;
2026-03-17 22:27:58 +08:00
QDoubleSpinBox* m_inputCamRoll;
QDoubleSpinBox* m_inputCamPitch;
QDoubleSpinBox* m_inputCamYaw;
QDoubleSpinBox* m_inputRobotX;
QDoubleSpinBox* m_inputRobotY;
QDoubleSpinBox* m_inputRobotZ;
QDoubleSpinBox* m_inputRobotRoll;
QDoubleSpinBox* m_inputRobotPitch;
QDoubleSpinBox* m_inputRobotYaw;
QPushButton* m_btnHandEyeAddInput;
2026-02-22 00:10:46 +08:00
// TCP 输入框
QDoubleSpinBox* m_inputTcpX;
QDoubleSpinBox* m_inputTcpY;
QDoubleSpinBox* m_inputTcpZ;
QDoubleSpinBox* m_inputTcpRx;
QDoubleSpinBox* m_inputTcpRy;
QDoubleSpinBox* m_inputTcpRz;
QPushButton* m_btnTcpAddInput;
2026-03-17 22:27:58 +08:00
// 标定板角度单位选择
QComboBox* m_cbCamAngleUnit;
// 标定板姿态标签(需动态更新文字)
QLabel* m_lblCamRx;
QLabel* m_lblCamRy;
QLabel* m_lblCamRz;
2026-03-17 22:27:58 +08:00
// 存储加载的标定板姿态信息(用于 Park 方法)
std::vector<std::array<double, 3>> m_boardPoseData; // 每行存储 roll, pitch, yaw (弧度)
2026-02-22 00:10:46 +08:00
};
#endif // CALIBDATAWIDGET_H