inspiredhand/jaka_robot/error_codes.cpp

31 lines
1.9 KiB
C++
Raw Permalink 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.

#include "error_codes.h"
#include <sstream>
std::string describeError(errno_t code) {
switch (code) {
case ERR_SUCC: return "成功";
case ERR_INVALID_HANDLER: return "无效的句柄(连接未建立或已断开)";
case ERR_INVALID_PARAMETER: return "无效参数(请检查传入参数范围/类型)";
case ERR_COMMUNICATION_ERR: return "通信错误(无法连接到控制器)";
case ERR_KINE_INVERSE_ERR: return "逆运动学求解失败(目标不可达或奇异)";
case ERR_EMERGENCY_PRESSED: return "急停E-Stop被触发解除后重试";
case ERR_NOT_POWERED: return "未上电,请先上电";
case ERR_NOT_ENABLED: return "未使能,请先使能机器人";
case ERR_DISABLE_SERVOMODE: return "不在伺服模式,无法执行轨迹运动";
case ERR_PROGRAM_IS_RUNNING: return "控制器正在运行程序,无法执行当前操作";
case ERR_CANNOT_OPEN_FILE: return "文件操作失败(文件不存在或无法打开)";
case ERR_MOTION_ABNORMAL: return "运动异常(运动过程中出现异常,可能超出关节/笛卡尔限位或奇异)";
case ERR_PROTECTIVE_STOP: return "保护停止protective stop检查报警并复位";
case ERR_EMERGENCY_STOP: return "紧急停止emergency stop请检查安全系统";
case ERR_SOFT_LIMIT: return "触及软限位soft limit目标或步进过大";
case ERR_MOVEL: return "直线运动失败(移动过程中出现错误)";
case ERR_MOVEJ: return "关节运动失败(移动过程中出现错误)";
case ERR_MOTION_TIMEOUT: return "运动超时(等待运动结束超时)";
default: {
std::ostringstream ss;
ss << "未知错误码: " << code << "(请查看 SDK 文档或联系支持)";
return ss.str();
}
}
}