ARCS SDK API  0.25.0
载入中...
搜索中...
未找到
type_def.h
浏览该文件的文档.
1/** @file type_def.h
2 * @brief 数据类型的定义
3 */
4#ifndef AUBO_SDK_TYPE_DEF_H
5#define AUBO_SDK_TYPE_DEF_H
6
7#include <stddef.h>
8#include <array>
9#include <vector>
10#include <memory>
11#include <functional>
12#include <iostream>
13#include <string>
14
15#ifdef _MSC_VER
16#pragma execution_character_set("utf-8")
17#endif
18
19namespace arcs {
20namespace common_interface {
21
22/// Cartesion degree of freedom, 6 for x,y,z,rx,ry,rz
23#define CARTESIAN_DOF 6
24#define SAFETY_PARAM_SELECT_NUM 2 /// normal + reduced
25#define SAFETY_PLANES_NUM 8 /// 安全平面的数量
26#define SAFETY_CUBIC_NUM 10 /// 安全立方体的数量
27#define TOOL_CONFIGURATION_NUM 3 /// 工具配置数量
28
29using Vector3d = std::array<double, 3>;
30using Vector4d = std::array<double, 4>;
31using Vector3f = std::array<float, 3>;
32using Vector4f = std::array<float, 4>;
33using Vector6f = std::array<float, 6>;
34
36{
38 {
39 for (int i = 0; i < SAFETY_PARAM_SELECT_NUM; i++) {
40 params[i].power = 0.;
41 params[i].momentum = 0.;
42 params[i].stop_time = 0.;
43 params[i].stop_distance = 0.;
44 params[i].reduced_entry_time = 0.;
45 params[i].reduced_entry_distance = 0.;
46 params[i].tcp_speed = 0.;
47 params[i].elbow_speed = 0.;
48 params[i].tcp_force = 0.;
49 params[i].elbow_force = 0.;
50 std::fill(params[i].qmin.begin(), params[i].qmin.end(), 0.);
51 std::fill(params[i].qmax.begin(), params[i].qmax.end(), 0.);
52 std::fill(params[i].qdmax.begin(), params[i].qdmax.end(), 0.);
53 std::fill(params[i].joint_torque.begin(),
54 params[i].joint_torque.end(), 0.);
55 params[i].tool_orientation.fill(0.);
56 params[i].tool_deviation = 0.;
57 for (int j = 0; j < SAFETY_PLANES_NUM; j++) {
58 params[i].planes[j].fill(0.);
59 params[i].restrict_elbow[j] = 0;
60 }
61 }
62 for (int i = 0; i < SAFETY_PLANES_NUM; i++) {
63 trigger_planes[i].plane.fill(0.);
64 trigger_planes[i].restrict_elbow = 0;
65 }
66 for (int i = 0; i < SAFETY_CUBIC_NUM; i++) {
67 cubic[i].orig.fill(0.);
68 cubic[i].size.fill(0.);
69 cubic[i].restrict_elbow = 0;
70 }
71 for (int i = 0; i < TOOL_CONFIGURATION_NUM; i++) {
72 tools[i].fill(0.);
73 }
74
76 tool_azimuth = 0.;
77 std::fill(safety_home.begin(), safety_home.end(), 0.);
78
88
98
101 }
102
103 uint32_t crc32{ 0 };
104
105 /// 最多可以保存2套参数, 默认使用第 0 套参数
106 struct
107 {
108 float power; ///< sum of joint torques times joint angular speeds
109 float momentum; ///< 机器人动量限制
110 float stop_time; ///< 停机时间 ms
111 float stop_distance; ///< 停机距离 m
112 float reduced_entry_time; ///< 进入缩减模式的最大时间
113 float
114 reduced_entry_distance; ///< 进入缩减模式的最大距离(可由安全平面触发)
119 std::vector<float> qmin;
120 std::vector<float> qmax;
121 std::vector<float> qdmax;
122 std::vector<float> joint_torque;
125 Vector4f planes[SAFETY_PLANES_NUM]; /// x,y,z,displacement
128
129 /// 8个触发平面
130 struct
131 {
132 Vector4f plane; /// x,y,z,displacement
133 int restrict_elbow;
135
136 struct
137 {
138 Vector6f orig; ///< 立方块的原点 (x,y,z,rx,ry,rz)
139 Vector3f size; ///< 立方块的尺寸 (x,y,z)
140 int restrict_elbow;
141 } cubic[SAFETY_CUBIC_NUM]; ///< 10个安全空间
142
143 /// 3个工具
145
146 float tool_inclination{ 0. }; ///< 倾角
147 float tool_azimuth{ 0. }; ///< 方位角
148 std::vector<float> safety_home;
149
150 /// 可配置IO的输入输出安全功能配置
160
170
171 int tp_3pe_for_handguide; ///< 是否将示教器三档位开关作为拖动功能开关
172 int allow_manual_high_speed; ///< 手动模式下允许高速运行
173};
174
175inline std::ostream &operator<<(std::ostream &os,
177{
178 // os << (int)vd;
179 return os;
180}
181
182/// 接口函数返回值定义
183///
184/// 整数为警告,负数为错误,0为没有错误也没有警告
185#define ENUM_AuboErrorCodes_DECLARES \
186 ENUM_ITEM(AUBO_OK, 0, "Success") \
187 ENUM_ITEM(AUBO_BAD_STATE, 1, "State error") \
188 ENUM_ITEM(AUBO_QUEUE_FULL, 2, "Planning queue full") \
189 ENUM_ITEM(AUBO_BUSY, 3, "The previous command is executing") \
190 ENUM_ITEM(AUBO_TIMEOUT, 4, "Timeout") \
191 ENUM_ITEM(AUBO_INVL_ARGUMENT, 5, "Invalid parameters") \
192 ENUM_ITEM(AUBO_NOT_IMPLETEMENT, 6, "Interface not implemented") \
193 ENUM_ITEM(AUBO_NO_ACCESS, 7, "Cannot access") \
194 ENUM_ITEM(AUBO_CONN_REFUSED, 8, "Connection refused") \
195 ENUM_ITEM(AUBO_CONN_RESET, 9, "Connection is reset") \
196 ENUM_ITEM(AUBO_INPROGRESS, 10, "Execution in progress") \
197 ENUM_ITEM(AUBO_EIO, 11, "Input/Output error") \
198 ENUM_ITEM(AUBO_NOBUFFS, 12, "") \
199 ENUM_ITEM(AUBO_REQUEST_IGNORE, 13, "Request was ignored") \
200 ENUM_ITEM(AUBO_ALGORITHM_PLAN_FAILED, 14, \
201 "Motion planning algorithm error") \
202 ENUM_ITEM(AUBO_VERSION_INCOMPAT, 15, "Interface version unmatch") \
203 ENUM_ITEM(AUBO_DIMENSION_ERR, 16, \
204 "Input parameter dimension is incorrect") \
205 ENUM_ITEM(AUBO_SINGULAR_ERR, 17, "Input configuration may be singular") \
206 ENUM_ITEM(AUBO_POS_BOUND_ERR, 18, \
207 "Input position boundary exceeds the limit range") \
208 ENUM_ITEM(AUBO_INIT_POS_ERR, 19, "Initial position input is unreasonable") \
209 ENUM_ITEM(AUBO_ELP_SETTING_ERR, 20, "Envelope body setting error") \
210 ENUM_ITEM(AUBO_TRAJ_GEN_FAIL, 21, "Trajectory generation failed") \
211 ENUM_ITEM(AUBO_TRAJ_SELF_COLLISION, 22, "Trajectory self collision") \
212 ENUM_ITEM( \
213 AUBO_IK_NO_CONVERGE, 23, \
214 "Inverse kinematics computation did not converge; computation failed") \
215 ENUM_ITEM(AUBO_IK_OUT_OF_RANGE, 24, \
216 "Inverse kinematics result out of robot range") \
217 ENUM_ITEM(AUBO_IK_CONFIG_DISMATCH, 25, \
218 "Inverse kinematics input configuration contains errors") \
219 ENUM_ITEM(AUBO_IK_JACOBIAN_FAILED, 26, \
220 "The calculation of the inverse Jacobian matrix failed") \
221 ENUM_ITEM(AUBO_IK_NO_SOLU, 27, \
222 "The target point has solutions, but it has exceeded the joint " \
223 "limit conditions") \
224 ENUM_ITEM(AUBO_IK_UNKOWN_ERROR, 28, "Inverse kinematics unkown error") \
225 ENUM_ITEM(AUBO_INST_QUEUED, 100, "Instruction pused into queue succeed") \
226 ENUM_ITEM(AUBO_INTERNAL_ERR, 101, "Internal error caused by alg .etc.") \
227 ENUM_ITEM(AUBO_ERR_UNKOWN, 99999, "Unkown error occurred.")
228
229// clang-format off
230/**
231 * The RuntimeState enum
232 *
233 */
234#define ENUM_RuntimeState_DECLARES \
235 ENUM_ITEM(Running, 0, "正在运行中") \
236 ENUM_ITEM(Retracting, 1, "倒退") \
237 ENUM_ITEM(Pausing, 2, "暂停中") \
238 ENUM_ITEM(Paused, 3, "暂停状态") \
239 ENUM_ITEM(Stepping, 4, "单步执行中") \
240 ENUM_ITEM(Stopping, 5, "受控停止中(保持原有轨迹)") \
241 ENUM_ITEM(Stopped, 6, "已停止") \
242 ENUM_ITEM(Aborting, 7, "停止(最大速度关节运动停机)")
243
244/**
245 * @brief The RobotModeType enum
246 *
247 * 硬件强相关
248 */
249#define ENUM_RobotModeType_DECLARES \
250 ENUM_ITEM(NoController, -1, "提供给示教器使用的, 如果aubo_control进程崩溃则会显示为NoController") \
251 ENUM_ITEM(Disconnected, 0, "没有连接到机械臂本体(控制器与接口板断开连接或是 EtherCAT 等总线断开)") \
252 ENUM_ITEM(ConfirmSafety, 1, "正在进行安全配置, 断电状态下进行") \
253 ENUM_ITEM(Booting, 2, "机械臂本体正在上电初始化") \
254 ENUM_ITEM(PowerOff, 3, "机械臂本体处于断电状态") \
255 ENUM_ITEM(PowerOn, 4, "机械臂本体上电成功, 刹车暂未松开(抱死), 关节初始状态未获取") \
256 ENUM_ITEM(Idle, 5, "机械臂上电成功, 刹车暂未松开(抱死), 电机不通电, 关节初始状态获取完成") \
257 ENUM_ITEM(BrakeReleasing, 6, "机械臂上电成功, 刹车正在松开") \
258 ENUM_ITEM(BackDrive, 7, "反向驱动:刹车松开, 电机不通电") \
259 ENUM_ITEM(Running, 8, "机械臂刹车松开, 运行模式, 控制权由硬件移交给软件") \
260 ENUM_ITEM(Maintaince, 9, "维护模式: 包括固件升级、参数写入等") \
261 ENUM_ITEM(Error, 10, "") \
262 ENUM_ITEM(PowerOffing, 11, "机械臂本体处于断电过程中")
263
264#define ENUM_SafetyModeType_DECLARES \
265 ENUM_ITEM(Undefined, 0, "安全状态待定") \
266 ENUM_ITEM(Normal, 1, "正常运行模式") \
267 ENUM_ITEM(ReducedMode, 2, "缩减运行模式") \
268 ENUM_ITEM(Recovery, 3, "启动时如果在安全限制之外, 机器人将进入recovery模式") \
269 ENUM_ITEM(Violation, 4, "超出安全限制(根据安全配置, 例如速度超限等)") \
270 ENUM_ITEM(ProtectiveStop, 5, "软件触发的停机(保持轨迹, 不抱闸, 不断电)") \
271 ENUM_ITEM(SafeguardStop, 6, "IO触发的防护停机(不保持轨迹, 抱闸, 不断电)") \
272 ENUM_ITEM(SystemEmergencyStop,7, "系统急停:急停信号由外部输入(可配置输入), 不对外输出急停信号") \
273 ENUM_ITEM(RobotEmergencyStop, 8, "机器人急停:控制柜急停输入或者示教器急停按键触发, 对外输出急停信号") \
274 ENUM_ITEM(Fault, 9, "机械臂硬件故障或者系统故障")
275 //ValidateJointId
276
277/**
278 * 根据ISO 10218-1:2011(E) 5.7节
279 * Automatic: In automatic mode, the robot shall execute the task programme and
280 * the safeguarding measures shall be functioning. Automatic operation shall be
281 * prevented if any stop condition is detected. Switching from this mode shall
282 * result in a stop.
283 */
284#define ENUM_OperationalModeType_DECLARES \
285 ENUM_ITEM(Disabled, 0, "禁用模式: 不使用Operational Mode") \
286 ENUM_ITEM(Automatic, 1, "自动模式: 机器人正常工作模式, 运行速度不会被限制") \
287 ENUM_ITEM(Manual, 2, "手动模式: 机器人编程示教模式(T1), 机器人运行速度将会被限制或者机器人程序校验模式(T2)")
288
289/**
290 * 机器人的控制模式, 最终的控制对象
291 */
292#define ENUM_RobotControlModeType_DECLARES \
293 ENUM_ITEM(Unknown, 0, "未知的控制模式") \
294 ENUM_ITEM(Position, 1, "位置控制 movej") \
295 ENUM_ITEM(Speed, 2, "速度控制 speedj/speedl") \
296 ENUM_ITEM(Servo, 3, "位置控制 servoj") \
297 ENUM_ITEM(Freedrive, 4, "拖动示教 freedrive_mode") \
298 ENUM_ITEM(Force, 5, "末端力控 force_mode") \
299 ENUM_ITEM(Torque, 6, "关节力矩控制") \
300 ENUM_ITEM(Collision, 7, "碰撞模式")
301
302#define ENUM_JointServoModeType_DECLARES \
303 ENUM_ITEM(Unknown, -1, "未知") \
304 ENUM_ITEM(Open, 0, "开环模式") \
305 ENUM_ITEM(Current, 1, "电流伺服模式") \
306 ENUM_ITEM(Velocity, 2, "速度伺服模式") \
307 ENUM_ITEM(Position, 3, "位置伺服模式") \
308 ENUM_ITEM(Torque, 4, "力矩伺服模式")
309
310#define ENUM_JointStateType_DECLARES \
311 ENUM_ITEM(Poweroff, 0, "节点未连接到接口板或者已经断电") \
312 ENUM_ITEM(Idle, 2, "节点空闲") \
313 ENUM_ITEM(Fault, 3, "节点错误, 节点停止伺服运动, 刹车抱死") \
314 ENUM_ITEM(Running, 4, "节点伺服") \
315 ENUM_ITEM(Bootload, 5, "节点bootloader状态, 暂停一切通讯")
316
317#define ENUM_StandardInputAction_DECLARES \
318 ENUM_ITEM(Default, 0, "无触发") \
319 ENUM_ITEM(Handguide, 1, "拖动示教,高电平触发") \
320 ENUM_ITEM(GoHome, 2, "运动到工程初始位姿,高电平触发") \
321 ENUM_ITEM(StartProgram, 3, "开始工程,上升沿触发") \
322 ENUM_ITEM(StopProgram, 4, "停止工程,上升沿触发") \
323 ENUM_ITEM(PauseProgram, 5, "暂停工程,上升沿触发") \
324 ENUM_ITEM(PopupDismiss, 6, "消除弹窗,上升沿触发") \
325 ENUM_ITEM(PowerOn, 7, "机器人上电/松刹车,上升沿触发") \
326 ENUM_ITEM(PowerOff, 8, "机器人抱死刹车/断电,上升沿触发") \
327 ENUM_ITEM(ResumeProgram, 9, "恢复工程,上升沿触发") \
328 ENUM_ITEM(SlowDown1, 10, "机器人减速触发1,高电平触发") \
329 ENUM_ITEM(SlowDown2, 11, "机器人减速触发2,高电平触发") \
330 ENUM_ITEM(SafeStop, 12, "安全停止,高电平触发") \
331 ENUM_ITEM(RunningGuard, 13, "信号,高电平有效") \
332 ENUM_ITEM(MoveToFirstPoint, 14, "运动到工程初始位姿,高电平触发") \
333 ENUM_ITEM(xSlowDown1, 15, "机器人减速触发1,低电平触发") \
334 ENUM_ITEM(xSlowDown2, 16, "机器人减速触发2,低电平触发")
335
336#define ENUM_StandardOutputRunState_DECLARES \
337 ENUM_ITEM(None, 0, "标准输出状态未定义") \
338 ENUM_ITEM(StopLow, 1, "低电平指示工程停止") \
339 ENUM_ITEM(StopHigh, 2, "高电平指示机器人停止") \
340 ENUM_ITEM(RunningHigh, 3, "指示工程正在运行") \
341 ENUM_ITEM(PausedHigh, 4, "指示工程已经暂停") \
342 ENUM_ITEM(AtHome, 5, "高电平指示机器人正在拖动") \
343 ENUM_ITEM(Handguiding, 6, "高电平指示机器人正在拖动") \
344 ENUM_ITEM(PowerOn, 7, "高电平指示机器人已经上电") \
345 ENUM_ITEM(RobotEmergencyStop, 8, "高电平指示机器人急停按下") \
346 ENUM_ITEM(SystemEmergencyStop, 9, "高电平指示外部输入系统急停按下") \
347 ENUM_ITEM(InternalEmergencyStop, 8, "高电平指示机器人急停按下") \
348 ENUM_ITEM(ExternalEmergencyStop, 9, "高电平指示外部输入系统急停按下") \
349 ENUM_ITEM(SystemError, 10, "系统错误,包括故障、超限、急停、安全停止、防护停止 ") \
350 ENUM_ITEM(NotSystemError, 11, "无系统错误,包括普通模式、缩减模式和恢复模式 ") \
351 ENUM_ITEM(RobotOperable, 12, "机器人可操作,机器人上电且松刹车了 ")
352
353#define ENUM_SafetyInputAction_DECLARES \
354 ENUM_ITEM(Unassigned, 0, "安全输入未分配动作") \
355 ENUM_ITEM(EmergencyStop, 1, "安全输入触发急停") \
356 ENUM_ITEM(SafeguardStop, 2, "安全输入触发防护停止, 边沿触发") \
357 ENUM_ITEM(SafeguardReset, 3, "安全输入触发防护重置, 边沿触发") \
358 ENUM_ITEM(ThreePositionSwitch, 4, "3档位使能开关") \
359 ENUM_ITEM(OperationalMode, 5, "切换自动模式和手动模式") \
360 ENUM_ITEM(HandGuide, 6, "拖动示教") \
361 ENUM_ITEM(ReducedMode, 7, "安全参数切换1(缩减模式),序号越低优先级越高,三路输出都无效时,选用第0组安全参数") \
362 ENUM_ITEM(AutomaticModeSafeguardStop, 8, "自动模式下防护停机输入(需要配置三档位使能设备)") \
363 ENUM_ITEM(AutomaticModeSafeguardReset, 9, "自动模式下上升沿触发防护重置(需要配置三档位使能设备)")
364
365#define ENUM_SafetyOutputRunState_DECLARES \
366 ENUM_ITEM(Unassigned, 0, "安全输出未定义") \
367 ENUM_ITEM(SystemEmergencyStop, 1, "输出高当有机器人急停输入或者急停按键被按下") \
368 ENUM_ITEM(NotSystemEmergencyStop, 2, "输出低当有机器人急停输入或者急停按键被按下") \
369 ENUM_ITEM(RobotMoving, 3, "输出高当有关节运动速度超过 0.1rad/s") \
370 ENUM_ITEM(RobotNotMoving, 4, "输出高当所有的关节运动速度不超过 0.1rad/s") \
371 ENUM_ITEM(ReducedMode, 5, "输出高当机器人处于缩减模式") \
372 ENUM_ITEM(NotReducedMode, 6, "输出高当机器人不处于缩减模式") \
373 ENUM_ITEM(SafeHome, 7, "输出高当机器人已经处于安全Home位姿") \
374 ENUM_ITEM(RobotNotStopping, 8, "输出低当机器人正在急停或者安全停止中")
375
376#define ENUM_PayloadIdentifyMoveAxis_DECLARES \
377 ENUM_ITEM(Joint_2_6, 0,"第2和6关节运动") \
378 ENUM_ITEM(Joint_3_6, 1,"第3和6关节运动") \
379 ENUM_ITEM(Joint_4_6, 2,"第4和6关节运动") \
380 ENUM_ITEM(Joint_4_5_6, 3,"第4、5、6关节运动") \
381
382#define ENUM_EnvelopingShape_DECLARES \
383 ENUM_ITEM(Cube, 1,"立方体") \
384 ENUM_ITEM(Column, 2,"柱状体") \
385 ENUM_ITEM(Stl, 3,"以STL文件的形式描述负载碰撞集合体")
386
387#define ENUM_TaskFrameType_DECLARES \
388 ENUM_ITEM(NONE, 0,"") \
389 ENUM_ITEM(POINT_FORCE, 1, "力控坐标系发生变换, 使得力控参考坐标系的y轴沿着机器人TCP指向力控所选特征的原点, x和z轴取决于所选特征的原始方向" \
390 "力控坐标系发生变换, 使得力控参考坐标系的y轴沿着机器人TCP指向力控所选特征的原点, x和z轴取决于所选特征的原始方向" \
391 "机器人TCP与所选特征的起点之间的距离至少为10mm" \
392 "优先选择X轴, 为所选特征的X轴在力控坐标系Y轴垂直平面上的投影, 如果所选特征的X轴与力控坐标系的Y轴平行, " \
393 "通过类似方法确定力控坐标系Z轴, Y-X或者Y-Z轴确定之后, 通过右手法则确定剩下的轴") \
394 ENUM_ITEM(FRAME_FORCE, 2,"力控坐标系不发生变换 SIMPLE_FORC") \
395 ENUM_ITEM(MOTION_FORCE, 3,"力控坐标系发生变换, 使得力控参考坐标系的x轴为机器人TCP速度在所选特征x-y平面上的投影y轴将垂直于机械臂运动, 并在所选特征的x-y平面内")\
396 ENUM_ITEM(TOOL_FORCE, 4,"以工具末端坐标系作为力控参考坐标系")
397
398#ifdef ERROR
399#undef ERROR
400#endif
401
402#define ENUM_TraceLevel_DECLARES \
403 ENUM_ITEM(FATAL, 0, "") \
404 ENUM_ITEM(ERROR, 1, "") \
405 ENUM_ITEM(WARNING, 2, "") \
406 ENUM_ITEM(INFO, 3, "") \
407 ENUM_ITEM(DEBUG, 4, "")
408
409#define ENUM_AxisModeType_DECLARES \
410 ENUM_ITEM(NoController, -1, "提供给示教器使用的, 如果aubo_control进程崩溃则会显示为NoController") \
411 ENUM_ITEM(Disconnected, 0, "未连接") \
412 ENUM_ITEM(PowerOff, 1, "断电") \
413 ENUM_ITEM(BrakeReleasing, 2, "刹车松开中") \
414 ENUM_ITEM(Idle, 3, "空闲") \
415 ENUM_ITEM(Running, 4, "运行中") \
416 ENUM_ITEM(Fault, 5, "错误状态")
417
418#define ENUM_SafeguedStopType_DECLARES \
419 ENUM_ITEM(None, 0, "无安全停止") \
420 ENUM_ITEM(SafeguedStopIOInput, 1, "安全停止(IO输入)") \
421 ENUM_ITEM(SafeguedStop3PE, 2, "安全停止(三态开关)") \
422 ENUM_ITEM(SafeguedStopOperational, 3, "安全停止(操作模式)")
423
424#define ENUM_ITEM(c, n, ...) c = n,
429
430enum class RuntimeState : int
431{
433};
434
435enum class RobotModeType : int
436{
438};
439
440enum class AxisModeType : int
441{
443};
444
445/**
446 * 安全状态:
447 *
448 */
449enum class SafetyModeType : int
450{
452};
453
454/**
455 * 操作模式
456 */
461
462/**
463 * 机器人控制模式
464 */
469
470/**
471 * 关节伺服模式
472 */
477
478/**
479 * 关节状态
480 */
481enum class JointStateType : int
482{
484};
485
486/**
487 * 标准输出运行状态
488 */
493
494/**
495 * @brief The StandardInputAction enum
496 */
501
506
511
516
521
526
531
536#undef ENUM_ITEM
537
538// clang-format on
539
540#define DECL_TO_STRING_FUNC(ENUM) \
541 inline std::string toString(ENUM v) \
542 { \
543 using T = ENUM; \
544 std::string name = #ENUM "."; \
545 ENUM_##ENUM##_DECLARES \
546 \
547 return #ENUM ".Unkown"; \
548 } \
549 inline std::ostream &operator<<(std::ostream &os, ENUM v) \
550 { \
551 os << toString(v); \
552 return os; \
553 }
554
555#define ENUM_ITEM(c, n, ...) \
556 if (v == T::c) { \
557 return name + #c; \
558 }
559
574
575#undef ENUM_ITEM
576
578{
579 Stopped,
580 Starting,
581 Stropping,
582 Running
583};
584
585enum class RefFrameType
586{
587 None, ///
588 Tool, ///< 工具坐标系
589 Path, ///< 轨迹坐标系
590 Base ///< 基坐标系
591};
592
593/// 圆周运动参数定义
595{
596 std::vector<double> pose_via; ///< 圆周运动途中点的位姿
597 std::vector<double> pose_to; ///< 圆周运动结束点的位姿
598 double a; ///< 加速度, 单位: m/s^2
599 double v; ///< 速度,单位: m/s
600 double blend_radius; ///< 交融半径,单位: m
601 double duration; ///< 运行时间,单位: s
602 double helix;
603 double spiral;
604 double direction;
605 int loop_times; ///< 暂不支持
606};
607
608inline std::ostream &operator<<(std::ostream &os, CircleParameters p)
609{
610 return os;
611}
612
614{
615 std::vector<double> frame; ///< 参考点,螺旋线的中心点和参考坐标系
616 int plane; ///< 参考平面选择 0-XY 1-YZ 2-ZX
617 double angle; ///< 转动的角度,如果为正数,机器人逆时针旋转
618 double spiral; ///< 正数外扩
619 double helix; ///< 正数上升
620};
621
622inline std::ostream &operator<<(std::ostream &os, SpiralParameters p)
623{
624 return os;
625}
626
628{
629 EnvelopingShape shape; // 包络体形状
630 std::vector<double>
631 ep_args; // 包络体组合,shape为None或Stl时无需对ep_args赋值;
632 // shape为Cube时ep_args有9个元素,分别为xmin,xmax,ymin,ymax,zmin,zmax,rx,ry,rz;
633 // shape为Column时ep_args有5个元素,分别为radius,height,rx,ry,rz;
634 std::string stl_path; // stl的路径(绝对路径),stl文件需为二进制文件,
635 // shape设置为Stl时,此项生效
636};
637
638inline std::ostream &operator<<(std::ostream &os, Enveloping p)
639{
640 return os;
641}
642
643/// 用于负载辨识的轨迹配置
645{
646 std::vector<Enveloping> envelopings; // 包络体组合
647 PayloadIdentifyMoveAxis move_axis; // 运动的轴(ID), 下标从0开始
648 std::vector<double> init_joint; // 关节初始位置
649 std::vector<double> upper_joint_bound; // 运动轴上限
650 std::vector<double> lower_joint_bound; // 运动轴下限
651 std::vector<double> max_velocity; // 关节运动的最大速度,默认值为 3.0
652 std::vector<double> max_acceleration; // 关节运动的最大加速度,默认值为 5.0
653};
654
655inline std::ostream &operator<<(std::ostream &os, TrajConfig p)
656{
657 return os;
658}
659
660// result with error code
661using ResultWithErrno = std::tuple<std::vector<double>, int>;
662using ResultWithErrno1 = std::tuple<std::vector<std::vector<double>>, int>;
663
664// mass, cog, aom, inertia
665using Payload = std::tuple<double, std::vector<double>, std::vector<double>,
666 std::vector<double>>;
667
668// force_offset, com, mass, angle
670 std::tuple<std::vector<double>, std::vector<double>, double,
671 std::vector<double>>;
672
673// force_offset, com, mass, angle error
675 std::tuple<std::vector<double>, std::vector<double>, double,
676 std::vector<double>, double>;
677
678// 动力学模型m,d,k
680 std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>;
681
682// double xmin;
683// double xmax;
684// double ymin;
685// double ymax;
686// double zmin;
687// double zmax;
688using Box = std::vector<double>;
689
690// double xcbottom;
691// double ycbottom;
692// double zcbottom;
693// double height;
694// double radius;
695using Cylinder = std::vector<double>;
696
697// double xc;
698// double yc;
699// double radius;
700using Sphere = std::vector<double>;
701
703{
704 uint64_t timestamp; ///< 时间戳,即系统时间
705 TraceLevel level; ///< 日志等级
706 int code; ///< 错误码
707 std::string source; ///< 发送消息的机器人别名 alias
708 ///< 可在 /root/arcs_ws/config/aubo_control.conf
709 ///< 配置文件中查到机器人的alias
710 std::vector<std::string> args; ///< 机器人参数
711};
712using RobotMsgVector = std::vector<RobotMsg>;
713
714/// RTDE菜单
716{
717 bool to_server; ///< 输入/输出
718 int chanel; ///< 通道
719 double frequency; ///< 更新频率
720 int trigger; ///< 触发方式(该功能暂未实现): 0 - 周期; 1 - 变化
721 std::vector<std::string> segments; ///< 字段列表
722};
723
724/// 异常类型
726{
727 parse_error = -32700, ///< 解析错误
728 invalid_request = -32600, ///< 无效请求
729 method_not_found = -32601, ///< 方法未找到
730 invalid_params = -32602, ///< 无效参数
731 internal_error = -32603, ///< 内部错误
732 server_error, ///< 服务器错误
733 invalid ///< 无效
735
736/// 异常码
738{
739 EC_DISCONNECTED = -1, ///< 断开连接
740 EC_NOT_LOGINED = -2, ///< 未登录
741 EC_INVAL_SOCKET = -3, ///< 无效套接字
742 EC_REQUEST_BUSY = -4, ///< 请求繁忙
743 EC_SEND_FAILED = -5, ///< 发送失败
744 EC_RECV_TIMEOUT = -6, ///< 接收超时
745 EC_RECV_ERROR = -7, ///< 接收错误
746 EC_PARSE_ERROR = -8, ///< 解析错误
747 EC_INVALID_REQUEST = -9, ///< 无效请求
748 EC_METHOD_NOT_FOUND = -10, ///< 方法未找到
749 EC_INVALID_PARAMS = -11, ///< 无效参数
750 EC_INTERNAL_ERROR = -12, ///< 内部错误
751 EC_SERVER_ERROR = -13, ///< 服务器错误
752 EC_INVALID = -14 ///< 无效
754
755/// 自定义异常类 AuboException
756class AuboException : public std::exception
757{
758public:
759 AuboException(int code, const std::string &prefix,
760 const std::string &message) noexcept
761 : code_(code), message_(prefix + "-" + message)
762 {
763 }
764
765 AuboException(int code, const std::string &message) noexcept
766 : code_(code), message_(message)
767 {
768 }
769
771 {
772 if (code_ >= -32603 && code_ <= -32600) {
773 return static_cast<error_type>(code_);
774 } else if (code_ >= -32099 && code_ <= -32000) {
775 return server_error;
776 } else if (code_ == -32700) {
777 return parse_error;
778 }
779 return invalid;
780 }
781
782 int code() const { return code_; }
783 const char *what() const noexcept override { return message_.c_str(); }
784
785private:
786 int code_; ///< 异常码
787 std::string message_; ///< 异常消息
788};
789
790inline const char *returnValue2Str(int retval)
791{
792 static const char *retval_str[] = {
793#define ENUM_ITEM(n, v, s) s,
795#undef ENUM_ITEM
796 };
797
798 enum arcs_index
799 {
800#define ENUM_ITEM(n, v, s) n##_INDEX,
802#undef ENUM_ITEM
803 };
804
805 int index = -1;
806
807#define ENUM_ITEM(n, v, s) \
808 if (retval == v) \
809 index = n##_INDEX;
811#undef ENUM_ITEM
812
813 if (index == -1)
814 {
815 index = AUBO_ERR_UNKOWN;
816 }
817
818 return retval_str[(unsigned)index];
819}
820
821} // namespace common_interface
822} // namespace arcs
823#endif
824
825#if defined ENABLE_JSON_TYPES
826#include "bindings/jsonrpc/json_types.h"
827#endif
自定义异常类 AuboException
Definition type_def.h:757
AuboException(int code, const std::string &prefix, const std::string &message) noexcept
Definition type_def.h:759
std::string message_
异常消息
Definition type_def.h:787
const char * what() const noexcept override
Definition type_def.h:783
AuboException(int code, const std::string &message) noexcept
Definition type_def.h:765
std::tuple< std::vector< double >, std::vector< double >, double, std::vector< double > > ForceSensorCalibResult
Definition type_def.h:671
std::ostream & operator<<(std::ostream &os, const RobotSafetyParameterRange &vd)
Definition type_def.h:175
std::tuple< std::vector< std::vector< double > >, int > ResultWithErrno1
Definition type_def.h:662
std::array< float, 3 > Vector3f
Definition type_def.h:31
JointServoModeType
关节伺服模式
Definition type_def.h:474
std::array< double, 3 > Vector3d
Definition type_def.h:29
std::tuple< std::vector< double >, std::vector< double >, double, std::vector< double >, double > ForceSensorCalibResultWithError
Definition type_def.h:676
RobotControlModeType
机器人控制模式
Definition type_def.h:466
std::tuple< std::vector< double >, std::vector< double >, std::vector< double > > DynamicsModel
Definition type_def.h:680
error_type
异常类型
Definition type_def.h:726
@ parse_error
解析错误
Definition type_def.h:727
@ method_not_found
方法未找到
Definition type_def.h:729
@ invalid_params
无效参数
Definition type_def.h:730
@ invalid_request
无效请求
Definition type_def.h:728
@ internal_error
内部错误
Definition type_def.h:731
@ server_error
服务器错误
Definition type_def.h:732
std::array< float, 6 > Vector6f
Definition type_def.h:33
StandardInputAction
The StandardInputAction enum
Definition type_def.h:498
std::vector< double > Box
Definition type_def.h:688
std::vector< double > Sphere
Definition type_def.h:700
StandardOutputRunState
标准输出运行状态
Definition type_def.h:490
std::tuple< double, std::vector< double >, std::vector< double >, std::vector< double > > Payload
Definition type_def.h:666
JointStateType
关节状态
Definition type_def.h:482
const char * returnValue2Str(int retval)
Definition type_def.h:790
@ EC_INVALID_REQUEST
无效请求
Definition type_def.h:747
@ EC_DISCONNECTED
断开连接
Definition type_def.h:739
@ EC_PARSE_ERROR
解析错误
Definition type_def.h:746
@ EC_SERVER_ERROR
服务器错误
Definition type_def.h:751
@ EC_SEND_FAILED
发送失败
Definition type_def.h:743
@ EC_INTERNAL_ERROR
内部错误
Definition type_def.h:750
@ EC_NOT_LOGINED
未登录
Definition type_def.h:740
@ EC_INVAL_SOCKET
无效套接字
Definition type_def.h:741
@ EC_RECV_ERROR
接收错误
Definition type_def.h:745
@ EC_RECV_TIMEOUT
接收超时
Definition type_def.h:744
@ EC_METHOD_NOT_FOUND
方法未找到
Definition type_def.h:748
@ EC_INVALID_PARAMS
无效参数
Definition type_def.h:749
@ EC_REQUEST_BUSY
请求繁忙
Definition type_def.h:742
std::array< float, 4 > Vector4f
Definition type_def.h:32
OperationalModeType
操作模式
Definition type_def.h:458
SafetyModeType
安全状态:
Definition type_def.h:450
std::array< double, 4 > Vector4d
Definition type_def.h:30
@ ENUM_PayloadIdentifyMoveAxis_DECLARES
Definition type_def.h:524
std::tuple< std::vector< double >, int > ResultWithErrno
Definition type_def.h:661
std::vector< RobotMsg > RobotMsgVector
Definition type_def.h:712
std::vector< double > Cylinder
Definition type_def.h:695
double duration
运行时间,单位: s
Definition type_def.h:601
double blend_radius
交融半径,单位: m
Definition type_def.h:600
std::vector< double > pose_via
圆周运动途中点的位姿
Definition type_def.h:596
double v
速度,单位: m/s
Definition type_def.h:599
std::vector< double > pose_to
圆周运动结束点的位姿
Definition type_def.h:597
double a
加速度, 单位: m/s^2
Definition type_def.h:598
std::vector< double > ep_args
Definition type_def.h:631
TraceLevel level
日志等级
Definition type_def.h:705
std::string source
发送消息的机器人别名 alias 可在 /root/arcs_ws/config/aubo_control.conf 配置文件中查到机器人的alias
Definition type_def.h:707
uint64_t timestamp
时间戳,即系统时间
Definition type_def.h:704
std::vector< std::string > args
机器人参数
Definition type_def.h:710
struct arcs::common_interface::RobotSafetyParameterRange::@1 trigger_planes[SAFETY_PLANES_NUM]
8个触发平面
struct arcs::common_interface::RobotSafetyParameterRange::@0 params[SAFETY_PARAM_SELECT_NUM]
最多可以保存2套参数, 默认使用第 0 套参数
float power
sum of joint torques times joint angular speeds
Definition type_def.h:108
int allow_manual_high_speed
手动模式下允许高速运行
Definition type_def.h:172
int tp_3pe_for_handguide
是否将示教器三档位开关作为拖动功能开关
Definition type_def.h:171
Vector6f orig
立方块的原点 (x,y,z,rx,ry,rz)
Definition type_def.h:138
struct arcs::common_interface::RobotSafetyParameterRange::@2 cubic[SAFETY_CUBIC_NUM]
10个安全空间
Vector3f size
立方块的尺寸 (x,y,z)
Definition type_def.h:139
Vector4f tools[TOOL_CONFIGURATION_NUM]
3个工具
Definition type_def.h:144
uint32_t safety_input_emergency_stop
可配置IO的输入输出安全功能配置
Definition type_def.h:151
int restrict_elbow[SAFETY_PLANES_NUM]
x,y,z,displacement
Definition type_def.h:126
float reduced_entry_time
进入缩减模式的最大时间
Definition type_def.h:112
float reduced_entry_distance
进入缩减模式的最大距离(可由安全平面触发)
Definition type_def.h:114
int trigger
触发方式(该功能暂未实现): 0 - 周期; 1 - 变化
Definition type_def.h:720
std::vector< std::string > segments
字段列表
Definition type_def.h:721
double angle
转动的角度,如果为正数,机器人逆时针旋转
Definition type_def.h:617
int plane
参考平面选择 0-XY 1-YZ 2-ZX
Definition type_def.h:616
std::vector< double > frame
参考点,螺旋线的中心点和参考坐标系
Definition type_def.h:615
用于负载辨识的轨迹配置
Definition type_def.h:645
std::vector< double > upper_joint_bound
Definition type_def.h:649
std::vector< double > max_acceleration
Definition type_def.h:652
std::vector< double > lower_joint_bound
Definition type_def.h:650
std::vector< Enveloping > envelopings
Definition type_def.h:646
std::vector< double > init_joint
Definition type_def.h:648
PayloadIdentifyMoveAxis move_axis
Definition type_def.h:647
std::vector< double > max_velocity
Definition type_def.h:651
#define TOOL_CONFIGURATION_NUM
Definition type_def.h:27
#define SAFETY_PLANES_NUM
Definition type_def.h:25
#define DECL_TO_STRING_FUNC(ENUM)
Definition type_def.h:540
#define SAFETY_PARAM_SELECT_NUM
Definition type_def.h:24
#define SAFETY_CUBIC_NUM
Definition type_def.h:26