正点原子开发板 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.

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