Browse Source

update

master
zhaohe 2 years ago
parent
commit
09830efe39
  1. 5
      README.md
  2. 157
      usrc/intelligent_winding_robot_ctrl.cpp
  3. 19
      usrc/intelligent_winding_robot_ctrl.hpp
  4. 4
      usrc/main.cpp

5
README.md

@ -169,6 +169,11 @@ step_winding_lineend_prepare 1
step_winding_lineend step_winding_lineend
step_winding_take_bullet_from_cooking_to_origin_pos 1 step_winding_take_bullet_from_cooking_to_origin_pos 1
¸¨Öú
step_take_back_bullet 1
``` ```
``` ```

157
usrc/intelligent_winding_robot_ctrl.cpp

@ -90,8 +90,12 @@ class WidthDetector {
m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 30, 0); m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 30, 0);
g_isrunning = true; g_isrunning = true;
} }
void start_run_forward_slow() {
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 30, 0);
g_isrunning = true;
}
void start_run_forward() { void start_run_forward() {
m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 330, 0);
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 330, 0);
g_isrunning = true; g_isrunning = true;
} }
void stop_run() { void stop_run() {
@ -99,7 +103,7 @@ class WidthDetector {
g_isrunning = false; g_isrunning = false;
} }
void startDetect() {
void startDetect(bool forward = false) {
m_detect_thread.stop(); m_detect_thread.stop();
m14_raoxiantance_move_to_reset(); m14_raoxiantance_move_to_reset();
wait_module_idle(14); wait_module_idle(14);
@ -137,17 +141,31 @@ class WidthDetector {
zos_delay(3); zos_delay(3);
} }
m_detect_thread.start([this]() {
while (!m_detect_thread.getExitFlag()) {
if (g_isrunning && getDetectGPIOState() == 0) {
stop_run();
m_dm->motor_read_pos(14, &g_nowpos);
g_nowdpos = cfg->m14_raoxiantance_tance_zero_pos - g_nowpos;
ZLOGI(TAG, "--------------now pos %d bullet width %d", g_nowpos, g_nowdpos);
} else if (!g_isrunning && getDetectGPIOState() != 0) {
start_run_back();
m_detect_thread.start([this, forward]() {
if (!forward) {
while (!m_detect_thread.getExitFlag()) {
if (g_isrunning && getDetectGPIOState() == 0) {
stop_run();
m_dm->motor_read_pos(14, &g_nowpos);
g_nowdpos = cfg->m14_raoxiantance_tance_zero_pos - g_nowpos;
ZLOGI(TAG, "--------------now pos %d bullet width %d", g_nowpos, g_nowdpos);
} else if (!g_isrunning && getDetectGPIOState() != 0) {
start_run_back();
}
zos_delay(3);
}
} else {
while (!m_detect_thread.getExitFlag()) {
if (g_isrunning && getDetectGPIOState() != 0) {
stop_run();
m_dm->motor_read_pos(14, &g_nowpos);
g_nowdpos = cfg->m14_raoxiantance_tance_zero_pos - g_nowpos;
ZLOGI(TAG, "--------------now pos %d bullet width %d", g_nowpos, g_nowdpos);
} else if (!g_isrunning && getDetectGPIOState() == 0) {
start_run_forward_slow();
}
zos_delay(3);
} }
zos_delay(3);
} }
}); });
} }
@ -178,10 +196,10 @@ int32_t IntelligentWindingRobotCtrl::initialize(APPDM* dm, ICmdParser* cmdparse)
} }
int32_t IntelligentWindingRobotCtrl::initialize_device() { int32_t IntelligentWindingRobotCtrl::initialize_device() {
cfg.xy_platform_takeline_clip00_pos_x = 1736;
cfg.xy_platform_takeline_clip00_pos_y = 16853;
cfg.xy_platform_takeline_clipXX_pos_x = 52307;
cfg.xy_platform_takeline_clipXX_pos_y = 31993;
cfg.xy_platform_takeline_clip00_pos_x = 1833;
cfg.xy_platform_takeline_clip00_pos_y = 16819;
cfg.xy_platform_takeline_clipXX_pos_x = 52381;
cfg.xy_platform_takeline_clipXX_pos_y = 32087;
cfg.clip_line = 12; cfg.clip_line = 12;
cfg.clip_each_line_num = 5; cfg.clip_each_line_num = 5;
@ -196,7 +214,7 @@ int32_t IntelligentWindingRobotCtrl::initialize_device() {
cfg.m13_yaxian_forward_reset_pos = 1015; cfg.m13_yaxian_forward_reset_pos = 1015;
cfg.m13_yaxian_backward_reset_pos = 2885; cfg.m13_yaxian_backward_reset_pos = 2885;
cfg.m13_jiaxian_clamp_direction = -1; cfg.m13_jiaxian_clamp_direction = -1;
cfg.m13_jiaxian_clamp_torque = 500;
cfg.m13_jiaxian_clamp_torque = 600;
cfg.m14_raoxiantance_reset_pos = 2047; cfg.m14_raoxiantance_reset_pos = 2047;
cfg.m14_raoxiantance_tance_zero_pos = 2829; cfg.m14_raoxiantance_tance_zero_pos = 2829;
@ -205,13 +223,14 @@ int32_t IntelligentWindingRobotCtrl::initialize_device() {
cfg.m15_paifei_press_direction = 1; cfg.m15_paifei_press_direction = 1;
cfg.m15_paifei_press_torque = 330; cfg.m15_paifei_press_torque = 330;
cfg.m16_xianlajin_reset_pos = 2047;
cfg.m16_xianlajin_tight_line_pos = 1966;
cfg.m16_xianlajin_winding_low_pos = 1885;
cfg.m16_xianlajin_winding_high_pos = 1835;
cfg.m16_xianlajin_line_entry_pos = 1800;
cfg.m16_xianlajin_cook_line_end_low_pos = 1820;
cfg.m16_xianlajin_cook_line_end_high_pos = 1741;
cfg.m16_xianlajin_reset_pos = 2047;
cfg.m16_xianlajin_cook_line_end_ready_pos = 1959;
cfg.m16_xianlajin_tight_line_pos = 1966;
cfg.m16_xianlajin_winding_low_pos = 1885;
cfg.m16_xianlajin_winding_high_pos = 1815;
cfg.m16_xianlajin_line_entry_pos = 1800;
cfg.m16_xianlajin_cook_line_end_low_pos = 1820;
cfg.m16_xianlajin_cook_line_end_high_pos = 1741;
cfg.m21_arm_hook_claws_full_pos = 2558; cfg.m21_arm_hook_claws_full_pos = 2558;
cfg.m21_arm_hook_claws_half_pos = 2194; cfg.m21_arm_hook_claws_half_pos = 2194;
@ -259,31 +278,35 @@ void IntelligentWindingRobotCtrl::regcb() {
// 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(); });
m_cmdparse->regCMD("app_m12_jiaxian_move_to_open_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_open_pos(); });
m_cmdparse->regCMD("app_m12_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_clamp_pos(); });
m_cmdparse->regCMD("app_m13_yaxian_move_to_reset_forward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_forward(); });
m_cmdparse->regCMD("app_m13_yaxian_move_to_reset_backward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_backward(); });
m_cmdparse->regCMD("app_m13_yaxian_press_clip", "()", 0, [this](PARAM) { return m13_yaxian_press_clip(); });
m_cmdparse->regCMD("app_m14_raoxiantance_move_to_reset", "()", 0, [this](PARAM) { return m14_raoxiantance_move_to_reset(); });
m_cmdparse->regCMD("app_m15_paifei_moveto_reset", "()", 0, [this](PARAM) { return m15_paifei_moveto_reset(); });
m_cmdparse->regCMD("app_m15_paifei_moveto_press", "()", 0, [this](PARAM) { return m15_paifei_moveto_press(); });
m_cmdparse->regCMD("app_m16_xianlajin_move_to_reset", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_reset(); });
m_cmdparse->regCMD("app_m16_xianlajin_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_tight_line_pos(); });
m_cmdparse->regCMD("app_m16_xianlajin_move_to_winding_low_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_low_pos(); });
m_cmdparse->regCMD("app_m16_xianlajin_move_to_winding_up_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_up_pos(); });
m_cmdparse->regCMD("app_m16_xianlajin_move_to_line_entry_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_line_entry_pos(); });
m_cmdparse->regCMD("app_m21_arm_hook_claws_reset", "()", 0, [this](PARAM) { return m21_arm_hook_claws_reset(); });
m_cmdparse->regCMD("app_m21_arm_hook_claws_move_to_half_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_half_pos(); });
m_cmdparse->regCMD("app_m21_arm_hook_claws_move_to_full_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_full_pos(); });
m_cmdparse->regCMD("app_m22_scissors_move_reset_pos", "()", 0, [this](PARAM) { return m22_scissors_move_reset_pos(); });
m_cmdparse->regCMD("app_m22_scissors_cut", "()", 0, [this](PARAM) { return m22_scissors_cut(); });
m_cmdparse->regCMD("app_m23_laxian_motor_move_to_reset_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_reset_pos(); });
m_cmdparse->regCMD("app_m23_laxian_motor_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_tight_line_pos(); });
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_reset_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_reset_pos(); });
m_cmdparse->regCMD("m11_arm_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m11_arm_jiaxian_move_to_clamp_pos(); });
m_cmdparse->regCMD("m12_jiaxian_move_to_open_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_open_pos(); });
m_cmdparse->regCMD("m12_jiaxian_move_to_clamp_pos", "()", 0, [this](PARAM) { return m12_jiaxian_move_to_clamp_pos(); });
m_cmdparse->regCMD("m13_yaxian_move_to_reset_forward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_forward(); });
m_cmdparse->regCMD("m13_yaxian_move_to_reset_backward", "()", 0, [this](PARAM) { return m13_yaxian_move_to_reset_backward(); });
m_cmdparse->regCMD("m13_yaxian_press_clip", "()", 0, [this](PARAM) { return m13_yaxian_press_clip(); });
m_cmdparse->regCMD("m14_raoxiantance_move_to_reset", "()", 0, [this](PARAM) { return m14_raoxiantance_move_to_reset(); });
m_cmdparse->regCMD("m15_paifei_moveto_reset", "()", 0, [this](PARAM) { return m15_paifei_moveto_reset(); });
m_cmdparse->regCMD("m15_paifei_moveto_press", "()", 0, [this](PARAM) { return m15_paifei_moveto_press(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_reset", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_reset(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_tight_line_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_low_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_low_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_winding_up_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_winding_up_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_line_entry_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_line_entry_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_high_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_high_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_low_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_low_pos(); });
m_cmdparse->regCMD("m16_xianlajin_move_to_cook_lineend_ready_pos", "()", 0, [this](PARAM) { return m16_xianlajin_move_to_cook_lineend_ready_pos(); });
m_cmdparse->regCMD("m21_arm_hook_claws_reset", "()", 0, [this](PARAM) { return m21_arm_hook_claws_reset(); });
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_half_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_half_pos(); });
m_cmdparse->regCMD("m21_arm_hook_claws_move_to_full_pos", "()", 0, [this](PARAM) { return m21_arm_hook_claws_move_to_full_pos(); });
m_cmdparse->regCMD("m22_scissors_move_reset_pos", "()", 0, [this](PARAM) { return m22_scissors_move_reset_pos(); });
m_cmdparse->regCMD("m22_scissors_cut", "()", 0, [this](PARAM) { return m22_scissors_cut(); });
m_cmdparse->regCMD("m23_laxian_motor_move_to_reset_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_reset_pos(); });
m_cmdparse->regCMD("m23_laxian_motor_move_to_tight_line_pos", "()", 0, [this](PARAM) { return m23_laxian_motor_move_to_tight_line_pos(); });
m_cmdparse->regCMD("start_probe_bullet_pos", "()", 0, [this](PARAM) { return start_probe_bullet_pos(); }); m_cmdparse->regCMD("start_probe_bullet_pos", "()", 0, [this](PARAM) { return start_probe_bullet_pos(); });
m_cmdparse->regCMD("start_probe_bullet_pos_forward", "()", 0, [this](PARAM) { return start_probe_bullet_pos_forward(); });
} }
void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid) { void IntelligentWindingRobotCtrl::wait_module_idle(int32_t moduleid) {
@ -386,7 +409,7 @@ int32_t IntelligentWindingRobotCtrl::device_reset() {
* 3. M13复位,M13是否复位成功 * 3. M13复位,M13是否复位成功
* 4. * 4.
*/ */
m_dm->module_stop(2);
enable_all_module(); enable_all_module();
m4_zreset(); m4_zreset();
m11_arm_jiaxian_move_to_reset_pos(); m11_arm_jiaxian_move_to_reset_pos();
@ -420,6 +443,7 @@ int32_t IntelligentWindingRobotCtrl::device_reset() {
bool IntelligentWindingRobotCtrl::is_hasbullet() { return g_widthDetector.isHasBullet(); } bool IntelligentWindingRobotCtrl::is_hasbullet() { return g_widthDetector.isHasBullet(); }
void IntelligentWindingRobotCtrl::start_probe_bullet_pos() { g_widthDetector.startDetect(); } void IntelligentWindingRobotCtrl::start_probe_bullet_pos() { g_widthDetector.startDetect(); }
void IntelligentWindingRobotCtrl::start_probe_bullet_pos_forward() { g_widthDetector.startDetect(true); }
void IntelligentWindingRobotCtrl::stop_probe_bullet_pos() { g_widthDetector.stopDetect(); } void IntelligentWindingRobotCtrl::stop_probe_bullet_pos() { g_widthDetector.stopDetect(); }
int32_t IntelligentWindingRobotCtrl::m11_arm_jiaxian_move_to_reset_pos() { return m_dm->motor_move_to_torque(11, cfg.m11_arm_jiaxian_reset_pos, 330, 0); } int32_t IntelligentWindingRobotCtrl::m11_arm_jiaxian_move_to_reset_pos() { return m_dm->motor_move_to_torque(11, cfg.m11_arm_jiaxian_reset_pos, 330, 0); }
@ -440,6 +464,7 @@ int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_line_entry_pos() { re
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_cook_lineend_high_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_cook_line_end_high_pos, 300, 0); } int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_cook_lineend_high_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_cook_line_end_high_pos, 300, 0); }
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_cook_lineend_low_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_cook_line_end_low_pos, 300, 0); } int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_cook_lineend_low_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_cook_line_end_low_pos, 300, 0); }
int32_t IntelligentWindingRobotCtrl::m16_xianlajin_move_to_cook_lineend_ready_pos() { return m_dm->motor_move_to(16, cfg.m16_xianlajin_cook_line_end_ready_pos, 300, 0); }
int32_t IntelligentWindingRobotCtrl::m21_arm_hook_claws_reset() { return m_dm->motor_move_to_zero_backward(21, 0, 0, 0, 0); } int32_t IntelligentWindingRobotCtrl::m21_arm_hook_claws_reset() { return m_dm->motor_move_to_zero_backward(21, 0, 0, 0, 0); }
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_half_pos() { return m_dm->motor_move_to(21, cfg.m21_arm_hook_claws_half_pos, 0, 0); }
@ -631,22 +656,27 @@ int32_t IntelligentWindingRobotCtrl::step_prepare_remove_line(int32_t bulletinde
int32_t IntelligentWindingRobotCtrl::step_remove_line() { int32_t IntelligentWindingRobotCtrl::step_remove_line() {
ZLOGI(TAG, "step_remove_line"); ZLOGI(TAG, "step_remove_line");
start_probe_bullet_pos();
start_probe_bullet_pos_forward();
m15_paifei_moveto_press(); m15_paifei_moveto_press();
WAIT_MODULES_IDLE(15); WAIT_MODULES_IDLE(15);
m_dm->motor_rotate_acctime(2, -1, 1000, 1000); m_dm->motor_rotate_acctime(2, -1, 1000, 1000);
/**
* @TODO:线
*/
for (size_t i = 0; i < 10; i++) {
int overtime = 90;
for (int i = 0; i < overtime; i++) {
osDelay(1000); osDelay(1000);
if (g_widthDetector.isRemoveLineEnd()) {
ZLOGI(TAG, "detect remove line end");
break;
}
if (i == overtime - 1) {
ZLOGI(TAG, "detect remove line end timeout");
}
} }
osDelay(5000);
m_dm->module_stop(2); m_dm->module_stop(2);
stop_probe_bullet_pos();
// m15_paifei_moveto_reset(); // m15_paifei_moveto_reset();
m15_paifei_moveto_reset(); m15_paifei_moveto_reset();
stop_probe_bullet_pos();
return 0; return 0;
} }
@ -699,17 +729,21 @@ int32_t IntelligentWindingRobotCtrl::step_winding_prepare() {
} }
int32_t IntelligentWindingRobotCtrl::step_winding() { int32_t IntelligentWindingRobotCtrl::step_winding() {
start_probe_bullet_pos();
m_dm->motor_rotate_acctime(2, 1, 1000, 10000); m_dm->motor_rotate_acctime(2, 1, 1000, 10000);
osDelay(1000); osDelay(1000);
m23_laxian_motor_move_to_reset_pos(); m23_laxian_motor_move_to_reset_pos();
for (size_t i = 0; i < 60; i++) {
for (size_t i = 0; i < 80; i++) { // TODO:60这里是个常量可能会造成绕线提前释放。
m16_xianlajin_move_to_winding_low_pos(); m16_xianlajin_move_to_winding_low_pos();
WAIT_MODULES_IDLE(16); WAIT_MODULES_IDLE(16);
m16_xianlajin_move_to_winding_up_pos(); m16_xianlajin_move_to_winding_up_pos();
WAIT_MODULES_IDLE(16); WAIT_MODULES_IDLE(16);
if (g_widthDetector.isFull()) {
break;
}
} }
m_dm->module_stop(2); m_dm->module_stop(2);
stop_probe_bullet_pos();
ZLOGI(TAG, "step_winding end...."); ZLOGI(TAG, "step_winding end....");
return 0; return 0;
} }
@ -734,6 +768,7 @@ int32_t IntelligentWindingRobotCtrl::step_winding_lineend_prepare(int bulletinde
xymove_to_bullet_pos(bulletindex); xymove_to_bullet_pos(bulletindex);
substep_zaxis_do_bullet_action(kBulletBulletHolderPos, kTakeBulletCase, kReleaseLine); substep_zaxis_do_bullet_action(kBulletBulletHolderPos, kTakeBulletCase, kReleaseLine);
xymove_to(cfg.xy_platform_cook_bullet_pos_x, cfg.xy_platform_cook_bullet_pos_y); xymove_to(cfg.xy_platform_cook_bullet_pos_x, cfg.xy_platform_cook_bullet_pos_y);
m16_xianlajin_move_to_tight_line_pos();
substep_zaxis_do_bullet_action(kCookPos, kTakeBackBullet, kReleaseLine); substep_zaxis_do_bullet_action(kCookPos, kTakeBackBullet, kReleaseLine);
return 0; return 0;
} }
@ -871,14 +906,18 @@ int32_t IntelligentWindingRobotCtrl::xy_reset() {
} }
int32_t IntelligentWindingRobotCtrl::setcfg(const char* cfgname, int32_t cfgvalue) { return 0; } int32_t IntelligentWindingRobotCtrl::setcfg(const char* cfgname, int32_t cfgvalue) { return 0; }
int32_t IntelligentWindingRobotCtrl::dumpcfg() { return 0; } int32_t IntelligentWindingRobotCtrl::dumpcfg() { return 0; }
int32_t IntelligentWindingRobotCtrl::start_winding() { // int32_t IntelligentWindingRobotCtrl::start_winding() { //
m_work_thread.start([this]() { m_work_thread.start([this]() {
try { try {
ZLOGI(TAG, "start_winding"); ZLOGI(TAG, "start_winding");
m_iswinding = true;
m_nowwinding_index = 0;
device_reset(); device_reset();
bool hasbullet = false; bool hasbullet = false;
for (size_t i = 0; i < 5 * 12; i++) { for (size_t i = 0; i < 5 * 12; i++) {
m_nowwinding_index = i + 1;
xymove_to(0, 0); xymove_to(0, 0);
step_take_bullet(i); step_take_bullet(i);
step_prepare_remove_line(i, hasbullet); step_prepare_remove_line(i, hasbullet);
@ -899,10 +938,12 @@ int32_t IntelligentWindingRobotCtrl::start_winding() { //
ZLOGE(TAG, "work thread catch unkown exception"); ZLOGE(TAG, "work thread catch unkown exception");
} }
disable_all_module(); // todo : 完成一个无异常版本 disable_all_module(); // todo : 完成一个无异常版本
m_iswinding = false;
}); });
return 0; return 0;
} }
int32_t IntelligentWindingRobotCtrl::stop_winding() { int32_t IntelligentWindingRobotCtrl::stop_winding() {
m_work_thread.stop(); m_work_thread.stop();
m_iswinding = false;
return 0; return 0;
} }

19
usrc/intelligent_winding_robot_ctrl.hpp

@ -68,6 +68,7 @@ class IntelligentWindingRobotCtrl {
int32_t m16_xianlajin_winding_low_pos; int32_t m16_xianlajin_winding_low_pos;
int32_t m16_xianlajin_winding_high_pos; int32_t m16_xianlajin_winding_high_pos;
int32_t m16_xianlajin_line_entry_pos; int32_t m16_xianlajin_line_entry_pos;
int32_t m16_xianlajin_cook_line_end_ready_pos;
int32_t m16_xianlajin_cook_line_end_high_pos; int32_t m16_xianlajin_cook_line_end_high_pos;
int32_t m16_xianlajin_cook_line_end_low_pos; int32_t m16_xianlajin_cook_line_end_low_pos;
@ -150,11 +151,21 @@ class IntelligentWindingRobotCtrl {
kKeepLine, kKeepLine,
} take_bullet_line_acktion_t; } take_bullet_line_acktion_t;
bool m_iswinding = false;
int32_t m_nowwinding_index = 0;
int32_t m_exception_val = 0;
typedef struct {
int32_t index;
} winding_event_t;
public: public:
int32_t initialize(APPDM* dm, ICmdParser* cmdparse); int32_t initialize(APPDM* dm, ICmdParser* cmdparse);
private: private:
void start_probe_bullet_pos();
void start_probe_bullet_pos();
void start_probe_bullet_pos_forward();
void stop_probe_bullet_pos(); void stop_probe_bullet_pos();
int32_t get_probe_bullet_pos(); int32_t get_probe_bullet_pos();
bool is_hasbullet(); bool is_hasbullet();
@ -173,6 +184,7 @@ class IntelligentWindingRobotCtrl {
int32_t m14_raoxiantance_move_to_reset(); int32_t m14_raoxiantance_move_to_reset();
int32_t m15_paifei_moveto_reset(); int32_t m15_paifei_moveto_reset();
int32_t m15_paifei_moveto_press(); int32_t m15_paifei_moveto_press();
int32_t m16_xianlajin_move_to_reset(); int32_t m16_xianlajin_move_to_reset();
int32_t m16_xianlajin_move_to_tight_line_pos(); int32_t m16_xianlajin_move_to_tight_line_pos();
int32_t m16_xianlajin_move_to_winding_low_pos(); int32_t m16_xianlajin_move_to_winding_low_pos();
@ -180,6 +192,8 @@ class IntelligentWindingRobotCtrl {
int32_t m16_xianlajin_move_to_line_entry_pos(); int32_t m16_xianlajin_move_to_line_entry_pos();
int32_t m16_xianlajin_move_to_cook_lineend_high_pos(); int32_t m16_xianlajin_move_to_cook_lineend_high_pos();
int32_t m16_xianlajin_move_to_cook_lineend_low_pos(); int32_t m16_xianlajin_move_to_cook_lineend_low_pos();
int32_t m16_xianlajin_move_to_cook_lineend_ready_pos();
int32_t m21_arm_hook_claws_reset(); int32_t m21_arm_hook_claws_reset();
int32_t m21_arm_hook_claws_move_to_half_pos(); int32_t m21_arm_hook_claws_move_to_half_pos();
@ -231,6 +245,9 @@ class IntelligentWindingRobotCtrl {
int32_t dumpcfg(); int32_t dumpcfg();
int32_t do_winding(int32_t index); int32_t do_winding(int32_t index);
int32_t get_winding_index() { return m_nowwinding_index; }
bool iswinding() { return m_iswinding; }
int32_t get_exception_val() { return m_exception_val; }
void processError(int32_t err); void processError(int32_t err);
}; };

4
usrc/main.cpp

@ -258,7 +258,7 @@ void Main::run() {
g_xyrobotctrlmodule.module_set_param(kcfg_motor_y_shift, 0); g_xyrobotctrlmodule.module_set_param(kcfg_motor_y_shift, 0);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_x_one_circle_pulse, 7344); g_xyrobotctrlmodule.module_set_param(kcfg_motor_x_one_circle_pulse, 7344);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_y_one_circle_pulse, 7344); g_xyrobotctrlmodule.module_set_param(kcfg_motor_y_one_circle_pulse, 7344);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_run_to_zero_speed, 50);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_run_to_zero_speed, 80);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_run_to_zero_dec, 1600); g_xyrobotctrlmodule.module_set_param(kcfg_motor_run_to_zero_dec, 1600);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_look_zero_edge_speed, 10); g_xyrobotctrlmodule.module_set_param(kcfg_motor_look_zero_edge_speed, 10);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_look_zero_edge_dec, 1600); g_xyrobotctrlmodule.module_set_param(kcfg_motor_look_zero_edge_dec, 1600);
@ -266,6 +266,7 @@ void Main::run() {
g_xyrobotctrlmodule.module_set_param(kcfg_motor_default_acc, 1000); g_xyrobotctrlmodule.module_set_param(kcfg_motor_default_acc, 1000);
g_xyrobotctrlmodule.module_set_param(kcfg_motor_default_dec, 1000); g_xyrobotctrlmodule.module_set_param(kcfg_motor_default_dec, 1000);
g_xyrobotctrlmodule.module_set_param(k_cfg_stepmotor_irun, 4); g_xyrobotctrlmodule.module_set_param(k_cfg_stepmotor_irun, 4);
g_xyrobotctrlmodule.module_active_cfg(); g_xyrobotctrlmodule.module_active_cfg();
g_z_step_motor.module_set_param(kcfg_motor_x_shift, 0); g_z_step_motor.module_set_param(kcfg_motor_x_shift, 0);
@ -300,6 +301,7 @@ void Main::run() {
*/ */
[this](const char* cmd, int32_t paramN, const char** paraV) { // [this](const char* cmd, int32_t paramN, const char** paraV) { //
ZLOGI(TAG, "process cmd:%s", cmd); ZLOGI(TAG, "process cmd:%s", cmd);
}, },
/** /**
* @brief ÌÕ¾§³ÛÏûÏ¢½âÎö * @brief ÌÕ¾§³ÛÏûÏ¢½âÎö

Loading…
Cancel
Save