|
|
@ -146,9 +146,31 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task(int32_t& dx, int32_t& dy) { |
|
|
|
|
|
|
|
int32_t XYRobotCtrlModule::exec_move_to_zero_task() { |
|
|
|
/*******************************************************************************
|
|
|
|
* 远离X零点 * |
|
|
|
*******************************************************************************/ |
|
|
|
if (m_Xgpio->getState()) { |
|
|
|
/**
|
|
|
|
* @brief 如果设备已经在零点,则反向移动一定距离远离零点 |
|
|
|
*/ |
|
|
|
_motor_move_by(m_cfg_runtozero_leave_away_zero_maxXY, 0, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_runtozero_dec); |
|
|
|
while (!_motor_is_reach_target()) { |
|
|
|
if (m_thread.getExitFlag()) break; |
|
|
|
vTaskDelay(1); |
|
|
|
} |
|
|
|
|
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
ZLOGI(TAG, "break move to zero thread exit"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
if (m_Xgpio->getState()) { |
|
|
|
ZLOGE(TAG, "leave away zero failed"); |
|
|
|
return err::kcommon_error_x_leave_away_zero_point_fail; |
|
|
|
} |
|
|
|
} |
|
|
|
/*******************************************************************************
|
|
|
|
* 移动X轴到零点 * |
|
|
|
*******************************************************************************/ |
|
|
|
_motor_move_by(m_cfg_runtozero_maxX, 0, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_runtozero_dec); |
|
|
|
_motor_move_by(-m_cfg_runtozero_maxX, 0, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_runtozero_dec); |
|
|
|
bool xreach_zero = false; |
|
|
|
while (!m_thread.getExitFlag() && !_motor_is_reach_target()) { |
|
|
|
// ZLOGI(TAG, "xgpio %d %d %d", m_Xgpio->getState(), m_stepM1->isReachTarget(), m_stepM2->isReachTarget());
|
|
|
@ -172,10 +194,34 @@ int32_t XYRobotCtrlModule::exec_move_to_zero_task() { |
|
|
|
} |
|
|
|
|
|
|
|
ZLOGI(TAG, "x reach zero"); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 远离Y零点 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
if (m_Ygpio->getState()) { |
|
|
|
/**
|
|
|
|
* @brief 如果设备已经在零点,则反向移动一定距离远离零点 |
|
|
|
*/ |
|
|
|
_motor_move_by(0, m_cfg_runtozero_leave_away_zero_maxXY, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_dec); |
|
|
|
while (!_motor_is_reach_target()) { |
|
|
|
if (m_thread.getExitFlag()) break; |
|
|
|
vTaskDelay(1); |
|
|
|
} |
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
ZLOGI(TAG, "break move to zero thread exit"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
if (m_Ygpio->getState()) { |
|
|
|
ZLOGE(TAG, "leave away zero failed"); |
|
|
|
return err::kcommon_error_y_leave_away_zero_point_fail; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 移动Y轴到零点 * |
|
|
|
*******************************************************************************/ |
|
|
|
_motor_move_by(0, m_cfg_runtozero_maxY, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_runtozero_dec); |
|
|
|
_motor_move_by(0, -m_cfg_runtozero_maxY, m_cfg_runtozero_speed, m_cfg_acc, m_cfg_runtozero_dec); |
|
|
|
bool yreach_zero = false; |
|
|
|
while (!m_thread.getExitFlag() && !_motor_is_reach_target()) { |
|
|
|
// ZLOGI(TAG, "ygpio %d", m_Ygpio->getState());
|
|
|
|