hex-zmq-servers 0.3.4__py3-none-any.whl → 0.3.6__py3-none-any.whl

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.
@@ -12,7 +12,7 @@ import numpy as np
12
12
  from collections import deque
13
13
 
14
14
  from ..cam_base import HexCamBase
15
- from ...zmq_base import hex_zmq_ts_now
15
+ from ...zmq_base import hex_ns_now, hex_zmq_ts_now
16
16
  from ...hex_launch import hex_log, HEX_LOG_LEVEL
17
17
  from berxel_py_wrapper import *
18
18
 
@@ -77,8 +77,21 @@ class HexCamBerxel(HexCamBase):
77
77
  depth_queue = hex_queues[1]
78
78
  stop_event = hex_queues[2]
79
79
 
80
+ # clean cache
81
+ clean_cnt = 0
82
+ while clean_cnt < 5:
83
+ hawk_rgb_frame = self.__device.readColorFrame(40)
84
+ hawk_depth_frame = self.__device.readDepthFrame(40)
85
+ if hawk_rgb_frame is not None:
86
+ self.__device.releaseFrame(hawk_rgb_frame)
87
+ if hawk_depth_frame is not None:
88
+ self.__device.releaseFrame(hawk_depth_frame)
89
+ clean_cnt += 1
90
+ time.sleep(0.01)
91
+
80
92
  rgb_count = 0
81
93
  depth_count = 0
94
+ bias_ns = hex_ns_now() - time.time_ns()
82
95
  while self._working.is_set() and not stop_event.is_set():
83
96
  # read frame
84
97
  hawk_rgb_frame = self.__device.readColorFrame(40)
@@ -86,13 +99,14 @@ class HexCamBerxel(HexCamBase):
86
99
 
87
100
  # collect rgb frame
88
101
  if hawk_rgb_frame is not None:
89
- ts, frame = self.__unpack_frame(hawk_rgb_frame, False)
102
+ ts, frame = self.__unpack_frame(hawk_rgb_frame, False, bias_ns)
90
103
  rgb_queue.append((ts, rgb_count, frame))
91
104
  rgb_count = (rgb_count + 1) % self._max_seq_num
92
105
 
93
106
  # collect depth frame
94
107
  if hawk_depth_frame is not None:
95
- ts, frame = self.__unpack_frame(hawk_depth_frame, True)
108
+ ts, frame = self.__unpack_frame(hawk_depth_frame, True,
109
+ bias_ns)
96
110
  depth_queue.append((ts, depth_count, frame))
97
111
  depth_count = (depth_count + 1) % self._max_seq_num
98
112
 
@@ -102,12 +116,17 @@ class HexCamBerxel(HexCamBase):
102
116
  # close
103
117
  self.close()
104
118
 
105
- def __unpack_frame(self, hawk_frame: BerxelHawkFrame, depth: bool = False):
119
+ def __unpack_frame(
120
+ self,
121
+ hawk_frame: BerxelHawkFrame,
122
+ depth: bool = False,
123
+ bias_ns: int = 0,
124
+ ):
106
125
  # common variables
107
- berxel_ts = hawk_frame.getTimeStamp()
126
+ berxel_ts_ns = bias_ns + int(hawk_frame.getTimeStamp() * 1_000)
108
127
  ts = {
109
- "s": berxel_ts // 1_000_000,
110
- "ns": berxel_ts % 1_000_000 * 1_000,
128
+ "s": berxel_ts_ns // 1_000_000_000,
129
+ "ns": berxel_ts_ns % 1_000_000_000,
111
130
  }
112
131
  width = hawk_frame.getWidth()
113
132
  height = hawk_frame.getHeight()
@@ -176,7 +195,8 @@ class HexCamBerxel(HexCamBase):
176
195
  device_idx = idx
177
196
  break
178
197
  if device_idx == -1:
179
- print(f"can not find device with serial number: {serial_number}")
198
+ print(
199
+ f"can not find device with serial number: {serial_number}")
180
200
  print("available device serial numbers:")
181
201
  for device in device_list:
182
202
  print(f"{device.serialNumber}")
@@ -196,7 +216,9 @@ class HexCamBerxel(HexCamBase):
196
216
  self.__device.setColorExposureGain(self.__exposure, self.__gain)
197
217
  self.__device.setRegistrationEnable(True)
198
218
  self.__device.setFrameSync(True)
199
- self.__device.setSystemClock()
219
+ while self.__device.setSystemClock() != 0:
220
+ print("set system clock failed")
221
+ time.sleep(0.1)
200
222
 
201
223
  intrinsic_params = self.__device.getDeviceIntriscParams()
202
224
  self.__intri[0] = intrinsic_params.colorIntrinsicParams.fx / 2
@@ -124,7 +124,7 @@ class HexNodeConfig():
124
124
  launch_path_dict: dict,
125
125
  ) -> HexNodeConfig:
126
126
  cfg_list = []
127
- for launch_name, launch_path in launch_path_dict.items():
127
+ for launch_name, (launch_path, launch_arg) in launch_path_dict.items():
128
128
  node_default_params_dict = launch_default_params_dict.get(
129
129
  launch_name, {})
130
130
 
@@ -146,6 +146,7 @@ class HexNodeConfig():
146
146
  HexNodeConfig.get_node_cfgs_from_launch(
147
147
  launch_path,
148
148
  launch_update_cfg,
149
+ launch_arg,
149
150
  ))
150
151
 
151
152
  final_cfg = HexNodeConfig()
@@ -159,6 +160,7 @@ class HexNodeConfig():
159
160
  def get_node_cfgs_from_launch(
160
161
  launch_path: str,
161
162
  params: dict | HexNodeConfig = {},
163
+ launch_arg: dict | None = None,
162
164
  ) -> HexNodeConfig:
163
165
  # normalize the path
164
166
  launch_path = os.path.abspath(launch_path)
@@ -185,10 +187,13 @@ class HexNodeConfig():
185
187
  get_node_cfgs_func = getattr(launch_module, "get_node_cfgs")
186
188
  if isinstance(params, dict):
187
189
  print("params is dict")
188
- node_cfgs = get_node_cfgs_func(params)
190
+ node_cfgs = get_node_cfgs_func(params, launch_arg)
189
191
  elif isinstance(params, HexNodeConfig):
190
192
  print("params is HexNodeConfig")
191
- node_cfgs = get_node_cfgs_func(params.get_cfgs(use_list=False))
193
+ node_cfgs = get_node_cfgs_func(
194
+ params.get_cfgs(use_list=False),
195
+ launch_arg,
196
+ )
192
197
  else:
193
198
  raise ValueError(f"Invalid params: {params}")
194
199
  return node_cfgs
@@ -287,6 +287,5 @@ class HexRobotHexarm(HexRobotBase):
287
287
  return
288
288
  self._working.clear()
289
289
  self.__arm_archer.stop()
290
- time.sleep(0.5)
291
290
  self.__hex_api.close()
292
291
  hex_log(HEX_LOG_LEVEL["info"], "HexRobotHexarm closed")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hex_zmq_servers
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: HEXFELLOW ZMQ Servers
5
5
  Author-email: Dong Zhaorui <joray.dong@hexfellow.com>
6
6
  Maintainer-email: jecjune <zejun.chen@hexfellow.com>, Dong Zhaorui <joray.dong@hexfellow.com>
@@ -1,11 +1,11 @@
1
1
  hex_zmq_servers/__init__.py,sha256=1dnB9YTRq5uAFHo_3dMp1t1UxS4ZrcuZ_7CzBwqAfEM,5426
2
2
  hex_zmq_servers/device_base.py,sha256=dABpeUg84Au-vtbVzvnv1Tmn_898CNOkIvH2UDUnV3I,1191
3
- hex_zmq_servers/hex_launch.py,sha256=opS_WwntAzV3UjOCVBo7FaLVW_dP3jlO40q-gFSBy68,17543
3
+ hex_zmq_servers/hex_launch.py,sha256=x-xCBhpjgK6yWHGk5o5kYsb5ef2GsdeLr8rX59EJR-0,17700
4
4
  hex_zmq_servers/zmq_base.py,sha256=RFRvl95oci6d-urP5n-qGDh5090pZ5q7Oy8_vNPqJxI,16380
5
5
  hex_zmq_servers/cam/__init__.py,sha256=hZ4NTEaO9uxcBua-nyJTpXxmk_GiIAcK2uWz3QQbwvE,1408
6
6
  hex_zmq_servers/cam/cam_base.py,sha256=3INQUYzzue4B0EiLEuo8IZDfLTifjmqXpXIkPaNA7dY,5134
7
7
  hex_zmq_servers/cam/berxel/__init__.py,sha256=3fK06RWAS_q8a_3z-RxFTv32e99og-4dMZTxH08TOcY,508
8
- hex_zmq_servers/cam/berxel/cam_berxel.py,sha256=l7SGnMUsM4D8HqHrJM9_QSyvLeNSRSDb37-_tSNHF-c,9035
8
+ hex_zmq_servers/cam/berxel/cam_berxel.py,sha256=yC1-eBZHrwVjyinZyg3AWKmpE7WqNSAbeP10sTWZP24,9820
9
9
  hex_zmq_servers/cam/berxel/cam_berxel_cli.py,sha256=ZbtZ4fjO0MCjqstfCxJwH1sMAtHKFKFIg9QI1zxplMQ,811
10
10
  hex_zmq_servers/cam/berxel/cam_berxel_srv.py,sha256=8QPhPpRsYnbbIFTQAT3sZA1nRTq1XpKg-GmD6ERUu9w,2311
11
11
  hex_zmq_servers/cam/dummy/__init__.py,sha256=EziQ8H8d9Vm1AYw4YryIumTXpx-lwEnlfzTl7VAnKHM,499
@@ -90,7 +90,7 @@ hex_zmq_servers/robot/gello/robot_gello.py,sha256=DyMELg490HykRYdbs4QVluR8oC7KAY
90
90
  hex_zmq_servers/robot/gello/robot_gello_cli.py,sha256=wnbRVrpIEE8G4ZzfjuSJA5TMPig-2I1oLJE-6b0kFSY,699
91
91
  hex_zmq_servers/robot/gello/robot_gello_srv.py,sha256=vCWgKpsO4MhZLspdaG45uHj8EB0gnptuj2SuxCaoEVI,2841
92
92
  hex_zmq_servers/robot/hexarm/__init__.py,sha256=07EUc2fCKqxYZbUUcDeD_AXvCAWI6r1qBjpWJ58_AcY,1414
93
- hex_zmq_servers/robot/hexarm/robot_hexarm.py,sha256=dUd_6JSHvlEIxkYLF1xCBZTOOcxt_VcfS2qcb-vEkgU,10364
93
+ hex_zmq_servers/robot/hexarm/robot_hexarm.py,sha256=-i8cB-FuW0X3k9MmGujz3MwmZ-usHjq6uiox6ox6bGk,10340
94
94
  hex_zmq_servers/robot/hexarm/robot_hexarm_cli.py,sha256=KO-I_CCjWwdckRKlxX7gIxUgsUKW3rcOycBo1nAxFEY,852
95
95
  hex_zmq_servers/robot/hexarm/robot_hexarm_srv.py,sha256=PE_WyLRXV_DbYVVQ0Wd60KlZZ37vfoEJVEhf2_4xADQ,2759
96
96
  hex_zmq_servers/robot/hexarm/urdf/archer_l6y/empty.urdf,sha256=g7Yn_uIM_ddb_K32FnDgHWSsvxH08oaPDiMb0yUb0Lg,7808
@@ -103,8 +103,8 @@ hex_zmq_servers/robot/hexarm/urdf/archer_y6/gp100.urdf,sha256=i8vpARxlQpYskLmTZ7
103
103
  hex_zmq_servers/robot/hexarm/urdf/archer_y6/gp100_handle.urdf,sha256=Tpii1Wk26jRtMqLWI2knrqBTIh7hCjpgGySlrBgdvpA,7458
104
104
  hex_zmq_servers/robot/hexarm/urdf/archer_y6/gp100_p050.urdf,sha256=6Zzc_PXDwtxw9xQEXQOH0hu_moaiQzeMC22hUqAQS9s,7459
105
105
  hex_zmq_servers/robot/hexarm/urdf/archer_y6/gp100_p050_handle.urdf,sha256=HNa7wweNYUj8YtSUfx87ASeNEIPIjB-gZ4O7RyHng6g,7456
106
- hex_zmq_servers-0.3.4.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
107
- hex_zmq_servers-0.3.4.dist-info/METADATA,sha256=vlE6l40uTHq955ndiXzA52hwcjhW7CvLfbPxwVx7Y6c,4750
108
- hex_zmq_servers-0.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
- hex_zmq_servers-0.3.4.dist-info/top_level.txt,sha256=lPH1DfgMrQOe0Grh8zSZopf6LmnLvb_aStVmZ41PyAg,16
110
- hex_zmq_servers-0.3.4.dist-info/RECORD,,
106
+ hex_zmq_servers-0.3.6.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
107
+ hex_zmq_servers-0.3.6.dist-info/METADATA,sha256=tAFV1LQtSeqWfvAc2Dr-WsqR7lmHi7Yf8jWF1zreDWk,4750
108
+ hex_zmq_servers-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
+ hex_zmq_servers-0.3.6.dist-info/top_level.txt,sha256=lPH1DfgMrQOe0Grh8zSZopf6LmnLvb_aStVmZ41PyAg,16
110
+ hex_zmq_servers-0.3.6.dist-info/RECORD,,