Browse Source

v1.0

master
zhaohe 2 years ago
parent
commit
3821317ce8
  1. 25
      usrc/intelligent_winding_robot_ctrl.cpp

25
usrc/intelligent_winding_robot_ctrl.cpp

@ -39,7 +39,7 @@ class WidthDetector {
APPDM* m_dm; APPDM* m_dm;
int32_t m_bullet_distance = 33; // ÀíÂÛÖµ33,ÕâÀïÈ¡±£ÊØÖµ20 int32_t m_bullet_distance = 33; // ÀíÂÛÖµ33,ÕâÀïÈ¡±£ÊØÖµ20
int32_t m_bullet_full_distance = 154;
int32_t m_bullet_full_distance = 144;
int32_t lastDistanceChangeTicket = 0; int32_t lastDistanceChangeTicket = 0;
public: public:
@ -56,7 +56,7 @@ class WidthDetector {
if (g_detectGpio.getState() != nowstate) { if (g_detectGpio.getState() != nowstate) {
return m_lastState; return m_lastState;
} }
osDelay(3);
osDelay(1);
} }
m_lastState = nowstate; m_lastState = nowstate;
return m_lastState; return m_lastState;
@ -98,17 +98,17 @@ class WidthDetector {
} }
} }
void m14_raoxiantance_move_to_reset() { m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 500, 0); }
void m14_raoxiantance_move_to_reset() { m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 330, 0); }
void start_run_back() { void start_run_back() {
m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 30, 0);
m_dm->motor_move_to(14, cfg->m14_raoxiantance_reset_pos, 330, 0);
g_isrunning = true; g_isrunning = true;
} }
void start_run_forward_slow() { void start_run_forward_slow() {
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 30, 0);
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos , 330, 0);
g_isrunning = true; g_isrunning = true;
} }
void start_run_forward() { void start_run_forward() {
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos + 100, 500, 0);
m_dm->motor_move_to(14, cfg->m14_raoxiantance_tance_zero_pos , 330, 0);
g_isrunning = true; g_isrunning = true;
} }
void stop_run() { void stop_run() {
@ -123,6 +123,7 @@ class WidthDetector {
int32_t enterticket = zos_get_tick(); int32_t enterticket = zos_get_tick();
start_run_forward(); start_run_forward();
while (true) { while (true) {
if (g_isrunning && getDetectGPIOState() != 0) { if (g_isrunning && getDetectGPIOState() != 0) {
@ -153,7 +154,7 @@ class WidthDetector {
} }
zos_delay(3); zos_delay(3);
} }
lastDistanceChangeTicket = zos_get_tick();
m_detect_thread.start([this, forward]() { m_detect_thread.start([this, forward]() {
if (!forward) { if (!forward) {
while (!m_detect_thread.getExitFlag()) { while (!m_detect_thread.getExitFlag()) {
@ -166,6 +167,7 @@ class WidthDetector {
} else if (!g_isrunning && getDetectGPIOState() != 0) { } else if (!g_isrunning && getDetectGPIOState() != 0) {
start_run_back(); start_run_back();
} }
// ZLOGI(TAG, "%d",getDetectGPIOState());
zos_delay(3); zos_delay(3);
} }
} else { } else {
@ -188,7 +190,7 @@ class WidthDetector {
void stopDetect() { void stopDetect() {
m_detect_thread.stop(); m_detect_thread.stop();
m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 500, 0);
m_dm->motor_move_to_torque(14, cfg->m14_raoxiantance_reset_pos, 330, 0);
wait_module_idle(14, 0); wait_module_idle(14, 0);
} }
@ -197,7 +199,7 @@ class WidthDetector {
bool isRemoveLineEnd() { return g_nowdpos < m_bullet_distance + 10; } bool isRemoveLineEnd() { return g_nowdpos < m_bullet_distance + 10; }
bool distanceIsStopChange() { bool distanceIsStopChange() {
if (zos_haspassedms(lastDistanceChangeTicket) > 10 * 1000) {
if (zos_haspassedms(lastDistanceChangeTicket) > 20 * 1000) {
return true; return true;
} }
return false; return false;
@ -244,7 +246,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 = 600;
cfg.m13_jiaxian_clamp_torque = 330;
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;
@ -350,6 +352,8 @@ int32_t IntelligentWindingRobotCtrl::stop_all_module() {
int32_t IntelligentWindingRobotCtrl::disable_all_module() { int32_t IntelligentWindingRobotCtrl::disable_all_module() {
ZLOGI(TAG, "m_dm->motor_enable(2, 0)"); ZLOGI(TAG, "m_dm->motor_enable(2, 0)");
stop_all_module();
m_dm->motor_enable(2, 0); m_dm->motor_enable(2, 0);
m_dm->xymotor_enable(3, 0); m_dm->xymotor_enable(3, 0);
m_dm->motor_enable(4, 0); m_dm->motor_enable(4, 0);
@ -364,7 +368,6 @@ int32_t IntelligentWindingRobotCtrl::disable_all_module() {
m_dm->motor_enable(22, 0); m_dm->motor_enable(22, 0);
m_dm->motor_enable(23, 0); m_dm->motor_enable(23, 0);
stop_all_module();
return 0; return 0;
} }

Loading…
Cancel
Save