|
|
@ -20,6 +20,13 @@ int32_t StepMotorCtrlModule::move_to(int32_t tox, function<void(move_to_cb_statu |
|
|
|
ZLOGI(TAG, "m%d move_to %d", m_id, tox); |
|
|
|
m_thread.stop(); |
|
|
|
|
|
|
|
if (m_cfg_min_x != 0 && tox < m_cfg_min_x) { |
|
|
|
tox = m_cfg_min_x; |
|
|
|
} |
|
|
|
if (m_cfg_max_x != 0 && tox > m_cfg_max_x) { |
|
|
|
tox = m_cfg_max_x; |
|
|
|
} |
|
|
|
|
|
|
|
updateStatus(1); |
|
|
|
m_thread.start([this, tox, status_cb]() { |
|
|
|
_motor_move_to(tox, m_cfg_velocity, m_cfg_acc, m_cfg_dec); |
|
|
@ -48,14 +55,12 @@ int32_t StepMotorCtrlModule::move_by(int32_t dx, function<void(move_by_cb_status |
|
|
|
getnowpos(xnow); |
|
|
|
|
|
|
|
int32_t toxnow = xnow + dx; |
|
|
|
move_to(toxnow, [this, status_cb, xnow](move_to_cb_status_t& status) { |
|
|
|
return move_to(toxnow, [this, status_cb, xnow](move_to_cb_status_t& status) { |
|
|
|
move_by_cb_status_t movebycb_status; |
|
|
|
movebycb_status.exec_status = status.exec_status; |
|
|
|
movebycb_status.dx = status.tox - xnow; |
|
|
|
if (status_cb) status_cb(movebycb_status); |
|
|
|
}); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t StepMotorCtrlModule::move_to_zero(function<void(move_to_zero_cb_status_t& status)> status_cb) { |
|
|
|
zlock_guard lock(m_lock); |
|
|
@ -349,7 +354,7 @@ void StepMotorCtrlModule::_motor_move_by(int32_t dpos, int32_t maxv, int32_t acc |
|
|
|
getnowpos(nowpos); |
|
|
|
|
|
|
|
int32_t topos = nowpos + dpos; |
|
|
|
int motorpos = 0; |
|
|
|
int32_t motorpos = 0; |
|
|
|
forward_kinematics(topos, motorpos); |
|
|
|
m_stepM1->moveTo(motorpos, maxv); |
|
|
|
} |
|
|
|