hex-zmq-servers 0.2.3__py3-none-any.whl → 0.2.4__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.
Files changed (31) hide show
  1. hex_zmq_servers/__init__.py +56 -35
  2. hex_zmq_servers/cam/__init__.py +6 -13
  3. hex_zmq_servers/cam/berxel/cam_berxel.py +16 -4
  4. hex_zmq_servers/cam/cam_base.py +7 -2
  5. hex_zmq_servers/cam/dummy/cam_dummy.py +11 -2
  6. hex_zmq_servers/config/mujoco_archer_d6y.json +1 -1
  7. hex_zmq_servers/config/mujoco_e3_desktop.json +1 -1
  8. hex_zmq_servers/config/robot_hexarm.json +1 -1
  9. hex_zmq_servers/device_base.py +1 -1
  10. hex_zmq_servers/mujoco/archer_d6y/model/robot.xml +7 -0
  11. hex_zmq_servers/mujoco/archer_d6y/model/scene.xml +1 -1
  12. hex_zmq_servers/mujoco/archer_d6y/mujoco_archer_d6y.py +38 -15
  13. hex_zmq_servers/mujoco/archer_d6y/mujoco_archer_d6y_srv.py +4 -1
  14. hex_zmq_servers/mujoco/e3_desktop/model/robot.xml +14 -0
  15. hex_zmq_servers/mujoco/e3_desktop/model/scene.xml +1 -1
  16. hex_zmq_servers/mujoco/e3_desktop/mujoco_e3_desktop.py +39 -16
  17. hex_zmq_servers/mujoco/e3_desktop/mujoco_e3_desktop_srv.py +9 -1
  18. hex_zmq_servers/mujoco/mujoco_base.py +17 -1
  19. hex_zmq_servers/robot/dummy/robot_dummy.py +12 -3
  20. hex_zmq_servers/robot/dummy/robot_dummy_srv.py +2 -0
  21. hex_zmq_servers/robot/gello/robot_gello.py +12 -5
  22. hex_zmq_servers/robot/gello/robot_gello_srv.py +2 -0
  23. hex_zmq_servers/robot/hexarm/robot_hexarm.py +45 -16
  24. hex_zmq_servers/robot/hexarm/robot_hexarm_srv.py +2 -0
  25. hex_zmq_servers/robot/robot_base.py +22 -2
  26. hex_zmq_servers/zmq_base.py +22 -4
  27. {hex_zmq_servers-0.2.3.dist-info → hex_zmq_servers-0.2.4.dist-info}/METADATA +45 -17
  28. {hex_zmq_servers-0.2.3.dist-info → hex_zmq_servers-0.2.4.dist-info}/RECORD +31 -31
  29. {hex_zmq_servers-0.2.3.dist-info → hex_zmq_servers-0.2.4.dist-info}/WHEEL +0 -0
  30. {hex_zmq_servers-0.2.3.dist-info → hex_zmq_servers-0.2.4.dist-info}/licenses/LICENSE +0 -0
  31. {hex_zmq_servers-0.2.3.dist-info → hex_zmq_servers-0.2.4.dist-info}/top_level.txt +0 -0
@@ -13,9 +13,6 @@ from .zmq_base import HexRate, hex_zmq_ts_now, hex_zmq_ts_delta_ms
13
13
  from .zmq_base import HexSafeValue, HexZMQClientBase, HexZMQServerBase, hex_server_helper
14
14
  from .zmq_base import HexZMQDummyClient, HexZMQDummyServer
15
15
 
16
- from .cam import HexCamBase, HexCamClientBase, HexCamServerBase
17
- from .cam import HexCamDummy, HexCamDummyClient, HexCamDummyServer
18
-
19
16
  from .mujoco import HexMujocoBase, HexMujocoClientBase, HexMujocoServerBase
20
17
  from .mujoco import HexMujocoArcherD6y, HexMujocoArcherD6yClient, HexMujocoArcherD6yServer
21
18
  from .mujoco import HexMujocoE3Desktop, HexMujocoE3DesktopClient, HexMujocoE3DesktopServer
@@ -30,20 +27,12 @@ import os
30
27
  file_dir = os.path.dirname(os.path.abspath(__file__))
31
28
  HEX_ZMQ_SERVERS_PATH_DICT = {
32
29
  "zmq_dummy": f"{file_dir}/zmq_base.py",
33
- "cam_dummy": f"{file_dir}/cam/dummy/cam_dummy_srv.py",
34
- "mujoco_archer_d6y":
35
- f"{file_dir}/mujoco/archer_d6y/mujoco_archer_d6y_srv.py",
36
- "mujoco_e3_desktop":
37
- f"{file_dir}/mujoco/e3_desktop/mujoco_e3_desktop_srv.py",
38
30
  "robot_dummy": f"{file_dir}/robot/dummy/robot_dummy_srv.py",
39
31
  "robot_gello": f"{file_dir}/robot/gello/robot_gello_srv.py",
40
32
  "robot_hexarm": f"{file_dir}/robot/hexarm/robot_hexarm_srv.py",
41
33
  }
42
34
  HEX_ZMQ_CONFIGS_PATH_DICT = {
43
35
  "zmq_dummy": f"{file_dir}/config/zmq_dummy.json",
44
- "cam_dummy": f"{file_dir}/config/cam_dummy.json",
45
- "mujoco_archer_d6y": f"{file_dir}/config/mujoco_archer_d6y.json",
46
- "mujoco_e3_desktop": f"{file_dir}/config/mujoco_e3_desktop.json",
47
36
  "robot_dummy": f"{file_dir}/config/robot_dummy.json",
48
37
  "robot_gello": f"{file_dir}/config/robot_gello.json",
49
38
  "robot_hexarm": f"{file_dir}/config/robot_hexarm.json",
@@ -76,25 +65,6 @@ __all__ = [
76
65
  "HexZMQDummyClient",
77
66
  "HexZMQDummyServer",
78
67
 
79
- # camera
80
- "HexCamBase",
81
- "HexCamClientBase",
82
- "HexCamServerBase",
83
- "HexCamDummy",
84
- "HexCamDummyClient",
85
- "HexCamDummyServer",
86
-
87
- # mujoco
88
- "HexMujocoBase",
89
- "HexMujocoClientBase",
90
- "HexMujocoServerBase",
91
- "HexMujocoArcherD6y",
92
- "HexMujocoArcherD6yClient",
93
- "HexMujocoArcherD6yServer",
94
- "HexMujocoE3Desktop",
95
- "HexMujocoE3DesktopClient",
96
- "HexMujocoE3DesktopServer",
97
-
98
68
  # robot
99
69
  "HexRobotBase",
100
70
  "HexRobotClientBase",
@@ -110,14 +80,31 @@ __all__ = [
110
80
  "HexRobotHexarmServer",
111
81
  ]
112
82
 
113
- # Optional: berxel
83
+ # Optional: camera
114
84
  try:
85
+ from .cam import HexCamBase, HexCamClientBase, HexCamServerBase
86
+ from .cam import HexCamDummy, HexCamDummyClient, HexCamDummyServer
115
87
  from .cam import HexCamBerxel, HexCamBerxelClient, HexCamBerxelServer
116
- HEX_ZMQ_SERVERS_PATH_DICT[
117
- "cam_berxel"] = f"{file_dir}/cam/berxel/cam_berxel_srv.py"
118
- HEX_ZMQ_CONFIGS_PATH_DICT[
119
- "cam_berxel"] = f"{file_dir}/config/cam_berxel.json"
88
+ HEX_ZMQ_SERVERS_PATH_DICT.update({
89
+ "cam_dummy":
90
+ f"{file_dir}/cam/dummy/cam_dummy_srv.py",
91
+ "cam_berxel":
92
+ f"{file_dir}/cam/berxel/cam_berxel_srv.py",
93
+ })
94
+ HEX_ZMQ_CONFIGS_PATH_DICT.update({
95
+ "cam_dummy":
96
+ f"{file_dir}/config/cam_dummy.json",
97
+ "cam_berxel":
98
+ f"{file_dir}/config/cam_berxel.json",
99
+ })
120
100
  __all__.extend([
101
+ # camera
102
+ "HexCamBase",
103
+ "HexCamClientBase",
104
+ "HexCamServerBase",
105
+ "HexCamDummy",
106
+ "HexCamDummyClient",
107
+ "HexCamDummyServer",
121
108
  "HexCamBerxel",
122
109
  "HexCamBerxelClient",
123
110
  "HexCamBerxelServer",
@@ -127,4 +114,38 @@ except ImportError:
127
114
  # Install with: pip install hex_zmq_servers[berxel]
128
115
  pass
129
116
 
117
+ # Optional: mujoco
118
+ try:
119
+ from .mujoco import HexMujocoBase, HexMujocoClientBase, HexMujocoServerBase
120
+ from .mujoco import HexMujocoArcherD6y, HexMujocoArcherD6yClient, HexMujocoArcherD6yServer
121
+ from .mujoco import HexMujocoE3Desktop, HexMujocoE3DesktopClient, HexMujocoE3DesktopServer
122
+ HEX_ZMQ_SERVERS_PATH_DICT.update({
123
+ "mujoco_archer_d6y":
124
+ f"{file_dir}/mujoco/archer_d6y/mujoco_archer_d6y_srv.py",
125
+ "mujoco_e3_desktop":
126
+ f"{file_dir}/mujoco/e3_desktop/mujoco_e3_desktop_srv.py",
127
+ })
128
+ HEX_ZMQ_CONFIGS_PATH_DICT.update({
129
+ "mujoco_archer_d6y":
130
+ f"{file_dir}/config/mujoco_archer_d6y.json",
131
+ "mujoco_e3_desktop":
132
+ f"{file_dir}/config/mujoco_e3_desktop.json",
133
+ })
134
+ __all__.extend([
135
+ # mujoco
136
+ "HexMujocoBase",
137
+ "HexMujocoClientBase",
138
+ "HexMujocoServerBase",
139
+ "HexMujocoArcherD6y",
140
+ "HexMujocoArcherD6yClient",
141
+ "HexMujocoArcherD6yServer",
142
+ "HexMujocoE3Desktop",
143
+ "HexMujocoE3DesktopClient",
144
+ "HexMujocoE3DesktopServer",
145
+ ])
146
+ except ImportError:
147
+ # mujoco not installed
148
+ # Install with: pip install hex_zmq_servers[mujoco]
149
+ pass
150
+
130
151
  # print("#### Thanks for using hex_zmq_servers :D ####")
@@ -8,6 +8,7 @@
8
8
 
9
9
  from .cam_base import HexCamBase, HexCamClientBase, HexCamServerBase
10
10
  from .dummy import HexCamDummy, HexCamDummyClient, HexCamDummyServer
11
+ from .berxel import HexCamBerxel, HexCamBerxelClient, HexCamBerxelServer
11
12
 
12
13
  __all__ = [
13
14
  # base
@@ -19,17 +20,9 @@ __all__ = [
19
20
  "HexCamDummy",
20
21
  "HexCamDummyClient",
21
22
  "HexCamDummyServer",
22
- ]
23
23
 
24
- # Optional: berxel (requires berxel_py_wrapper)
25
- try:
26
- from .berxel import HexCamBerxel, HexCamBerxelClient, HexCamBerxelServer
27
- __all__.extend([
28
- "HexCamBerxel",
29
- "HexCamBerxelClient",
30
- "HexCamBerxelServer",
31
- ])
32
- except ImportError:
33
- # berxel_py_wrapper not installed
34
- # Install with: pip install hex_zmq_servers[berxel]
35
- pass
24
+ # berxel
25
+ "HexCamBerxel",
26
+ "HexCamBerxelClient",
27
+ "HexCamBerxelServer",
28
+ ]
@@ -7,10 +7,15 @@
7
7
  ################################################################
8
8
 
9
9
  import cv2
10
+ import threading
10
11
  import numpy as np
11
12
 
12
13
  from ..cam_base import HexCamBase
13
- from ...zmq_base import HexSafeValue
14
+ from ...zmq_base import (
15
+ hex_zmq_ts_now,
16
+ HexSafeValue,
17
+ )
18
+ from ...hex_launch import hex_log, HEX_LOG_LEVEL
14
19
  from berxel_py_wrapper import *
15
20
 
16
21
  CAMERA_CONFIG = {
@@ -69,13 +74,14 @@ class HexCamBerxel(HexCamBase):
69
74
  self._wait_for_working()
70
75
  return self.__serial_number
71
76
 
72
- def work_loop(self, hex_values: list[HexSafeValue]):
77
+ def work_loop(self, hex_values: list[HexSafeValue | threading.Event]):
73
78
  rgb_value = hex_values[0]
74
79
  depth_value = hex_values[1]
80
+ stop_event = hex_values[2]
75
81
 
76
82
  rgb_count = 0
77
83
  depth_count = 0
78
- while self._working.is_set():
84
+ while self._working.is_set() and not stop_event.is_set():
79
85
  # read frame
80
86
  hawk_rgb_frame = self.__device.readColorFrame(40)
81
87
  hawk_depth_frame = self.__device.readDepthFrame(40)
@@ -95,6 +101,9 @@ class HexCamBerxel(HexCamBase):
95
101
  self.__device.releaseFrame(hawk_rgb_frame)
96
102
  self.__device.releaseFrame(hawk_depth_frame)
97
103
 
104
+ # close
105
+ self.close()
106
+
98
107
  def __unpack_frame(self, hawk_frame: BerxelHawkFrame, depth: bool = False):
99
108
  # common variables
100
109
  berxel_ts = hawk_frame.getTimeStamp()
@@ -132,7 +141,7 @@ class HexCamBerxel(HexCamBase):
132
141
  )
133
142
  frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
134
143
 
135
- return ts, frame
144
+ return ts if self.__sens_ts else hex_zmq_ts_now(), frame
136
145
 
137
146
  def __open_device(self, serial_number: str | None = None) -> bool:
138
147
  # init context
@@ -220,9 +229,12 @@ class HexCamBerxel(HexCamBase):
220
229
  return False
221
230
 
222
231
  def close(self):
232
+ if not self._working.is_set():
233
+ return
223
234
  self._working.clear()
224
235
  self.__stop_stream()
225
236
  self.__close_device()
237
+ hex_log(HEX_LOG_LEVEL["info"], "HexCamBerxel closed")
226
238
 
227
239
  def __stop_stream(self):
228
240
  if self.__device is None:
@@ -6,6 +6,7 @@
6
6
  # Date : 2025-09-16
7
7
  ################################################################
8
8
 
9
+ import threading
9
10
  import numpy as np
10
11
  from abc import abstractmethod
11
12
 
@@ -30,7 +31,7 @@ class HexCamBase(HexDeviceBase):
30
31
  HexDeviceBase.__del__(self)
31
32
 
32
33
  @abstractmethod
33
- def work_loop(self, hex_values: list[HexSafeValue]):
34
+ def work_loop(self, hex_values: list[HexSafeValue | threading.Event]):
34
35
  raise NotImplementedError(
35
36
  "`work_loop` should be implemented by the child class")
36
37
 
@@ -97,7 +98,11 @@ class HexCamServerBase(HexZMQServerBase):
97
98
 
98
99
  def work_loop(self):
99
100
  try:
100
- self._device.work_loop([self._rgb_value, self._depth_value])
101
+ self._device.work_loop([
102
+ self._rgb_value,
103
+ self._depth_value,
104
+ self._stop_event,
105
+ ])
101
106
  finally:
102
107
  self._device.close()
103
108
 
@@ -6,6 +6,7 @@
6
6
  # Date : 2025-09-12
7
7
  ################################################################
8
8
 
9
+ import threading
9
10
  import numpy as np
10
11
 
11
12
  from ..cam_base import HexCamBase
@@ -14,6 +15,7 @@ from ...zmq_base import (
14
15
  HexRate,
15
16
  HexSafeValue,
16
17
  )
18
+ from ...hex_launch import hex_log, HEX_LOG_LEVEL
17
19
 
18
20
 
19
21
  class HexCamDummy(HexCamBase):
@@ -25,14 +27,15 @@ class HexCamDummy(HexCamBase):
25
27
  def __del__(self):
26
28
  HexCamBase.__del__(self)
27
29
 
28
- def work_loop(self, hex_values: list[HexSafeValue]):
30
+ def work_loop(self, hex_values: list[HexSafeValue | threading.Event]):
29
31
  rgb_value = hex_values[0]
30
32
  depth_value = hex_values[1]
33
+ stop_event = hex_values[2]
31
34
 
32
35
  rgb_count = 0
33
36
  depth_count = 0
34
37
  rate = HexRate(60)
35
- while self._working.is_set():
38
+ while self._working.is_set() and not stop_event.is_set():
36
39
  # rgb
37
40
  rgb_img = np.random.randint(
38
41
  0,
@@ -56,5 +59,11 @@ class HexCamDummy(HexCamBase):
56
59
  # sleep
57
60
  rate.sleep()
58
61
 
62
+ # close
63
+ self.close()
64
+
59
65
  def close(self):
66
+ if not self._working.is_set():
67
+ return
60
68
  self._working.clear()
69
+ hex_log(HEX_LOG_LEVEL["info"], "HexCamDummy closed")
@@ -7,7 +7,7 @@
7
7
  "server_num_workers": 4
8
8
  },
9
9
  "params": {
10
- "states_rate": 250,
10
+ "states_rate": 500,
11
11
  "img_rate": 30,
12
12
  "tau_ctrl": false,
13
13
  "mit_kp": [
@@ -7,7 +7,7 @@
7
7
  "server_num_workers": 4
8
8
  },
9
9
  "params": {
10
- "states_rate": 250,
10
+ "states_rate": 500,
11
11
  "img_rate": 30,
12
12
  "tau_ctrl": false,
13
13
  "mit_kp": [
@@ -9,7 +9,7 @@
9
9
  "params": {
10
10
  "device_ip": "172.18.8.161",
11
11
  "device_port": 8439,
12
- "control_hz": 250,
12
+ "control_hz": 500,
13
13
  "arm_type": 16,
14
14
  "use_gripper": true,
15
15
  "mit_kp": [
@@ -32,7 +32,7 @@ class HexDeviceBase(ABC):
32
32
  self._working.wait(0.1)
33
33
 
34
34
  @abstractmethod
35
- def work_loop(self, hex_values: list[HexSafeValue]):
35
+ def work_loop(self, hex_values: list[HexSafeValue | threading.Event]):
36
36
  raise NotImplementedError(
37
37
  "`work_loop` should be implemented by the child class")
38
38
 
@@ -41,6 +41,13 @@
41
41
  <geom pos="0.04 0 0.12" quat="0.6830127 0.6830127 0.1830127 -0.1830127" type="mesh" rgba="0.1 0.1 0.1 1" mesh="camera_link" />
42
42
  <camera name="end_camera" pos="0.066 0 0.105" quat="0.8660254 0.0 -0.5 0.0" fovy="50"/>
43
43
 
44
+ # ee frame
45
+ <body name="ee_frame" pos="0.1870 0.0 0.0" quat="1 0 0 0">
46
+ <geom type="cylinder" size="0.002 0.01" pos="0.01 0.00 0.00" quat="0.7071068 0.0000000 0.7071068 0.0000000" rgba="1 0 0 1" contype="0" conaffinity="0" group="4"/>
47
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.01 0.00" quat="0.7071068 0.7071068 0.0000000 0.0000000" rgba="0 1 0 1" contype="0" conaffinity="0" group="4"/>
48
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.00 0.01" quat="1.0000000 0.0000000 0.0000000 0.0000000" rgba="0 0 1 1" contype="0" conaffinity="0" group="4"/>
49
+ </body>
50
+
44
51
  # gripper helper
45
52
  <body name="gripper_left_helper_link" pos="0.057667 0.030604 2.5e-05">
46
53
  <inertial pos="0.00299357 0.0232625 -5e-05" quat="0.996724 0 0 0.0808839" mass="0.00594562" diaginertia="2.74798e-06 1.47567e-06 1.34732e-06"/>
@@ -1,7 +1,7 @@
1
1
  <mujoco model="archer_d6y scene">
2
2
  <compiler angle="radian"/>
3
3
  <option integrator="implicitfast"/>
4
- <option timestep="4e-3"/>
4
+ <option timestep="2e-3"/>
5
5
 
6
6
  <statistic center="0.3 0 0.45" extent="0.8" meansize="0.05"/>
7
7
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  import os
10
10
  import copy
11
+ import threading
11
12
  import cv2
12
13
  import numpy as np
13
14
 
@@ -21,10 +22,11 @@ from ...zmq_base import (
21
22
  HexRate,
22
23
  HexSafeValue,
23
24
  )
25
+ from ...hex_launch import hex_log, HEX_LOG_LEVEL
24
26
  from hex_robo_utils import HexCtrlUtilMitJoint as CtrlUtil
25
27
 
26
28
  MUJOCO_CONFIG = {
27
- "states_rate": 250,
29
+ "states_rate": 500,
28
30
  "img_rate": 30,
29
31
  "tau_ctrl": False,
30
32
  "mit_kp": [200.0, 200.0, 200.0, 75.0, 15.0, 15.0, 20.0],
@@ -122,12 +124,13 @@ class HexMujocoArcherD6y(HexMujocoBase):
122
124
  self.__viewer.sync()
123
125
  return True
124
126
 
125
- def work_loop(self, hex_values: list[HexSafeValue]):
127
+ def work_loop(self, hex_values: list[HexSafeValue | threading.Event]):
126
128
  states_robot_value = hex_values[0]
127
129
  states_obj_value = hex_values[1]
128
130
  cmds_robot_value = hex_values[2]
129
131
  rgb_value = hex_values[3]
130
132
  depth_value = hex_values[4]
133
+ stop_event = hex_values[5]
131
134
 
132
135
  last_states_ts = {"s": 0, "ns": 0}
133
136
  states_robot_count = 0
@@ -140,7 +143,7 @@ class HexMujocoArcherD6y(HexMujocoBase):
140
143
  states_trig_count = 0
141
144
  img_trig_count = 0
142
145
 
143
- while self._working.is_set():
146
+ while self._working.is_set() and not stop_event.is_set():
144
147
  states_trig_count += 1
145
148
  if states_trig_count >= self.__states_trig_thresh:
146
149
  states_trig_count = 0
@@ -167,8 +170,7 @@ class HexMujocoArcherD6y(HexMujocoBase):
167
170
  cmds_robot_pack = cmds_robot_value.get(timeout_s=-1.0)
168
171
  if cmds_robot_pack is not None:
169
172
  ts, seq, cmds = cmds_robot_pack
170
- delta_seq = (seq - last_cmds_robot_seq) % self._max_seq_num
171
- if delta_seq > 0 and delta_seq < 1e6:
173
+ if seq != last_cmds_robot_seq:
172
174
  last_cmds_robot_seq = seq
173
175
  if hex_zmq_ts_delta_ms(hex_zmq_ts_now(), ts) < 200.0:
174
176
  self.__set_cmds(cmds)
@@ -197,6 +199,9 @@ class HexMujocoArcherD6y(HexMujocoBase):
197
199
  # sleep
198
200
  rate.sleep()
199
201
 
202
+ # close
203
+ self.close()
204
+
200
205
  def __get_states(self):
201
206
  pos = copy.deepcopy(self.__data.qpos)
202
207
  vel = copy.deepcopy(self.__data.qvel)
@@ -213,23 +218,38 @@ class HexMujocoArcherD6y(HexMujocoBase):
213
218
  def __set_cmds(self, cmds: np.ndarray):
214
219
  tau_cmds = None
215
220
  if not self.__tau_ctrl:
221
+ cmd_pos = None
222
+ tar_vel = np.zeros_like(cmds)
223
+ cmd_tor = np.zeros_like(cmds)
224
+ cmd_kp = self.__mit_kp.copy()
225
+ cmd_kd = self.__mit_kd.copy()
216
226
  if len(cmds.shape) == 1:
217
- cmd_pos = cmds.copy()
218
- cmd_tor = np.zeros_like(cmds)
227
+ cmd_pos = cmds
228
+ elif len(cmds.shape) == 2:
229
+ if cmds.shape[1] == 2:
230
+ cmd_pos = cmds[:, 0].copy()
231
+ cmd_tor = cmds[:, 1].copy()
232
+ elif cmds.shape[1] == 5:
233
+ cmd_pos = cmds[:, 0].copy()
234
+ tar_vel = cmds[:, 1].copy()
235
+ cmd_tor = cmds[:, 2].copy()
236
+ cmd_kp = cmds[:, 3].copy()
237
+ cmd_kd = cmds[:, 4].copy()
238
+ else:
239
+ raise ValueError(f"The shape of cmds is invalid: {cmds.shape}")
219
240
  else:
220
- cmd_pos = cmds[:, 0].copy()
221
- cmd_tor = cmds[:, 1].copy()
222
- cmd_pos = self._apply_pos_limits(
241
+ raise ValueError(f"The shape of cmds is invalid: {cmds.shape}")
242
+ tar_pos = self._apply_pos_limits(
223
243
  cmd_pos,
224
244
  self._limits[0, :, 0],
225
245
  self._limits[0, :, 1],
226
246
  )
227
- cmd_pos[-1] /= self.__gripper_ratio
247
+ tar_pos[-1] /= self.__gripper_ratio
228
248
  tau_cmds = self.__mit_ctrl(
229
- self.__mit_kp,
230
- self.__mit_kd,
231
- cmd_pos,
232
- np.zeros(len(self.__state_robot_idx)),
249
+ cmd_kp,
250
+ cmd_kd,
251
+ tar_pos,
252
+ tar_vel,
233
253
  self.__data.qpos[self.__state_robot_idx],
234
254
  self.__data.qvel[self.__state_robot_idx],
235
255
  cmd_tor,
@@ -259,8 +279,11 @@ class HexMujocoArcherD6y(HexMujocoBase):
259
279
  }
260
280
 
261
281
  def close(self):
282
+ if not self._working.is_set():
283
+ return
262
284
  self._working.clear()
263
285
  self.__rgb_cam.close()
264
286
  self.__depth_cam.close()
265
287
  if not self.__headless:
266
288
  self.__viewer.close()
289
+ hex_log(HEX_LOG_LEVEL["info"], "HexMujocoArcherD6y closed")
@@ -31,7 +31,7 @@ NET_CONFIG = {
31
31
  }
32
32
 
33
33
  MUJOCO_CONFIG = {
34
- "states_rate": 250,
34
+ "states_rate": 500,
35
35
  "img_rate": 30,
36
36
  "headless": False,
37
37
  "sens_ts": True,
@@ -64,6 +64,7 @@ class HexMujocoArcherD6yServer(HexMujocoServerBase):
64
64
  self._cmds_value,
65
65
  self._rgb_value,
66
66
  self._depth_value,
67
+ self._stop_event,
67
68
  ])
68
69
  finally:
69
70
  self._device.close()
@@ -104,6 +105,8 @@ class HexMujocoArcherD6yServer(HexMujocoServerBase):
104
105
  def _process_request(self, recv_hdr: dict, recv_buf: np.ndarray):
105
106
  if recv_hdr["cmd"] == "is_working":
106
107
  return self.no_ts_hdr(recv_hdr, self._device.is_working()), None
108
+ elif recv_hdr["cmd"] == "seq_clear":
109
+ return self.no_ts_hdr(recv_hdr, self._seq_clear()), None
107
110
  elif recv_hdr["cmd"] == "reset":
108
111
  return self.no_ts_hdr(recv_hdr, self._device.reset()), None
109
112
  elif recv_hdr["cmd"] == "get_dofs":
@@ -45,6 +45,13 @@
45
45
  <geom pos="0.04 0 0.12" quat="0.6830127 0.6830127 0.1830127 -0.1830127" type="mesh" rgba="0.1 0.1 0.1 1" mesh="camera_link" />
46
46
  <camera name="left_camera" pos="0.066 0 0.105" quat="0.8660254 0.0 -0.5 0.0" fovy="50"/>
47
47
 
48
+ # ee frame
49
+ <body name="left_ee_frame" pos="0.1870 0.0 0.0" quat="1 0 0 0">
50
+ <geom type="cylinder" size="0.002 0.01" pos="0.01 0.00 0.00" quat="0.7071068 0.0000000 0.7071068 0.0000000" rgba="1 0 0 1" contype="0" conaffinity="0" group="4"/>
51
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.01 0.00" quat="0.7071068 0.7071068 0.0000000 0.0000000" rgba="0 1 0 1" contype="0" conaffinity="0" group="4"/>
52
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.00 0.01" quat="1.0000000 0.0000000 0.0000000 0.0000000" rgba="0 0 1 1" contype="0" conaffinity="0" group="4"/>
53
+ </body>
54
+
48
55
  # gripper helper
49
56
  <body name="left_gripper_left_helper_link" pos="0.057667 0.030604 2.5e-05">
50
57
  <inertial pos="0.00299357 0.0232625 -5e-05" quat="0.996724 0 0 0.0808839" mass="0.00594562" diaginertia="2.74798e-06 1.47567e-06 1.34732e-06"/>
@@ -127,6 +134,13 @@
127
134
  <geom pos="0.04 0 0.12" quat="0.6830127 0.6830127 0.1830127 -0.1830127" type="mesh" rgba="0.1 0.1 0.1 1" mesh="camera_link" />
128
135
  <camera name="right_camera" pos="0.066 0 0.105" quat="0.8660254 0.0 -0.5 0.0" fovy="50"/>
129
136
 
137
+ # ee frame
138
+ <body name="right_ee_frame" pos="0.1870 0.0 0.0" quat="1 0 0 0">
139
+ <geom type="cylinder" size="0.002 0.01" pos="0.01 0.00 0.00" quat="0.7071068 0.0000000 0.7071068 0.0000000" rgba="1 0 0 1" contype="0" conaffinity="0" group="4"/>
140
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.01 0.00" quat="0.7071068 0.7071068 0.0000000 0.0000000" rgba="0 1 0 1" contype="0" conaffinity="0" group="4"/>
141
+ <geom type="cylinder" size="0.002 0.01" pos="0.00 0.00 0.01" quat="1.0000000 0.0000000 0.0000000 0.0000000" rgba="0 0 1 1" contype="0" conaffinity="0" group="4"/>
142
+ </body>
143
+
130
144
  # gripper helper
131
145
  <body name="right_gripper_left_helper_link" pos="0.057667 0.030604 2.5e-05">
132
146
  <inertial pos="0.00299357 0.0232625 -5e-05" quat="0.996724 0 0 0.0808839" mass="0.00594562" diaginertia="2.74798e-06 1.47567e-06 1.34732e-06"/>
@@ -1,7 +1,7 @@
1
1
  <mujoco model="e3_desktop scene">
2
2
  <compiler angle="radian"/>
3
3
  <option integrator="implicitfast"/>
4
- <option timestep="4e-3"/>
4
+ <option timestep="2e-3"/>
5
5
 
6
6
  <statistic center="0.3 0 0.45" extent="0.8" meansize="0.05"/>
7
7