hex-zmq-servers 0.3.8__py3-none-any.whl → 0.3.10__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.
- hex_zmq_servers/cam/berxel/cam_berxel.py +2 -1
- hex_zmq_servers/cam/berxel/cam_berxel_cli.py +2 -0
- hex_zmq_servers/cam/berxel/cam_berxel_srv.py +4 -1
- hex_zmq_servers/cam/cam_base.py +33 -12
- hex_zmq_servers/cam/dummy/cam_dummy.py +2 -2
- hex_zmq_servers/cam/dummy/cam_dummy_cli.py +2 -0
- hex_zmq_servers/cam/dummy/cam_dummy_srv.py +4 -1
- hex_zmq_servers/cam/realsense/cam_realsense.py +5 -3
- hex_zmq_servers/cam/realsense/cam_realsense_cli.py +2 -0
- hex_zmq_servers/cam/realsense/cam_realsense_srv.py +4 -1
- hex_zmq_servers/cam/rgb/cam_rgb.py +5 -3
- hex_zmq_servers/cam/rgb/cam_rgb_cli.py +2 -0
- hex_zmq_servers/cam/rgb/cam_rgb_srv.py +4 -1
- hex_zmq_servers/config/cam_berxel.json +2 -0
- hex_zmq_servers/config/cam_dummy.json +2 -0
- hex_zmq_servers/config/cam_realsense.json +2 -0
- hex_zmq_servers/config/cam_rgb.json +2 -0
- hex_zmq_servers/config/mujoco_archer_y6.json +2 -0
- hex_zmq_servers/config/mujoco_e3_desktop.json +2 -0
- hex_zmq_servers/config/robot_dummy.json +2 -0
- hex_zmq_servers/config/robot_gello.json +2 -0
- hex_zmq_servers/config/robot_hexarm.json +2 -0
- hex_zmq_servers/config/zmq_dummy.json +2 -0
- hex_zmq_servers/device_base.py +2 -1
- hex_zmq_servers/mujoco/archer_y6/mujoco_archer_y6.py +9 -6
- hex_zmq_servers/mujoco/archer_y6/mujoco_archer_y6_cli.py +3 -1
- hex_zmq_servers/mujoco/archer_y6/mujoco_archer_y6_srv.py +10 -6
- hex_zmq_servers/mujoco/e3_desktop/mujoco_e3_desktop.py +24 -17
- hex_zmq_servers/mujoco/e3_desktop/mujoco_e3_desktop_cli.py +72 -20
- hex_zmq_servers/mujoco/e3_desktop/mujoco_e3_desktop_srv.py +19 -14
- hex_zmq_servers/mujoco/mujoco_base.py +87 -35
- hex_zmq_servers/robot/dummy/robot_dummy.py +4 -2
- hex_zmq_servers/robot/dummy/robot_dummy_cli.py +2 -0
- hex_zmq_servers/robot/dummy/robot_dummy_srv.py +4 -1
- hex_zmq_servers/robot/gello/robot_gello.py +4 -2
- hex_zmq_servers/robot/gello/robot_gello_cli.py +2 -0
- hex_zmq_servers/robot/gello/robot_gello_srv.py +4 -1
- hex_zmq_servers/robot/hexarm/robot_hexarm.py +4 -2
- hex_zmq_servers/robot/hexarm/robot_hexarm_cli.py +2 -0
- hex_zmq_servers/robot/hexarm/robot_hexarm_srv.py +4 -1
- hex_zmq_servers/robot/robot_base.py +21 -10
- hex_zmq_servers/zmq_base.py +13 -0
- {hex_zmq_servers-0.3.8.dist-info → hex_zmq_servers-0.3.10.dist-info}/METADATA +1 -1
- {hex_zmq_servers-0.3.8.dist-info → hex_zmq_servers-0.3.10.dist-info}/RECORD +47 -47
- {hex_zmq_servers-0.3.8.dist-info → hex_zmq_servers-0.3.10.dist-info}/WHEEL +0 -0
- {hex_zmq_servers-0.3.8.dist-info → hex_zmq_servers-0.3.10.dist-info}/licenses/LICENSE +0 -0
- {hex_zmq_servers-0.3.8.dist-info → hex_zmq_servers-0.3.10.dist-info}/top_level.txt +0 -0
|
@@ -30,8 +30,9 @@ class HexCamBerxel(HexCamBase):
|
|
|
30
30
|
def __init__(
|
|
31
31
|
self,
|
|
32
32
|
camera_config: dict = CAMERA_CONFIG,
|
|
33
|
+
realtime_mode: bool = False,
|
|
33
34
|
):
|
|
34
|
-
HexCamBase.__init__(self)
|
|
35
|
+
HexCamBase.__init__(self, realtime_mode)
|
|
35
36
|
|
|
36
37
|
try:
|
|
37
38
|
self.__serial_number = camera_config["serial_number"]
|
|
@@ -24,6 +24,8 @@ except (ImportError, ValueError):
|
|
|
24
24
|
NET_CONFIG = {
|
|
25
25
|
"ip": "127.0.0.1",
|
|
26
26
|
"port": 12345,
|
|
27
|
+
"realtime_mode": False,
|
|
28
|
+
"deque_maxlen": 10,
|
|
27
29
|
"client_timeout_ms": 200,
|
|
28
30
|
"server_timeout_ms": 1_000,
|
|
29
31
|
"server_num_workers": 4,
|
|
@@ -48,7 +50,8 @@ class HexCamBerxelServer(HexCamServerBase):
|
|
|
48
50
|
HexCamServerBase.__init__(self, net_config)
|
|
49
51
|
|
|
50
52
|
# camera
|
|
51
|
-
self._device = HexCamBerxel(params_config
|
|
53
|
+
self._device = HexCamBerxel(params_config,
|
|
54
|
+
net_config.get("realtime_mode", False))
|
|
52
55
|
|
|
53
56
|
def _process_request(self, recv_hdr: dict, recv_buf: np.ndarray):
|
|
54
57
|
if recv_hdr["cmd"] == "is_working":
|
hex_zmq_servers/cam/cam_base.py
CHANGED
|
@@ -17,6 +17,8 @@ from ..zmq_base import HexZMQClientBase, HexZMQServerBase, HexRate
|
|
|
17
17
|
NET_CONFIG = {
|
|
18
18
|
"ip": "127.0.0.1",
|
|
19
19
|
"port": 12345,
|
|
20
|
+
"realtime_mode": False,
|
|
21
|
+
"deque_maxlen": 10,
|
|
20
22
|
"client_timeout_ms": 200,
|
|
21
23
|
"server_timeout_ms": 1_000,
|
|
22
24
|
"server_num_workers": 4,
|
|
@@ -25,8 +27,8 @@ NET_CONFIG = {
|
|
|
25
27
|
|
|
26
28
|
class HexCamBase(HexDeviceBase):
|
|
27
29
|
|
|
28
|
-
def __init__(self):
|
|
29
|
-
HexDeviceBase.__init__(self)
|
|
30
|
+
def __init__(self, realtime_mode: bool = False):
|
|
31
|
+
HexDeviceBase.__init__(self, realtime_mode)
|
|
30
32
|
|
|
31
33
|
def __del__(self):
|
|
32
34
|
HexDeviceBase.__del__(self)
|
|
@@ -47,24 +49,40 @@ class HexCamClientBase(HexZMQClientBase):
|
|
|
47
49
|
def __init__(self, net_config: dict = NET_CONFIG):
|
|
48
50
|
HexZMQClientBase.__init__(self, net_config)
|
|
49
51
|
self._rgb_seq = 0
|
|
52
|
+
self._used_rgb_seq = 0
|
|
50
53
|
self._depth_seq = 0
|
|
51
|
-
self.
|
|
52
|
-
self.
|
|
54
|
+
self._used_depth_seq = 0
|
|
55
|
+
self._rgb_queue = deque(maxlen=self._deque_maxlen)
|
|
56
|
+
self._depth_queue = deque(maxlen=self._deque_maxlen)
|
|
53
57
|
|
|
54
58
|
def __del__(self):
|
|
55
59
|
HexZMQClientBase.__del__(self)
|
|
56
60
|
|
|
57
61
|
def get_rgb(self, newest: bool = False):
|
|
58
62
|
try:
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if self._realtime_mode or newest:
|
|
64
|
+
hdr, img = self._rgb_queue[-1]
|
|
65
|
+
if self._used_rgb_seq != hdr["args"]:
|
|
66
|
+
self._used_rgb_seq = hdr["args"]
|
|
67
|
+
return hdr, img
|
|
68
|
+
else:
|
|
69
|
+
return None, None
|
|
70
|
+
else:
|
|
71
|
+
return self._rgb_queue.popleft()
|
|
61
72
|
except IndexError:
|
|
62
73
|
return None, None
|
|
63
74
|
|
|
64
75
|
def get_depth(self, newest: bool = False):
|
|
65
76
|
try:
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
if self._realtime_mode or newest:
|
|
78
|
+
hdr, img = self._depth_queue[-1]
|
|
79
|
+
if self._used_depth_seq != hdr["args"]:
|
|
80
|
+
self._used_depth_seq = hdr["args"]
|
|
81
|
+
return hdr, img
|
|
82
|
+
else:
|
|
83
|
+
return None, None
|
|
84
|
+
else:
|
|
85
|
+
return self._depth_queue.popleft()
|
|
68
86
|
except IndexError:
|
|
69
87
|
return None, None
|
|
70
88
|
|
|
@@ -117,8 +135,8 @@ class HexCamServerBase(HexZMQServerBase):
|
|
|
117
135
|
def __init__(self, net_config: dict = NET_CONFIG):
|
|
118
136
|
HexZMQServerBase.__init__(self, net_config)
|
|
119
137
|
self._device: HexDeviceBase = None
|
|
120
|
-
self._rgb_queue = deque(maxlen=
|
|
121
|
-
self._depth_queue = deque(maxlen=
|
|
138
|
+
self._rgb_queue = deque(maxlen=self._deque_maxlen)
|
|
139
|
+
self._depth_queue = deque(maxlen=self._deque_maxlen)
|
|
122
140
|
|
|
123
141
|
def __del__(self):
|
|
124
142
|
HexZMQServerBase.__del__(self)
|
|
@@ -143,9 +161,12 @@ class HexCamServerBase(HexZMQServerBase):
|
|
|
143
161
|
|
|
144
162
|
try:
|
|
145
163
|
if depth_flag:
|
|
146
|
-
ts, count, img = self._depth_queue
|
|
164
|
+
ts, count, img = self._depth_queue[
|
|
165
|
+
-1] if self._realtime_mode else self._depth_queue.popleft(
|
|
166
|
+
)
|
|
147
167
|
else:
|
|
148
|
-
ts, count, img = self._rgb_queue
|
|
168
|
+
ts, count, img = self._rgb_queue[
|
|
169
|
+
-1] if self._realtime_mode else self._rgb_queue.popleft()
|
|
149
170
|
except IndexError:
|
|
150
171
|
return {"cmd": f"{recv_hdr['cmd']}_failed"}, None
|
|
151
172
|
except Exception as e:
|
|
@@ -20,8 +20,8 @@ from ...hex_launch import hex_log, HEX_LOG_LEVEL
|
|
|
20
20
|
|
|
21
21
|
class HexCamDummy(HexCamBase):
|
|
22
22
|
|
|
23
|
-
def __init__(self, params_config: dict = {}):
|
|
24
|
-
HexCamBase.__init__(self)
|
|
23
|
+
def __init__(self, params_config: dict = {}, realtime_mode: bool = False):
|
|
24
|
+
HexCamBase.__init__(self, realtime_mode)
|
|
25
25
|
self._working.set()
|
|
26
26
|
|
|
27
27
|
def __del__(self):
|
|
@@ -24,6 +24,8 @@ except (ImportError, ValueError):
|
|
|
24
24
|
NET_CONFIG = {
|
|
25
25
|
"ip": "127.0.0.1",
|
|
26
26
|
"port": 12345,
|
|
27
|
+
"realtime_mode": False,
|
|
28
|
+
"deque_maxlen": 10,
|
|
27
29
|
"client_timeout_ms": 200,
|
|
28
30
|
"server_timeout_ms": 1_000,
|
|
29
31
|
"server_num_workers": 4,
|
|
@@ -40,7 +42,8 @@ class HexCamDummyServer(HexCamServerBase):
|
|
|
40
42
|
HexCamServerBase.__init__(self, net_config)
|
|
41
43
|
|
|
42
44
|
# camera
|
|
43
|
-
self._device = HexCamDummy(params_config
|
|
45
|
+
self._device = HexCamDummy(params_config,
|
|
46
|
+
net_config.get("realtime_mode", False))
|
|
44
47
|
|
|
45
48
|
def _process_request(self, recv_hdr: dict, recv_buf: np.ndarray):
|
|
46
49
|
if recv_hdr["cmd"] == "is_working":
|
|
@@ -32,8 +32,9 @@ class HexCamRealsense(HexCamBase):
|
|
|
32
32
|
def __init__(
|
|
33
33
|
self,
|
|
34
34
|
camera_config: dict = CAMERA_CONFIG,
|
|
35
|
+
realtime_mode: bool = False,
|
|
35
36
|
):
|
|
36
|
-
HexCamBase.__init__(self)
|
|
37
|
+
HexCamBase.__init__(self, realtime_mode)
|
|
37
38
|
|
|
38
39
|
try:
|
|
39
40
|
self.__serial_number = camera_config["serial_number"]
|
|
@@ -134,8 +135,9 @@ class HexCamRealsense(HexCamBase):
|
|
|
134
135
|
color_frame = aligned_frames.get_color_frame()
|
|
135
136
|
if color_frame:
|
|
136
137
|
|
|
137
|
-
rgb_queue.append(
|
|
138
|
-
|
|
138
|
+
rgb_queue.append(
|
|
139
|
+
(sen_ts if self.__sens_ts else cur_ns, rgb_count,
|
|
140
|
+
np.asanyarray(color_frame.get_data())))
|
|
139
141
|
rgb_count = (rgb_count + 1) % self._max_seq_num
|
|
140
142
|
|
|
141
143
|
# collect depth frame
|
|
@@ -24,6 +24,8 @@ except (ImportError, ValueError):
|
|
|
24
24
|
NET_CONFIG = {
|
|
25
25
|
"ip": "127.0.0.1",
|
|
26
26
|
"port": 12345,
|
|
27
|
+
"realtime_mode": False,
|
|
28
|
+
"deque_maxlen": 10,
|
|
27
29
|
"client_timeout_ms": 200,
|
|
28
30
|
"server_timeout_ms": 1_000,
|
|
29
31
|
"server_num_workers": 4,
|
|
@@ -47,7 +49,8 @@ class HexCamRealsenseServer(HexCamServerBase):
|
|
|
47
49
|
HexCamServerBase.__init__(self, net_config)
|
|
48
50
|
|
|
49
51
|
# camera
|
|
50
|
-
self._device = HexCamRealsense(params_config
|
|
52
|
+
self._device = HexCamRealsense(params_config,
|
|
53
|
+
net_config.get("realtime_mode", False))
|
|
51
54
|
|
|
52
55
|
def _process_request(self, recv_hdr: dict, recv_buf: np.ndarray):
|
|
53
56
|
if recv_hdr["cmd"] == "is_working":
|
|
@@ -35,8 +35,9 @@ class HexCamRGB(HexCamBase):
|
|
|
35
35
|
def __init__(
|
|
36
36
|
self,
|
|
37
37
|
camera_config: dict = CAMERA_CONFIG,
|
|
38
|
+
realtime_mode: bool = False,
|
|
38
39
|
):
|
|
39
|
-
HexCamBase.__init__(self)
|
|
40
|
+
HexCamBase.__init__(self, realtime_mode)
|
|
40
41
|
|
|
41
42
|
try:
|
|
42
43
|
self.__cam_path = camera_config["cam_path"]
|
|
@@ -106,8 +107,9 @@ class HexCamRGB(HexCamBase):
|
|
|
106
107
|
|
|
107
108
|
rgb_count = 0
|
|
108
109
|
depth_queue.append((hex_zmq_ts_now(), 0,
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
np.zeros(
|
|
111
|
+
(self.__resolution[1], self.__resolution[0]),
|
|
112
|
+
dtype=np.uint16)))
|
|
111
113
|
rate = HexRate(self.__frame_rate * 5)
|
|
112
114
|
while self._working.is_set() and not stop_event.is_set():
|
|
113
115
|
# read frame
|
|
@@ -24,6 +24,8 @@ except (ImportError, ValueError):
|
|
|
24
24
|
NET_CONFIG = {
|
|
25
25
|
"ip": "127.0.0.1",
|
|
26
26
|
"port": 12345,
|
|
27
|
+
"realtime_mode": False,
|
|
28
|
+
"deque_maxlen": 10,
|
|
27
29
|
"client_timeout_ms": 200,
|
|
28
30
|
"server_timeout_ms": 1_000,
|
|
29
31
|
"server_num_workers": 4,
|
|
@@ -47,7 +49,8 @@ class HexCamRGBServer(HexCamServerBase):
|
|
|
47
49
|
HexCamServerBase.__init__(self, net_config)
|
|
48
50
|
|
|
49
51
|
# camera
|
|
50
|
-
self._device = HexCamRGB(params_config
|
|
52
|
+
self._device = HexCamRGB(params_config,
|
|
53
|
+
net_config.get("realtime_mode", False))
|
|
51
54
|
|
|
52
55
|
def _process_request(self, recv_hdr: dict, recv_buf: np.ndarray):
|
|
53
56
|
if recv_hdr["cmd"] == "is_working":
|
hex_zmq_servers/device_base.py
CHANGED
|
@@ -15,9 +15,10 @@ from .zmq_base import MAX_SEQ_NUM
|
|
|
15
15
|
|
|
16
16
|
class HexDeviceBase(ABC):
|
|
17
17
|
|
|
18
|
-
def __init__(self):
|
|
18
|
+
def __init__(self, realtime_mode: bool = False):
|
|
19
19
|
# variables
|
|
20
20
|
self._max_seq_num = MAX_SEQ_NUM
|
|
21
|
+
self._realtime_mode = realtime_mode
|
|
21
22
|
# thread
|
|
22
23
|
self._working = threading.Event()
|
|
23
24
|
|
|
@@ -49,8 +49,9 @@ class HexMujocoArcherY6(HexMujocoBase):
|
|
|
49
49
|
def __init__(
|
|
50
50
|
self,
|
|
51
51
|
mujoco_config: dict = MUJOCO_CONFIG,
|
|
52
|
+
realtime_mode: bool = False,
|
|
52
53
|
):
|
|
53
|
-
HexMujocoBase.__init__(self)
|
|
54
|
+
HexMujocoBase.__init__(self, realtime_mode)
|
|
54
55
|
|
|
55
56
|
try:
|
|
56
57
|
states_rate = mujoco_config["states_rate"]
|
|
@@ -163,11 +164,11 @@ class HexMujocoArcherY6(HexMujocoBase):
|
|
|
163
164
|
self.__bias_ns = hex_ns_now() - self.__data.time * 1_000_000_000
|
|
164
165
|
init_ts = self.__mujoco_ts() if self.__sens_ts else hex_zmq_ts_now()
|
|
165
166
|
rgb_queue.append((init_ts, 0,
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
np.zeros((self.__height, self.__width, 3),
|
|
168
|
+
dtype=np.uint8)))
|
|
168
169
|
depth_queue.append((init_ts, 0,
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
np.zeros((self.__height, self.__width),
|
|
171
|
+
dtype=np.uint16)))
|
|
171
172
|
while self._working.is_set() and not stop_event.is_set():
|
|
172
173
|
states_trig_count += 1
|
|
173
174
|
if states_trig_count >= self.__states_trig_thresh:
|
|
@@ -194,7 +195,9 @@ class HexMujocoArcherY6(HexMujocoBase):
|
|
|
194
195
|
# cmds
|
|
195
196
|
cmds_robot_pack = None
|
|
196
197
|
try:
|
|
197
|
-
cmds_robot_pack = cmds_robot_queue
|
|
198
|
+
cmds_robot_pack = cmds_robot_queue[
|
|
199
|
+
-1] if self._realtime_mode else cmds_robot_queue.popleft(
|
|
200
|
+
)
|
|
198
201
|
except IndexError:
|
|
199
202
|
pass
|
|
200
203
|
if cmds_robot_pack is not None:
|
|
@@ -12,6 +12,8 @@ from ...zmq_base import HexRate
|
|
|
12
12
|
NET_CONFIG = {
|
|
13
13
|
"ip": "127.0.0.1",
|
|
14
14
|
"port": 12345,
|
|
15
|
+
"realtime_mode": False,
|
|
16
|
+
"deque_maxlen": 10,
|
|
15
17
|
"client_timeout_ms": 200,
|
|
16
18
|
"server_timeout_ms": 1_000,
|
|
17
19
|
"server_num_workers": 4,
|
|
@@ -60,7 +62,7 @@ class HexMujocoArcherY6Client(HexMujocoClientBase):
|
|
|
60
62
|
self._depth_queue.append((hdr, img))
|
|
61
63
|
|
|
62
64
|
try:
|
|
63
|
-
cmds = self._cmds_queue
|
|
65
|
+
cmds = self._cmds_queue[-1]
|
|
64
66
|
_ = self._set_cmds_inner(cmds)
|
|
65
67
|
except IndexError:
|
|
66
68
|
pass
|
|
@@ -25,6 +25,8 @@ except (ImportError, ValueError):
|
|
|
25
25
|
NET_CONFIG = {
|
|
26
26
|
"ip": "127.0.0.1",
|
|
27
27
|
"port": 12345,
|
|
28
|
+
"realtime_mode": False,
|
|
29
|
+
"deque_maxlen": 10,
|
|
28
30
|
"client_timeout_ms": 200,
|
|
29
31
|
"server_timeout_ms": 1_000,
|
|
30
32
|
"server_num_workers": 4,
|
|
@@ -48,13 +50,14 @@ class HexMujocoArcherY6Server(HexMujocoServerBase):
|
|
|
48
50
|
HexMujocoServerBase.__init__(self, net_config)
|
|
49
51
|
|
|
50
52
|
# mujoco
|
|
51
|
-
self._device = HexMujocoArcherY6(
|
|
53
|
+
self._device = HexMujocoArcherY6(
|
|
54
|
+
params_config, net_config.get("realtime_mode", False))
|
|
52
55
|
|
|
53
56
|
# values
|
|
54
|
-
self._states_robot_queue = deque(maxlen=
|
|
55
|
-
self._states_obj_queue = deque(maxlen=
|
|
56
|
-
self._rgb_queue = deque(maxlen=
|
|
57
|
-
self._depth_queue = deque(maxlen=
|
|
57
|
+
self._states_robot_queue = deque(maxlen=self._deque_maxlen)
|
|
58
|
+
self._states_obj_queue = deque(maxlen=self._deque_maxlen)
|
|
59
|
+
self._rgb_queue = deque(maxlen=self._deque_maxlen)
|
|
60
|
+
self._depth_queue = deque(maxlen=self._deque_maxlen)
|
|
58
61
|
|
|
59
62
|
def work_loop(self):
|
|
60
63
|
try:
|
|
@@ -87,7 +90,8 @@ class HexMujocoArcherY6Server(HexMujocoServerBase):
|
|
|
87
90
|
f"unknown robot name: {robot_name} in {recv_hdr['cmd']}")
|
|
88
91
|
|
|
89
92
|
try:
|
|
90
|
-
ts, count, states = queue
|
|
93
|
+
ts, count, states = queue[
|
|
94
|
+
-1] if self._realtime_mode else queue.popleft()
|
|
91
95
|
except IndexError:
|
|
92
96
|
return {"cmd": f"{recv_hdr['cmd']}_failed"}, None
|
|
93
97
|
except Exception as e:
|
|
@@ -50,8 +50,9 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
50
50
|
def __init__(
|
|
51
51
|
self,
|
|
52
52
|
mujoco_config: dict = MUJOCO_CONFIG,
|
|
53
|
+
realtime_mode: bool = False,
|
|
53
54
|
):
|
|
54
|
-
HexMujocoBase.__init__(self)
|
|
55
|
+
HexMujocoBase.__init__(self, realtime_mode)
|
|
55
56
|
|
|
56
57
|
try:
|
|
57
58
|
states_rate = mujoco_config["states_rate"]
|
|
@@ -198,23 +199,23 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
198
199
|
self.__bias_ns = hex_ns_now() - self.__data.time * 1_000_000_000
|
|
199
200
|
init_ts = self.__mujoco_ts() if self.__sens_ts else hex_zmq_ts_now()
|
|
200
201
|
head_rgb_queue.append((init_ts, 0,
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
np.zeros((self.__height, self.__width, 3),
|
|
203
|
+
dtype=np.uint8)))
|
|
203
204
|
head_depth_queue.append((init_ts, 0,
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
np.zeros((self.__height, self.__width),
|
|
206
|
+
dtype=np.uint16)))
|
|
206
207
|
left_rgb_queue.append((init_ts, 0,
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
np.zeros((self.__height, self.__width, 3),
|
|
209
|
+
dtype=np.uint8)))
|
|
209
210
|
left_depth_queue.append((init_ts, 0,
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
np.zeros((self.__height, self.__width),
|
|
212
|
+
dtype=np.uint16)))
|
|
212
213
|
right_rgb_queue.append((init_ts, 0,
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
np.zeros((self.__height, self.__width, 3),
|
|
215
|
+
dtype=np.uint8)))
|
|
215
216
|
right_depth_queue.append((init_ts, 0,
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
np.zeros((self.__height, self.__width),
|
|
218
|
+
dtype=np.uint16)))
|
|
218
219
|
while self._working.is_set() and not stop_event.is_set():
|
|
219
220
|
states_trig_count += 1
|
|
220
221
|
if states_trig_count >= self.__states_trig_thresh:
|
|
@@ -244,7 +245,9 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
244
245
|
# cmds
|
|
245
246
|
cmds_left_pack = None
|
|
246
247
|
try:
|
|
247
|
-
cmds_left_pack = cmds_left_queue
|
|
248
|
+
cmds_left_pack = cmds_left_queue[
|
|
249
|
+
-1] if self._realtime_mode else cmds_left_queue.popleft(
|
|
250
|
+
)
|
|
248
251
|
except IndexError:
|
|
249
252
|
pass
|
|
250
253
|
if cmds_left_pack is not None:
|
|
@@ -258,7 +261,9 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
258
261
|
|
|
259
262
|
cmds_right_pack = None
|
|
260
263
|
try:
|
|
261
|
-
cmds_right_pack = cmds_right_queue
|
|
264
|
+
cmds_right_pack = cmds_right_queue[
|
|
265
|
+
-1] if self._realtime_mode else cmds_right_queue.popleft(
|
|
266
|
+
)
|
|
262
267
|
except IndexError:
|
|
263
268
|
pass
|
|
264
269
|
if cmds_right_pack is not None:
|
|
@@ -286,7 +291,8 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
286
291
|
if self.__head_depth:
|
|
287
292
|
ts, depth_img = self.__get_depth("head_camera")
|
|
288
293
|
if depth_img is not None:
|
|
289
|
-
head_depth_queue.append(
|
|
294
|
+
head_depth_queue.append(
|
|
295
|
+
(ts, head_depth_count, depth_img))
|
|
290
296
|
head_depth_count = (head_depth_count +
|
|
291
297
|
1) % self._max_seq_num
|
|
292
298
|
|
|
@@ -302,7 +308,8 @@ class HexMujocoE3Desktop(HexMujocoBase):
|
|
|
302
308
|
if self.__left_depth:
|
|
303
309
|
ts, depth_img = self.__get_depth("left_camera")
|
|
304
310
|
if depth_img is not None:
|
|
305
|
-
left_depth_queue.append(
|
|
311
|
+
left_depth_queue.append(
|
|
312
|
+
(ts, left_depth_count, depth_img))
|
|
306
313
|
left_depth_count = (left_depth_count +
|
|
307
314
|
1) % self._max_seq_num
|
|
308
315
|
|