|
|
@ -113,12 +113,17 @@ int32_t MiniRobotCtrlModule::move_forward(s32 torque) { |
|
|
|
m_thread.stop(); |
|
|
|
if (!m_bus->moveTo(m_id, 4095, 0, torque)) return err::ksubdevice_overtime; |
|
|
|
m_thread.start([this, torque]() { |
|
|
|
uint8_t moveflag = 0; |
|
|
|
while (true) { |
|
|
|
if (m_thread.getExitFlag()) break; |
|
|
|
m_thread.sleep(10); |
|
|
|
|
|
|
|
m_bus->getMoveFlag(m_id, moveflag); |
|
|
|
if (moveflag == 0) { |
|
|
|
// ²»Í£Ö¹¶æ»ú
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
stop(0); |
|
|
|
ZLOGI(TAG, "%d move_forward stop", m_module_id); |
|
|
|
}); |
|
|
|
|
|
|
|
return 0; |
|
|
@ -132,12 +137,17 @@ int32_t MiniRobotCtrlModule::move_backward(s32 torque) { |
|
|
|
m_thread.stop(); |
|
|
|
if (!m_bus->moveTo(m_id, 0, 0, torque)) return err::ksubdevice_overtime; |
|
|
|
m_thread.start([this, torque]() { |
|
|
|
uint8_t moveflag = 0; |
|
|
|
while (true) { |
|
|
|
if (m_thread.getExitFlag()) break; |
|
|
|
m_thread.sleep(10); |
|
|
|
|
|
|
|
m_bus->getMoveFlag(m_id, moveflag); |
|
|
|
if (moveflag == 0) { |
|
|
|
// ²»Í£Ö¹¶æ»ú
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
stop(0); |
|
|
|
ZLOGI(TAG, "%d move_forward stop", m_module_id); |
|
|
|
}); |
|
|
|
|
|
|
|
return 0; |
|
|
@ -274,8 +284,14 @@ int32_t MiniRobotCtrlModule::getid(int32_t *id) { |
|
|
|
*id = m_module_id; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_stop() { return stop(0); } |
|
|
|
int32_t MiniRobotCtrlModule::module_break() { return stop(0); } |
|
|
|
int32_t MiniRobotCtrlModule::module_stop() { |
|
|
|
m_thread.stop(); |
|
|
|
return stop(0); |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_break() { |
|
|
|
m_thread.stop(); |
|
|
|
return stop(0); |
|
|
|
} |
|
|
|
int32_t MiniRobotCtrlModule::module_get_last_exec_status(int32_t *status) { |
|
|
|
*status = m_last_exec_status; |
|
|
|
return 0; |
|
|
|