GrabBag/GrabBagApp/Presenter/Inc/ProtocolCommon.h

72 lines
2.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 PROTOCOLCOMMON_H
#define PROTOCOLCOMMON_H
#include <functional>
#include <vector>
#include <cstdint>
/**
* @brief 机械臂坐标结构体
*/
struct RobotCoordinate {
float x; // X坐标
float y; // Y坐标
float z; // Z坐标
float rx; // X轴旋转
float ry; // Y轴旋转
float rz; // Z轴旋转
};
/**
* @brief 单个目标位置数据简化版只包含必要的x,y,z,rz
*/
struct TargetPosition {
float x; // X坐标
float y; // Y坐标
float z; // Z坐标
float rz; // Z轴旋转yaw角
uint16_t cameraId; // 相机ID从1开始编号
};
/**
* @brief 多目标检测结果数据结构
*/
struct MultiTargetData {
uint16_t count; // 目标数量
uint16_t cameraId; // 当前检测的相机ID从1开始编号
std::vector<TargetPosition> targets; // 目标位置列表
MultiTargetData() : count(0), cameraId(1) {} // 默认相机ID为1
};
/**
* @brief 通用连接状态枚举
*/
enum ConnectionStatus {
STATUS_DISCONNECTED = 0, // 断开连接
STATUS_CONNECTED = 1, // 已连接
STATUS_IDLE = 2, // 空闲状态
STATUS_WORKING = 3, // 工作中
STATUS_ERROR = 4 // 错误状态
};
/**
* @brief 连接状态回调函数类型
* @param connected true-连接false-断开
*/
using ConnectionCallback = std::function<void(bool connected)>;
/**
* @brief 开始工作信号回调函数类型
* @param startWork true-开始工作false-停止工作
* @param cameraId 相机ID从1开始编号12...
*/
using WorkSignalCallback = std::function<bool(bool startWork, int cameraId)>;
// 工作状态定义(公共常量)
static const uint16_t WORK_STATUS_IDLE = 0; // 空闲
static const uint16_t WORK_STATUS_CAMERA1_DONE = 1; // 相机1工作完成
static const uint16_t WORK_STATUS_CAMERA2_DONE = 2; // 相机2工作完成
static const uint16_t WORK_STATUS_BUSY = 3; // 忙碌
#endif // PROTOCOLCOMMON_H