xArm-Python-SDK 1.14.8__tar.gz → 1.15.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xarm_python_sdk-1.14.8/xArm_Python_SDK.egg-info → xarm_python_sdk-1.15.0}/PKG-INFO +3 -2
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0/xArm_Python_SDK.egg-info}/PKG-INFO +3 -2
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd.py +7 -1
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_base.py +18 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_handler.py +127 -18
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_tool.py +3 -0
- xarm_python_sdk-1.15.0/xarm/version.py +1 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/wrapper/xarm_api.py +182 -7
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/base.py +35 -1
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/gpio.py +28 -4
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/gripper.py +89 -2
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/xarm.py +15 -7
- xarm_python_sdk-1.14.8/xarm/version.py +0 -1
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/LICENSE +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/README.rst +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/setup.cfg +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/setup.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/SOURCES.txt +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/dependency_links.txt +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/not-zip-safe +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/top_level.txt +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/comm/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/comm/base.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/comm/serial_port.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/comm/socket_port.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/comm/uxbus_cmd_protocol.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/config/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/config/x_code.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/config/x_config.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/utils/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/utils/convert.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/utils/crc16.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/utils/debug_print.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/utils/log.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/version.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd_ser.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd_tcp.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_highlight.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_node.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/blockly_tool.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/gcode.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/list_ports.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/modbus_tcp.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/threads.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/tools/utils.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/wrapper/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/wrapper/studio_api.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/__init__.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/base_board.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/code.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/decorator.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/events.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/ft_sensor.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/grammar_async.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/grammar_coroutine.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/modbus_tcp.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/parse.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/record.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/report.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/robotiq.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/servo.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/studio.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/track.py +0 -0
- {xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xarm/x3/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: xArm-Python-SDK
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.15.0
|
|
4
4
|
Summary: Python SDK for xArm
|
|
5
5
|
Author: Vinman
|
|
6
6
|
Author-email: vinman@ufactory.cc
|
|
@@ -10,6 +10,7 @@ Dynamic: author
|
|
|
10
10
|
Dynamic: author-email
|
|
11
11
|
Dynamic: description
|
|
12
12
|
Dynamic: license
|
|
13
|
+
Dynamic: license-file
|
|
13
14
|
Dynamic: summary
|
|
14
15
|
|
|
15
16
|
Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: xArm-Python-SDK
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.15.0
|
|
4
4
|
Summary: Python SDK for xArm
|
|
5
5
|
Author: Vinman
|
|
6
6
|
Author-email: vinman@ufactory.cc
|
|
@@ -10,6 +10,7 @@ Dynamic: author
|
|
|
10
10
|
Dynamic: author-email
|
|
11
11
|
Dynamic: description
|
|
12
12
|
Dynamic: license
|
|
13
|
+
Dynamic: license-file
|
|
13
14
|
Dynamic: summary
|
|
14
15
|
|
|
15
16
|
Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.
|
|
@@ -1397,9 +1397,12 @@ class UxbusCmd(object):
|
|
|
1397
1397
|
txdata = bytes([param_type])
|
|
1398
1398
|
if param_type == 1:
|
|
1399
1399
|
txdata += convert.fp32_to_bytes(param_val)
|
|
1400
|
+
elif param_type == 12 or param_type == 14:
|
|
1401
|
+
txdata += convert.fp32s_to_bytes(param_val, 6)
|
|
1400
1402
|
else:
|
|
1403
|
+
# 2/3/6/11/13
|
|
1401
1404
|
txdata += convert.int32_to_bytes(param_val)
|
|
1402
|
-
return self.set_nu8(XCONF.UxbusReg.SET_COMMON_PARAM, txdata,
|
|
1405
|
+
return self.set_nu8(XCONF.UxbusReg.SET_COMMON_PARAM, txdata, len(txdata))
|
|
1403
1406
|
|
|
1404
1407
|
def get_common_param(self, param_type):
|
|
1405
1408
|
txdata = bytes([param_type])
|
|
@@ -1409,7 +1412,10 @@ class UxbusCmd(object):
|
|
|
1409
1412
|
if ret[0] != XCONF.UxbusState.ERR_NOTTCP:
|
|
1410
1413
|
if param_type == 1:
|
|
1411
1414
|
data[1] = convert.bytes_to_fp32(ret[1:])
|
|
1415
|
+
elif param_type == 12 or param_type == 14:
|
|
1416
|
+
data[1] = convert.bytes_to_fp32s(ret[1:], 6)
|
|
1412
1417
|
else:
|
|
1418
|
+
# 2/3/6/11/13
|
|
1413
1419
|
data[1] = convert.bytes_to_u32(ret[1:])
|
|
1414
1420
|
return data
|
|
1415
1421
|
|
|
@@ -224,6 +224,24 @@ class _BlocklyBase(_BlocklyNode):
|
|
|
224
224
|
addr = int(fields[0].text.replace(' ', '').replace('0x', '').replace(',', '').replace('\xa0', ''), 16)
|
|
225
225
|
return "list(map(lambda x: hex(x).split('0x')[1].upper().zfill(4)[:2] + ' ' + hex(x).split('0x')[1]." \
|
|
226
226
|
"upper().zfill(4)[2:], self._arm.read_holding_registers({}, 1)[1]))[0]".format(str(addr))
|
|
227
|
+
elif block.attrib['type'] == 'get_position':
|
|
228
|
+
direction_li = ['X', 'Y', 'Z', 'R', 'P', 'Y']
|
|
229
|
+
fields = self._get_nodes('field', root=block)
|
|
230
|
+
is_axis = True if fields[0].text == 'axis' else False
|
|
231
|
+
direction = int(fields[1].text)
|
|
232
|
+
if is_axis:
|
|
233
|
+
return 'round(self._arm.get_position_aa()[1][{}], 2)'.format(direction-1)
|
|
234
|
+
else:
|
|
235
|
+
return 'round(self._arm.get_position()[1][{}], 2)'.format(direction-1)
|
|
236
|
+
elif block.attrib['type'] == 'get_joint_angle':
|
|
237
|
+
angle_li = ['J1', 'J2', 'J3', 'J4', 'J5', 'J6']
|
|
238
|
+
fields = self._get_nodes('field', root=block)
|
|
239
|
+
servo_angle = fields[0].text
|
|
240
|
+
return 'round(self._arm.get_servo_angle(servo_id={})[1], 2)'.format(servo_angle)
|
|
241
|
+
elif block.attrib['type'] == 'check_bio_g2_gripper_is_catch':
|
|
242
|
+
fields = self._get_nodes('field', root=block)
|
|
243
|
+
timeout = float(fields[0].text)
|
|
244
|
+
return 'self._arm.arm.check_bio_gripper_is_catch(timeout={})'.format(timeout)
|
|
227
245
|
|
|
228
246
|
|
|
229
247
|
def __get_logic_compare(self, block, arg_map=None):
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import json
|
|
10
10
|
import re
|
|
11
|
+
import math
|
|
11
12
|
from ._blockly_base import _BlocklyBase, OPS_MAP
|
|
12
13
|
from ._blockly_highlight import HIGHLIGHT_BLOCKS
|
|
13
14
|
|
|
@@ -417,8 +418,9 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
417
418
|
fields = self._get_nodes('field', root=block)
|
|
418
419
|
io = fields[0].text
|
|
419
420
|
value = 0 if fields[1].text == 'LOW' else 1
|
|
420
|
-
|
|
421
|
-
|
|
421
|
+
is_sync = fields[2].text if len(fields) > 2 else 'True'
|
|
422
|
+
delay_sec = fields[3].text if len(fields) > 3 else 0
|
|
423
|
+
self._append_main_code('code = self._arm.set_tgpio_digital({}, {}, delay_sec={}, sync={})'.format(io, value, delay_sec, is_sync), indent + 2)
|
|
422
424
|
self._append_main_code('if not self._check_code(code, \'set_tgpio_digital\'):', indent + 2)
|
|
423
425
|
self._append_main_code(' return', indent + 2)
|
|
424
426
|
|
|
@@ -435,6 +437,28 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
435
437
|
self._append_main_code('if not self._check_code(code, \'set_tgpio_digital_with_xyz\'):', indent + 2)
|
|
436
438
|
self._append_main_code(' return', indent + 2)
|
|
437
439
|
|
|
440
|
+
def _handle_gpio_set_digital_with_xyz_var(self, block, indent=0, arg_map=None):
|
|
441
|
+
value_nodes = self._get_nodes('value', root=block)
|
|
442
|
+
x = self._get_block_val(value_nodes[0], arg_map)
|
|
443
|
+
y = self._get_block_val(value_nodes[1], arg_map)
|
|
444
|
+
z = self._get_block_val(value_nodes[2], arg_map)
|
|
445
|
+
xyz_li = [x, y, z]
|
|
446
|
+
xyz = []
|
|
447
|
+
for i in range(3):
|
|
448
|
+
if re.match('\d+(\.\d+)*$', xyz_li[i]) is not None:
|
|
449
|
+
xyz.append(float(xyz_li[i]))
|
|
450
|
+
else:
|
|
451
|
+
xyz.append(math.log2(3) if i == 0 else math.log2(5) if i == 1 else math.log2(7))
|
|
452
|
+
xyz = str(xyz).replace(str(math.log2(3)), xyz_li[0]).replace(str(math.log2(5)), xyz_li[1]).replace(
|
|
453
|
+
str(math.log2(7)), xyz_li[2])
|
|
454
|
+
tol_r = self._get_block_val(value_nodes[3], arg_map)
|
|
455
|
+
io = self._get_block_val(value_nodes[4], arg_map)
|
|
456
|
+
value = 0 if self._get_block_val(value_nodes[5], arg_map) == 'LOW' else 1
|
|
457
|
+
self._append_main_code(
|
|
458
|
+
'code = self._arm.set_tgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
459
|
+
self._append_main_code('if not self._check_code(code, \'set_tgpio_digital_with_xyz\'):', indent + 2)
|
|
460
|
+
self._append_main_code(' return', indent + 2)
|
|
461
|
+
|
|
438
462
|
def _handle_get_suction_cup(self, block, indent=0, arg_map=None):
|
|
439
463
|
self._append_main_code('{}self._arm.get_suction_cup(hardware_version={})'.format('{}', self._vacuum_version), indent + 2)
|
|
440
464
|
|
|
@@ -442,7 +466,7 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
442
466
|
fields = self._get_nodes('field', root=block)
|
|
443
467
|
state = 1 if fields[0].text == 'ON' else 0
|
|
444
468
|
timeout = float(fields[1].text)
|
|
445
|
-
self._append_main_code('self._arm.arm.check_air_pump_state({}, timeout={})'.format(state, timeout), indent + 2)
|
|
469
|
+
self._append_main_code('self._arm.arm.check_air_pump_state({}, timeout={}, hardware_version={})'.format(state, timeout, self._vacuum_version), indent + 2)
|
|
446
470
|
|
|
447
471
|
def _handle_check_bio_gripper_is_catch(self, block, indent=0, arg_map=None):
|
|
448
472
|
fields = self._get_nodes('field', root=block)
|
|
@@ -464,7 +488,7 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
464
488
|
wait = False
|
|
465
489
|
fields = self._get_nodes('field', root=block, name='delay')
|
|
466
490
|
delay_sec = fields[0].text if len(fields) > 0 else 0
|
|
467
|
-
self._append_main_code('code = self._arm.set_suction_cup({}, wait={}, delay_sec={}, hardware_version={})'.format(
|
|
491
|
+
self._append_main_code('code = self._arm.set_suction_cup({}, wait={}, delay_sec={}, hardware_version={})'.format(on, wait, delay_sec, self._vacuum_version), indent + 2)
|
|
468
492
|
self._append_main_code('if not self._check_code(code, \'set_suction_cup\'):', indent + 2)
|
|
469
493
|
self._append_main_code(' return', indent + 2)
|
|
470
494
|
|
|
@@ -511,8 +535,9 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
511
535
|
fields = self._get_nodes('field', root=block)
|
|
512
536
|
io = fields[0].text
|
|
513
537
|
value = 0 if fields[1].text == 'LOW' else 1
|
|
514
|
-
|
|
515
|
-
|
|
538
|
+
is_sync = fields[2].text if len(fields) > 2 else 'True'
|
|
539
|
+
delay_sec = fields[3].text if len(fields) > 3 else 0
|
|
540
|
+
self._append_main_code('code = self._arm.set_cgpio_digital({}, {}, delay_sec={}, sync={})'.format(io, value, delay_sec, is_sync), indent + 2)
|
|
516
541
|
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital\'):', indent + 2)
|
|
517
542
|
self._append_main_code(' return', indent + 2)
|
|
518
543
|
|
|
@@ -525,6 +550,27 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
525
550
|
tol_r = fields[3].text
|
|
526
551
|
io = fields[4].text
|
|
527
552
|
value = 0 if fields[5].text == 'LOW' else 1
|
|
553
|
+
self._append_main_code(
|
|
554
|
+
'code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
555
|
+
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
|
|
556
|
+
self._append_main_code(' return', indent + 2)
|
|
557
|
+
|
|
558
|
+
def _handle_gpio_set_controller_digital_with_xyz_var(self, block, indent=0, arg_map=None):
|
|
559
|
+
value_nodes = self._get_nodes('value', root=block)
|
|
560
|
+
x = self._get_block_val(value_nodes[0], arg_map)
|
|
561
|
+
y = self._get_block_val(value_nodes[1], arg_map)
|
|
562
|
+
z = self._get_block_val(value_nodes[2], arg_map)
|
|
563
|
+
xyz_li = [x, y, z]
|
|
564
|
+
xyz = []
|
|
565
|
+
for i in range(3):
|
|
566
|
+
if re.match('\d+(\.\d+)*$', xyz_li[i]) is not None:
|
|
567
|
+
xyz.append(float(xyz_li[i]))
|
|
568
|
+
else:
|
|
569
|
+
xyz.append(math.log2(3) if i == 0 else math.log2(5) if i == 1 else math.log2(7))
|
|
570
|
+
xyz = str(xyz).replace(str(math.log2(3)), xyz_li[0]).replace(str(math.log2(5)), xyz_li[1]).replace(str(math.log2(7)), xyz_li[2])
|
|
571
|
+
tol_r = self._get_block_val(value_nodes[3], arg_map)
|
|
572
|
+
io = self._get_block_val(value_nodes[4], arg_map)
|
|
573
|
+
value = 0 if self._get_block_val(value_nodes[5], arg_map) == 'LOW' else 1
|
|
528
574
|
self._append_main_code('code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
529
575
|
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
|
|
530
576
|
self._append_main_code(' return', indent + 2)
|
|
@@ -533,20 +579,43 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
533
579
|
fields = self._get_nodes('field', root=block)
|
|
534
580
|
io = fields[0].text
|
|
535
581
|
value = 0 if fields[1].text == 'LOW' else 1
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
self._append_main_code('
|
|
582
|
+
is_sync = fields[2].text if len(fields) > 2 else 'True'
|
|
583
|
+
delay_sec = fields[3].text if len(fields) > 3 else 0
|
|
584
|
+
self._append_main_code('code = self._arm.set_cgpio_digital({}, {}, delay_sec={}, sync={})'.format(io, value, delay_sec, is_sync), indent + 2)
|
|
585
|
+
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital\'):', indent + 2)
|
|
539
586
|
self._append_main_code(' return', indent + 2)
|
|
540
587
|
|
|
541
588
|
def _handle_gpio_set_controller_digital_with_xyz_do(self, block, indent=0, arg_map=None):
|
|
542
|
-
|
|
543
|
-
x =
|
|
544
|
-
y =
|
|
545
|
-
z =
|
|
589
|
+
value_nodes = self._get_nodes('value', root=block)
|
|
590
|
+
x = self._get_block_val(value_nodes[0], arg_map)
|
|
591
|
+
y = self._get_block_val(value_nodes[1], arg_map)
|
|
592
|
+
z = self._get_block_val(value_nodes[2], arg_map)
|
|
546
593
|
xyz = list(map(float, [x, y, z]))
|
|
547
|
-
tol_r =
|
|
548
|
-
io =
|
|
549
|
-
value = 0 if
|
|
594
|
+
tol_r = self._get_block_val(value_nodes[3], arg_map)
|
|
595
|
+
io = self._get_block_val(value_nodes[4], arg_map)
|
|
596
|
+
value = 0 if self._get_block_val(value_nodes[5], arg_map) == 'LOW' else 1
|
|
597
|
+
self._append_main_code(
|
|
598
|
+
'code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
599
|
+
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
|
|
600
|
+
self._append_main_code(' return', indent + 2)
|
|
601
|
+
|
|
602
|
+
def _handle_gpio_set_controller_digital_with_xyz_do_var(self, block, indent=0, arg_map=None):
|
|
603
|
+
value_nodes = self._get_nodes('value', root=block)
|
|
604
|
+
x = self._get_block_val(value_nodes[0], arg_map)
|
|
605
|
+
y = self._get_block_val(value_nodes[1], arg_map)
|
|
606
|
+
z = self._get_block_val(value_nodes[2], arg_map)
|
|
607
|
+
tol_r = self._get_block_val(value_nodes[3], arg_map)
|
|
608
|
+
io = self._get_block_val(value_nodes[4], arg_map)
|
|
609
|
+
value = 0 if self._get_block_val(value_nodes[5], arg_map) == 'LOW' else 1
|
|
610
|
+
xyz_li = [x, y, z]
|
|
611
|
+
xyz = []
|
|
612
|
+
for i in range(3):
|
|
613
|
+
if re.match('\d+(\.\d+)*$', xyz_li[i]) is not None:
|
|
614
|
+
xyz.append(float(xyz_li[i]))
|
|
615
|
+
else:
|
|
616
|
+
xyz.append(math.log2(3) if i == 0 else math.log2(5) if i == 1 else math.log2(7))
|
|
617
|
+
xyz = str(xyz).replace(str(math.log2(3)), xyz_li[0]).replace(str(math.log2(5)), xyz_li[1]).replace(
|
|
618
|
+
str(math.log2(7)), xyz_li[2])
|
|
550
619
|
self._append_main_code('code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
551
620
|
self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
|
|
552
621
|
self._append_main_code(' return', indent + 2)
|
|
@@ -564,11 +633,35 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
564
633
|
self._append_main_code('if not self._check_code(code, \'set_cgpio_analog_with_xyz\'):', indent + 2)
|
|
565
634
|
self._append_main_code(' return', indent + 2)
|
|
566
635
|
|
|
636
|
+
def _handle_gpio_set_controller_analog_with_xyz_var(self, block, indent=0, arg_map=None):
|
|
637
|
+
value_nodes = self._get_nodes('value', root=block)
|
|
638
|
+
x = self._get_block_val(value_nodes[0], arg_map)
|
|
639
|
+
y = self._get_block_val(value_nodes[1], arg_map)
|
|
640
|
+
z = self._get_block_val(value_nodes[2], arg_map)
|
|
641
|
+
# xyz = list(map(lambda x: float(x) if re.match('\d+(\.\d+)*$', x) is not None else [x, y, z].index(x), [x, y, z]))
|
|
642
|
+
xyz_li = [x, y, z]
|
|
643
|
+
xyz = []
|
|
644
|
+
for i in range(3):
|
|
645
|
+
if re.match('\d+(\.\d+)*$', xyz_li[i]) is not None:
|
|
646
|
+
xyz.append(float(xyz_li[i]))
|
|
647
|
+
else:
|
|
648
|
+
xyz.append(math.log2(3) if i == 0 else math.log2(5) if i == 1 else math.log2(7))
|
|
649
|
+
xyz = str(xyz).replace(str(math.log2(3)), xyz_li[0]).replace(str(math.log2(5)), xyz_li[1]).replace(
|
|
650
|
+
str(math.log2(7)), xyz_li[2])
|
|
651
|
+
tol_r = self._get_block_val(value_nodes[3], arg_map)
|
|
652
|
+
io = self._get_block_val(value_nodes[4], arg_map)
|
|
653
|
+
value = self._get_block_val(value_nodes[5], arg_map)
|
|
654
|
+
self._append_main_code('code = self._arm.set_cgpio_analog_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
|
|
655
|
+
self._append_main_code('if not self._check_code(code, \'set_cgpio_analog_with_xyz\'):', indent + 2)
|
|
656
|
+
self._append_main_code(' return', indent + 2)
|
|
657
|
+
|
|
567
658
|
def _handle_gpio_set_controller_analog(self, block, indent=0, arg_map=None):
|
|
568
|
-
|
|
659
|
+
fields = self._get_nodes('field', root=block)
|
|
660
|
+
io = fields[0].text
|
|
661
|
+
is_sync = fields[1].text
|
|
569
662
|
value = self._get_node('value', root=block)
|
|
570
663
|
value = self._get_block_val(value, arg_map=arg_map)
|
|
571
|
-
self._append_main_code('code = self._arm.set_cgpio_analog({}, {})'.format(io, value), indent + 2)
|
|
664
|
+
self._append_main_code('code = self._arm.set_cgpio_analog({}, {}, sync={})'.format(io, value, is_sync), indent + 2)
|
|
572
665
|
self._append_main_code('if not self._check_code(code, \'set_cgpio_analog\'):', indent + 2)
|
|
573
666
|
self._append_main_code(' return', indent + 2)
|
|
574
667
|
|
|
@@ -686,6 +779,11 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
686
779
|
self._append_main_code('if not self._check_code(code, \'set_gripper_status\'):', indent + 2)
|
|
687
780
|
self._append_main_code(' return', indent + 2)
|
|
688
781
|
|
|
782
|
+
def _handle_set_bio_g2_gripper_init(self, block, indent=0, arg_map=None):
|
|
783
|
+
self._append_main_code('code = self._arm.set_bio_gripper_enable(True)', indent + 2)
|
|
784
|
+
self._append_main_code('if not self._check_code(code, \'set_bio_gripper_enable\'):', indent + 2)
|
|
785
|
+
self._append_main_code(' return', indent + 2)
|
|
786
|
+
|
|
689
787
|
def _handle_set_bio_gripper_init(self, block, indent=0, arg_map=None):
|
|
690
788
|
self._append_main_code('code = self._arm.set_bio_gripper_enable(True)', indent + 2)
|
|
691
789
|
self._append_main_code('if not self._check_code(code, \'set_bio_gripper_enable\'):', indent + 2)
|
|
@@ -707,6 +805,16 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
707
805
|
self._append_main_code('if not self._check_code(code, \'close_bio_gripper\'):', indent + 2)
|
|
708
806
|
self._append_main_code(' return', indent + 2)
|
|
709
807
|
|
|
808
|
+
def _handle_set_bio_gripper_pos_force(self, block, indent=0, arg_map=None):
|
|
809
|
+
fields = self._get_nodes('field', root=block)
|
|
810
|
+
pos = fields[0].text
|
|
811
|
+
speed = fields[1].text
|
|
812
|
+
force = fields[2].text
|
|
813
|
+
wait = fields[3].text == 'TRUE'
|
|
814
|
+
self._append_main_code('code = self._arm.set_bio_gripper_position(pos={}, speed={}, force={}, wait={})'.format(pos, speed, force, wait), indent + 2)
|
|
815
|
+
self._append_main_code('if not self._check_code(code, \'open_bio_gripper\'):', indent + 2)
|
|
816
|
+
self._append_main_code(' return', indent + 2)
|
|
817
|
+
|
|
710
818
|
def _handle_set_robotiq_init(self, block, indent=0, arg_map=None):
|
|
711
819
|
self._append_main_code('code, ret = self._arm.robotiq_reset()', indent + 2)
|
|
712
820
|
self._append_main_code('if not self._check_code(code, \'robotiq_reset\'):', indent + 2)
|
|
@@ -1124,6 +1232,7 @@ class _BlocklyHandler(_BlocklyBase):
|
|
|
1124
1232
|
if (self._is_exec or (not self._is_exec and not self._is_ide)) and code.strip() and code not in \
|
|
1125
1233
|
['finally:', 'else:'] and all([i not in code for i in ['elif', 'except', 'def', 'class']]) \
|
|
1126
1234
|
and not code.startswith('@'):
|
|
1235
|
+
# 只有在studio执行blockly时或者SDK直接调用run_blockly_app时才会执行
|
|
1127
1236
|
code_indent = re.match('(\s*).*', code).group(1)
|
|
1128
1237
|
self._append_main_code(code_indent + 'if not self.is_alive:', indent + 2)
|
|
1129
1238
|
self._append_main_code(code_indent + 'return', indent + 3)
|
|
@@ -97,6 +97,9 @@ class BlocklyTool(_BlocklyHandler):
|
|
|
97
97
|
self._append_main_code(' # Event Loop', indent=-1)
|
|
98
98
|
self._append_main_code(' while self.is_alive:', indent=-1)
|
|
99
99
|
self._append_main_code(' time.sleep(0.5)', indent=-1)
|
|
100
|
+
|
|
101
|
+
if self._is_main_run_code and (self._main_run_code_list[-1] == ' try:' or ' # ' in self._main_run_code_list[-1]):
|
|
102
|
+
self._append_main_code(' pass', indent=-1)
|
|
100
103
|
# catch exception and release callback
|
|
101
104
|
self._append_main_code(' except Exception as e:', indent=-1)
|
|
102
105
|
self._append_main_code(' self.pprint(\'MainException: {}\'.format(e))', indent=-1)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.15.0'
|
|
@@ -1678,16 +1678,17 @@ class XArmAPI(object):
|
|
|
1678
1678
|
|
|
1679
1679
|
def set_gravity_direction(self, direction, wait=True):
|
|
1680
1680
|
"""
|
|
1681
|
-
Set the direction
|
|
1681
|
+
Set the gravity direction for proper torque compensation and collision detection.
|
|
1682
1682
|
|
|
1683
1683
|
Note:
|
|
1684
|
-
1.
|
|
1685
|
-
2.
|
|
1686
|
-
|
|
1684
|
+
1. Use only if necessary. Incorrect settings may affect torque compensation.
|
|
1685
|
+
2. Changes are not saved automatically. Call save_conf() to save the settings,
|
|
1686
|
+
otherwise, they will be lost after a reboot.
|
|
1687
|
+
3. Use clean_conf() to restore the system default settings.
|
|
1687
1688
|
4. The clean_conf interface can restore system default settings
|
|
1688
1689
|
|
|
1689
|
-
:param direction: direction
|
|
1690
|
-
:param wait:
|
|
1690
|
+
:param direction: Gravity direction vector [x, y, z], e.g., [0, 0, -1] for a floor-mounted arm.
|
|
1691
|
+
:param wait: Whether to wait for the robotic arm to stop or clear all previous queued commands before applying the setting.
|
|
1691
1692
|
:return: code
|
|
1692
1693
|
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
1693
1694
|
"""
|
|
@@ -1888,6 +1889,17 @@ class XArmAPI(object):
|
|
|
1888
1889
|
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
1889
1890
|
"""
|
|
1890
1891
|
return self._arm.get_tgpio_digital(ionum)
|
|
1892
|
+
|
|
1893
|
+
def get_tool_digital_input(self, ionum=None):
|
|
1894
|
+
"""
|
|
1895
|
+
Get the digital value of the specified Tool GPIO,Compared with the "get_tgpio_digital" interface,
|
|
1896
|
+
the value of TI2 is obtained when the ionum is not transmitted.
|
|
1897
|
+
|
|
1898
|
+
:param ionum: 0 or 1 or or 2 or 3 or 4 (both 0 and 4), default is None
|
|
1899
|
+
:return: tuple((code, value or value list)), only when code is 0, the returned result is correct.
|
|
1900
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
1901
|
+
"""
|
|
1902
|
+
return self._arm.get_tool_digital_input(ionum)
|
|
1891
1903
|
|
|
1892
1904
|
def set_tgpio_digital(self, ionum, value, delay_sec=None, sync=True):
|
|
1893
1905
|
"""
|
|
@@ -2802,6 +2814,52 @@ class XArmAPI(object):
|
|
|
2802
2814
|
"""
|
|
2803
2815
|
return self._arm.set_bio_gripper_speed(speed)
|
|
2804
2816
|
|
|
2817
|
+
def set_bio_gripper_control_mode(self, mode):
|
|
2818
|
+
"""
|
|
2819
|
+
Set the bio gripper control mode
|
|
2820
|
+
Note:
|
|
2821
|
+
1. Only available in the new version of BIO Gripper
|
|
2822
|
+
|
|
2823
|
+
:param mode: mode
|
|
2824
|
+
0: bio gripper opening and closing mode
|
|
2825
|
+
1: position loop mode
|
|
2826
|
+
|
|
2827
|
+
:return: code
|
|
2828
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
2829
|
+
"""
|
|
2830
|
+
|
|
2831
|
+
return self._arm.set_bio_gripper_control_mode(mode)
|
|
2832
|
+
|
|
2833
|
+
def set_bio_gripper_force(self, force):
|
|
2834
|
+
"""
|
|
2835
|
+
Set the bio gripper force
|
|
2836
|
+
Note:
|
|
2837
|
+
1. Only available in the new version of BIO Gripper
|
|
2838
|
+
|
|
2839
|
+
:param force: gripper force between 10 and 100
|
|
2840
|
+
|
|
2841
|
+
:return: code
|
|
2842
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
2843
|
+
"""
|
|
2844
|
+
|
|
2845
|
+
return self._arm.set_bio_gripper_force(force)
|
|
2846
|
+
|
|
2847
|
+
def set_bio_gripper_position(self, pos, speed=0, force=100, wait=True, timeout=5, **kwargs):
|
|
2848
|
+
"""
|
|
2849
|
+
Set the bio gripper position
|
|
2850
|
+
|
|
2851
|
+
:param pos: gripper pos between 71 and 150
|
|
2852
|
+
:param speed: gripper speed between 0 and 4500
|
|
2853
|
+
:param force: gripper force between 10 and 100
|
|
2854
|
+
:param wait: whether to wait for the robotiq motion to complete, default is True
|
|
2855
|
+
:param timeout: maximum waiting time(unit: second), default is 5, only available if wait=True
|
|
2856
|
+
|
|
2857
|
+
:return: tuple((code, robotiq_response))
|
|
2858
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
2859
|
+
robotiq_response: See the robotiq documentation
|
|
2860
|
+
"""
|
|
2861
|
+
return self._arm.set_bio_gripper_position(pos, speed=speed, force=force, wait=wait, timeout=timeout, **kwargs)
|
|
2862
|
+
|
|
2805
2863
|
def open_bio_gripper(self, speed=0, wait=True, timeout=5, **kwargs):
|
|
2806
2864
|
"""
|
|
2807
2865
|
Open the bio gripper
|
|
@@ -4222,8 +4280,125 @@ class XArmAPI(object):
|
|
|
4222
4280
|
:return: tuple((code, speed_info)), only when code is 0, the returned result is correct.
|
|
4223
4281
|
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4224
4282
|
speed_info: [result_code, servo_id, servo_speed]
|
|
4225
|
-
result_code: 0
|
|
4283
|
+
result_code: 0: Pass, -1: Fail, >0: abnormal(1:Trajectory not loaded or incorrect status;2:The input magnification is incorrect)
|
|
4226
4284
|
servo_id: Effective only when result_code is -1
|
|
4227
4285
|
servo_speed: Effective only when result_code is -1
|
|
4228
4286
|
"""
|
|
4229
4287
|
return self._arm.get_traj_speeding(rate)
|
|
4288
|
+
|
|
4289
|
+
def set_ft_collision_detection(self, on_off):
|
|
4290
|
+
"""
|
|
4291
|
+
Set whether to enable collision detection with the Six-axis Force Torque Sensor
|
|
4292
|
+
Note:
|
|
4293
|
+
1. only available if firmware_version >= 2.5.109
|
|
4294
|
+
2. the Six-axis Force Torque Sensor is required (the third party is not currently supported)
|
|
4295
|
+
3. the Six-axis Force Torque Sensor needs to be enabled and set force mode
|
|
4296
|
+
|
|
4297
|
+
:param on_off: enable or not
|
|
4298
|
+
|
|
4299
|
+
:return: code
|
|
4300
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4301
|
+
"""
|
|
4302
|
+
return self._arm.set_ft_collision_detection(on_off)
|
|
4303
|
+
|
|
4304
|
+
def set_ft_collision_rebound(self, on_off):
|
|
4305
|
+
"""
|
|
4306
|
+
Set whether to enable collision rebound with the Six-axis Force Torque Sensor
|
|
4307
|
+
Note:
|
|
4308
|
+
1. only available if firmware_version >= 2.5.109
|
|
4309
|
+
|
|
4310
|
+
:param on_off: enable or not
|
|
4311
|
+
|
|
4312
|
+
:return: code
|
|
4313
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4314
|
+
"""
|
|
4315
|
+
return self._arm.set_ft_collision_rebound(on_off)
|
|
4316
|
+
|
|
4317
|
+
def set_ft_collision_threshold(self, thresholds):
|
|
4318
|
+
"""
|
|
4319
|
+
Set the threshold of the collision detection with the Six-axis Force Torque Sensor
|
|
4320
|
+
Note:
|
|
4321
|
+
1. only available if firmware_version >= 2.5.109
|
|
4322
|
+
|
|
4323
|
+
:param thresholds: collision detection thresholds, [x(N), y(N), z(N), Rx(Nm), Ry(Nm), Rz(Nm)]
|
|
4324
|
+
x: [5, 200] (N)
|
|
4325
|
+
y: [5, 200] (N)
|
|
4326
|
+
z: [5, 200] (N)
|
|
4327
|
+
Rx: [0.1, 4] (Nm)
|
|
4328
|
+
Ry: [0.1, 4] (Nm)
|
|
4329
|
+
Rz: [0.1, 4] (Nm)
|
|
4330
|
+
|
|
4331
|
+
:return: code
|
|
4332
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4333
|
+
"""
|
|
4334
|
+
return self._arm.set_ft_collision_threshold(thresholds)
|
|
4335
|
+
|
|
4336
|
+
def set_ft_collision_reb_distance(self, distances, is_radian=None):
|
|
4337
|
+
"""
|
|
4338
|
+
Set the rebound distance of the collision rebound with the Six-axis Force Torque Sensor
|
|
4339
|
+
Note:
|
|
4340
|
+
1. only available if firmware_version >= 2.5.109
|
|
4341
|
+
|
|
4342
|
+
:param distances: collision rebound distance, [x(mm), y(mm), z(mm), Rx(° or rad), Ry(° or rad), Rz(° or rad)]
|
|
4343
|
+
x: [2, 200] (mm)
|
|
4344
|
+
y: [2, 200] (mm)
|
|
4345
|
+
z: [2, 200] (mm)
|
|
4346
|
+
Rx: [0.2, 50] (°)
|
|
4347
|
+
Ry: [0.2, 50] (°)
|
|
4348
|
+
Rz: [0.2, 50] (°)
|
|
4349
|
+
:param is_radian: the value of distance (only Rx/Ry/Rz) is in radians or not, default is self.default_is_radian
|
|
4350
|
+
|
|
4351
|
+
:return: code
|
|
4352
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4353
|
+
"""
|
|
4354
|
+
return self._arm.set_ft_collision_reb_distance(distances, is_radian=is_radian)
|
|
4355
|
+
|
|
4356
|
+
def get_ft_collision_detection(self):
|
|
4357
|
+
"""
|
|
4358
|
+
Get the collision detection with the Six-axis Force Torque Sensor is enable or not
|
|
4359
|
+
Note:
|
|
4360
|
+
1. only available if firmware_version >= 2.5.109
|
|
4361
|
+
|
|
4362
|
+
:return: tuple((code, on_off)), only when code is 0, the returned result is correct.
|
|
4363
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4364
|
+
on_off: enable or not
|
|
4365
|
+
"""
|
|
4366
|
+
return self._arm.get_ft_collision_detection()
|
|
4367
|
+
|
|
4368
|
+
def get_ft_collision_rebound(self):
|
|
4369
|
+
"""
|
|
4370
|
+
Get the collision rebound with the Six-axis Force Torque Sensor is enable or not
|
|
4371
|
+
Note:
|
|
4372
|
+
1. only available if firmware_version >= 2.5.109
|
|
4373
|
+
|
|
4374
|
+
:return: tuple((code, on_off)), only when code is 0, the returned result is correct.
|
|
4375
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4376
|
+
on_off: enable or not
|
|
4377
|
+
"""
|
|
4378
|
+
return self._arm.get_ft_collision_rebound()
|
|
4379
|
+
|
|
4380
|
+
def get_ft_collision_threshold(self):
|
|
4381
|
+
"""
|
|
4382
|
+
Get the collision threshold with the Six-axis Force Torque Sensor
|
|
4383
|
+
Note:
|
|
4384
|
+
1. only available if firmware_version >= 2.5.109
|
|
4385
|
+
|
|
4386
|
+
:return: tuple((code, threshold)), only when code is 0, the returned result is correct.
|
|
4387
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4388
|
+
threshold: [x(N), y(N), z(N), Rx(Nm), Ry(Nm), Rz(Nm)]
|
|
4389
|
+
"""
|
|
4390
|
+
return self._arm.get_ft_collision_threshold()
|
|
4391
|
+
|
|
4392
|
+
def get_ft_collision_reb_distance(self, is_radian=None):
|
|
4393
|
+
"""
|
|
4394
|
+
Get the collision rebound distance with the Six-axis Force Torque Sensor
|
|
4395
|
+
Note:
|
|
4396
|
+
1. only available if firmware_version >= 2.5.109
|
|
4397
|
+
|
|
4398
|
+
:param is_radian: the returned value (only Rx/Ry/Rz) is in radians or not, default is self.default_is_radian
|
|
4399
|
+
|
|
4400
|
+
:return: tuple((code, threshold)), only when code is 0, the returned result is correct.
|
|
4401
|
+
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
|
|
4402
|
+
distance: [x(mm), y(mm), z(mm), Rx(° or rad), Ry(° or rad), Rz(° or rad)]
|
|
4403
|
+
"""
|
|
4404
|
+
return self._arm.get_ft_collision_reb_distance(is_radian=is_radian)
|
|
@@ -14,6 +14,7 @@ import uuid
|
|
|
14
14
|
import queue
|
|
15
15
|
import struct
|
|
16
16
|
import threading
|
|
17
|
+
from collections.abc import Iterable
|
|
17
18
|
try:
|
|
18
19
|
from multiprocessing.pool import ThreadPool
|
|
19
20
|
except:
|
|
@@ -2601,4 +2602,37 @@ class Base(BaseObject, Events):
|
|
|
2601
2602
|
def get_traj_speeding(self, rate):
|
|
2602
2603
|
ret = self.arm_cmd.get_traj_speeding(rate)
|
|
2603
2604
|
ret[0] = self._check_code(ret[0])
|
|
2604
|
-
return ret[0], ret[1:]
|
|
2605
|
+
return ret[0], ret[1:]
|
|
2606
|
+
|
|
2607
|
+
def set_ft_collision_detection(self, on_off):
|
|
2608
|
+
return self.set_common_param(11, int(on_off))
|
|
2609
|
+
|
|
2610
|
+
def set_ft_collision_rebound(self, on_off):
|
|
2611
|
+
return self.set_common_param(13, int(on_off))
|
|
2612
|
+
|
|
2613
|
+
def set_ft_collision_threshold(self, thresholds):
|
|
2614
|
+
assert isinstance(thresholds, Iterable) and len(thresholds) >= 6
|
|
2615
|
+
return self.set_common_param(12, thresholds)
|
|
2616
|
+
|
|
2617
|
+
def set_ft_collision_reb_distance(self, distances, is_radian=None):
|
|
2618
|
+
assert isinstance(distances, Iterable) and len(distances) >= 6
|
|
2619
|
+
is_radian = self._default_is_radian if is_radian is None else is_radian
|
|
2620
|
+
if not is_radian:
|
|
2621
|
+
distances[3:6] = list(map(lambda x: float('{}'.format(math.radians(x))), distances[3:6]))
|
|
2622
|
+
return self.set_common_param(14, distances)
|
|
2623
|
+
|
|
2624
|
+
def get_ft_collision_detection(self):
|
|
2625
|
+
return self.get_common_param(11)
|
|
2626
|
+
|
|
2627
|
+
def get_ft_collision_rebound(self):
|
|
2628
|
+
return self.get_common_param(13)
|
|
2629
|
+
|
|
2630
|
+
def get_ft_collision_threshold(self):
|
|
2631
|
+
return self.get_common_param(12)
|
|
2632
|
+
|
|
2633
|
+
def get_ft_collision_reb_distance(self, is_radian=None):
|
|
2634
|
+
ret = self.get_common_param(14)
|
|
2635
|
+
is_radian = self._default_is_radian if is_radian is None else is_radian
|
|
2636
|
+
if ret[0] == 0 and not is_radian:
|
|
2637
|
+
ret[1][3:6] = list(map(lambda x: float('{:.6f}'.format(math.degrees(x))), ret[1][3:6]))
|
|
2638
|
+
return ret
|
|
@@ -76,12 +76,12 @@ class GPIO(Base):
|
|
|
76
76
|
# versions = [ret1[1], ret2[1], ret3[1]]
|
|
77
77
|
|
|
78
78
|
return code, '.'.join(map(str, versions))
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
@xarm_is_connected(_type='get')
|
|
81
81
|
def get_tgpio_digital(self, ionum=None):
|
|
82
82
|
assert ionum is None or ionum == 0 or ionum == 1 or ionum == 2 or ionum == 3 or ionum == 4, 'The value of parameter ionum can only be 0 or 1 or None.'
|
|
83
83
|
if self.check_is_simulation_robot():
|
|
84
|
-
return 0, [0, 0] if ionum is None else 0
|
|
84
|
+
return 0, [0, 0, 0, 0] if ionum is None else 0
|
|
85
85
|
if ionum == 2:
|
|
86
86
|
# Only available for Lite6 and 850
|
|
87
87
|
ret = self.arm_cmd.tgpio_addr_r16(0x0A12)
|
|
@@ -91,6 +91,30 @@ class GPIO(Base):
|
|
|
91
91
|
if ret[0] == 0:
|
|
92
92
|
self.tgpio_state['digital'] = ret[1:]
|
|
93
93
|
return ret[0], ret[1:] if ionum is None else ret[ionum + 1 if ionum < 3 else ionum]
|
|
94
|
+
|
|
95
|
+
@xarm_is_connected(_type='get')
|
|
96
|
+
def get_tool_digital_input(self, ionum=None):
|
|
97
|
+
assert ionum is None or ionum == 0 or ionum == 1 or ionum == 2 or ionum == 3 or ionum == 4, 'The value of parameter ionum can only be 0 or 1 or None.'
|
|
98
|
+
if self.check_is_simulation_robot():
|
|
99
|
+
return 0, [0, 0, 0, 0, 0] if ionum is None else 0
|
|
100
|
+
if ionum == 2:
|
|
101
|
+
# Only available for Lite6 and 850
|
|
102
|
+
ret = self.arm_cmd.tgpio_addr_r16(0x0A12)
|
|
103
|
+
return ret[0], ret[1] & 0x0001
|
|
104
|
+
elif isinstance(ionum, int):
|
|
105
|
+
ret = self.arm_cmd.tgpio_get_digital()
|
|
106
|
+
if ret[0] == 0:
|
|
107
|
+
self.tgpio_state['digital'] = ret[1:]
|
|
108
|
+
return ret[0], ret[ionum+1 if ionum < 3 else ionum]
|
|
109
|
+
else:
|
|
110
|
+
ret1 = self.arm_cmd.tgpio_get_digital()
|
|
111
|
+
if ret1[0] == 0:
|
|
112
|
+
self.tgpio_state['digital'] = ret1[1:]
|
|
113
|
+
ret2 = [0]
|
|
114
|
+
if self.is_lite6 or self.is_850:
|
|
115
|
+
ret2 = self.arm_cmd.tgpio_addr_r16(0x0A12)
|
|
116
|
+
ret1.insert(3, ret2[1])
|
|
117
|
+
return ret1[0] or ret2[0], ret1[1:4] if self.is_lite6 else ret1[1:] if self.is_850 or int(self.sn[2:6]) >= 1305 else ret1[1:3]
|
|
94
118
|
|
|
95
119
|
@xarm_is_connected(_type='get')
|
|
96
120
|
def get_tgpio_output_digital(self, ionum=None):
|
|
@@ -377,9 +401,9 @@ class GPIO(Base):
|
|
|
377
401
|
@xarm_is_ready(_type='set')
|
|
378
402
|
@xarm_is_not_simulation_mode(ret=0)
|
|
379
403
|
def set_tgpio_digital_with_xyz(self, ionum, value, xyz, fault_tolerance_radius):
|
|
380
|
-
assert isinstance(ionum, int) and 1 >= ionum >= 0
|
|
404
|
+
assert isinstance(ionum, int) and (1 >= ionum >= 0 or 4 >= ionum >= 3)
|
|
381
405
|
assert fault_tolerance_radius >= 0, 'The value of parameter fault_tolerance_radius must be greater than or equal to 0.'
|
|
382
|
-
ret = self.arm_cmd.tgpio_position_set_digital(ionum, value, xyz, fault_tolerance_radius)
|
|
406
|
+
ret = self.arm_cmd.tgpio_position_set_digital(ionum - 1 if ionum >= 3 else ionum, value, xyz, fault_tolerance_radius)
|
|
383
407
|
self.log_api_info('API -> set_tgpio_digital_with_xyz(ionum={}, value={}, xyz={}, fault_tolerance_radius={}) -> code={}'.format(ionum, value, xyz, fault_tolerance_radius, ret[0]), code=ret[0])
|
|
384
408
|
return ret[0]
|
|
385
409
|
|
|
@@ -20,6 +20,7 @@ class Gripper(GPIO):
|
|
|
20
20
|
def __init__(self):
|
|
21
21
|
super(Gripper, self).__init__()
|
|
22
22
|
self._gripper_error_code = 0
|
|
23
|
+
self._bio_gripper_version = 0 # 0表示未曾获取SN判别,1表示旧的(获取SN失败), 2表示新的(获取SN成功)
|
|
23
24
|
|
|
24
25
|
@property
|
|
25
26
|
def gripper_error_code(self):
|
|
@@ -612,6 +613,58 @@ class Gripper(GPIO):
|
|
|
612
613
|
code = self.__bio_gripper_wait_enable_completed(timeout=timeout)
|
|
613
614
|
self.log_api_info('API -> set_bio_gripper_enable(enable={}, wait={}, timeout={}) ->code={}'.format(enable, wait, timeout, code), code=code)
|
|
614
615
|
# self.bio_gripper_is_enabled = True if code == 0 else self.bio_gripper_is_enabled
|
|
616
|
+
self.get_bio_gripper_sn()
|
|
617
|
+
return code
|
|
618
|
+
|
|
619
|
+
@xarm_is_connected(_type='get')
|
|
620
|
+
@xarm_is_not_simulation_mode(ret=0)
|
|
621
|
+
def get_bio_gripper_sn(self):
|
|
622
|
+
code, ret = self.get_bio_gripper_register(address=0x0B10, number_of_registers=16)
|
|
623
|
+
if code == APIState.MODBUS_ERR_LENG:
|
|
624
|
+
self._bio_gripper_version = 1
|
|
625
|
+
return code, ret
|
|
626
|
+
elif code != 0:
|
|
627
|
+
self._bio_gripper_version = 0
|
|
628
|
+
return code, ''
|
|
629
|
+
else:
|
|
630
|
+
self._bio_gripper_version = 2
|
|
631
|
+
# return code, ''.join(list(map(chr, ret[5:])))
|
|
632
|
+
ret_list = [int(str(ret[i]) + str(ret[i+1])) for i in range(3, 31, 2)]
|
|
633
|
+
return code, ''.join(list(map(chr, ret_list)))
|
|
634
|
+
|
|
635
|
+
@xarm_is_connected(_type='set')
|
|
636
|
+
@xarm_is_not_simulation_mode(ret=0)
|
|
637
|
+
def set_bio_gripper_control_mode(self, mode):
|
|
638
|
+
data_frame = [0x08, 0x06, 0x11, 0x0A, 0x00, mode]
|
|
639
|
+
code, _ = self.__bio_gripper_send_modbus(data_frame, 6)
|
|
640
|
+
# reset mcu
|
|
641
|
+
data_frame = [0x08, 0x06, 0x06, 0x07, 0x00, 0x01]
|
|
642
|
+
self.__bio_gripper_send_modbus(data_frame, 6)
|
|
643
|
+
# wait mcu reboot
|
|
644
|
+
time.sleep(0.6)
|
|
645
|
+
self.bio_gripper_speed = 0
|
|
646
|
+
return code
|
|
647
|
+
|
|
648
|
+
@xarm_is_connected(_type='get')
|
|
649
|
+
@xarm_is_not_simulation_mode(ret=0)
|
|
650
|
+
def get_bio_gripper_control_mode(self):
|
|
651
|
+
code, ret = self.get_bio_gripper_register(address=0x010A, number_of_registers=1)
|
|
652
|
+
mode = (ret[-2] * 256 + ret[-1]) if code == 0 else -1
|
|
653
|
+
return code, mode
|
|
654
|
+
|
|
655
|
+
# @xarm_is_connected(_type='set')
|
|
656
|
+
# @xarm_is_not_simulation_mode(ret=0)
|
|
657
|
+
# def set_bio_gripper_zero(self):
|
|
658
|
+
# data_frame = [0x08, 0x06, 0x08, 0x0C, 0x00, 0x01]
|
|
659
|
+
# code, _ = self.__bio_gripper_send_modbus(data_frame, 6)
|
|
660
|
+
# return code
|
|
661
|
+
|
|
662
|
+
@xarm_is_connected(_type='set')
|
|
663
|
+
@xarm_is_not_simulation_mode(ret=0)
|
|
664
|
+
def set_bio_gripper_force(self, force):
|
|
665
|
+
force = 1 if force < 1 else 100 if force > 100 else force
|
|
666
|
+
data_frame = [0x08, 0x06, 0x05, 0x06, 0x00, force]
|
|
667
|
+
code, _ = self.__bio_gripper_send_modbus(data_frame, 6)
|
|
615
668
|
return code
|
|
616
669
|
|
|
617
670
|
@xarm_is_connected(_type='set')
|
|
@@ -624,7 +677,7 @@ class Gripper(GPIO):
|
|
|
624
677
|
return code
|
|
625
678
|
|
|
626
679
|
@xarm_is_connected(_type='set')
|
|
627
|
-
def set_bio_gripper_position(self, pos, speed=0, wait=True, timeout=5, **kwargs):
|
|
680
|
+
def set_bio_gripper_position(self, pos, speed=0, force=100, wait=True, timeout=5, **kwargs):
|
|
628
681
|
if kwargs.get('wait_motion', True):
|
|
629
682
|
has_error = self.error_code != 0
|
|
630
683
|
is_stop = self.is_stop
|
|
@@ -638,12 +691,24 @@ class Gripper(GPIO):
|
|
|
638
691
|
self.set_bio_gripper_enable(True)
|
|
639
692
|
if speed > 0 and speed != self.bio_gripper_speed:
|
|
640
693
|
self.set_bio_gripper_speed(speed)
|
|
694
|
+
|
|
695
|
+
if self._bio_gripper_version == 0:
|
|
696
|
+
self.get_bio_gripper_sn()
|
|
697
|
+
if self._bio_gripper_version == 2:
|
|
698
|
+
code, mode = self.get_bio_gripper_control_mode()
|
|
699
|
+
if mode == 1:
|
|
700
|
+
# pos = int(pos * 3.798 - 269.620)
|
|
701
|
+
pos = int(pos * 3.7342 - 265.13)
|
|
702
|
+
self.set_bio_gripper_force(force)
|
|
703
|
+
|
|
641
704
|
data_frame = [0x08, 0x10, 0x07, 0x00, 0x00, 0x02, 0x04]
|
|
642
705
|
data_frame.extend(list(struct.pack('>i', pos)))
|
|
643
706
|
code, _ = self.__bio_gripper_send_modbus(data_frame, 6)
|
|
644
707
|
if code == 0 and wait:
|
|
645
708
|
code = self.__bio_gripper_wait_motion_completed(timeout=timeout)
|
|
646
|
-
self.log_api_info(
|
|
709
|
+
self.log_api_info(
|
|
710
|
+
'API -> set_bio_gripper_position(pos={}, wait={}, timeout={}) ->code={}'.format(pos, wait, timeout, code),
|
|
711
|
+
code=code)
|
|
647
712
|
return code
|
|
648
713
|
|
|
649
714
|
@xarm_is_connected(_type='set')
|
|
@@ -716,6 +781,28 @@ class Gripper(GPIO):
|
|
|
716
781
|
versions[2] = convert.bytes_to_u16(ret[7:9])
|
|
717
782
|
return code, '.'.join(map(str, versions))
|
|
718
783
|
|
|
784
|
+
@xarm_is_connected(_type='get')
|
|
785
|
+
@xarm_is_not_simulation_mode(ret=(0, 0))
|
|
786
|
+
def get_bio_gripper_position(self):
|
|
787
|
+
code, ret = self.get_bio_gripper_register(address=0x0702, number_of_registers=2)
|
|
788
|
+
bio_position = (ret[-4] * 256**3 + ret[-3] * 256**2 + ret[-2] * 256 + ret[-1]) if code == 0 else -1
|
|
789
|
+
bio_position = round((bio_position + 265.13) / 3.7342, 0)
|
|
790
|
+
return code, bio_position
|
|
791
|
+
|
|
792
|
+
@xarm_is_connected(_type='get')
|
|
793
|
+
@xarm_is_not_simulation_mode(ret=(0, 0))
|
|
794
|
+
def get_bio_gripper_speed(self):
|
|
795
|
+
code, ret = self.get_bio_gripper_register(address=0x0303)
|
|
796
|
+
bio_speed = (ret[-2] * 256 + ret[-1]) if code == 0 else -1
|
|
797
|
+
return code, bio_speed
|
|
798
|
+
|
|
799
|
+
@xarm_is_connected(_type='get')
|
|
800
|
+
@xarm_is_not_simulation_mode(ret=(0, 0))
|
|
801
|
+
def get_bio_gripper_force(self):
|
|
802
|
+
code, ret = self.get_bio_gripper_register(address=0x0506)
|
|
803
|
+
bio_force = (ret[-2] * 256 + ret[-1]) if code == 0 else -1
|
|
804
|
+
return code, bio_force
|
|
805
|
+
|
|
719
806
|
@xarm_is_connected(_type='set')
|
|
720
807
|
def clean_bio_gripper_error(self):
|
|
721
808
|
data_frame = [0x08, 0x06, 0x00, 0x0F, 0x00, 0x00]
|
|
@@ -1555,13 +1555,19 @@ class XArm(Gripper, Servo, Record, RobotIQ, BaseBoard, Track, FtSensor, ModbusTc
|
|
|
1555
1555
|
x = kwargs.get('x') if 'x' in kwargs else args[0]
|
|
1556
1556
|
y = kwargs.get('y') if 'y' in kwargs else args[1]
|
|
1557
1557
|
z = kwargs.get('z') if 'z' in kwargs else args[2]
|
|
1558
|
-
|
|
1558
|
+
x_offset = kwargs.get('x_offset') if 'x_offset' in kwargs else args[3] if len(args) >= 4 else 0
|
|
1559
|
+
y_offset = kwargs.get('y_offset') if 'y_offset' in kwargs else args[4] if len(args) >= 5 else 0
|
|
1560
|
+
z_offset = kwargs.get('z_offset') if 'z_offset' in kwargs else args[5] if len(args) >= 6 else 0
|
|
1561
|
+
params = [x, y, z, x_offset, y_offset, z_offset]
|
|
1559
1562
|
elif tool_type == XCONF.CollisionToolType.CYLINDER:
|
|
1560
1563
|
assert ('radius' in kwargs or len(args) >= 2) \
|
|
1561
1564
|
and ('height' in kwargs or len(args) >= 1), 'params error, must specify radius,height parameter'
|
|
1562
1565
|
radius = kwargs.get('radius') if 'radius' in kwargs else args[0]
|
|
1563
1566
|
height = kwargs.get('height') if 'height' in kwargs else args[1]
|
|
1564
|
-
|
|
1567
|
+
x_offset = kwargs.get('x_offset') if 'x_offset' in kwargs else args[2] if len(args) >= 3 else 0
|
|
1568
|
+
y_offset = kwargs.get('y_offset') if 'y_offset' in kwargs else args[3] if len(args) >= 4 else 0
|
|
1569
|
+
z_offset = kwargs.get('z_offset') if 'z_offset' in kwargs else args[4] if len(args) >= 5 else 0
|
|
1570
|
+
params = [radius, height, x_offset, y_offset, z_offset]
|
|
1565
1571
|
else:
|
|
1566
1572
|
params = [] if tool_type < XCONF.CollisionToolType.USE_PRIMITIVES else list(args)
|
|
1567
1573
|
ret = self.arm_cmd.set_collision_tool_model(tool_type, params)
|
|
@@ -1756,19 +1762,21 @@ class XArm(Gripper, Servo, Record, RobotIQ, BaseBoard, Track, FtSensor, ModbusTc
|
|
|
1756
1762
|
return ret[0], ret[1][0]
|
|
1757
1763
|
|
|
1758
1764
|
@xarm_is_connected(_type='set')
|
|
1759
|
-
def get_max_joint_velocity(self, eveloc, joint_pos, is_radian=None):
|
|
1765
|
+
def get_max_joint_velocity(self, eveloc, joint_pos, is_radian=None, return_is_radian=True):
|
|
1760
1766
|
"""
|
|
1761
1767
|
Obtain maximum joint angular velocity
|
|
1762
1768
|
:param eveloc: Maximum TCP speed
|
|
1763
1769
|
:param joint_pos: joint angle list (unit: rad if is_radian is True else °), angle should be a list of values
|
|
1764
|
-
whose length is the number of joints like [axis-1, axis-2, axis-3, axis-
|
|
1765
|
-
:param is_radian: the
|
|
1770
|
+
whose length is the number of joints like [axis-1, axis-2, axis-3, axis-4, axis-5, axis-6, axis-7]
|
|
1771
|
+
:param is_radian: the param angles value is in radians or not, default is self.default_is_radian
|
|
1772
|
+
:param return_is_radian: the returned value is in radians or not, default is True
|
|
1766
1773
|
"""
|
|
1767
1774
|
is_radian = self._default_is_radian if is_radian is None else is_radian
|
|
1768
1775
|
joints = [0] * 7
|
|
1769
1776
|
for i in range(min(len(joint_pos), 7)):
|
|
1770
1777
|
joints[i] = to_radian(joint_pos[i], is_radian)
|
|
1771
|
-
|
|
1778
|
+
ret = self.arm_cmd.get_max_joint_velocity(eveloc, joints)
|
|
1779
|
+
return ret if return_is_radian else math.radians(ret)
|
|
1772
1780
|
|
|
1773
1781
|
@xarm_is_connected(_type='get')
|
|
1774
1782
|
def iden_tcp_load(self, estimated_mass=0):
|
|
@@ -1855,7 +1863,7 @@ class XArm(Gripper, Servo, Record, RobotIQ, BaseBoard, Track, FtSensor, ModbusTc
|
|
|
1855
1863
|
@xarm_is_ready(_type='set')
|
|
1856
1864
|
def send_hex_cmd(self, datas, timeout=10):
|
|
1857
1865
|
ret = self.arm_cmd.send_hex_cmd(datas, timeout)
|
|
1858
|
-
return ret[1:]
|
|
1866
|
+
return self._check_code(ret[0]), ret[1:]
|
|
1859
1867
|
# ret = self.arm_cmd.send_hex_request(datas)
|
|
1860
1868
|
# if ret == -1:
|
|
1861
1869
|
# return [XCONF.UxbusState.ERR_NOTTCP]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.14.8'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xarm_python_sdk-1.14.8 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|