ARCS SDK API  0.24.0
robot_manage.h
浏览该文件的文档.
1 /** @file robot_manage.h
2  * @brief 机器人管理接口,如上电、启动、拖动示教模式等
3  */
4 #ifndef AUBO_SDK_ROBOT_CONTROL_INTERFACE_H
5 #define AUBO_SDK_ROBOT_CONTROL_INTERFACE_H
6 
7 #include <vector>
8 #include <thread>
9 
10 #include <aubo/global_config.h>
11 #include <aubo/type_def.h>
12 
13 namespace arcs {
14 namespace common_interface {
15 
16 class ARCS_ABI_EXPORT RobotManage
17 {
18 public:
19  RobotManage();
20  virtual ~RobotManage();
21 
22  /**
23  * 发起机器人上电请求
24  *
25  * @return 成功返回0; 失败返回错误码
26  * AUBO_BAD_STATE
27  *
28  * @throws arcs::common_interface::AuboException
29  *
30  * @par Python函数原型
31  * poweron(self: pyaubo_sdk.RobotManage) -> int
32  *
33  * @par Lua函数原型
34  * poweron() -> number
35  *
36  * @par C++示例
37  * @code
38  * auto rpc_cli = std::make_shared<RpcClient>();
39  * auto robot_name = rpc_cli->getRobotNames().front();
40  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->poweron();
41  * @endcode
42  *
43  */
44  int poweron();
45 
46  /**
47  * 发起机器人启动请求
48  *
49  * @return 成功返回0; 失败返回错误码
50  * AUBO_BAD_STATE
51  *
52  * @throws arcs::common_interface::AuboException
53  *
54  * @par Python函数原型
55  * startup(self: pyaubo_sdk.RobotManage) -> int
56  *
57  * @par Lua函数原型
58  * startup() -> number
59  *
60  * @par C++示例
61  * @code
62  * auto rpc_cli = std::make_shared<RpcClient>();
63  * auto robot_name = rpc_cli->getRobotNames().front();
64  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->startup();
65  * @endcode
66  */
67  int startup();
68 
69  /**
70  * 发起机器人断电请求
71  *
72  * @return 成功返回0; 失败返回错误码
73  * AUBO_BAD_STATE
74  *
75  * @throws arcs::common_interface::AuboException
76  *
77  * @par Python函数原型
78  * poweroff(self: pyaubo_sdk.RobotManage) -> int
79  *
80  * @par Lua函数原型
81  * poweroff() -> number
82  *
83  * @par C++示例
84  * @code
85  * auto rpc_cli = std::make_shared<RpcClient>();
86  * auto robot_name = rpc_cli->getRobotNames().front();
87  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->poweroff();
88  * @endcode
89  */
90  int poweroff();
91 
92  /**
93  * 发起机器人反向驱动请求
94  *
95  * @param enable
96  *
97  * @return 成功返回0; 失败返回错误码
98  * AUBO_BUSY
99  * AUBO_BAD_STATE
100  * -AUBO_INVL_ARGUMENT
101  * -AUBO_BAD_STATE
102  *
103  * @throws arcs::common_interface::AuboException
104  *
105  * @par Python函数原型
106  * backdrive(self: pyaubo_sdk.RobotManage, arg0: bool) -> int
107  *
108  * @par Lua函数原型
109  * backdrive(enable: boolean) -> number
110  *
111  * @par C++示例
112  * @code
113  * auto rpc_cli = std::make_shared<RpcClient>();
114  * auto robot_name = rpc_cli->getRobotNames().front();
115  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->backdrive(true);
116  * @endcode
117  *
118  */
119  int backdrive(bool enable);
120 
121  /**
122  * 发起机器人自由驱动请求
123  * 接口在软件版本 0.31.x 后已废弃,使用 handguideMode 接口替换
124  * handguideMode({1,1,1,1,1}, {0,0,0,0,0,0})
125  *
126  * @param enable
127  *
128  * @return 成功返回0; 失败返回错误码
129  * AUBO_BUSY
130  * AUBO_BAD_STATE
131  * -AUBO_INVL_ARGUMENT
132  * -AUBO_BAD_STATE
133  *
134  * @throws arcs::common_interface::AuboException
135  *
136  * @par Python函数原型
137  * freedrive(self: pyaubo_sdk.RobotManage, arg0: bool) -> int
138  *
139  * @par Lua函数原型
140  * freedrive(enable: boolean) -> number
141  *
142  * @par C++示例
143  * @code
144  * auto rpc_cli = std::make_shared<RpcClient>();
145  * auto robot_name = rpc_cli->getRobotNames().front();
146  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->freedrive(true);
147  * @endcode
148  *
149  */
150  int freedrive(bool enable);
151 
152  /**
153  * 高阶拖动示教
154  *
155  * @param freeAxes 可以拖动的轴 0-不能拖动 1-可以拖动
156  * @param feature 如果维度为0,代表基于 TCP 坐标系拖动
157  *
158  * @return 成功返回0; 失败返回错误码
159  * AUBO_BUSY
160  * AUBO_BAD_STATE
161  * -AUBO_INVL_ARGUMENT
162  * -AUBO_BAD_STATE
163  *
164  * @throws arcs::common_interface::AuboException
165  *
166  */
167  int handguideMode(const std::vector<int> &freeAxes,
168  const std::vector<double> &feature);
169 
170  /**
171  * 退出拖动示教
172  *
173  * @note 暂未实现
174  *
175  * @return 成功返回0; 失败返回错误码
176  * AUBO_BUSY
177  * AUBO_BAD_STATE
178  * -AUBO_BAD_STATE
179  *
180  * @throws arcs::common_interface::AuboException
181  *
182  */
183  int exitHandguideMode();
184 
185  /**
186  * 获取拖动示教器的状态(是否处于奇异空间)
187  *
188  * @note 暂未实现
189  *
190  * @return
191  * • 0 - 正常操作.
192  * • 1 - 接近奇异空间.
193  * • 2 - 极其接近奇异点,将产生较大的拖动阻尼.
194  *
195  * @throws arcs::common_interface::AuboException
196  *
197  */
198  int getHandguideStatus();
199 
200  /**
201  * 获取拖动示教器触发源
202  *
203  * @note 暂未实现
204  *
205  * @return
206  *
207  * @throws arcs::common_interface::AuboException
208  *
209  */
210  int getHandguideTrigger();
211 
212  /**
213  * 获取拖动示教使能状态
214  *
215  * @return 使能返回true; 失能返回false
216  *
217  * @throws arcs::common_interface::AuboException
218  *
219  */
220  bool isHandguideEnabled();
221 
222  /**
223  * 发起机器人进入/退出仿真模式请求
224  *
225  * @param enable
226  *
227  * @return 成功返回0;失败返回错误码
228  * AUBO_BUSY
229  * AUBO_BAD_STATE
230  * -AUBO_INVL_ARGUMENT
231  * -AUBO_BAD_STATE
232  *
233  * @throws arcs::common_interface::AuboException
234  *
235  * @par Python函数原型
236  * setSim(self: pyaubo_sdk.RobotManage, arg0: bool) -> int
237  *
238  * @par Lua函数原型
239  * setSim(enable: boolean) -> number
240  *
241  * @par C++示例
242  * @code
243  * auto rpc_cli = std::make_shared<RpcClient>();
244  * auto robot_name = rpc_cli->getRobotNames().front();
245  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->setSim(true);
246  * @endcode
247  *
248  */
249  int setSim(bool enable);
250 
251  /**
252  * 设置机器人操作模式
253  *
254  * @param mode 操作模式
255  *
256  * @return 成功返回0; 失败返回错误码
257  * -AUBO_BAD_STATE
258  *
259  * @throws arcs::common_interface::AuboException
260  *
261  * @par Python函数原型
262  * setOperationalMode(self: pyaubo_sdk.RobotManage, arg0:
263  * arcs::common_interface::OperationalModeType) -> int
264  *
265  * @par Lua函数原型
266  * setOperationalMode(mode: number) -> number
267  *
268  * @par C++示例
269  * @code
270  * auto rpc_cli = std::make_shared<RpcClient>();
271  * auto robot_name = rpc_cli->getRobotNames().front();
272  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->setOperationalMode(OperationalModeType::Automatic);
273  * @endcode
274  *
275  */
276  int setOperationalMode(OperationalModeType mode);
277 
278  /**
279  * 获取机器人操作模式
280  *
281  * @return 机器人操作模式
282  *
283  * @throws arcs::common_interface::AuboException
284  *
285  * @par Python函数原型
286  * getOperationalMode(self: pyaubo_sdk.RobotManage) ->
287  * arcs::common_interface::OperationalModeType
288  *
289  * @par Lua函数原型
290  * getOperationalMode() -> number
291  *
292  * @par C++示例
293  * @code
294  * auto rpc_cli = std::make_shared<RpcClient>();
295  * auto robot_name = rpc_cli->getRobotNames().front();
296  * OperationalModeType mode =
297  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->getOperationalMode();
298  * @endcode
299  *
300  */
301  OperationalModeType getOperationalMode();
302 
303  /**
304  * 获取控制模式
305  *
306  * @return 控制模式
307  *
308  * @throws arcs::common_interface::AuboException
309  *
310  * @par Python函数原型
311  * getRobotControlMode(self: pyaubo_sdk.RobotManage) ->
312  * arcs::common_interface::RobotControlModeType
313  *
314  * @par Lua函数原型
315  * getRobotControlMode() -> number
316  *
317  * @par C++示例
318  * @code
319  * auto rpc_cli = std::make_shared<RpcClient>();
320  * auto robot_name = rpc_cli->getRobotNames().front();
321  * RobotControlModeType mode =
322  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->getRobotControlMode();
323  * @endcode
324  */
325  RobotControlModeType getRobotControlMode();
326 
327  /**
328  * 是否使能了拖动示教模式
329  *
330  * @return 使能返回true; 反之返回false
331  *
332  * @throws arcs::common_interface::AuboException
333  *
334  * @par Python函数原型
335  * isFreedriveEnabled(self: pyaubo_sdk.RobotManage) -> bool
336  *
337  * @par Lua函数原型
338  * isFreedriveEnabled() -> boolean
339  *
340  * @par C++示例
341  * @code
342  * auto rpc_cli = std::make_shared<RpcClient>();
343  * auto robot_name = rpc_cli->getRobotNames().front();
344  * bool isEnabled =
345  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->isFreedriveEnabled();
346  * @endcode
347  *
348  */
349  bool isFreedriveEnabled();
350 
351  /**
352  * 是否使能了反向驱动模式
353  *
354  * @return 使能返回true; 反之返回false
355  *
356  * @throws arcs::common_interface::AuboException
357  *
358  * @par Python函数原型
359  * isBackdriveEnabled(self: pyaubo_sdk.RobotManage) -> bool
360  *
361  * @par Lua函数原型
362  * isBackdriveEnabled() -> boolean
363  *
364  * @par C++示例
365  * @code
366  * auto rpc_cli = std::make_shared<RpcClient>();
367  * auto robot_name = rpc_cli->getRobotNames().front();
368  * bool isEnabled =
369  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->isBackdriveEnabled();
370  * @endcode
371  */
372  bool isBackdriveEnabled();
373 
374  /**
375  * 是否使能了仿真模式
376  *
377  * @return 使能返回true; 反之返回false
378  *
379  * @throws arcs::common_interface::AuboException
380  *
381  * @par Python函数原型
382  * isSimulationEnabled(self: pyaubo_sdk.RobotManage) -> bool
383  *
384  * @par Lua函数原型
385  * isSimulationEnabled() -> boolean
386  *
387  * @par C++示例
388  * @code
389  * auto rpc_cli = std::make_shared<RpcClient>();
390  * auto robot_name = rpc_cli->getRobotNames().front();
391  * bool isEnabled =
392  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->isSimulationEnabled();
393  * @endcode
394  */
395  bool isSimulationEnabled();
396 
397  /**
398  * 清除防护停机,包括碰撞停机
399  *
400  * @return 成功返回0;失败返回错误码
401  * AUBO_BUSY
402  * AUBO_BAD_STATE
403  * -AUBO_BAD_STATE
404  *
405  * @throws arcs::common_interface::AuboException
406  *
407  * @par Python函数原型
408  * setUnlockProtectiveStop(self: pyaubo_sdk.RobotManage) -> int
409  *
410  * @par Lua函数原型
411  * setUnlockProtectiveStop() -> number
412  *
413  * @par C++示例
414  * @code
415  * auto rpc_cli = std::make_shared<RpcClient>();
416  * auto robot_name = rpc_cli->getRobotNames().front();
417  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->setUnlockProtectiveStop();
418  * @endcode
419  */
420  int setUnlockProtectiveStop();
421 
422  /**
423  * 重置安全接口板,一般在机器人断电之后需要重置时调用,比如机器人急停、故障等之后
424  *
425  * @return 成功返回0; 失败返回错误码
426  * AUBO_BUSY
427  * AUBO_BAD_STATE
428  * -AUBO_BAD_STATE
429  *
430  * @throws arcs::common_interface::AuboException
431  *
432  * @par Python函数原型
433  * restartInterfaceBoard(self: pyaubo_sdk.RobotManage) -> int
434  *
435  * @par Lua函数原型
436  * restartInterfaceBoard() -> number
437  *
438  * @par C++示例
439  * @code
440  * auto rpc_cli = std::make_shared<RpcClient>();
441  * auto robot_name = rpc_cli->getRobotNames().front();
442  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->restartInterfaceBoard();
443  * @endcode
444  */
445  int restartInterfaceBoard();
446 
447  /**
448  * 开始实时轨迹的记录
449  *
450  * @param file_name
451  *
452  * @return 成功返回0;失败返回错误码
453  * AUBO_BUSY
454  * AUBO_BAD_STATE
455  * -AUBO_INVL_ARGUMENT
456  * -AUBO_BAD_STATE
457  *
458  * @throws arcs::common_interface::AuboException
459  *
460  */
461  int startRecord(const std::string &file_name);
462 
463  /**
464  * 停止实时记录
465  *
466  * @return 成功返回0;失败返回错误码
467  * AUBO_BUSY
468  * AUBO_BAD_STATE
469  * -AUBO_BAD_STATE
470  *
471  * @throws arcs::common_interface::AuboException
472  *
473  */
474  int stopRecord();
475 
476  /**
477  * 暂停实时记录
478  *
479  * @param pause
480  *
481  * @return 成功返回0;失败返回错误码
482  * AUBO_BUSY
483  * AUBO_BAD_STATE
484  * -AUBO_BAD_STATE
485  *
486  * @throws arcs::common_interface::AuboException
487  *
488  */
489  int pauseRecord(bool pause);
490 
491  /**
492  * 发起机器人进入/退出联动模式请求,
493  * 只有操作模式为自动或者无时,才能使能联动模式
494  *
495  * @param enable
496  *
497  * @return 成功返回0; 失败返回错误码
498  * AUBO_BUSY
499  * AUBO_REQUEST_IGNORE
500  * -AUBO_BAD_STATE
501  *
502  * @throws arcs::common_interface::AuboException
503  *
504  * @par Python函数原型
505  * setLinkModeEnable(self: pyaubo_sdk.RobotManage, arg0: bool) -> int
506  *
507  * @par Lua函数原型
508  * setLinkModeEnable(enable: boolean) -> number
509  *
510  * @par C++示例
511  * @code
512  * auto rpc_cli = std::make_shared<RpcClient>();
513  * auto robot_name = rpc_cli->getRobotNames().front();
514  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->setLinkModeEnable(true);
515  * @endcode
516  *
517  */
518  int setLinkModeEnable(bool enable);
519 
520  /**
521  * 是否使能了联动模式,联动模式下用户可以通过外部IO控制机器人(用户可以对IO的功能进行配置)
522  *
523  * @return 使能返回true; 反之返回false
524  *
525  * @throws arcs::common_interface::AuboException
526  *
527  * @par Python函数原型
528  * isLinkModeEnabled(self: pyaubo_sdk.RobotManage) -> bool
529  *
530  * @par Lua函数原型
531  * isLinkModeEnabled() -> boolean
532  *
533  * @par C++示例
534  * @code
535  * auto rpc_cli = std::make_shared<RpcClient>();
536  * auto robot_name = rpc_cli->getRobotNames().front();
537  * bool isEnabled =
538  * rpc_cli->getRobotInterface(robot_name)->getRobotManage()->isLinkModeEnabled();
539  * @endcode
540  */
541  bool isLinkModeEnabled();
542 
543 protected:
544  void *d_;
545 };
546 using RobotManagePtr = std::shared_ptr<RobotManage>;
547 
548 // clang-format off
549 #define RobotManage_DECLARES \
550  _FUNC(RobotManage, 0, poweron) \
551  _FUNC(RobotManage, 0, startup) \
552  _FUNC(RobotManage, 0, poweroff) \
553  _FUNC(RobotManage, 1, backdrive, enable) \
554  _FUNC(RobotManage, 1, freedrive, enable) \
555  _FUNC(RobotManage, 2, handguideMode, freeAxes,feature) \
556  _FUNC(RobotManage, 0, exitHandguideMode) \
557  _FUNC(RobotManage, 0, getHandguideStatus) \
558  _FUNC(RobotManage, 0, getHandguideTrigger) \
559  _FUNC(RobotManage, 0, isHandguideEnabled) \
560  _FUNC(RobotManage, 1, setSim, enable) \
561  _FUNC(RobotManage, 1, setOperationalMode, mode) \
562  _FUNC(RobotManage, 0, getOperationalMode) \
563  _FUNC(RobotManage, 0, getRobotControlMode) \
564  _FUNC(RobotManage, 0, isSimulationEnabled) \
565  _FUNC(RobotManage, 0, isFreedriveEnabled) \
566  _FUNC(RobotManage, 0, isBackdriveEnabled) \
567  _FUNC(RobotManage, 0, setUnlockProtectiveStop) \
568  _INST(RobotManage, 1, startRecord, file_name) \
569  _INST(RobotManage, 0, stopRecord) \
570  _INST(RobotManage, 1, pauseRecord, pause) \
571  _FUNC(RobotManage, 0, restartInterfaceBoard) \
572  _FUNC(RobotManage, 1, setLinkModeEnable, enable) \
573  _FUNC(RobotManage, 0, isLinkModeEnabled)
574 // clang-format on
575 } // namespace common_interface
576 } // namespace arcs
577 
578 #endif // AUBO_SDK_ROBOT_CONTROL_INTERFACE_H
数据类型的定义
OperationalModeType
操作模式
Definition: type_def.h:455
RobotControlModeType
机器人控制模式
Definition: type_def.h:463
std::shared_ptr< RobotManage > RobotManagePtr
Definition: robot_manage.h:546
Definition: aubo_api.h:17