|
44 | 44 | from .utils import compare_time, version_is_ge, filter_invalid_number |
45 | 45 | from .decorator import xarm_is_connected, xarm_is_ready, xarm_is_not_simulation_mode, xarm_wait_until_cmdnum_lt_max, xarm_wait_until_not_pause |
46 | 46 | from .code import APIState |
| 47 | +from .report import ReportDataStructure |
47 | 48 | from ..tools.threads import ThreadManage |
48 | 49 | from ..version import __version__ |
49 | 50 |
|
@@ -274,6 +275,8 @@ def __init__(self, port=None, is_radian=False, do_not_open=False, **kwargs): |
274 | 275 | self.rh56_finger_speed = [0, 0, 0, 0, 0, 0] |
275 | 276 | self.rh56_finger_force = [0, 0, 0, 0, 0, 0] |
276 | 277 |
|
| 278 | + self.report_data = None |
| 279 | + |
277 | 280 | if not do_not_open: |
278 | 281 | self.connect() |
279 | 282 |
|
@@ -1201,16 +1204,19 @@ def _connect_report(self): |
1201 | 1204 | self._port, XCONF.SocketConf.TCP_REPORT_REAL_PORT, |
1202 | 1205 | buffer_size=1024 if not self._is_old_protocol else 87, |
1203 | 1206 | forbid_uds=self._forbid_uds) |
| 1207 | + self.report_data = ReportDataStructure.create(XCONF.SocketConf.TCP_REPORT_REAL_PORT, is_radian=self._default_is_radian) |
1204 | 1208 | elif self._report_type == 'normal': |
1205 | 1209 | self._stream_report = SocketPort( |
1206 | 1210 | self._port, XCONF.SocketConf.TCP_REPORT_NORM_PORT, |
1207 | 1211 | buffer_size=XCONF.SocketConf.TCP_REPORT_NORMAL_BUF_SIZE if not self._is_old_protocol else 87, |
1208 | 1212 | forbid_uds=self._forbid_uds) |
| 1213 | + self.report_data = ReportDataStructure.create(XCONF.SocketConf.TCP_REPORT_NORM_PORT, is_radian=self._default_is_radian) |
1209 | 1214 | else: |
1210 | 1215 | self._stream_report = SocketPort( |
1211 | 1216 | self._port, XCONF.SocketConf.TCP_REPORT_RICH_PORT, |
1212 | 1217 | buffer_size=1024 if not self._is_old_protocol else 187, |
1213 | 1218 | forbid_uds=self._forbid_uds) |
| 1219 | + self.report_data = ReportDataStructure.create(XCONF.SocketConf.TCP_REPORT_RICH_PORT, is_radian=self._default_is_radian) |
1214 | 1220 |
|
1215 | 1221 | def __report_callback(self, report_id, item, name=''): |
1216 | 1222 | if report_id in self._report_callbacks.keys(): |
@@ -1349,6 +1355,7 @@ def _report_thread_handle(self): |
1349 | 1355 | size = convert.bytes_to_u32(recv_data) |
1350 | 1356 | if self._is_old_protocol and size > 256: |
1351 | 1357 | self._is_old_protocol = False |
| 1358 | + self.report_data.update(recv_data) |
1352 | 1359 | self._handle_report_data(recv_data) |
1353 | 1360 | # else: |
1354 | 1361 | # if self.connected: |
@@ -2245,6 +2252,7 @@ def get_joint_states(self, is_radian=None, num=3): |
2245 | 2252 | ret[0] = self._check_code(ret[0]) |
2246 | 2253 | positon = ret[1:8] |
2247 | 2254 | result = [positon] |
| 2255 | + num = num & 0x0F |
2248 | 2256 | if num >= 2: |
2249 | 2257 | velocity = ret[8:15] |
2250 | 2258 | result.append(velocity) |
|
0 commit comments