Skip to content

Commit 6c8c2d5

Browse files
committed
[feat] support new version vacuum gripper
1. support vacuum gripper with contact connection
1 parent a471f9f commit 6c8c2d5

File tree

6 files changed

+49
-22
lines changed

6 files changed

+49
-22
lines changed

doc/api/xarm_api.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrapper.xarm_api
1+
xArm-Python-SDK API Documentation (V1.14.6): class XArmAPI in module xarm.wrapper.xarm_api
22

33
## class __XArmAPI__
44
****************************************
@@ -978,7 +978,7 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
978978

979979
> Get the digital value of the specified Controller GPIO
980980
>
981-
> :param ionum: 0~15 or None(both 0~15), default is None
981+
> :param ionum: 0~7(CI0~CI7), 8~15(DI0~DI7) or None(both 0~15), default is None
982982
> :return: tuple((code, value or value list)), only when code is 0, the returned result is correct.
983983
>     code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
984984
@@ -1619,6 +1619,19 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
16191619
>     code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
16201620
16211621

1622+
#### def __get_traj_speeding__(self, rate):
1623+
1624+
> Obtain the joint and velocity values of joint overspeed during trajectory recording
1625+
> :param rate: speed rate, It can only be 1/2/4
1626+
>
1627+
> :return: tuple((code, speed_info)), only when code is 0, the returned result is correct.
1628+
>     code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
1629+
>     speed_info: [result_code, servo_id, servo_speed]
1630+
>                 result_code: 0:Pass, -1: Fail, >0: abnormal(1:Trajectory not loaded or incorrect status;2:The input magnification is incorrect)
1631+
>                 servo_id: Effective only when result_code is -1
1632+
>                 servo_speed: Effective only when result_code is -1
1633+
1634+
16221635
#### def __get_trajectories__(self):
16231636

16241637
> get the trajectories
@@ -2311,6 +2324,14 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
23112324
> :param path: app path
23122325
23132326

2327+
#### def __run_gcode_app__(self, path, **kwargs):
2328+
2329+
> Run gcode project file by xArmStudio software
2330+
> :param path: gcode file path
2331+
>
2332+
> :return: code, only when code is 0, the returned result is correct.
2333+
2334+
23142335
#### def __run_gcode_file__(self, path, **kwargs):
23152336

23162337
> Run the gcode file
@@ -2508,7 +2529,7 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
25082529

25092530
> Set the digital value of the specified Controller GPIO
25102531
>
2511-
> :param ionum: 0~15
2532+
> :param ionum: 0~7(CO0~CO7), 8~15(DO0~DO7)
25122533
> :param value: value
25132534
> :param delay_sec: delay effective time from the current start, in seconds, default is None(effective immediately)
25142535
> :param sync: whether to execute in the motion queue, set to False to execute immediately(default is True)
@@ -2521,7 +2542,7 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
25212542
#### def __set_cgpio_digital_input_function__(self, ionum, fun):
25222543

25232544
> Set the digital input functional mode of the Controller GPIO
2524-
> :param ionum: 0~15
2545+
> :param ionum: 0~7(CI0~CI7), 8~15(DI0~DI7)
25252546
> :param fun: functional mode
25262547
>     0: general input
25272548
>     1: external emergency stop
@@ -2537,7 +2558,7 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
25372558
#### def __set_cgpio_digital_output_function__(self, ionum, fun):
25382559

25392560
> Set the digital output functional mode of the specified Controller GPIO
2540-
> :param ionum: 0~15
2561+
> :param ionum: 0~7(CO0~CO7), 8~15(DO0~DO7)
25412562
> :param fun: functionnal mode
25422563
>     0: general output
25432564
>     1: emergency stop
@@ -3565,7 +3586,7 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
35653586
>         code >= 0: the last_used_tcp_speed/last_used_tcp_acc will be modified
35663587
35673588

3568-
#### def __set_vacuum_gripper__(self, on, wait=False, timeout=3, delay_sec=None, sync=True):
3589+
#### def __set_vacuum_gripper__(self, on, wait=False, timeout=3, delay_sec=None, sync=True, hardware_version=1):
35693590

35703591
> Set vacuum gripper state
35713592
>
@@ -3578,6 +3599,9 @@ xArm-Python-SDK API Documentation (V1.14.2): class XArmAPI in module xarm.wrappe
35783599
> :param sync: whether to execute in the motion queue, set to False to execute immediately(default is True)
35793600
>     1. only available if firmware_version >= 2.4.101
35803601
> &ensp;&ensp;&ensp;&ensp;2. only available if delay_sec <= 0
3602+
> :param hardware_version: hardware version
3603+
> &ensp;&ensp;&ensp;&ensp;1: Plug-in Connection, default
3604+
> &ensp;&ensp;&ensp;&ensp;2: Contact Connection
35813605
> :return: code
35823606
> &ensp;&ensp;&ensp;&ensp;code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
35833607

xarm/core/wrapper/uxbus_cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def move_circle(self, pose1, pose2, mvvelo, mvacc, mvtime, percent, only_check_t
566566

567567
def move_circle_common(self, pose1, pose2, mvvelo, mvacc, mvtime, percent, coord=0, is_axis_angle=False, only_check_type=0, feedback_key=None):
568568
"""
569-
通用指令固件1.10.0开始支持
569+
通用指令, 固件1.10.0开始支持
570570
"""
571571
txdata = [0] * 16
572572
for i in range(6):

xarm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.14.5'
1+
__version__ = '1.14.6'

xarm/wrapper/xarm_api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ def get_vacuum_gripper(self):
19251925
"""
19261926
return self._arm.get_suction_cup()
19271927

1928-
def set_vacuum_gripper(self, on, wait=False, timeout=3, delay_sec=None, sync=True):
1928+
def set_vacuum_gripper(self, on, wait=False, timeout=3, delay_sec=None, sync=True, hardware_version=1):
19291929
"""
19301930
Set vacuum gripper state
19311931
@@ -1938,10 +1938,13 @@ def set_vacuum_gripper(self, on, wait=False, timeout=3, delay_sec=None, sync=Tru
19381938
:param sync: whether to execute in the motion queue, set to False to execute immediately(default is True)
19391939
1. only available if firmware_version >= 2.4.101
19401940
2. only available if delay_sec <= 0
1941+
:param hardware_version: hardware version
1942+
1: Plug-in Connection, default
1943+
2: Contact Connection
19411944
:return: code
19421945
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
19431946
"""
1944-
return self._arm.set_suction_cup(on, wait=wait, timeout=timeout, delay_sec=delay_sec, sync=sync)
1947+
return self._arm.set_suction_cup(on, wait=wait, timeout=timeout, delay_sec=delay_sec, sync=sync, hardware_version=hardware_version)
19451948

19461949
def get_cgpio_digital(self, ionum=None):
19471950
"""

xarm/x3/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,10 @@ def connect(self, port=None, baudrate=None, timeout=None, axis=None, arm_type=No
932932
self._report_connect_changed_callback()
933933
else:
934934
if SerialPort is None:
935-
raise Exception('serial module is not found, if you want to connect to xArm with serial, please `pip install pyserial==3.4`')
935+
raise Exception('serial module is not found, if you want to connect to xArm with serial, please `pip install pyserial>=3.4`')
936936
self._stream = SerialPort(self._port)
937937
if not self.connected:
938-
raise Exception('connect serail failed')
938+
raise Exception('connect serial failed')
939939
self._report_error_warn_changed_callback()
940940

941941
self.arm_cmd = UxbusCmdSer(self._stream)

xarm/x3/gpio.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,21 @@ def get_tgpio_li_state(self, Ti_Li, timeout=3):
336336
@xarm_wait_until_cmdnum_lt_max
337337
@xarm_is_ready(_type='set')
338338
@xarm_is_not_simulation_mode(ret=0)
339-
def set_suction_cup(self, on, wait=True, timeout=3, delay_sec=None, sync=True):
339+
def set_suction_cup(self, on, wait=True, timeout=3, delay_sec=None, sync=True, hardware_version=1):
340340
if on:
341-
code1 = self.set_tgpio_digital(ionum=0, value=1, delay_sec=delay_sec, sync=sync)
342-
code2 = self.set_tgpio_digital(ionum=1, value=0, delay_sec=delay_sec, sync=sync)
341+
code1 = self.set_tgpio_digital(ionum=0 if hardware_version == 1 else 3, value=1, delay_sec=delay_sec, sync=sync)
342+
code2 = self.set_tgpio_digital(ionum=1 if hardware_version == 1 else 4, value=0, delay_sec=delay_sec, sync=sync)
343343
else:
344-
code1 = self.set_tgpio_digital(ionum=0, value=0, delay_sec=delay_sec, sync=sync)
345-
code2 = self.set_tgpio_digital(ionum=1, value=1, delay_sec=delay_sec, sync=sync)
344+
code1 = self.set_tgpio_digital(ionum=0 if hardware_version == 1 else 3, value=0, delay_sec=delay_sec, sync=sync)
345+
code2 = self.set_tgpio_digital(ionum=1 if hardware_version == 1 else 4, value=1, delay_sec=delay_sec, sync=sync)
346346
code = code1 if code2 == 0 else code2
347347
if code == 0 and wait:
348348
start = time.monotonic()
349349
code = APIState.SUCTION_CUP_TOUT
350350
if delay_sec is not None and delay_sec > 0:
351351
timeout += delay_sec
352352
while time.monotonic() - start < timeout:
353-
ret = self.get_suction_cup()
353+
ret = self.get_suction_cup(hardware_version=hardware_version)
354354
if ret[0] == XCONF.UxbusState.ERR_CODE:
355355
code = XCONF.UxbusState.ERR_CODE
356356
break
@@ -369,8 +369,8 @@ def set_suction_cup(self, on, wait=True, timeout=3, delay_sec=None, sync=True):
369369
return code
370370

371371
@xarm_is_connected(_type='get')
372-
def get_suction_cup(self):
373-
return self.get_tgpio_digital(ionum=0)
372+
def get_suction_cup(self, hardware_version=1):
373+
return self.get_tgpio_digital(ionum=0 if hardware_version == 1 else 3)
374374

375375
@xarm_wait_until_not_pause
376376
@xarm_wait_until_cmdnum_lt_max
@@ -412,14 +412,14 @@ def config_io_reset_when_stop(self, io_type, on_off):
412412

413413
@xarm_is_connected(_type='set')
414414
@xarm_is_not_simulation_mode(ret=False)
415-
def check_air_pump_state(self, state, timeout=3):
415+
def check_air_pump_state(self, state, timeout=3, hardware_version=1):
416416
start_time = time.monotonic()
417417
is_first = True
418418
while is_first or time.monotonic() - start_time < timeout:
419419
is_first = False
420420
if not self.connected or self.state == 4:
421421
return False
422-
ret = self.get_suction_cup()
422+
ret = self.get_suction_cup(hardware_version=hardware_version)
423423
if ret[0] == XCONF.UxbusState.ERR_CODE:
424424
return False
425425
if ret[0] == 0:

0 commit comments

Comments
 (0)