Skip to content

Commit d7861fa

Browse files
committed
[fix] fix wait move
1 parent 91cd91f commit d7861fa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

xarm/x3/base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,8 @@ def _wait_feedback(self, timeout=None, trans_id=-1, ignore_log=False):
23532353
expired = time.monotonic() + timeout + (self._sleep_finish_time if self._sleep_finish_time > time.monotonic() else 0)
23542354
else:
23552355
expired = 0
2356+
cnt = 0
2357+
max_cnt = 10
23562358
state5_cnt = 0
23572359
while timeout is None or time.monotonic() < expired:
23582360
if not self.connected:
@@ -2381,6 +2383,21 @@ def _wait_feedback(self, timeout=None, trans_id=-1, ignore_log=False):
23812383
state5_cnt = 0
23822384
if trans_id in self._fb_transid_result_map:
23832385
return 0, self._fb_transid_result_map.pop(trans_id, -1)
2386+
2387+
if time.monotonic() < self._sleep_finish_time or state == 3:
2388+
cnt = 0
2389+
max_cnt = 2 if state == 3 else max_cnt
2390+
time.sleep(0.05)
2391+
continue
2392+
if state == 0 or state == 1:
2393+
cnt = 0
2394+
max_cnt = 2
2395+
time.sleep(0.05)
2396+
continue
2397+
else:
2398+
cnt += 1
2399+
if cnt >= max_cnt:
2400+
return 0, -1
23842401
time.sleep(0.05)
23852402
return APIState.WAIT_FINISH_TIMEOUT, -1
23862403

0 commit comments

Comments
 (0)