|
|
@ -80,8 +80,13 @@ int32_t IntelligentWindingRobotCtrl::initialize_device() { |
|
|
|
void IntelligentWindingRobotCtrl::regcb() { |
|
|
|
// device_reset
|
|
|
|
m_cmdparse->regCMD("device_reset", "()", 0, [this](PARAM) { device_reset(); }); |
|
|
|
m_cmdparse->regCMD("enable_all_module", "()", 0, [this](PARAM) { enable_all_module(); }); |
|
|
|
m_cmdparse->regCMD("disable_all_module", "()", 0, [this](PARAM) { disable_all_module(); }); |
|
|
|
m_cmdparse->regCMD("xy_run_to_clip_pos_test", "()", 1, [this](PARAM) { return xy_run_to_clip_pos_test(atoi(paraV[0])); }); |
|
|
|
m_cmdparse->regCMD("disable_all_motor", "()", 0, [this](PARAM) { return disable_all_motor(); }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// m_cmdparse->regCMD("disable_all_motor", "()", 0, [this](PARAM) { return disable_all_motor(); });
|
|
|
|
|
|
|
|
m_cmdparse->regCMD("app_m11_arm_jiaxian_move_to_reset_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_reset_pos(); }); |
|
|
|
m_cmdparse->regCMD("app_m11_arm_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_clamp_pos(); }); |
|
|
@ -136,36 +141,101 @@ void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void IntelligentWindingRobotCtrl::wait_modules_idle(...) { |
|
|
|
void IntelligentWindingRobotCtrl::wait_modules_idle(void* mark, ...) { |
|
|
|
int32_t moduleid = 0; |
|
|
|
va_list args; |
|
|
|
va_start(args, moduleid); |
|
|
|
while (moduleid != -1) { |
|
|
|
va_start(args, mark); |
|
|
|
moduleid = va_arg(args, int32_t); |
|
|
|
while (moduleid > 0) { |
|
|
|
wait_module_idle(moduleid); |
|
|
|
moduleid = va_arg(args, int32_t); |
|
|
|
} |
|
|
|
va_end(args); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::disable_all_module() { |
|
|
|
m_dm->motor_enable(2, 0); |
|
|
|
m_dm->xymotor_enable(3, 0); |
|
|
|
m_dm->motor_enable(4, 0); |
|
|
|
m_dm->motor_enable(11, 0); |
|
|
|
m_dm->motor_enable(12, 0); |
|
|
|
m_dm->motor_enable(13, 0); |
|
|
|
m_dm->motor_enable(14, 0); |
|
|
|
m_dm->motor_enable(15, 0); |
|
|
|
m_dm->motor_enable(16, 0); |
|
|
|
|
|
|
|
m_dm->motor_enable(21, 0); |
|
|
|
m_dm->motor_enable(22, 0); |
|
|
|
m_dm->motor_enable(23, 0); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t IntelligentWindingRobotCtrl::enable_all_module() { |
|
|
|
m_dm->motor_enable(2, 1); |
|
|
|
m_dm->xymotor_enable(3, 1); |
|
|
|
m_dm->motor_enable(4, 1); |
|
|
|
m_dm->motor_enable(11, 1); |
|
|
|
m_dm->motor_enable(12, 1); |
|
|
|
m_dm->motor_enable(13, 1); |
|
|
|
m_dm->motor_enable(14, 1); |
|
|
|
m_dm->motor_enable(15, 1); |
|
|
|
m_dm->motor_enable(16, 1); |
|
|
|
|
|
|
|
m_dm->motor_enable(21, 1); |
|
|
|
m_dm->motor_enable(22, 1); |
|
|
|
m_dm->motor_enable(23, 1); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
#define WAIT_MODULES_IDLE(...) \
|
|
|
|
{ wait_modules_idle(NULL, __VA_ARGS__, NULL); } |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::device_reset() { |
|
|
|
// Z轴复位
|
|
|
|
zreset(); |
|
|
|
m21_arm_hook_claws_reset(); |
|
|
|
/**
|
|
|
|
* @ |
|
|
|
* |
|
|
|
* 1. Z轴及其组件复位 |
|
|
|
* 2. 除了M13外,其他电机复位 |
|
|
|
* 3. M13复位,等待一定时间,查看M13是否复位成功 |
|
|
|
* 4. 机械臂复位 |
|
|
|
*/ |
|
|
|
|
|
|
|
enable_all_module(); |
|
|
|
m4_zreset(); |
|
|
|
m11_arm_jiaxian_move_to_reset_pos(); |
|
|
|
xy_reset(); |
|
|
|
m21_arm_hook_claws_reset(); |
|
|
|
WAIT_MODULES_IDLE(4, 11, 21); |
|
|
|
|
|
|
|
m12_jiaxian_move_to_reset_pos(); |
|
|
|
m14_raoxiantance_move_to_reset(); |
|
|
|
m15_paifei_moveto_reset(); |
|
|
|
m16_xianlajin_move_to_reset(); |
|
|
|
m22_scissors_move_reset_pos(); |
|
|
|
m23_laxian_motor_move_to_reset_pos(); |
|
|
|
WAIT_MODULES_IDLE(12, 14, 15, 16, 22, 23); |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 优化复位逻辑,超时复位失败,报警 |
|
|
|
*/ |
|
|
|
m13_yaxian_move_to_reset_backward(); |
|
|
|
wait_module_idle(13); |
|
|
|
|
|
|
|
m_dm->xymotor_move_to_zero(XYRobot_ID); |
|
|
|
wait_module_idle(XYRobot_ID); |
|
|
|
|
|
|
|
ZLOGI(TAG, "device_reset finished...."); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::m11_arm_jiaxian_move_to_reset_pos() { return m_dm->motor_move_to(11, cfg.m11_arm_jiaxian_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m11_arm_jiaxian_move_to_clamp_pos() { return m_dm->motor_move_to_with_torque(11, cfg.m11_arm_jiaxian_clamp_direction, cfg.m11_arm_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m11_arm_jiaxian_move_to_clamp_pos() { return m_dm->motor_rotate_with_torque(11, cfg.m11_arm_jiaxian_clamp_direction, cfg.m11_arm_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m12_jiaxian_move_to_reset_pos() { return m_dm->motor_move_to(12, cfg.m12_jiaxian_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m12_jiaxian_move_to_clamp_pos() { return m_dm->motor_move_to_with_torque(12, cfg.m12_jiaxian_clamp_direction, cfg.m12_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m12_jiaxian_move_to_clamp_pos() { return m_dm->motor_rotate_with_torque(12, cfg.m12_jiaxian_clamp_direction, cfg.m12_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m13_yaxian_move_to_reset_forward() { return m_dm->motor_move_to(13, cfg.m13_yaxian_forward_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m13_yaxian_move_to_reset_backward() { return m_dm->motor_move_to(13, cfg.m13_yaxian_backward_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m13_yaxian_press_clip() { return m_dm->motor_move_to_with_torque(13, cfg.m13_jiaxian_clamp_direction, cfg.m13_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m13_yaxian_press_clip() { return m_dm->motor_rotate_with_torque(13, cfg.m13_jiaxian_clamp_direction, cfg.m13_jiaxian_clamp_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m14_raoxiantance_move_to_reset() { return m_dm->motor_move_to(14, cfg.m14_raoxiantance_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m15_paifei_moveto_reset() { return m_dm->motor_move_to(15, cfg.m15_paifei_reset_pos, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m15_paifei_moveto_press() { return m_dm->motor_move_to_with_torque(15, cfg.m15_paifei_press_direction, cfg.m15_paifei_press_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m15_paifei_moveto_press() { return m_dm->motor_rotate_with_torque(15, cfg.m15_paifei_press_direction, cfg.m15_paifei_press_torque); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_reset() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_reset_pos, 300, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_tight_line_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_tight_line_pos, 100, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_winding_low_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_winding_low_pos, 100, 0); } |
|
|
@ -175,9 +245,23 @@ int32_t IntelligentWindingRobotCtrl::m21_arm_hook_claws_reset() { return m_dm->m |
|
|
|
int32_t IntelligentWindingRobotCtrl::m21_arm_hook_claws_move_to_half_pos() { return m_dm->motor_move_to(21, cfg.m21_arm_hook_claws_half_pos, 0, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m21_arm_hook_claws_move_to_full_pos() { return m_dm->motor_move_to(21, cfg.m21_arm_hook_claws_full_pos, 0, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m22_scissors_move_reset_pos() { return 0; } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m22_scissors_cut() { return m_dm->motor_move_to_with_torque(22, 1, 4095); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m22_scissors_cut() { return m_dm->motor_rotate_with_torque(22, 1, 4095); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m23_laxian_motor_move_to_reset_pos() { return m_dm->motor_move_to_zero_backward(23, 0, 0, 0, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m23_laxian_motor_move_to_tight_line_pos() { return m_dm->motor_move_to(23, 500, 0, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m4_zreset() { m_dm->motor_move_to_zero_backward(4, 450, 300, 2000, 0); } |
|
|
|
int32_t IntelligentWindingRobotCtrl::m4_zmove_to(int32_t pos) { |
|
|
|
ZLOGI(TAG, "zmove_to %d", pos); |
|
|
|
int32_t nowpos = 0; |
|
|
|
m_dm->motor_read_pos(ZMOTOR_ID, &nowpos); |
|
|
|
if (pos >= nowpos) { |
|
|
|
m_dm->motor_move_to(ZMOTOR_ID, pos, 450, 600); |
|
|
|
} else { |
|
|
|
m_dm->motor_move_to(ZMOTOR_ID, pos, 1000, 600); |
|
|
|
} |
|
|
|
if (pos == 0) { |
|
|
|
m4_zreset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::main_shaft_run() { |
|
|
|
ZLOGI(TAG, "main_shaft_run"); |
|
|
@ -214,26 +298,7 @@ int32_t IntelligentWindingRobotCtrl::start_winding() { return 0; } |
|
|
|
int32_t IntelligentWindingRobotCtrl::stop_winding() { return 0; } |
|
|
|
int32_t IntelligentWindingRobotCtrl::reset_and_check_device() { return 0; } |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::disable_all_motor() { |
|
|
|
m_dm->motor_enable(2, 0); |
|
|
|
m_dm->xymotor_enable(XYRobot_ID, 0); |
|
|
|
m_dm->motor_enable(11, 0); |
|
|
|
m_dm->motor_enable(12, 0); |
|
|
|
m_dm->motor_enable(13, 0); |
|
|
|
m_dm->motor_enable(14, 0); |
|
|
|
m_dm->motor_enable(15, 0); |
|
|
|
m_dm->motor_enable(16, 0); |
|
|
|
|
|
|
|
m_dm->motor_enable(21, 0); |
|
|
|
m_dm->motor_enable(22, 0); |
|
|
|
m_dm->motor_enable(23, 0); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::xy_get_point(int32_t clip_index, int32_t& x, int32_t& y) { |
|
|
|
// x = 0;
|
|
|
|
// y = 0;
|
|
|
|
|
|
|
|
int clip_x_off = clip_index / cfg.clip_each_line_num; |
|
|
|
int clip_y_off = clip_index % cfg.clip_each_line_num; |
|
|
|
|
|
|
@ -245,6 +310,8 @@ int32_t IntelligentWindingRobotCtrl::xy_get_point(int32_t clip_index, int32_t& x |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
#if 0
|
|
|
|
int32_t IntelligentWindingRobotCtrl::zmove_to(int32_t pos) { |
|
|
|
ZLOGI(TAG, "zmove_to %d", pos); |
|
|
|
int32_t nowpos = 0; |
|
|
@ -264,10 +331,10 @@ int32_t IntelligentWindingRobotCtrl::zmove_to(int32_t pos) { |
|
|
|
int32_t IntelligentWindingRobotCtrl::zreset() { |
|
|
|
ZLOGI(TAG, "zreset"); |
|
|
|
m_dm->motor_enable(ZMOTOR_ID, 1); |
|
|
|
m_dm->motor_move_to_zero_backward(4, 450, 300, 2000, 0); |
|
|
|
wait_module_idle(ZMOTOR_ID); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::xymove_to(int32_t x, int32_t y) { |
|
|
|
ZLOGI(TAG, "xymove_to %d %d", x, y); |
|
|
@ -283,6 +350,7 @@ int32_t IntelligentWindingRobotCtrl::xy_reset() { |
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::xy_run_to_clip_pos_test(int32_t clip_index) { |
|
|
|
#if 0
|
|
|
|
ZLOGI(TAG, "xy_run_to_clip_pos_test %d", clip_index); |
|
|
|
if (clip_index >= cfg.clip_line * cfg.clip_each_line_num) { |
|
|
|
ZLOGE(TAG, "clip_index %d out of range", clip_index); |
|
|
@ -303,6 +371,7 @@ int32_t IntelligentWindingRobotCtrl::xy_run_to_clip_pos_test(int32_t clip_index) |
|
|
|
zmove_to(cfg.z_axis_take_clip_pos); |
|
|
|
m21_arm_hook_claws_reset(); |
|
|
|
zmove_to(0); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
int32_t IntelligentWindingRobotCtrl::setcfg(const char* cfgname, int32_t cfgvalue) { |
|
|
|