Skip to content

Commit b84d392

Browse files
committed
feat:"set_suction_cup and get_suction_cup" add hardware_version param
1 parent 9f6ac54 commit b84d392

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

xarm/tools/blockly/_blockly_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, xml_path):
3131
self._funcs = {}
3232
self._define_is_prime_func = False
3333
self._define_bin_matchs_func = False
34+
self._vacuum_version = '1'
3435

3536
def _get_field_value(self, block):
3637
field = self._get_node('field', root=block)
@@ -94,12 +95,13 @@ def _get_condition_expression(self, value_block, arg_map=None):
9495
self._define_bin_matchs_func = True
9596
return 'self._cgpio_digitals_is_matchs_bin(\'{}\')'.format(bin_val)
9697
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)
9899
elif block.attrib['type'] == 'check_air_pump_state':
99100
fields = self._get_nodes('field', root=block)
100101
state = 1 if fields[0].text == 'ON' else 0
101102
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)
103105
elif block.attrib['type'] == 'check_bio_gripper_is_catch':
104106
fields = self._get_nodes('field', root=block)
105107
timeout = float(fields[0].text)

xarm/tools/blockly/_blockly_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(self, xml_path):
4141
self.is_run_linear_track = False
4242
self._is_run_blockly = False
4343
self._listen_counter = False
44+
self._vacuum_version = '1'
4445

4546
def _append_init_code(self, code):
4647
self._init_code_list.append(code)
@@ -435,7 +436,7 @@ def _handle_gpio_set_digital_with_xyz(self, block, indent=0, arg_map=None):
435436
self._append_main_code(' return', indent + 2)
436437

437438
def _handle_get_suction_cup(self, block, indent=0, arg_map=None):
438-
self._append_main_code('{}self._arm.get_suction_cup()', indent + 2)
439+
self._append_main_code('{}self._arm.get_suction_cup(hardware_version={})'.format('{}', self._vacuum_version), indent + 2)
439440

440441
def _handle_check_air_pump_state(self, block, indent=0, arg_map=None):
441442
fields = self._get_nodes('field', root=block)
@@ -463,7 +464,7 @@ def _handle_set_suction_cup(self, block, indent=0, arg_map=None):
463464
wait = False
464465
fields = self._get_nodes('field', root=block, name='delay')
465466
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)
467+
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)
467468
self._append_main_code('if not self._check_code(code, \'set_suction_cup\'):', indent + 2)
468469
self._append_main_code(' return', indent + 2)
469470

xarm/tools/blockly/_blockly_tool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def to_python(self, path=None, arm=None, init=True, wait_seconds=1, mode=0, stat
2424
if not self._is_converted:
2525
self._is_exec = kwargs.get('is_exec', False)
2626
self._is_ide = kwargs.get('is_ide', False)
27+
self._vacuum_version = kwargs.get('vacuum_version', '1')
2728
# highlight_callback: only use pack to run blockly in studio
2829
self._highlight_callback = kwargs.get('highlight_callback', None)
2930
# axis_type: Obtain the type of mechanical arm axis for end leveling use

0 commit comments

Comments
 (0)