GrabBag/Tools/CalibView/Inc/CalibDataWidget.h
2026-03-17 22:27:58 +08:00

213 lines
5.1 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 CALIBDATAWIDGET_H
#define CALIBDATAWIDGET_H
#include <QWidget>
#include <QTableWidget>
#include <QPushButton>
#include <QComboBox>
#include <QGroupBox>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include "../../Module/HandEyeCalib/Inc/IHandEyeCalib.h"
#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;
/**
* @brief 获取 Eye-To-Hand 完整位姿数据(用于 Park 方法)
*/
void getEyeToHandPoseData(std::vector<HECEyeToHandData>& calibData) const;
/**
* @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;
/**
* @brief 获取当前选择的欧拉角顺序
*/
HECEulerOrder getEulerOrder() const;
/**
* @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();
/**
* @brief 创建手眼标定数据表格Eye-To-Hand 和 Eye-In-Hand 共用)
*/
QWidget* createHandEyeGroup();
/**
* @brief 创建 TCP 标定数据组
*/
QWidget* createTCPCalibGroup();
/**
* @brief 更新表格显示
*/
void updateTableVisibility();
// 标定模式选择
QComboBox* m_cbCalibType;
// 欧拉角顺序选择
QComboBox* m_cbEulerOrder;
// 手眼标定通用数据表格Eye-To-Hand 和 Eye-In-Hand 共用)
QTableWidget* m_tableHandEye;
QWidget* m_groupHandEye;
// 手眼标定内联按钮
QPushButton* m_btnHandEyeAddRow;
QPushButton* m_btnHandEyeDeleteRow;
QPushButton* m_btnHandEyeCalib;
// 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;
// 手眼标定通用输入框
QDoubleSpinBox* m_inputCamX;
QDoubleSpinBox* m_inputCamY;
QDoubleSpinBox* m_inputCamZ;
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;
// TCP 输入框
QDoubleSpinBox* m_inputTcpX;
QDoubleSpinBox* m_inputTcpY;
QDoubleSpinBox* m_inputTcpZ;
QDoubleSpinBox* m_inputTcpRx;
QDoubleSpinBox* m_inputTcpRy;
QDoubleSpinBox* m_inputTcpRz;
QPushButton* m_btnTcpAddInput;
// 存储加载的标定板姿态信息(用于 Park 方法)
std::vector<std::array<double, 3>> m_boardPoseData; // 每行存储 roll, pitch, yaw (弧度)
};
#endif // CALIBDATAWIDGET_H