正点原子开发板 alientek_develop_board cancmder
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

480 lines
21 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include "intelligent_winding_robot_ctrl.hpp"
  2. #include <stdlib.h>
  3. #include <string.h>
  4. using namespace std;
  5. using namespace iflytop;
  6. #define TAG "IntelligentWindingRobotCtrl"
  7. #define DO(exptr) \
  8. { \
  9. int32_t ret = exptr; \
  10. if (ret != 0) { \
  11. return ret; \
  12. } \
  13. }
  14. void IntelligentWindingRobotCtrl::processError(int32_t err) { ZLOGE(TAG, "processError: %d", err); }
  15. void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid) {
  16. zos_delay(100);
  17. while (true) {
  18. int32_t status = 0;
  19. int32_t ecode = m_dm->module_get_status(moduleid, &status);
  20. if (ecode != 0) {
  21. processError(ecode);
  22. break;
  23. };
  24. ZLOGI(TAG, "wait_module_idle %d %d....", moduleid, status);
  25. if (status == 0) break;
  26. if (status == 2) {
  27. processError(err::kfail);
  28. break;
  29. };
  30. zos_delay(1000);
  31. }
  32. }
  33. int32_t IntelligentWindingRobotCtrl::initialize_device() { return 0; }
  34. // �ŷ϶���
  35. int32_t IntelligentWindingRobotCtrl::paifei_duoji_moveto_reset() {
  36. ZLOGI(TAG, "paifei_duoji_moveto_reset %d %d %d", 15, cfg.paifei_duoji_reset_pos, 330);
  37. DO(m_dm->motor_move_to(15, cfg.paifei_duoji_reset_pos, 2000, 0));
  38. wait_module_idle(15);
  39. return 0;
  40. }
  41. int32_t IntelligentWindingRobotCtrl::paifei_duoji_moveto_press() {
  42. ZLOGI(TAG, "paifei_duoji_moveto_press %d %d %d", 15, cfg.paifei_duoji_press_pos, cfg.paifei_duoji_press_torque);
  43. DO(m_dm->motor_move_to_with_torque(15, cfg.paifei_duoji_press_pos, cfg.paifei_duoji_press_torque));
  44. wait_module_idle(15);
  45. }
  46. /**
  47. * @brief ̽
  48. */
  49. int32_t IntelligentWindingRobotCtrl::raoxiantance_duoji_move_to_reset() {
  50. ZLOGI(TAG, "raoxiantance_duoji_move_to_reset %d %d %d", 14, cfg.raoxiantance_duoji_reset_pos, 330);
  51. DO(m_dm->motor_move_to(14, cfg.raoxiantance_duoji_reset_pos, 2000, 0));
  52. wait_module_idle(14);
  53. return 0;
  54. }
  55. int32_t IntelligentWindingRobotCtrl::raoxiantance_duoji_move_to_get_thickness(int32_t* thickness) {
  56. ZLOGI(TAG, "raoxiantance_duoji_move_to_get_thickness %d %d", 14, cfg.raoxiantance_duoji_tance_zero_pos);
  57. DO(m_dm->motor_move_to_with_torque(14, cfg.raoxiantance_duoji_tance_zero_pos, 200));
  58. zos_delay(2000);
  59. int32_t nowpos = 0;
  60. DO(m_dm->motor_read_pos(14, &nowpos));
  61. *thickness = cfg.raoxiantance_duoji_tance_zero_pos - nowpos;
  62. DO(raoxiantance_duoji_move_to_reset());
  63. return 0;
  64. }
  65. /**
  66. * @brief ѹ߶
  67. */
  68. int32_t IntelligentWindingRobotCtrl::yaxian_duoji_move_to_reset() {
  69. ZLOGI(TAG, "yaxian_duoji_move_to_reset %d %d %d", 13, cfg.yaxian_duoji_reset_pos, 330);
  70. DO(m_dm->motor_move_to(13, cfg.yaxian_duoji_reset_pos, 2000, 0));
  71. wait_module_idle(13);
  72. return 0;
  73. }
  74. int32_t IntelligentWindingRobotCtrl::yaxian_duoji_move_to_press_pos() {
  75. ZLOGI(TAG, "yaxian_duoji_move_to_press_pos %d %d %d", 13, cfg.yaxian_duoji_press_pos, cfg.yaxian_duoji_press_torque);
  76. DO(m_dm->motor_move_to_with_torque(13, cfg.yaxian_duoji_press_pos, cfg.yaxian_duoji_press_torque));
  77. wait_module_idle(13);
  78. return 0;
  79. }
  80. int32_t IntelligentWindingRobotCtrl::yaxian_duoji_move_to_wait_for_press_pos() {
  81. ZLOGI(TAG, "yaxian_duoji_move_to_wait_for_press_pos %d %d %d", 13, cfg.yaxian_duoji_wait_for_press_pos, cfg.yaxian_duoji_press_torque);
  82. DO(m_dm->motor_move_to_with_torque(13, cfg.yaxian_duoji_wait_for_press_pos, cfg.yaxian_duoji_press_torque));
  83. wait_module_idle(13);
  84. return 0;
  85. }
  86. /**
  87. * @brief
  88. */
  89. int32_t IntelligentWindingRobotCtrl::xianlajin_duoji_move_to_reset() {
  90. ZLOGI(TAG, "xianlajin_duoji_move_to_reset %d %d %d", 12, cfg.xianlajin_duoji_reset_pos, 330);
  91. DO(m_dm->motor_move_to(16, cfg.xianlajin_duoji_reset_pos, 2000, 0));
  92. wait_module_idle(16);
  93. return 0;
  94. } // ��λ
  95. int32_t IntelligentWindingRobotCtrl::xianlajin_duoji_move_to_line_entry_pos() {
  96. ZLOGI(TAG, "xianlajin_duoji_move_to_line_entry_pos %d %d %d", 16, cfg.xianlajin_duoji_line_entry_pos, 330);
  97. DO(m_dm->motor_move_to(16, cfg.xianlajin_duoji_line_entry_pos, 2000, 0));
  98. wait_module_idle(16);
  99. return 0;
  100. } // ����λ
  101. int32_t IntelligentWindingRobotCtrl::xianlajin_duoji_move_to_tight_line_pos() {
  102. ZLOGI(TAG, "xianlajin_duoji_move_to_tight_line_pos %d %d %d", 16, cfg.xianlajin_duoji_tight_line_pos, 330);
  103. DO(m_dm->motor_move_to(16, cfg.xianlajin_duoji_tight_line_pos, 2000, 0));
  104. wait_module_idle(16);
  105. return 0;
  106. } // �����
  107. int32_t IntelligentWindingRobotCtrl::xianlajin_duoji_move_to_loose_line_pos() {
  108. ZLOGI(TAG, "xianlajin_duoji_move_to_loose_line_pos %d %d %d", 16, cfg.xianlajin_duoji_loose_line_pos, 330);
  109. DO(m_dm->motor_move_to(16, cfg.xianlajin_duoji_loose_line_pos, 2000, 0));
  110. wait_module_idle(16);
  111. return 0;
  112. } // �����
  113. /**
  114. * @brief ߶12
  115. */
  116. int32_t IntelligentWindingRobotCtrl::jiaxian_duoji_move_to_reset_pos() {
  117. ZLOGI(TAG, "jiaxian_duoji_move_to_reset_pos %d %d %d", 12, cfg.jiaxian_duoji_reset_pos, 330);
  118. DO(m_dm->motor_move_to(12, cfg.jiaxian_duoji_reset_pos, 2000, 0));
  119. wait_module_idle(12);
  120. return 0;
  121. }
  122. int32_t IntelligentWindingRobotCtrl::jiaxian_duoji_move_to_clamp_pos() {
  123. ZLOGI(TAG, "jiaxian_duoji_move_to_clamp_pos %d %d %d", 12, cfg.jiaxian_duoji_clamp_pos, cfg.jiaxian_duoji_clamp_torque);
  124. DO(m_dm->motor_move_to_with_torque(12, cfg.jiaxian_duoji_clamp_pos, cfg.jiaxian_duoji_clamp_torque));
  125. wait_module_idle(12);
  126. return 0;
  127. }
  128. /**
  129. * @brief
  130. */
  131. int32_t IntelligentWindingRobotCtrl::scissors_move_reset_pos() {
  132. // ZLOGI(TAG, "scissors_move_reset_pos %d", 11);
  133. ZLOGI(TAG, "scissors_move_reset_pos");
  134. return 0;
  135. } // block
  136. int32_t IntelligentWindingRobotCtrl::scissors_cut() {
  137. ZLOGI(TAG, "scissors_cut %d", 22);
  138. DO(m_dm->motor_move_by(22, 4095, 0, 0));
  139. wait_module_idle(22);
  140. return 0;
  141. } // block
  142. /**
  143. * @brief еۼ߶
  144. */
  145. int32_t IntelligentWindingRobotCtrl::arm_jiaxian_duoji_move_to_reset_pos() {
  146. ZLOGI(TAG, "arm_jiaxian_duoji_move_to_reset_pos");
  147. DO(m_dm->motor_move_to(11, cfg.arm_jiaxian_duoji_reset_pos, 2000, 0));
  148. wait_module_idle(11);
  149. return 0;
  150. }
  151. int32_t IntelligentWindingRobotCtrl::arm_jiaxian_duoji_move_to_clamp_pos() {
  152. ZLOGI(TAG, "arm_jiaxian_duoji_move_to_clamp_pos");
  153. DO(m_dm->motor_move_to_with_torque(11, cfg.arm_jiaxian_duoji_clamp_direction, cfg.arm_jiaxian_duoji_clamp_torque));
  154. wait_module_idle(11);
  155. return 0;
  156. }
  157. /**
  158. * @brief е۹צ
  159. */
  160. int32_t IntelligentWindingRobotCtrl::arm_hook_claws_reset() {
  161. ZLOGI(TAG, "arm_hook_claws_reset");
  162. DO(m_dm->motor_move_to_zero_backward(21, 0, 0, 0, 0));
  163. wait_module_idle(21);
  164. return 0;
  165. }
  166. int32_t IntelligentWindingRobotCtrl::arm_hook_claws_move_to_half_pos() {
  167. ZLOGI(TAG, "arm_hook_claws_move_to_half_pos");
  168. DO(m_dm->motor_move_to(21, cfg.arm_hook_claws_half_pos, 0, 0));
  169. wait_module_idle(21);
  170. return 0;
  171. }
  172. int32_t IntelligentWindingRobotCtrl::arm_hook_claws_move_to_full_pos() {
  173. ZLOGI(TAG, "arm_hook_claws_move_to_full_pos");
  174. DO(m_dm->motor_move_to(21, cfg.arm_hook_claws_full_pos, 0, 0));
  175. wait_module_idle(21);
  176. return 0;
  177. }
  178. int32_t IntelligentWindingRobotCtrl::main_shaft_run() {
  179. ZLOGI(TAG, "main_shaft_run");
  180. DO(m_dm->motor_rotate_acctime(2, 1, 1000, 10000));
  181. return 0;
  182. }
  183. int32_t IntelligentWindingRobotCtrl::main_shaft_stop() {
  184. ZLOGI(TAG, "main_shaft_stop");
  185. DO(m_dm->module_stop(2));
  186. return 0;
  187. }
  188. /**
  189. * @brief XYƽ̨
  190. */
  191. int32_t IntelligentWindingRobotCtrl::xy_platform_reset() { return 0; }
  192. /**
  193. * @brief Z
  194. */
  195. int32_t IntelligentWindingRobotCtrl::z_axis_reset() { return 0; }
  196. int32_t IntelligentWindingRobotCtrl::z_axis_move_to(int32_t pos) { return 0; }
  197. int32_t IntelligentWindingRobotCtrl::xy_move_to_zero() { return 0; } // �ƶ�����λ
  198. int32_t IntelligentWindingRobotCtrl::xy_take_clip(int32_t index) { return 0; } // ȡ����
  199. int32_t IntelligentWindingRobotCtrl::xy_take_line() { return 0; } // ȡ��
  200. int32_t IntelligentWindingRobotCtrl::xy_take_back_clip() { return 0; } // �ŵ���
  201. int32_t IntelligentWindingRobotCtrl::xy_remove_line() { return 0; } // �Ƴ���
  202. int32_t IntelligentWindingRobotCtrl::do_reset_device() {}
  203. int32_t IntelligentWindingRobotCtrl::do_winding(int32_t index) {}
  204. /**
  205. * @brief
  206. */
  207. int32_t IntelligentWindingRobotCtrl::start_winding() { return 0; }
  208. int32_t IntelligentWindingRobotCtrl::stop_winding() { return 0; }
  209. int32_t IntelligentWindingRobotCtrl::reset_and_check_device() { return 0; }
  210. int32_t IntelligentWindingRobotCtrl::device_reset() {
  211. // Z�Ḵλ
  212. zreset();
  213. arm_hook_claws_reset();
  214. arm_jiaxian_duoji_move_to_reset_pos();
  215. xy_reset();
  216. ZLOGI(TAG, "device_reset finished....");
  217. }
  218. int32_t IntelligentWindingRobotCtrl::disable_all_motor() {
  219. m_dm->motor_enable(2, 0);
  220. m_dm->xymotor_enable(XYRobot_ID, 0);
  221. m_dm->motor_enable(11, 0);
  222. m_dm->motor_enable(12, 0);
  223. m_dm->motor_enable(13, 0);
  224. m_dm->motor_enable(14, 0);
  225. m_dm->motor_enable(15, 0);
  226. m_dm->motor_enable(16, 0);
  227. m_dm->motor_enable(21, 0);
  228. m_dm->motor_enable(22, 0);
  229. m_dm->motor_enable(23, 0);
  230. return 0;
  231. }
  232. int32_t IntelligentWindingRobotCtrl::xy_get_point(int32_t clip_index, int32_t& x, int32_t& y) {
  233. // x = 0;
  234. // y = 0;
  235. int clip_x_off = clip_index / cfg.clip_each_line_num;
  236. int clip_y_off = clip_index % cfg.clip_each_line_num;
  237. float eachx = (cfg.xy_platform_takeline_clipXX_pos_x - cfg.xy_platform_takeline_clip00_pos_x) / (cfg.clip_line - 1);
  238. float eachy = (cfg.xy_platform_takeline_clipXX_pos_y - cfg.xy_platform_takeline_clip00_pos_y) / (cfg.clip_each_line_num - 1);
  239. x = cfg.xy_platform_takeline_clip00_pos_x + eachx * clip_x_off;
  240. y = cfg.xy_platform_takeline_clip00_pos_y + eachy * clip_y_off;
  241. return 0;
  242. }
  243. int32_t IntelligentWindingRobotCtrl::zmove_to(int32_t pos) {
  244. ZLOGI(TAG, "zmove_to %d", pos);
  245. int32_t nowpos = 0;
  246. m_dm->motor_read_pos(ZMOTOR_ID, &nowpos);
  247. if (pos >= nowpos) {
  248. m_dm->motor_move_to(ZMOTOR_ID, pos, 450, 600);
  249. } else {
  250. m_dm->motor_move_to(ZMOTOR_ID, pos, 1000, 600);
  251. }
  252. if(pos == 0){
  253. zreset();
  254. }
  255. wait_module_idle(ZMOTOR_ID);
  256. return 0;
  257. }
  258. int32_t IntelligentWindingRobotCtrl::zreset() {
  259. ZLOGI(TAG, "zreset");
  260. m_dm->motor_enable(ZMOTOR_ID, 1);
  261. m_dm->motor_move_to_zero_backward(4, 450, 300, 2000, 0);
  262. wait_module_idle(ZMOTOR_ID);
  263. return 0;
  264. }
  265. int32_t IntelligentWindingRobotCtrl::xymove_to(int32_t x, int32_t y) {
  266. ZLOGI(TAG, "xymove_to %d %d", x, y);
  267. m_dm->xymotor_move_to(XYRobot_ID, x, y, 0);
  268. wait_module_idle(XYRobot_ID);
  269. return 0;
  270. }
  271. int32_t IntelligentWindingRobotCtrl::xy_reset() {
  272. ZLOGI(TAG, "xy_reset");
  273. m_dm->xymotor_move_to_zero(XYRobot_ID);
  274. wait_module_idle(XYRobot_ID);
  275. return 0;
  276. }
  277. int32_t IntelligentWindingRobotCtrl::xy_run_to_clip_pos_test(int32_t clip_index) {
  278. ZLOGI(TAG, "xy_run_to_clip_pos_test %d", clip_index);
  279. if (clip_index >= cfg.clip_line * cfg.clip_each_line_num) {
  280. ZLOGE(TAG, "clip_index %d out of range", clip_index);
  281. return err::kparam_out_of_range;
  282. }
  283. zreset();
  284. arm_jiaxian_duoji_move_to_reset_pos();
  285. arm_hook_claws_reset();
  286. int32_t x = 0;
  287. int32_t y = 0;
  288. xy_get_point(clip_index, x, y);
  289. xymove_to(x, y);
  290. zmove_to(cfg.z_axis_take_clip_pos);
  291. arm_hook_claws_move_to_full_pos();
  292. zmove_to(0);
  293. zmove_to(cfg.z_axis_take_clip_pos);
  294. arm_hook_claws_reset();
  295. zmove_to(0);
  296. }
  297. int32_t IntelligentWindingRobotCtrl::setcfg(const char* cfgname, int32_t cfgvalue) {
  298. #if 0
  299. if (strcmp(cfgname, "paifei_duoji_reset_pos") == 0)
  300. cfg.paifei_duoji_reset_pos = cfgvalue;
  301. else if (strcmp(cfgname, "paifei_duoji_press_pos") == 0)
  302. cfg.paifei_duoji_press_pos = cfgvalue;
  303. else if (strcmp(cfgname, "paifei_duoji_press_torque") == 0)
  304. cfg.paifei_duoji_press_torque = cfgvalue;
  305. else if (strcmp(cfgname, "raoxiantance_duoji_reset_pos") == 0)
  306. cfg.raoxiantance_duoji_reset_pos = cfgvalue;
  307. else if (strcmp(cfgname, "raoxiantance_duoji_tance_zero_pos") == 0)
  308. cfg.raoxiantance_duoji_tance_zero_pos = cfgvalue;
  309. else if (strcmp(cfgname, "yaxian_duoji_reset_pos") == 0)
  310. cfg.yaxian_duoji_reset_pos = cfgvalue;
  311. else if (strcmp(cfgname, "yaxian_duoji_press_pos") == 0)
  312. cfg.yaxian_duoji_press_pos = cfgvalue;
  313. else if (strcmp(cfgname, "yaxian_duoji_press_torque") == 0)
  314. cfg.yaxian_duoji_press_torque = cfgvalue;
  315. else if (strcmp(cfgname, "yaxian_duoji_wait_for_press_pos") == 0)
  316. cfg.yaxian_duoji_wait_for_press_pos = cfgvalue;
  317. else if (strcmp(cfgname, "xianlajin_duoji_reset_pos") == 0)
  318. cfg.xianlajin_duoji_reset_pos = cfgvalue;
  319. else if (strcmp(cfgname, "xianlajin_duoji_line_entry_pos") == 0)
  320. cfg.xianlajin_duoji_line_entry_pos = cfgvalue;
  321. else if (strcmp(cfgname, "xianlajin_duoji_tight_line_pos") == 0)
  322. cfg.xianlajin_duoji_tight_line_pos = cfgvalue;
  323. else if (strcmp(cfgname, "xianlajin_duoji_loose_line_pos") == 0)
  324. cfg.xianlajin_duoji_loose_line_pos = cfgvalue;
  325. else if (strcmp(cfgname, "jiaxian_duoji_reset_pos") == 0)
  326. cfg.jiaxian_duoji_reset_pos = cfgvalue;
  327. else if (strcmp(cfgname, "jiaxian_duoji_clamp_pos") == 0)
  328. cfg.jiaxian_duoji_clamp_pos = cfgvalue;
  329. else if (strcmp(cfgname, "jiaxian_duoji_clamp_torque") == 0)
  330. cfg.jiaxian_duoji_clamp_torque = cfgvalue;
  331. else if (strcmp(cfgname, "arm_jiaxian_duoji_reset_pos") == 0)
  332. cfg.arm_jiaxian_duoji_reset_pos = cfgvalue;
  333. else if (strcmp(cfgname, "arm_jiaxian_duoji_clamp_pos") == 0)
  334. cfg.arm_jiaxian_duoji_clamp_pos = cfgvalue;
  335. else if (strcmp(cfgname, "arm_jiaxian_duoji_clamp_torque") == 0)
  336. cfg.arm_jiaxian_duoji_clamp_torque = cfgvalue;
  337. else if (strcmp(cfgname, "scissors_reset_pos") == 0)
  338. cfg.scissors_reset_pos = cfgvalue;
  339. else if (strcmp(cfgname, "scissors_cut_pos") == 0)
  340. cfg.scissors_cut_pos = cfgvalue;
  341. else if (strcmp(cfgname, "arm_hook_claws_half_pos") == 0)
  342. cfg.arm_hook_claws_half_pos = cfgvalue;
  343. else if (strcmp(cfgname, "arm_hook_claws_full_pos") == 0)
  344. cfg.arm_hook_claws_full_pos = cfgvalue;
  345. return 0;
  346. #endif
  347. return 0;
  348. }
  349. int32_t IntelligentWindingRobotCtrl::dumpcfg() {
  350. #if 0
  351. ZLOGI(TAG, "paifei_duoji_reset_pos %d", cfg.paifei_duoji_reset_pos);
  352. ZLOGI(TAG, "paifei_duoji_press_pos %d", cfg.paifei_duoji_press_pos);
  353. ZLOGI(TAG, "paifei_duoji_press_torque %d", cfg.paifei_duoji_press_torque);
  354. ZLOGI(TAG, "raoxiantance_duoji_reset_pos %d", cfg.raoxiantance_duoji_reset_pos);
  355. ZLOGI(TAG, "raoxiantance_duoji_tance_zero_pos %d", cfg.raoxiantance_duoji_tance_zero_pos);
  356. ZLOGI(TAG, "yaxian_duoji_reset_pos %d", cfg.yaxian_duoji_reset_pos);
  357. ZLOGI(TAG, "yaxian_duoji_press_pos %d", cfg.yaxian_duoji_press_pos);
  358. ZLOGI(TAG, "yaxian_duoji_press_torque %d", cfg.yaxian_duoji_press_torque);
  359. ZLOGI(TAG, "yaxian_duoji_wait_for_press_pos %d", cfg.yaxian_duoji_wait_for_press_pos);
  360. ZLOGI(TAG, "xianlajin_duoji_reset_pos %d", cfg.xianlajin_duoji_reset_pos);
  361. ZLOGI(TAG, "xianlajin_duoji_line_entry_pos %d", cfg.xianlajin_duoji_line_entry_pos);
  362. ZLOGI(TAG, "xianlajin_duoji_tight_line_pos %d", cfg.xianlajin_duoji_tight_line_pos);
  363. ZLOGI(TAG, "xianlajin_duoji_loose_line_pos %d", cfg.xianlajin_duoji_loose_line_pos);
  364. ZLOGI(TAG, "jiaxian_duoji_reset_pos %d", cfg.jiaxian_duoji_reset_pos);
  365. ZLOGI(TAG, "jiaxian_duoji_clamp_pos %d", cfg.jiaxian_duoji_clamp_pos);
  366. ZLOGI(TAG, "jiaxian_duoji_clamp_torque %d", cfg.jiaxian_duoji_clamp_torque);
  367. ZLOGI(TAG, "arm_jiaxian_duoji_reset_pos %d", cfg.arm_jiaxian_duoji_reset_pos);
  368. ZLOGI(TAG, "arm_jiaxian_duoji_clamp_pos %d", cfg.arm_jiaxian_duoji_clamp_pos);
  369. ZLOGI(TAG, "arm_jiaxian_duoji_clamp_torque %d", cfg.arm_jiaxian_duoji_clamp_torque);
  370. ZLOGI(TAG, "scissors_reset_pos %d", cfg.scissors_reset_pos);
  371. ZLOGI(TAG, "scissors_cut_pos %d", cfg.scissors_cut_pos);
  372. ZLOGI(TAG, "arm_hook_claws_half_pos %d", cfg.arm_hook_claws_half_pos);
  373. ZLOGI(TAG, "arm_hook_claws_full_pos %d", cfg.arm_hook_claws_full_pos);
  374. #endif
  375. return 0;
  376. }
  377. #if 1
  378. int32_t IntelligentWindingRobotCtrl::initialize(ZModuleDeviceManager* dm, ICmdParser* cmdparse) {
  379. m_dm = dm;
  380. m_cmdparse = cmdparse;
  381. cfg.xy_platform_takeline_clip00_pos_x = 1736;
  382. cfg.xy_platform_takeline_clip00_pos_y = 16853;
  383. cfg.xy_platform_takeline_clipXX_pos_x = 52307;
  384. cfg.xy_platform_takeline_clipXX_pos_y = 31993;
  385. cfg.clip_line = 12;
  386. cfg.clip_each_line_num = 5;
  387. cfg.arm_jiaxian_duoji_reset_pos = 2619;
  388. cfg.arm_jiaxian_duoji_clamp_torque = 330;
  389. cfg.arm_jiaxian_duoji_clamp_direction = -1;
  390. cfg.z_axis_take_clip_pos = 6924;
  391. cfg.arm_hook_claws_full_pos = 2458;
  392. cfg.arm_hook_claws_half_pos = 2294;
  393. regcb();
  394. return 0;
  395. }
  396. #endif
  397. #define PARAM int32_t paramN, const char **paraV, ICmdParserACK *ack
  398. void IntelligentWindingRobotCtrl::regcb() {
  399. // device_reset
  400. m_cmdparse->regCMD("device_reset", "()", 0, [this](PARAM) { return device_reset(); });
  401. m_cmdparse->regCMD("xy_run_to_clip_pos_test", "()", 1, [this](PARAM) { return xy_run_to_clip_pos_test(atoi(paraV[0])); });
  402. m_cmdparse->regCMD("disable_all_motor", "()", 0, [this](PARAM) { return disable_all_motor(); });
  403. #if 0
  404. m_cmdparse->regCMD("app_paifei_duoji_moveto_reset", "()", 0, [this](PARAM) { return paifei_duoji_moveto_reset(); });
  405. m_cmdparse->regCMD("app_paifei_duoji_moveto_press", "()", 0, [this](PARAM) { return paifei_duoji_moveto_press(); });
  406. m_cmdparse->regCMD("app_raoxiantance_duoji_move_to_reset", "()", 0, [this](PARAM) { return raoxiantance_duoji_move_to_reset(); });
  407. m_cmdparse->regCMD("app_raoxiantance_duoji_move_to_get_thickness", "()", 0, [this](PARAM) {
  408. int32_t thickness = 0;
  409. int32_t err = raoxiantance_duoji_move_to_get_thickness(ack->getAck(1));
  410. ack->acktype = ICmdParserACK::kAckType_int32;
  411. ack->rawlen = sizeof(int32_t);
  412. });
  413. m_cmdparse->regCMD("app_yaxian_duoji_move_to_reset", "()", 0, [this](PARAM) { return yaxian_duoji_move_to_reset(); });
  414. m_cmdparse->regCMD("app_yaxian_duoji_move_to_press_pos", "()", 0, [this](PARAM) { return yaxian_duoji_move_to_press_pos(); });
  415. m_cmdparse->regCMD("app_yaxian_duoji_move_to_wait_for_press_pos", "()", 0, [this](PARAM) { return yaxian_duoji_move_to_wait_for_press_pos(); });
  416. m_cmdparse->regCMD("app_xianlajin_duoji_move_to_reset", "()", 0, [this](PARAM) { return xianlajin_duoji_move_to_reset(); });
  417. m_cmdparse->regCMD("app_xianlajin_duoji_move_to_line_entry_pos", "()", 0, [this](PARAM) { return xianlajin_duoji_move_to_line_entry_pos(); });
  418. m_cmdparse->regCMD("app_xianlajin_duoji_move_to_tight_line_pos", "()", 0, [this](PARAM) { return xianlajin_duoji_move_to_tight_line_pos(); });
  419. m_cmdparse->regCMD("app_xianlajin_duoji_move_to_loose_line_pos", "()", 0, [this](PARAM) { return xianlajin_duoji_move_to_loose_line_pos(); });
  420. m_cmdparse->regCMD("app_jiaxian_duoji_move_to_reset_pos", "()", 0, [this](PARAM) { return jiaxian_duoji_move_to_reset_pos(); });
  421. m_cmdparse->regCMD("app_jiaxian_duoji_move_to_clamp_pos", "()", 0, [this](PARAM) { return jiaxian_duoji_move_to_clamp_pos(); });
  422. m_cmdparse->regCMD("app_scissors_move_reset_pos", "()", 0, [this](PARAM) { return scissors_move_reset_pos(); });
  423. m_cmdparse->regCMD("app_scissors_cut", "()", 0, [this](PARAM) { return scissors_cut(); });
  424. m_cmdparse->regCMD("app_arm_jiaxian_duoji_move_to_reset_pos", "()", 0, [this](PARAM) { return arm_jiaxian_duoji_move_to_reset_pos(); });
  425. m_cmdparse->regCMD("app_arm_jiaxian_duoji_move_to_clamp_pos", "()", 0, [this](PARAM) { return arm_jiaxian_duoji_move_to_clamp_pos(); });
  426. m_cmdparse->regCMD("app_arm_hook_claws_reset", "()", 0, [this](PARAM) { return arm_hook_claws_reset(); });
  427. m_cmdparse->regCMD("app_arm_hook_claws_move_to_half_pos", "()", 0, [this](PARAM) { return arm_hook_claws_move_to_half_pos(); });
  428. m_cmdparse->regCMD("app_arm_hook_claws_move_to_full_pos", "()", 0, [this](PARAM) { return arm_hook_claws_move_to_full_pos(); });
  429. m_cmdparse->regCMD("app_main_shaft_run", "()", 0, [this](PARAM) { return main_shaft_run(); });
  430. m_cmdparse->regCMD("app_main_shaft_stop", "()", 0, [this](PARAM) { return main_shaft_stop(); });
  431. m_cmdparse->regCMD("app_xy_platform_reset", "()", 0, [this](PARAM) { return xy_platform_reset(); });
  432. m_cmdparse->regCMD("app_z_axis_reset", "()", 0, [this](PARAM) { return z_axis_reset(); });
  433. m_cmdparse->regCMD("app_z_axis_move_to", "(int32_t pos)", 1, [this](PARAM) { return z_axis_move_to(atoi(paraV[0])); });
  434. m_cmdparse->regCMD("app_xy_reset", "()", 0, [this](PARAM) { return xy_reset(); });
  435. m_cmdparse->regCMD("app_xy_move_to_zero", "()", 0, [this](PARAM) { return xy_move_to_zero(); });
  436. m_cmdparse->regCMD("app_xy_take_clip", "(int32_t index)", 1, [this](PARAM) { return xy_take_clip(atoi(paraV[0])); });
  437. m_cmdparse->regCMD("app_xy_take_line", "()", 0, [this](PARAM) { return xy_take_line(); });
  438. m_cmdparse->regCMD("app_xy_take_back_clip", "()", 0, [this](PARAM) { return xy_take_back_clip(); });
  439. m_cmdparse->regCMD("app_xy_remove_line", "()", 0, [this](PARAM) { return xy_remove_line(); });
  440. m_cmdparse->regCMD("app_start_winding", "()", 0, [this](PARAM) { return start_winding(); });
  441. m_cmdparse->regCMD("app_stop_winding", "()", 0, [this](PARAM) { return stop_winding(); });
  442. m_cmdparse->regCMD("app_reset_and_check_device", "()", 0, [this](PARAM) { return reset_and_check_device(); });
  443. m_cmdparse->regCMD("app_setcfg", "(const char* cfgname, int32_t cfgvalue)", 2, [this](PARAM) { return setcfg(paraV[0], atoi(paraV[1])); });
  444. m_cmdparse->regCMD("app_dumpcfg", "()", 0, [this](PARAM) { return dumpcfg(); });
  445. #endif
  446. }