184 lines
5.0 KiB
C++
184 lines
5.0 KiB
C++
//
|
||
// Created by xtkuang on 2025/5/7.
|
||
//
|
||
|
||
#ifndef CMVR_ES_STATE_DEFINE_H
|
||
#define CMVR_ES_STATE_DEFINE_H
|
||
|
||
#include <atomic>
|
||
#include <cstdint>
|
||
#include <cmath>
|
||
#include <iostream>
|
||
#include <string>
|
||
#include <set>
|
||
#include <vector>
|
||
|
||
#include "common/types/agv/agv_types.h"
|
||
#include "common/types/geometry_types.h"
|
||
|
||
|
||
namespace cmvr::device{
|
||
enum Lifecycle{
|
||
INIT, // 初始化:设备刚创建或刚上电,正在初始化
|
||
READY, // 就绪:设备已初始化完成,可以开始工作
|
||
RUNNING,// 运行中:设备正在正常工作或采集
|
||
ERROR, // 错误:设备发生故障或异常,不能正常工作
|
||
STOP, // 停止:设备已停止工作,但没有严重错误
|
||
ESTOP // 急停:设备处于紧急停止状态,通常需要人工干预才能恢复
|
||
};
|
||
|
||
enum AudioFormat {
|
||
WAV,
|
||
MP3,
|
||
AAC,
|
||
OGG,
|
||
FLAC,
|
||
UNKNOWN
|
||
};
|
||
|
||
enum class AudioStreamFormat {
|
||
PCM = 0,
|
||
MP3 = 1,
|
||
AAC = 2,
|
||
WAV = 3,
|
||
OPUS = 4,
|
||
UNKNOWN = 99
|
||
};
|
||
|
||
struct AudioStreamFrameData {
|
||
std::vector<uint8_t> data;
|
||
int sample_rate = 44100;
|
||
int channels = 2;
|
||
AudioStreamFormat format = AudioStreamFormat::PCM;
|
||
std::string codec = "pcm_s16le";
|
||
int64_t pts = 0;
|
||
int64_t dts = 0;
|
||
int nb_samples = 0;
|
||
uint64_t stream_epoch = 0;
|
||
uint64_t sequence = 0;
|
||
int64_t capture_monotonic_ns = 0;
|
||
int64_t capture_utc_ns = 0;
|
||
int32_t time_base_num = 1;
|
||
int32_t time_base_den = 44100;
|
||
int64_t duration = 0;
|
||
bool discontinuity = false;
|
||
uint32_t codec_config_generation = 0;
|
||
std::vector<uint8_t> codec_config;
|
||
};
|
||
|
||
// ------------------------------------- robot -------------------------------------
|
||
typedef enum {
|
||
FORWARD, BACKWARD,
|
||
X_POSITIVE, // X轴正向
|
||
X_NEGATIVE, // X轴负向
|
||
Y_POSITIVE, // Y轴正向
|
||
Y_NEGATIVE, // Y轴负向
|
||
Z_POSITIVE, // Z轴正向
|
||
Z_NEGATIVE, // Z轴负向
|
||
// 角度方向也可以添加
|
||
ROTATE_X, // 绕X轴旋转
|
||
ROTATE_Y, // 绕Y轴旋转
|
||
ROTATE_Z // 绕Z轴旋转
|
||
} RobotJointIndexDirection;
|
||
|
||
|
||
|
||
/// robot cartesian index
|
||
typedef enum {
|
||
X, Y, Z, RX, RY, RZ
|
||
} RobotCartesian;
|
||
|
||
typedef struct {
|
||
std::string name;
|
||
bool is_ready;
|
||
bool power_on;
|
||
double position;
|
||
double velocity;
|
||
double current;
|
||
double torque;
|
||
double target_position;
|
||
double target_velocity;
|
||
int target_feedback_gain;
|
||
double target_feedforward_torque;
|
||
double temperature;
|
||
double voltage;
|
||
} JointState;
|
||
|
||
typedef struct{
|
||
std::vector<double> temperature;
|
||
std::vector<double> voltage;
|
||
std::vector<double> joint_positions;
|
||
bool error;
|
||
std::string error_msg;
|
||
} RobotState;
|
||
|
||
struct CameraState {
|
||
bool is_initialized; ///< 是否已初始化
|
||
bool is_opened;
|
||
bool is_streaming; ///< 是否正在采集视频数据
|
||
bool is_recording;
|
||
bool is_error;
|
||
std::string error_message;
|
||
int fps;
|
||
int width;
|
||
int height;
|
||
};
|
||
|
||
/// @brief 从 XML 或其他配置中读取的相机网络参数
|
||
struct CameraConfig {
|
||
std::string ipAddress; ///< 相机 IP 地址
|
||
};
|
||
|
||
|
||
typedef struct{
|
||
bool is_initialized; ///< 是否已初始化
|
||
bool is_running;
|
||
bool is_recording;
|
||
bool is_error;
|
||
int volume; // 0~100, 支持软音量调节
|
||
std::string error_message;
|
||
} MicrophoneState;
|
||
|
||
typedef struct{
|
||
|
||
} GripperState;
|
||
|
||
typedef struct{
|
||
int angle; //自由度角度
|
||
int speed; //自由度速度
|
||
int force; //实际受力
|
||
int position; //执行器位置
|
||
int current; //执行器实际电流
|
||
int temperature; //执行器温度
|
||
int error; //执行器故障信息
|
||
std::vector<std::string> error_message;
|
||
} RH56DFTPDexHand;
|
||
|
||
typedef struct{
|
||
bool is_initialized; //是否初始化
|
||
RH56DFTPDexHand hands[6]; // 包含6个自由度状态
|
||
} DexHandState;
|
||
|
||
typedef struct {
|
||
float voltage; //< 电压(V)
|
||
float current; //< 电流(A)
|
||
float temperature; //< 温度(°C)
|
||
int charge_percentage; //< 剩余电量(%)
|
||
bool is_charging; //< 是否正在充电
|
||
Lifecycle health; //< 电池健康状态
|
||
std::string vendor_info; //< 厂商信息(可选)
|
||
} BatteryState;
|
||
|
||
typedef struct {
|
||
bool is_initialized;
|
||
bool is_running;
|
||
bool is_decoding;
|
||
bool is_paused;
|
||
int volume; // 0~100, 支持软音量调节
|
||
} SpeakerState;
|
||
|
||
}
|
||
|
||
|
||
#endif //CMVR_ES_STATE_DEFINE_H
|