Skip to content

Commit

Permalink
[fix] fix ft_sensor_get_error
Browse files Browse the repository at this point in the history
  • Loading branch information
vimior committed Sep 28, 2024
1 parent 5a86d4a commit 490c725
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
8 changes: 4 additions & 4 deletions doc/api/xarm_api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xArm-Python-SDK API Documentation (V1.14.6): class XArmAPI in module xarm.wrapper.xarm_api
xArm-Python-SDK API Documentation (V1.14.7): class XArmAPI in module xarm.wrapper.xarm_api

## class __XArmAPI__
****************************************
Expand Down Expand Up @@ -1673,9 +1673,9 @@ xArm-Python-SDK API Documentation (V1.14.6): class XArmAPI in module xarm.wrappe
>     2: Contact Connection
> :return: tuple((code, state)), only when code is 0, the returned result is correct.
>     code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
>     state: suction cup state
>         0: suction cup is off
>         1: suction cup is on
>     state: vacuum gripper state
>         0: vacuum gripper is off
>         1: vacuum gripper is on

#### def __get_version__(self):
Expand Down
6 changes: 4 additions & 2 deletions doc/tool/gen_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import pydoc
import re

sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
curr_file_dir = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(curr_file_dir, '../..'))

from xarm.wrapper import XArmAPI
from xarm.version import __version__

from doc.tool.markdown_doc import MarkdownDoc

open('../api/xarm_api.md', 'w', encoding='utf-8').write(
doc_filepath = os.path.join(curr_file_dir, '../api/xarm_api.md')
open(doc_filepath, 'w', encoding='utf-8').write(
pydoc.render_doc(XArmAPI,
title='xArm-Python-SDK API Documentation (V{}): %s'.format(__version__),
renderer=MarkdownDoc()))
Expand Down
32 changes: 19 additions & 13 deletions xarm/core/wrapper/uxbus_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,21 +1247,27 @@ def ft_sensor_get_config(self):
]
return ret

@lock_require
def ft_sensor_get_error(self):
txdata = bytes([8])
txdata += convert.u16_to_bytes(0x0010)
ret = self.send_modbus_request(XCONF.UxbusReg.SERVO_R16B, txdata, 3)
if ret == -1:
return [XCONF.UxbusState.ERR_NOTTCP] * (7 + 1)
ret = self.servo_addr_r16(8, 0x0010)
if ret[0] in [0, 1, 2] and len(ret) > 1 and ret[1] == 27:
ret[0] = 0
return ret

ret = self.recv_modbus_response(XCONF.UxbusReg.SERVO_R16B, ret, 4, XCONF.UxbusConf.GET_TIMEOUT)
if ret[0] in [0, 1, 2]:
if convert.bytes_to_long_big(ret[1:5]) == 27:
return [ret[0], 0]
else:
return [ret[0], ret[3]]
return [ret[0], 0]
# @lock_require
# def ft_sensor_get_error(self):
# txdata = bytes([8])
# txdata += convert.u16_to_bytes(0x0010)
# ret = self.send_modbus_request(XCONF.UxbusReg.SERVO_R16B, txdata, 3)
# if ret == -1:
# return [XCONF.UxbusState.ERR_NOTTCP] * (7 + 1)

# ret = self.recv_modbus_response(XCONF.UxbusReg.SERVO_R16B, ret, 4, self._G_TOUT)
# if ret[0] in [0, 1, 2]:
# if convert.bytes_to_long_big(ret[1:5]) == 27:
# return [ret[0], 0]
# else:
# return [ret[0], ret[3]]
# return [ret[0], 0]

def cali_tcp_pose(self, four_pnts):
txdata = []
Expand Down
6 changes: 3 additions & 3 deletions xarm/wrapper/xarm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1922,9 +1922,9 @@ def get_vacuum_gripper(self, hardware_version=1):
2: Contact Connection
:return: tuple((code, state)), only when code is 0, the returned result is correct.
code: See the [API Code Documentation](./xarm_api_code.md#api-code) for details.
state: suction cup state
0: suction cup is off
1: suction cup is on
state: vacuum gripper state
0: vacuum gripper is off
1: vacuum gripper is on
"""
return self._arm.get_suction_cup(hardware_version=hardware_version)

Expand Down

0 comments on commit 490c725

Please sign in to comment.