Skip to content

Commit beff20e

Browse files
committed
save code
1 parent 16d706c commit beff20e

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

pymycobot/cobotx.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,38 @@ def set_error_detect_mode(self, mode):
237237

238238
def get_error_detect_mode(self):
239239
"""Set error detection mode"""
240-
return self._mesg(ProtocolCode.GET_ERROR_DETECT_MODE, has_reply=True)
240+
return self._mesg(ProtocolCode.GET_ERROR_DETECT_MODE, has_reply=True)
241+
242+
def sync_send_angles(self, degrees, speed, timeout=15):
243+
"""Send the angle in synchronous state and return when the target point is reached
244+
245+
Args:
246+
degrees: a list of degree values(List[float]), length 6.
247+
speed: (int) 0 ~ 100
248+
timeout: default 7s.
249+
"""
250+
t = time.time()
251+
self.send_angles(degrees, speed)
252+
while time.time() - t < timeout:
253+
f = self.is_in_position(degrees, 0)
254+
if f == 1:
255+
break
256+
time.sleep(0.1)
257+
return self
258+
259+
def sync_send_coords(self, coords, speed, mode=0, timeout=15):
260+
"""Send the coord in synchronous state and return when the target point is reached
261+
262+
Args:
263+
coords: a list of coord values(List[float])
264+
speed: (int) 0 ~ 100
265+
mode: (int): 0 - angular(default), 1 - linear
266+
timeout: default 7s.
267+
"""
268+
t = time.time()
269+
self.send_coords(coords, speed, mode)
270+
while time.time() - t < timeout:
271+
if self.is_in_position(coords, 1) == 1:
272+
break
273+
time.sleep(0.1)
274+
return self

0 commit comments

Comments
 (0)