xArm-Python-SDK 1.14.7__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.
Files changed (72) hide show
  1. xarm_python_sdk-1.15.0/PKG-INFO +22 -0
  2. xarm_python_sdk-1.15.0/README.rst +7 -0
  3. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/setup.py +2 -2
  4. xarm_python_sdk-1.15.0/xArm_Python_SDK.egg-info/PKG-INFO +22 -0
  5. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/SOURCES.txt +1 -1
  6. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd.py +7 -1
  7. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_base.py +22 -2
  8. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_handler.py +129 -19
  9. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_tool.py +4 -0
  10. xarm_python_sdk-1.15.0/xarm/version.py +1 -0
  11. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/wrapper/xarm_api.py +182 -7
  12. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/base.py +35 -1
  13. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/gpio.py +30 -6
  14. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/gripper.py +89 -2
  15. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/xarm.py +15 -7
  16. xarm_python_sdk-1.14.7/PKG-INFO +0 -10
  17. xarm_python_sdk-1.14.7/README.md +0 -430
  18. xarm_python_sdk-1.14.7/xArm_Python_SDK.egg-info/PKG-INFO +0 -10
  19. xarm_python_sdk-1.14.7/xarm/version.py +0 -1
  20. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/LICENSE +0 -0
  21. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/setup.cfg +0 -0
  22. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/dependency_links.txt +0 -0
  23. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/not-zip-safe +0 -0
  24. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xArm_Python_SDK.egg-info/top_level.txt +0 -0
  25. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/__init__.py +0 -0
  26. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/__init__.py +0 -0
  27. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/comm/__init__.py +0 -0
  28. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/comm/base.py +0 -0
  29. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/comm/serial_port.py +0 -0
  30. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/comm/socket_port.py +0 -0
  31. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/comm/uxbus_cmd_protocol.py +0 -0
  32. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/config/__init__.py +0 -0
  33. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/config/x_code.py +0 -0
  34. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/config/x_config.py +0 -0
  35. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/utils/__init__.py +0 -0
  36. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/utils/convert.py +0 -0
  37. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/utils/crc16.py +0 -0
  38. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/utils/debug_print.py +0 -0
  39. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/utils/log.py +0 -0
  40. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/version.py +0 -0
  41. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/__init__.py +0 -0
  42. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd_ser.py +0 -0
  43. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/core/wrapper/uxbus_cmd_tcp.py +0 -0
  44. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/__init__.py +0 -0
  45. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/__init__.py +0 -0
  46. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_highlight.py +0 -0
  47. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly/_blockly_node.py +0 -0
  48. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/blockly_tool.py +0 -0
  49. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/gcode.py +0 -0
  50. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/list_ports.py +0 -0
  51. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/modbus_tcp.py +0 -0
  52. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/threads.py +0 -0
  53. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/tools/utils.py +0 -0
  54. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/wrapper/__init__.py +0 -0
  55. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/wrapper/studio_api.py +0 -0
  56. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/__init__.py +0 -0
  57. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/base_board.py +0 -0
  58. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/code.py +0 -0
  59. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/decorator.py +0 -0
  60. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/events.py +0 -0
  61. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/ft_sensor.py +0 -0
  62. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/grammar_async.py +0 -0
  63. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/grammar_coroutine.py +0 -0
  64. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/modbus_tcp.py +0 -0
  65. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/parse.py +0 -0
  66. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/record.py +0 -0
  67. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/report.py +0 -0
  68. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/robotiq.py +0 -0
  69. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/servo.py +0 -0
  70. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/studio.py +0 -0
  71. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/track.py +0 -0
  72. {xarm_python_sdk-1.14.7 → xarm_python_sdk-1.15.0}/xarm/x3/utils.py +0 -0
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: xArm-Python-SDK
3
+ Version: 1.15.0
4
+ Summary: Python SDK for xArm
5
+ Author: Vinman
6
+ Author-email: vinman@ufactory.cc
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: description
12
+ Dynamic: license
13
+ Dynamic: license-file
14
+ Dynamic: summary
15
+
16
+ Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.
17
+
18
+ :Website: https://www.ufactory.cc/
19
+ :Github: https://github.com/xArm-Developer/xArm-Python-SDK
20
+ :Docs: http://docs.api.ufactory.cc
21
+ :Release Note: https://github.com/xArm-Developer/xArm-Python-SDK/blob/master/README.md#update-summary
22
+ :Bug Reports: support@ufactory.cc
@@ -0,0 +1,7 @@
1
+ Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.
2
+
3
+ :Website: https://www.ufactory.cc/
4
+ :Github: https://github.com/xArm-Developer/xArm-Python-SDK
5
+ :Docs: http://docs.api.ufactory.cc
6
+ :Release Note: https://github.com/xArm-Developer/xArm-Python-SDK/blob/master/README.md#update-summary
7
+ :Bug Reports: support@ufactory.cc
@@ -36,8 +36,8 @@ with open(os.path.join(os.getcwd(), ver_path)) as ver_file:
36
36
 
37
37
  version = main_ns['__version__']
38
38
 
39
- # long_description = open('README.rst').read()
40
- long_description = 'long description for xArm-Python-SDK'
39
+ long_description = open('README.rst').read()
40
+ # long_description = 'long description for xArm-Python-SDK'
41
41
 
42
42
  try:
43
43
  with open(os.path.join(os.getcwd(), 'requirements.txt')) as f:
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: xArm-Python-SDK
3
+ Version: 1.15.0
4
+ Summary: Python SDK for xArm
5
+ Author: Vinman
6
+ Author-email: vinman@ufactory.cc
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: description
12
+ Dynamic: license
13
+ Dynamic: license-file
14
+ Dynamic: summary
15
+
16
+ Python SDK for UFACTORY robotic arm 850, xArm 5/6/7, and Lite6.
17
+
18
+ :Website: https://www.ufactory.cc/
19
+ :Github: https://github.com/xArm-Developer/xArm-Python-SDK
20
+ :Docs: http://docs.api.ufactory.cc
21
+ :Release Note: https://github.com/xArm-Developer/xArm-Python-SDK/blob/master/README.md#update-summary
22
+ :Bug Reports: support@ufactory.cc
@@ -1,5 +1,5 @@
1
1
  LICENSE
2
- README.md
2
+ README.rst
3
3
  setup.py
4
4
  xArm_Python_SDK.egg-info/PKG-INFO
5
5
  xArm_Python_SDK.egg-info/SOURCES.txt
@@ -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, 5)
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
 
@@ -31,6 +31,7 @@ class _BlocklyBase(_BlocklyNode):
31
31
  self._funcs = {}
32
32
  self._define_is_prime_func = False
33
33
  self._define_bin_matchs_func = False
34
+ self._vacuum_version = '1'
34
35
 
35
36
  def _get_field_value(self, block):
36
37
  field = self._get_node('field', root=block)
@@ -94,12 +95,13 @@ class _BlocklyBase(_BlocklyNode):
94
95
  self._define_bin_matchs_func = True
95
96
  return 'self._cgpio_digitals_is_matchs_bin(\'{}\')'.format(bin_val)
96
97
  elif block.attrib['type'] == 'get_suction_cup':
97
- return 'self._arm.get_suction_cup()[{}]'.format(1)
98
+ return 'self._arm.get_suction_cup(hardware_version={})[{}]'.format(self._vacuum_version, 1)
98
99
  elif block.attrib['type'] == 'check_air_pump_state':
99
100
  fields = self._get_nodes('field', root=block)
100
101
  state = 1 if fields[0].text == 'ON' else 0
101
102
  timeout = float(fields[1].text)
102
- return 'self._arm.arm.check_air_pump_state({}, timeout={})'.format(state, timeout)
103
+ return 'self._arm.arm.check_air_pump_state({}, timeout={}, hardware_version={})'.format(state, timeout,
104
+ self._vacuum_version)
103
105
  elif block.attrib['type'] == 'check_bio_gripper_is_catch':
104
106
  fields = self._get_nodes('field', root=block)
105
107
  timeout = float(fields[0].text)
@@ -222,6 +224,24 @@ class _BlocklyBase(_BlocklyNode):
222
224
  addr = int(fields[0].text.replace(' ', '').replace('0x', '').replace(',', '').replace('\xa0', ''), 16)
223
225
  return "list(map(lambda x: hex(x).split('0x')[1].upper().zfill(4)[:2] + ' ' + hex(x).split('0x')[1]." \
224
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)
225
245
 
226
246
 
227
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
 
@@ -41,6 +42,7 @@ class _BlocklyHandler(_BlocklyBase):
41
42
  self.is_run_linear_track = False
42
43
  self._is_run_blockly = False
43
44
  self._listen_counter = False
45
+ self._vacuum_version = '1'
44
46
 
45
47
  def _append_init_code(self, code):
46
48
  self._init_code_list.append(code)
@@ -416,8 +418,9 @@ class _BlocklyHandler(_BlocklyBase):
416
418
  fields = self._get_nodes('field', root=block)
417
419
  io = fields[0].text
418
420
  value = 0 if fields[1].text == 'LOW' else 1
419
- delay_sec = fields[2].text if len(fields) > 2 else 0
420
- self._append_main_code('code = self._arm.set_tgpio_digital({}, {}, delay_sec={})'.format(io, value, delay_sec), indent + 2)
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)
421
424
  self._append_main_code('if not self._check_code(code, \'set_tgpio_digital\'):', indent + 2)
422
425
  self._append_main_code(' return', indent + 2)
423
426
 
@@ -434,14 +437,36 @@ class _BlocklyHandler(_BlocklyBase):
434
437
  self._append_main_code('if not self._check_code(code, \'set_tgpio_digital_with_xyz\'):', indent + 2)
435
438
  self._append_main_code(' return', indent + 2)
436
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
+
437
462
  def _handle_get_suction_cup(self, block, indent=0, arg_map=None):
438
- self._append_main_code('{}self._arm.get_suction_cup()', indent + 2)
463
+ self._append_main_code('{}self._arm.get_suction_cup(hardware_version={})'.format('{}', self._vacuum_version), indent + 2)
439
464
 
440
465
  def _handle_check_air_pump_state(self, block, indent=0, arg_map=None):
441
466
  fields = self._get_nodes('field', root=block)
442
467
  state = 1 if fields[0].text == 'ON' else 0
443
468
  timeout = float(fields[1].text)
444
- 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)
445
470
 
446
471
  def _handle_check_bio_gripper_is_catch(self, block, indent=0, arg_map=None):
447
472
  fields = self._get_nodes('field', root=block)
@@ -463,7 +488,7 @@ class _BlocklyHandler(_BlocklyBase):
463
488
  wait = False
464
489
  fields = self._get_nodes('field', root=block, name='delay')
465
490
  delay_sec = fields[0].text if len(fields) > 0 else 0
466
- self._append_main_code('code = self._arm.set_suction_cup({}, wait={}, delay_sec={})'.format( on, wait, delay_sec), indent + 2)
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)
467
492
  self._append_main_code('if not self._check_code(code, \'set_suction_cup\'):', indent + 2)
468
493
  self._append_main_code(' return', indent + 2)
469
494
 
@@ -510,8 +535,9 @@ class _BlocklyHandler(_BlocklyBase):
510
535
  fields = self._get_nodes('field', root=block)
511
536
  io = fields[0].text
512
537
  value = 0 if fields[1].text == 'LOW' else 1
513
- delay_sec = fields[2].text if len(fields) > 2 else 0
514
- self._append_main_code('code = self._arm.set_cgpio_digital({}, {}, delay_sec={})'.format(io, value, delay_sec), indent + 2)
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)
515
541
  self._append_main_code('if not self._check_code(code, \'set_cgpio_digital\'):', indent + 2)
516
542
  self._append_main_code(' return', indent + 2)
517
543
 
@@ -524,6 +550,27 @@ class _BlocklyHandler(_BlocklyBase):
524
550
  tol_r = fields[3].text
525
551
  io = fields[4].text
526
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
527
574
  self._append_main_code('code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
528
575
  self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
529
576
  self._append_main_code(' return', indent + 2)
@@ -532,20 +579,43 @@ class _BlocklyHandler(_BlocklyBase):
532
579
  fields = self._get_nodes('field', root=block)
533
580
  io = fields[0].text
534
581
  value = 0 if fields[1].text == 'LOW' else 1
535
- delay_sec = fields[2].text if len(fields) > 2 else 0
536
- self._append_main_code('code = self._arm.set_cgpio_digital({}, {}, delay_sec={})'.format(io, value, delay_sec), indent + 2)
537
- self._append_main_code('if not self._check_code(code, \'set_suction_cup\'):', indent + 2)
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)
538
586
  self._append_main_code(' return', indent + 2)
539
587
 
540
588
  def _handle_gpio_set_controller_digital_with_xyz_do(self, block, indent=0, arg_map=None):
541
- fields = self._get_nodes('field', root=block)
542
- x = fields[0].text
543
- y = fields[1].text
544
- z = fields[2].text
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)
545
593
  xyz = list(map(float, [x, y, z]))
546
- tol_r = fields[3].text
547
- io = fields[4].text
548
- value = 0 if fields[5].text == 'LOW' else 1
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])
549
619
  self._append_main_code('code = self._arm.set_cgpio_digital_with_xyz({}, {}, {}, {})'.format(io, value, xyz, tol_r), indent + 2)
550
620
  self._append_main_code('if not self._check_code(code, \'set_cgpio_digital_with_xyz\'):', indent + 2)
551
621
  self._append_main_code(' return', indent + 2)
@@ -563,11 +633,35 @@ class _BlocklyHandler(_BlocklyBase):
563
633
  self._append_main_code('if not self._check_code(code, \'set_cgpio_analog_with_xyz\'):', indent + 2)
564
634
  self._append_main_code(' return', indent + 2)
565
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
+
566
658
  def _handle_gpio_set_controller_analog(self, block, indent=0, arg_map=None):
567
- io = self._get_node('field', block).text
659
+ fields = self._get_nodes('field', root=block)
660
+ io = fields[0].text
661
+ is_sync = fields[1].text
568
662
  value = self._get_node('value', root=block)
569
663
  value = self._get_block_val(value, arg_map=arg_map)
570
- 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)
571
665
  self._append_main_code('if not self._check_code(code, \'set_cgpio_analog\'):', indent + 2)
572
666
  self._append_main_code(' return', indent + 2)
573
667
 
@@ -685,6 +779,11 @@ class _BlocklyHandler(_BlocklyBase):
685
779
  self._append_main_code('if not self._check_code(code, \'set_gripper_status\'):', indent + 2)
686
780
  self._append_main_code(' return', indent + 2)
687
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
+
688
787
  def _handle_set_bio_gripper_init(self, block, indent=0, arg_map=None):
689
788
  self._append_main_code('code = self._arm.set_bio_gripper_enable(True)', indent + 2)
690
789
  self._append_main_code('if not self._check_code(code, \'set_bio_gripper_enable\'):', indent + 2)
@@ -706,6 +805,16 @@ class _BlocklyHandler(_BlocklyBase):
706
805
  self._append_main_code('if not self._check_code(code, \'close_bio_gripper\'):', indent + 2)
707
806
  self._append_main_code(' return', indent + 2)
708
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
+
709
818
  def _handle_set_robotiq_init(self, block, indent=0, arg_map=None):
710
819
  self._append_main_code('code, ret = self._arm.robotiq_reset()', indent + 2)
711
820
  self._append_main_code('if not self._check_code(code, \'robotiq_reset\'):', indent + 2)
@@ -1123,6 +1232,7 @@ class _BlocklyHandler(_BlocklyBase):
1123
1232
  if (self._is_exec or (not self._is_exec and not self._is_ide)) and code.strip() and code not in \
1124
1233
  ['finally:', 'else:'] and all([i not in code for i in ['elif', 'except', 'def', 'class']]) \
1125
1234
  and not code.startswith('@'):
1235
+ # 只有在studio执行blockly时或者SDK直接调用run_blockly_app时才会执行
1126
1236
  code_indent = re.match('(\s*).*', code).group(1)
1127
1237
  self._append_main_code(code_indent + 'if not self.is_alive:', indent + 2)
1128
1238
  self._append_main_code(code_indent + 'return', indent + 3)
@@ -24,6 +24,7 @@ class BlocklyTool(_BlocklyHandler):
24
24
  if not self._is_converted:
25
25
  self._is_exec = kwargs.get('is_exec', False)
26
26
  self._is_ide = kwargs.get('is_ide', False)
27
+ self._vacuum_version = kwargs.get('vacuum_version', '1')
27
28
  # highlight_callback: only use pack to run blockly in studio
28
29
  self._highlight_callback = kwargs.get('highlight_callback', None)
29
30
  # axis_type: Obtain the type of mechanical arm axis for end leveling use
@@ -96,6 +97,9 @@ class BlocklyTool(_BlocklyHandler):
96
97
  self._append_main_code(' # Event Loop', indent=-1)
97
98
  self._append_main_code(' while self.is_alive:', indent=-1)
98
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)
99
103
  # catch exception and release callback
100
104
  self._append_main_code(' except Exception as e:', indent=-1)
101
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 of gravity
1681
+ Set the gravity direction for proper torque compensation and collision detection.
1682
1682
 
1683
1683
  Note:
1684
- 1. Do not use if not required
1685
- 2. If not saved, it will be lost after reboot
1686
- 3. The save_conf interface can record the current settings and will not be lost after the restart.
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 of gravity, such as [x(mm), y(mm), z(mm)]
1690
- :param wait: whether to wait for the robotic arm to stop or all previous queue commands to be executed or cleared before setting
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:Pass, -1: Fail, >0: abnormal(1:Trajectory not loaded or incorrect status;2:The input magnification is incorrect)
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)