ARCS SDK API  0.24.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 
19 namespace arcs {
20 namespace 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 
29 using Vector3d = std::array<double, 3>;
30 using Vector4d = std::array<double, 4>;
31 using Vector3f = std::array<float, 3>;
32 using Vector4f = std::array<float, 4>;
33 using 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 
75  tool_inclination = 0.;
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; ///< 进入缩减模式的最大距离(可由安全平面触发)
115  float tcp_speed;
116  float elbow_speed;
117  float tcp_force;
118  float elbow_force;
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 
175 inline std::ostream &operator<<(std::ostream &os,
176  const RobotSafetyParameterRange &vd)
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_ERR_UNKOWN, 99999, "Unkown error occurred.")
226 
227 // clang-format off
228 /**
229  * The RuntimeState enum
230  *
231  */
232 #define ENUM_RuntimeState_DECLARES \
233  ENUM_ITEM(Running, 0, "正在运行中") \
234  ENUM_ITEM(Retracting, 1, "倒退") \
235  ENUM_ITEM(Pausing, 2, "暂停中") \
236  ENUM_ITEM(Paused, 3, "暂停状态") \
237  ENUM_ITEM(Stepping, 4, "单步执行中") \
238  ENUM_ITEM(Stopping, 5, "受控停止中(保持原有轨迹)") \
239  ENUM_ITEM(Stopped, 6, "已停止") \
240  ENUM_ITEM(Aborting, 7, "停止(最大速度关节运动停机)")
241 
242 /**
243  * @brief The RobotModeType enum
244  *
245  * 硬件强相关
246  */
247 #define ENUM_RobotModeType_DECLARES \
248  ENUM_ITEM(NoController, -1, "提供给示教器使用的, 如果aubo_control进程崩溃则会显示为NoController") \
249  ENUM_ITEM(Disconnected, 0, "没有连接到机械臂本体(控制器与接口板断开连接或是 EtherCAT 等总线断开)") \
250  ENUM_ITEM(ConfirmSafety, 1, "正在进行安全配置, 断电状态下进行") \
251  ENUM_ITEM(Booting, 2, "机械臂本体正在上电初始化") \
252  ENUM_ITEM(PowerOff, 3, "机械臂本体处于断电状态") \
253  ENUM_ITEM(PowerOn, 4, "机械臂本体上电成功, 刹车暂未松开(抱死), 关节初始状态未获取") \
254  ENUM_ITEM(Idle, 5, "机械臂上电成功, 刹车暂未松开(抱死), 电机不通电, 关节初始状态获取完成") \
255  ENUM_ITEM(BrakeReleasing, 6, "机械臂上电成功, 刹车正在松开") \
256  ENUM_ITEM(BackDrive, 7, "反向驱动:刹车松开, 电机不通电") \
257  ENUM_ITEM(Running, 8, "机械臂刹车松开, 运行模式, 控制权由硬件移交给软件") \
258  ENUM_ITEM(Maintaince, 9, "维护模式: 包括固件升级、参数写入等") \
259  ENUM_ITEM(Error, 10, "") \
260  ENUM_ITEM(PowerOffing, 11, "机械臂本体处于断电过程中")
261 
262 #define ENUM_SafetyModeType_DECLARES \
263  ENUM_ITEM(Undefined, 0, "安全状态待定") \
264  ENUM_ITEM(Normal, 1, "正常运行模式") \
265  ENUM_ITEM(ReducedMode, 2, "缩减运行模式") \
266  ENUM_ITEM(Recovery, 3, "启动时如果在安全限制之外, 机器人将进入recovery模式") \
267  ENUM_ITEM(Violation, 4, "超出安全限制(根据安全配置, 例如速度超限等)") \
268  ENUM_ITEM(ProtectiveStop, 5, "软件触发的停机(保持轨迹, 不抱闸, 不断电)") \
269  ENUM_ITEM(SafeguardStop, 6, "IO触发的防护停机(不保持轨迹, 抱闸, 不断电)") \
270  ENUM_ITEM(SystemEmergencyStop,7, "系统急停:急停信号由外部输入(可配置输入), 不对外输出急停信号") \
271  ENUM_ITEM(RobotEmergencyStop, 8, "机器人急停:控制柜急停输入或者示教器急停按键触发, 对外输出急停信号") \
272  ENUM_ITEM(Fault, 9, "机械臂硬件故障或者系统故障")
273  //ValidateJointId
274 
275 /**
276  * 根据ISO 10218-1:2011(E) 5.7节
277  * Automatic: In automatic mode, the robot shall execute the task programme and
278  * the safeguarding measures shall be functioning. Automatic operation shall be
279  * prevented if any stop condition is detected. Switching from this mode shall
280  * result in a stop.
281  */
282 #define ENUM_OperationalModeType_DECLARES \
283  ENUM_ITEM(Disabled, 0, "禁用模式: 不使用Operational Mode") \
284  ENUM_ITEM(Automatic, 1, "自动模式: 机器人正常工作模式, 运行速度不会被限制") \
285  ENUM_ITEM(Manual, 2, "手动模式: 机器人编程示教模式(T1), 机器人运行速度将会被限制或者机器人程序校验模式(T2)")
286 
287 /**
288  * 机器人的控制模式, 最终的控制对象
289  */
290 #define ENUM_RobotControlModeType_DECLARES \
291  ENUM_ITEM(Unknown, 0, "未知的控制模式") \
292  ENUM_ITEM(Position, 1, "位置控制 movej") \
293  ENUM_ITEM(Speed, 2, "速度控制 speedj/speedl") \
294  ENUM_ITEM(Servo, 3, "位置控制 servoj") \
295  ENUM_ITEM(Freedrive, 4, "拖动示教 freedrive_mode") \
296  ENUM_ITEM(Force, 5, "末端力控 force_mode") \
297  ENUM_ITEM(Torque, 6, "关节力矩控制") \
298  ENUM_ITEM(Collision, 7, "碰撞模式")
299 
300 #define ENUM_JointServoModeType_DECLARES \
301  ENUM_ITEM(Unknown, -1, "未知") \
302  ENUM_ITEM(Open, 0, "开环模式") \
303  ENUM_ITEM(Current, 1, "电流伺服模式") \
304  ENUM_ITEM(Velocity, 2, "速度伺服模式") \
305  ENUM_ITEM(Position, 3, "位置伺服模式") \
306  ENUM_ITEM(Torque, 4, "力矩伺服模式")
307 
308 #define ENUM_JointStateType_DECLARES \
309  ENUM_ITEM(Poweroff, 0, "节点未连接到接口板或者已经断电") \
310  ENUM_ITEM(Idle, 2, "节点空闲") \
311  ENUM_ITEM(Fault, 3, "节点错误, 节点停止伺服运动, 刹车抱死") \
312  ENUM_ITEM(Running, 4, "节点伺服") \
313  ENUM_ITEM(Bootload, 5, "节点bootloader状态, 暂停一切通讯")
314 
315 #define ENUM_StandardInputAction_DECLARES \
316  ENUM_ITEM(Default, 0, "无触发") \
317  ENUM_ITEM(Handguide, 1, "拖动示教,高电平触发") \
318  ENUM_ITEM(GoHome, 2, "运动到工程初始位姿,高电平触发") \
319  ENUM_ITEM(StartProgram, 3, "开始工程,上升沿触发") \
320  ENUM_ITEM(StopProgram, 4, "停止工程,上升沿触发") \
321  ENUM_ITEM(PauseProgram, 5, "暂停工程,上升沿触发") \
322  ENUM_ITEM(PopupDismiss, 6, "消除弹窗,上升沿触发") \
323  ENUM_ITEM(PowerOn, 7, "机器人上电/松刹车,上升沿触发") \
324  ENUM_ITEM(PowerOff, 8, "机器人抱死刹车/断电,上升沿触发") \
325  ENUM_ITEM(ResumeProgram, 9, "恢复工程,上升沿触发") \
326  ENUM_ITEM(SlowDown1, 10, "机器人减速触发1,高电平触发") \
327  ENUM_ITEM(SlowDown2, 11, "机器人减速触发2,高电平触发") \
328  ENUM_ITEM(SafeStop, 12, "安全停止,高电平触发") \
329  ENUM_ITEM(RunningGuard, 13, "信号,高电平有效") \
330  ENUM_ITEM(MoveToFirstPoint, 14, "运动到工程初始位姿,高电平触发") \
331  ENUM_ITEM(xSlowDown1, 15, "机器人减速触发1,低电平触发") \
332  ENUM_ITEM(xSlowDown2, 16, "机器人减速触发2,低电平触发")
333 
334 #define ENUM_StandardOutputRunState_DECLARES \
335  ENUM_ITEM(None, 0, "标准输出状态未定义") \
336  ENUM_ITEM(StopLow, 1, "低电平指示工程停止") \
337  ENUM_ITEM(StopHigh, 2, "高电平指示机器人停止") \
338  ENUM_ITEM(RunningHigh, 3, "指示工程正在运行") \
339  ENUM_ITEM(PausedHigh, 4, "指示工程已经暂停") \
340  ENUM_ITEM(AtHome, 5, "高电平指示机器人正在拖动") \
341  ENUM_ITEM(Handguiding, 6, "高电平指示机器人正在拖动") \
342  ENUM_ITEM(PowerOn, 7, "高电平指示机器人已经上电") \
343  ENUM_ITEM(RobotEmergencyStop, 8, "高电平指示机器人急停按下") \
344  ENUM_ITEM(SystemEmergencyStop, 9, "高电平指示外部输入系统急停按下") \
345  ENUM_ITEM(InternalEmergencyStop, 8, "高电平指示机器人急停按下") \
346  ENUM_ITEM(ExternalEmergencyStop, 9, "高电平指示外部输入系统急停按下") \
347  ENUM_ITEM(SystemError, 10, "系统错误,包括故障、超限、急停、安全停止、防护停止 ") \
348  ENUM_ITEM(NotSystemError, 11, "无系统错误,包括普通模式、缩减模式和恢复模式 ") \
349  ENUM_ITEM(RobotOperable, 12, "机器人可操作,机器人上电且松刹车了 ")
350 
351 #define ENUM_SafetyInputAction_DECLARES \
352  ENUM_ITEM(Unassigned, 0, "安全输入未分配动作") \
353  ENUM_ITEM(EmergencyStop, 1, "安全输入触发急停") \
354  ENUM_ITEM(SafeguardStop, 2, "安全输入触发防护停止, 边沿触发") \
355  ENUM_ITEM(SafeguardReset, 3, "安全输入触发防护重置, 边沿触发") \
356  ENUM_ITEM(ThreePositionSwitch, 4, "3档位使能开关") \
357  ENUM_ITEM(OperationalMode, 5, "切换自动模式和手动模式") \
358  ENUM_ITEM(HandGuide, 6, "拖动示教") \
359  ENUM_ITEM(ReducedMode, 7, "安全参数切换1(缩减模式),序号越低优先级越高,三路输出都无效时,选用第0组安全参数") \
360  ENUM_ITEM(AutomaticModeSafeguardStop, 8, "自动模式下防护停机输入(需要配置三档位使能设备)") \
361  ENUM_ITEM(AutomaticModeSafeguardReset, 9, "自动模式下上升沿触发防护重置(需要配置三档位使能设备)")
362 
363 #define ENUM_SafetyOutputRunState_DECLARES \
364  ENUM_ITEM(Unassigned, 0, "安全输出未定义") \
365  ENUM_ITEM(SystemEmergencyStop, 1, "输出高当有机器人急停输入或者急停按键被按下") \
366  ENUM_ITEM(NotSystemEmergencyStop, 2, "输出低当有机器人急停输入或者急停按键被按下") \
367  ENUM_ITEM(RobotMoving, 3, "输出高当有关节运动速度超过 0.1rad/s") \
368  ENUM_ITEM(RobotNotMoving, 4, "输出高当所有的关节运动速度不超过 0.1rad/s") \
369  ENUM_ITEM(ReducedMode, 5, "输出高当机器人处于缩减模式") \
370  ENUM_ITEM(NotReducedMode, 6, "输出高当机器人不处于缩减模式") \
371  ENUM_ITEM(SafeHome, 7, "输出高当机器人已经处于安全Home位姿") \
372  ENUM_ITEM(RobotNotStopping, 8, "输出低当机器人正在急停或者安全停止中")
373 
374 #define ENUM_PayloadIdentifyMoveAxis_DECLARES \
375  ENUM_ITEM(Joint_2_6, 0,"第2和6关节运动") \
376  ENUM_ITEM(Joint_3_6, 1,"第3和6关节运动") \
377  ENUM_ITEM(Joint_4_6, 2,"第4和6关节运动") \
378  ENUM_ITEM(Joint_4_5_6, 3,"第4、5、6关节运动") \
379 
380 #define ENUM_EnvelopingShape_DECLARES \
381  ENUM_ITEM(Cube, 1,"立方体") \
382  ENUM_ITEM(Column, 2,"柱状体") \
383  ENUM_ITEM(Stl, 3,"以STL文件的形式描述负载碰撞集合体")
384 
385 #define ENUM_TaskFrameType_DECLARES \
386  ENUM_ITEM(NONE, 0,"") \
387  ENUM_ITEM(POINT_FORCE, 1, "力控坐标系发生变换, 使得力控参考坐标系的y轴沿着机器人TCP指向力控所选特征的原点, x和z轴取决于所选特征的原始方向" \
388  "力控坐标系发生变换, 使得力控参考坐标系的y轴沿着机器人TCP指向力控所选特征的原点, x和z轴取决于所选特征的原始方向" \
389  "机器人TCP与所选特征的起点之间的距离至少为10mm" \
390  "优先选择X轴, 为所选特征的X轴在力控坐标系Y轴垂直平面上的投影, 如果所选特征的X轴与力控坐标系的Y轴平行, " \
391  "通过类似方法确定力控坐标系Z轴, Y-X或者Y-Z轴确定之后, 通过右手法则确定剩下的轴") \
392  ENUM_ITEM(FRAME_FORCE, 2,"力控坐标系不发生变换 SIMPLE_FORC") \
393  ENUM_ITEM(MOTION_FORCE, 3,"力控坐标系发生变换, 使得力控参考坐标系的x轴为机器人TCP速度在所选特征x-y平面上的投影y轴将垂直于机械臂运动, 并在所选特征的x-y平面内")\
394  ENUM_ITEM(TOOL_FORCE, 4,"以工具末端坐标系作为力控参考坐标系")
395 
396 #ifdef ERROR
397 #undef ERROR
398 #endif
399 
400 #define ENUM_TraceLevel_DECLARES \
401  ENUM_ITEM(FATAL, 0, "") \
402  ENUM_ITEM(ERROR, 1, "") \
403  ENUM_ITEM(WARNING, 2, "") \
404  ENUM_ITEM(INFO, 3, "") \
405  ENUM_ITEM(DEBUG, 4, "")
406 
407 #define ENUM_AxisModeType_DECLARES \
408  ENUM_ITEM(NoController, -1, "提供给示教器使用的, 如果aubo_control进程崩溃则会显示为NoController") \
409  ENUM_ITEM(Disconnected, 0, "未连接") \
410  ENUM_ITEM(PowerOff, 1, "断电") \
411  ENUM_ITEM(BrakeReleasing, 2, "刹车松开中") \
412  ENUM_ITEM(Idle, 3, "空闲") \
413  ENUM_ITEM(Running, 4, "运行中") \
414  ENUM_ITEM(Fault, 5, "错误状态")
415 
416 #define ENUM_SafeguedStopType_DECLARES \
417  ENUM_ITEM(None, 0, "无安全停止") \
418  ENUM_ITEM(SafeguedStopIOInput, 1, "安全停止(IO输入)") \
419  ENUM_ITEM(SafeguedStop3PE, 2, "安全停止(三态开关)") \
420  ENUM_ITEM(SafeguedStopOperational, 3, "安全停止(操作模式)")
421 
422 #define ENUM_ITEM(c, n, ...) c = n,
423 enum AuboErrorCodes : int
424 {
426 };
427 
428 enum class RuntimeState : int
429 {
431 };
432 
433 enum class RobotModeType : int
434 {
436 };
437 
438 enum class AxisModeType : int
439 {
441 };
442 
443 /**
444  * 安全状态:
445  *
446  */
447 enum class SafetyModeType : int
448 {
450 };
451 
452 /**
453  * 操作模式
454  */
455 enum class OperationalModeType : int
456 {
458 };
459 
460 /**
461  * 机器人控制模式
462  */
463 enum class RobotControlModeType : int
464 {
466 };
467 
468 /**
469  * 关节伺服模式
470  */
471 enum class JointServoModeType : int
472 {
474 };
475 
476 /**
477  * 关节状态
478  */
479 enum class JointStateType : int
480 {
482 };
483 
484 /**
485  * 标准输出运行状态
486  */
487 enum class StandardOutputRunState : int
488 {
490 };
491 
492 /**
493  * @brief The StandardInputAction enum
494  */
495 enum class StandardInputAction : int
496 {
498 };
499 
500 enum class SafetyInputAction : int
501 {
503 };
504 
505 enum class SafetyOutputRunState : int
506 {
508 };
509 
511 {
513 };
514 
515 enum EnvelopingShape : int
516 {
518 };
519 
521 {
523 };
524 
526 {
528 };
529 
531 {
533 };
534 #undef ENUM_ITEM
535 
536 // clang-format on
537 
538 #define DECL_TO_STRING_FUNC(ENUM) \
539  inline std::string toString(ENUM v) \
540  { \
541  using T = ENUM; \
542  std::string name = #ENUM "."; \
543  ENUM_##ENUM##_DECLARES \
544  \
545  return #ENUM ".Unkown"; \
546  } \
547  inline std::ostream &operator<<(std::ostream &os, ENUM v) \
548  { \
549  os << toString(v); \
550  return os; \
551  }
552 
553 #define ENUM_ITEM(c, n, ...) \
554  if (v == T::c) { \
555  return name + #c; \
556  }
557 
572 
573 #undef ENUM_ITEM
574 
576 {
577  Stopped,
578  Starting,
579  Stropping,
580  Running
581 };
582 
583 enum class RefFrameType
584 {
585  None, ///
586  Tool, ///< 工具坐标系
587  Path, ///< 轨迹坐标系
588  Base ///< 基坐标系
589 };
590 
591 /// 圆周运动参数定义
593 {
594  std::vector<double> pose_via; ///< 圆周运动途中点的位姿
595  std::vector<double> pose_to; ///< 圆周运动结束点的位姿
596  double a; ///< 加速度, 单位: m/s^2
597  double v; ///< 速度,单位: m/s
598  double blend_radius; ///< 交融半径,单位: m
599  double duration; ///< 运行时间,单位: s
600  double helix;
601  double spiral;
602  double direction;
603  int loop_times; ///< 暂不支持
604 };
605 
606 inline std::ostream &operator<<(std::ostream &os, CircleParameters p)
607 {
608  return os;
609 }
610 
612 {
613  std::vector<double> frame; ///< 参考点,螺旋线的中心点和参考坐标系
614  int plane; ///< 参考平面选择 0-XY 1-YZ 2-ZX
615  double angle; ///< 转动的角度,如果为正数,机器人逆时针旋转
616  double spiral; ///< 正数外扩
617  double helix; ///< 正数上升
618 };
619 
620 inline std::ostream &operator<<(std::ostream &os, SpiralParameters p)
621 {
622  return os;
623 }
624 
626 {
627  EnvelopingShape shape; // 包络体形状
628  std::vector<double>
629  ep_args; // 包络体组合,shape为None或Stl时无需对ep_args赋值;
630  // shape为Cube时ep_args有9个元素,分别为xmin,xmax,ymin,ymax,zmin,zmax,rx,ry,rz;
631  // shape为Column时ep_args有5个元素,分别为radius,height,rx,ry,rz;
632  std::string stl_path; // stl的路径(绝对路径),stl文件需为二进制文件,
633  // shape设置为Stl时,此项生效
634 };
635 
636 inline std::ostream &operator<<(std::ostream &os, Enveloping p)
637 {
638  return os;
639 }
640 
641 /// 用于负载辨识的轨迹配置
643 {
644  std::vector<Enveloping> envelopings; // 包络体组合
645  PayloadIdentifyMoveAxis move_axis; // 运动的轴(ID), 下标从0开始
646  std::vector<double> init_joint; // 关节初始位置
647  std::vector<double> upper_joint_bound; // 运动轴上限
648  std::vector<double> lower_joint_bound; // 运动轴下限
649  std::vector<double> max_velocity; // 关节运动的最大速度,默认值为 3.0
650  std::vector<double> max_acceleration; // 关节运动的最大加速度,默认值为 5.0
651 };
652 
653 inline std::ostream &operator<<(std::ostream &os, TrajConfig p)
654 {
655  return os;
656 }
657 
658 // result with error code
659 using ResultWithErrno = std::tuple<std::vector<double>, int>;
660 using ResultWithErrno1 = std::tuple<std::vector<std::vector<double>>, int>;
661 
662 // mass, cog, aom, inertia
663 using Payload = std::tuple<double, std::vector<double>, std::vector<double>,
664  std::vector<double>>;
665 
666 // force_offset, com, mass, angle
668  std::tuple<std::vector<double>, std::vector<double>, double,
669  std::vector<double>>;
670 
671 // force_offset, com, mass, angle error
673  std::tuple<std::vector<double>, std::vector<double>, double,
674  std::vector<double>, double>;
675 
676 // 动力学模型m,d,k
677 using DynamicsModel =
678  std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>;
679 
680 // double xmin;
681 // double xmax;
682 // double ymin;
683 // double ymax;
684 // double zmin;
685 // double zmax;
686 using Box = std::vector<double>;
687 
688 // double xcbottom;
689 // double ycbottom;
690 // double zcbottom;
691 // double height;
692 // double radius;
693 using Cylinder = std::vector<double>;
694 
695 // double xc;
696 // double yc;
697 // double radius;
698 using Sphere = std::vector<double>;
699 
700 struct RobotMsg
701 {
702  uint64_t timestamp; ///< 时间戳,即系统时间
703  TraceLevel level; ///< 日志等级
704  int code; ///< 错误码
705  std::string source; ///< 发送消息的机器人别名 alias
706  ///< 可在 /root/arcs_ws/config/aubo_control.conf
707  ///< 配置文件中查到机器人的alias
708  std::vector<std::string> args; ///< 机器人参数
709 };
710 using RobotMsgVector = std::vector<RobotMsg>;
711 
712 /// RTDE菜单
714 {
715  bool to_server; ///< 输入/输出
716  int chanel; ///< 通道
717  double frequency; ///< 更新频率
718  int trigger; ///< 触发方式(该功能暂未实现): 0 - 周期; 1 - 变化
719  std::vector<std::string> segments; ///< 字段列表
720 };
721 
722 /// 异常类型
724 {
725  parse_error = -32700, ///< 解析错误
726  invalid_request = -32600, ///< 无效请求
727  method_not_found = -32601, ///< 方法未找到
728  invalid_params = -32602, ///< 无效参数
729  internal_error = -32603, ///< 内部错误
730  server_error, ///< 服务器错误
731  invalid ///< 无效
732 };
733 
734 /// 异常码
736 {
737  EC_DISCONNECTED = -1, ///< 断开连接
738  EC_NOT_LOGINED = -2, ///< 未登录
739  EC_INVAL_SOCKET = -3, ///< 无效套接字
740  EC_REQUEST_BUSY = -4, ///< 请求繁忙
741  EC_SEND_FAILED = -5, ///< 发送失败
742  EC_RECV_TIMEOUT = -6, ///< 接收超时
743  EC_RECV_ERROR = -7, ///< 接收错误
744  EC_PARSE_ERROR = -8, ///< 解析错误
745  EC_INVALID_REQUEST = -9, ///< 无效请求
746  EC_METHOD_NOT_FOUND = -10, ///< 方法未找到
747  EC_INVALID_PARAMS = -11, ///< 无效参数
748  EC_INTERNAL_ERROR = -12, ///< 内部错误
749  EC_SERVER_ERROR = -13, ///< 服务器错误
750  EC_INVALID = -14 ///< 无效
751 };
752 
753 /// 自定义异常类 AuboException
754 class AuboException : public std::exception
755 {
756 public:
757  AuboException(int code, const std::string &prefix,
758  const std::string &message) noexcept
759  : code_(code), message_(prefix + "-" + message)
760  {
761  }
762 
763  AuboException(int code, const std::string &message) noexcept
764  : code_(code), message_(message)
765  {
766  }
767 
768  error_type type() const
769  {
770  if (code_ >= -32603 && code_ <= -32600) {
771  return static_cast<error_type>(code_);
772  } else if (code_ >= -32099 && code_ <= -32000) {
773  return server_error;
774  } else if (code_ == -32700) {
775  return parse_error;
776  }
777  return invalid;
778  }
779 
780  int code() const { return code_; }
781  const char *what() const noexcept override { return message_.c_str(); }
782 
783 private:
784  int code_; ///< 异常码
785  std::string message_; ///< 异常消息
786 };
787 
788 inline const char *returnValue2Str(int retval)
789 {
790  static const char *retval_str[] = {
791 #define ENUM_ITEM(n, v, s) s,
793 #undef ENUM_ITEM
794  };
795 
796  enum arcs_index
797  {
798 #define ENUM_ITEM(n, v, s) n##_INDEX,
800 #undef ENUM_ITEM
801  };
802 
803  int index = -1;
804 
805 #define ENUM_ITEM(n, v, s) \
806  if (retval == v) \
807  index = n##_INDEX;
809 #undef ENUM_ITEM
810 
811  if (index == -1)
812  {
813  index = AUBO_ERR_UNKOWN;
814  }
815 
816  return retval_str[(unsigned)index];
817 }
818 
819 } // namespace common_interface
820 } // namespace arcs
821 #endif
822 
823 #if defined ENABLE_JSON_TYPES
824 #include "bindings/jsonrpc/json_types.h"
825 #endif
std::tuple< std::vector< double >, int > ResultWithErrno
Definition: type_def.h:659
struct arcs::common_interface::RobotSafetyParameterRange::@1 trigger_planes[SAFETY_PLANES_NUM]
8个触发平面
std::tuple< double, std::vector< double >, std::vector< double >, std::vector< double >> Payload
Definition: type_def.h:664
std::vector< double > Box
Definition: type_def.h:686
自定义异常类 AuboException
Definition: type_def.h:754
ExceptionCode
异常码
Definition: type_def.h:735
std::array< double, 3 > Vector3d
Definition: type_def.h:29
Vector3f size
立方块的尺寸 (x,y,z)
Definition: type_def.h:139
int restrict_elbow[SAFETY_PLANES_NUM]
x,y,z,displacement
Definition: type_def.h:126
StandardOutputRunState
标准输出运行状态
Definition: type_def.h:487
std::vector< double > ep_args
Definition: type_def.h:629
std::array< float, 6 > Vector6f
Definition: type_def.h:33
#define DECL_TO_STRING_FUNC(ENUM)
Definition: type_def.h:538
double duration
运行时间,单位: s
Definition: type_def.h:599
float reduced_entry_time
进入缩减模式的最大时间
Definition: type_def.h:112
std::vector< double > max_acceleration
Definition: type_def.h:650
std::vector< Enveloping > envelopings
Definition: type_def.h:644
OperationalModeType
操作模式
Definition: type_def.h:455
std::vector< double > init_joint
Definition: type_def.h:646
std::tuple< std::vector< double >, std::vector< double >, double, std::vector< double >> ForceSensorCalibResult
Definition: type_def.h:669
float reduced_entry_distance
进入缩减模式的最大距离(可由安全平面触发)
Definition: type_def.h:114
int plane
参考平面选择 0-XY 1-YZ 2-ZX
Definition: type_def.h:614
struct arcs::common_interface::RobotSafetyParameterRange::@0 params[SAFETY_PARAM_SELECT_NUM]
最多可以保存2套参数, 默认使用第 0 套参数
std::string message_
异常消息
Definition: type_def.h:785
PayloadIdentifyMoveAxis move_axis
Definition: type_def.h:645
JointServoModeType
关节伺服模式
Definition: type_def.h:471
error_type
异常类型
Definition: type_def.h:723
AuboException(int code, const std::string &prefix, const std::string &message) noexcept
Definition: type_def.h:757
#define SAFETY_CUBIC_NUM
Definition: type_def.h:26
int tp_3pe_for_handguide
是否将示教器三档位开关作为拖动功能开关
Definition: type_def.h:171
uint64_t timestamp
时间戳,即系统时间
Definition: type_def.h:702
const char * what() const noexceptoverride
Definition: type_def.h:781
std::vector< std::string > args
机器人参数
Definition: type_def.h:708
struct arcs::common_interface::RobotSafetyParameterRange::@2 cubic[SAFETY_CUBIC_NUM]
10个安全空间
AuboException(int code, const std::string &message) noexcept
Definition: type_def.h:763
float power
sum of joint torques times joint angular speeds
Definition: type_def.h:108
用于负载辨识的轨迹配置
Definition: type_def.h:642
#define TOOL_CONFIGURATION_NUM
Definition: type_def.h:27
TraceLevel level
日志等级
Definition: type_def.h:703
std::vector< double > Cylinder
Definition: type_def.h:693
std::tuple< std::vector< std::vector< double >>, int > ResultWithErrno1
Definition: type_def.h:660
std::vector< double > Sphere
Definition: type_def.h:698
std::string source
发送消息的机器人别名 alias 可在 /root/arcs_ws/config/aubo_control.conf 配置文件中查到机器人的alias ...
Definition: type_def.h:705
RobotControlModeType
机器人控制模式
Definition: type_def.h:463
double a
加速度, 单位: m/s^2
Definition: type_def.h:596
std::vector< double > max_velocity
Definition: type_def.h:649
std::vector< double > pose_via
圆周运动途中点的位姿
Definition: type_def.h:594
std::tuple< std::vector< double >, std::vector< double >, std::vector< double >> DynamicsModel
Definition: type_def.h:678
int trigger
触发方式(该功能暂未实现): 0 - 周期; 1 - 变化
Definition: type_def.h:718
uint32_t safety_input_emergency_stop
可配置IO的输入输出安全功能配置
Definition: type_def.h:151
std::array< float, 3 > Vector3f
Definition: type_def.h:31
bool to_server
输入/输出
Definition: type_def.h:715
std::tuple< std::vector< double >, std::vector< double >, double, std::vector< double >, double > ForceSensorCalibResultWithError
Definition: type_def.h:674
std::vector< double > pose_to
圆周运动结束点的位姿
Definition: type_def.h:595
std::vector< double > frame
参考点,螺旋线的中心点和参考坐标系
Definition: type_def.h:613
SafetyModeType
安全状态:
Definition: type_def.h:447
double blend_radius
交融半径,单位: m
Definition: type_def.h:598
int allow_manual_high_speed
手动模式下允许高速运行
Definition: type_def.h:172
std::vector< std::string > segments
字段列表
Definition: type_def.h:719
StandardInputAction
The StandardInputAction enum.
Definition: type_def.h:495
double v
速度,单位: m/s
Definition: type_def.h:597
#define SAFETY_PARAM_SELECT_NUM
Definition: type_def.h:24
JointStateType
关节状态
Definition: type_def.h:479
Vector4f tools[TOOL_CONFIGURATION_NUM]
3个工具
Definition: type_def.h:144
std::array< double, 4 > Vector4d
Definition: type_def.h:30
std::vector< double > upper_joint_bound
Definition: type_def.h:647
std::vector< double > lower_joint_bound
Definition: type_def.h:648
const char * returnValue2Str(int retval)
Definition: type_def.h:788
double frequency
更新频率
Definition: type_def.h:717
Definition: aubo_api.h:17
std::array< float, 4 > Vector4f
Definition: type_def.h:32
Vector6f orig
立方块的原点 (x,y,z,rx,ry,rz)
Definition: type_def.h:138
double angle
转动的角度,如果为正数,机器人逆时针旋转
Definition: type_def.h:615
圆周运动参数定义
Definition: type_def.h:592
std::vector< RobotMsg > RobotMsgVector
Definition: type_def.h:710
#define SAFETY_PLANES_NUM
Definition: type_def.h:25
std::ostream & operator<<(std::ostream &os, const RobotSafetyParameterRange &vd)
Definition: type_def.h:175