hex-util-msg 0.1.0a0__tar.gz → 0.1.0a2__tar.gz

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 (73) hide show
  1. hex_util_msg-0.1.0a2/PKG-INFO +341 -0
  2. hex_util_msg-0.1.0a2/README.md +311 -0
  3. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/__init__.py +8 -4
  4. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/dataclass/__init__.py +19 -18
  5. hex_util_msg-0.1.0a0/hex_util_msg/dataclass/dataclass_ros.py → hex_util_msg-0.1.0a2/hex_util_msg/dataclass/dataclass_base.py +16 -16
  6. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/dataclass/dataclass_robo.py +39 -35
  7. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/dataclass/dataclass_teleop.py +3 -3
  8. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Header.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseHeader.py +15 -15
  9. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/HexJnt.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseJntFull.py +49 -49
  10. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/JointState.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseJntState.py +25 -25
  11. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Odometry.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseOdometry.py +15 -15
  12. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Pose.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBasePose.py +6 -6
  13. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Quaternion.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseQuaternion.py +8 -8
  14. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Time.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseTime.py +6 -6
  15. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Twist.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseTwist.py +6 -6
  16. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/Vector3.py → hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/HexBaseVector3.py +7 -7
  17. hex_util_msg-0.1.0a2/hex_util_msg/fbs/msg_base/__init__.py +21 -0
  18. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_envelope/MsgPayload.py +4 -4
  19. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboArmCtrl.py +6 -6
  20. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboArmCtrlMode.py +4 -3
  21. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboArmCtrlStamped.py +2 -2
  22. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboArmState.py +4 -4
  23. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboArmStateStamped.py +2 -2
  24. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboChsCtrl.py +4 -4
  25. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboChsCtrlMode.py +3 -2
  26. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboChsCtrlStamped.py +2 -2
  27. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboChsState.py +4 -4
  28. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboChsStateStamped.py +2 -2
  29. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboGripCtrl.py +2 -2
  30. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboGripCtrlMode.py +4 -3
  31. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboGripCtrlStamped.py +2 -2
  32. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboGripState.py +2 -2
  33. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboGripStateStamped.py +2 -2
  34. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboLiftCtrl.py +13 -5
  35. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboLiftCtrlMode.py +3 -2
  36. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboLiftCtrlStamped.py +2 -2
  37. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboLiftState.py +4 -4
  38. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboLiftStateStamped.py +2 -2
  39. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboManipCtrlStamped.py +2 -2
  40. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboManipStateStamped.py +2 -2
  41. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_teleop/HexTeleopHandleCtrlStamped.py +2 -2
  42. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_teleop/HexTeleopHandleStateStamped.py +2 -2
  43. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/trans/__init__.py +37 -37
  44. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/trans/hex_msg_trans.py +22 -18
  45. hex_util_msg-0.1.0a2/hex_util_msg/trans/trans_base.py +219 -0
  46. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/trans/trans_robo.py +75 -73
  47. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/trans/trans_teleop.py +7 -7
  48. hex_util_msg-0.1.0a2/hex_util_msg.egg-info/PKG-INFO +341 -0
  49. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg.egg-info/SOURCES.txt +12 -12
  50. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/pyproject.toml +1 -1
  51. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/tests/test_hex_msg_trans.py +32 -32
  52. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/tests/test_hex_util_msg_imports.py +27 -21
  53. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/tests/test_msg_robo.py +67 -65
  54. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/tests/test_msg_teleop.py +7 -7
  55. hex_util_msg-0.1.0a0/PKG-INFO +0 -305
  56. hex_util_msg-0.1.0a0/README.md +0 -275
  57. hex_util_msg-0.1.0a0/hex_util_msg/fbs/msg_ros/__init__.py +0 -21
  58. hex_util_msg-0.1.0a0/hex_util_msg/trans/trans_ros.py +0 -220
  59. hex_util_msg-0.1.0a0/hex_util_msg.egg-info/PKG-INFO +0 -305
  60. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/LICENSE +0 -0
  61. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/MANIFEST.in +0 -0
  62. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_envelope/MsgEnvelope.py +0 -0
  63. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_envelope/__init__.py +0 -0
  64. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboManipCtrl.py +0 -0
  65. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/HexRoboManipState.py +0 -0
  66. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_robo/__init__.py +0 -0
  67. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_teleop/HexTeleopHandleCtrl.py +0 -0
  68. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_teleop/HexTeleopHandleState.py +0 -0
  69. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg/fbs/msg_teleop/__init__.py +0 -0
  70. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg.egg-info/dependency_links.txt +0 -0
  71. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg.egg-info/requires.txt +0 -0
  72. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/hex_util_msg.egg-info/top_level.txt +0 -0
  73. {hex_util_msg-0.1.0a0 → hex_util_msg-0.1.0a2}/setup.cfg +0 -0
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: hex_util_msg
3
+ Version: 0.1.0a2
4
+ Summary: HEXFELLOW Util Message
5
+ Author-email: Dong Zhaorui <dzr159@gmail.com>
6
+ Maintainer-email: jecjune <zejun.chen@hexfellow.com>, Dong Zhaorui <dzr159@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/hexfellow/hex_util_msg
9
+ Project-URL: Repository, https://github.com/hexfellow/hex_util_msg.git
10
+ Project-URL: Bug Tracker, https://github.com/hexfellow/hex_util_msg/issues
11
+ Project-URL: Documentation, https://github.com/hexfellow/hex_util_msg/wiki
12
+ Keywords: hex,util,message
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: POSIX :: Linux
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: flatbuffers>=25.0.0
28
+ Requires-Dist: numpy>=1.17.4
29
+ Dynamic: license-file
30
+
31
+ <h1 align="center">HEXFELLOW UTILITY MESSAGES</h1>
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/hexfellow/hex_util_msg/stargazers">
35
+ <img src="https://img.shields.io/github/stars/hexfellow/hex_util_msg?style=flat-square&logo=github" />
36
+ </a>
37
+ <a href="https://github.com/hexfellow/hex_util_msg/forks">
38
+ <img src="https://img.shields.io/github/forks/hexfellow/hex_util_msg?style=flat-square&logo=github" />
39
+ </a>
40
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
41
+ <a href="https://github.com/hexfellow/hex_util_msg/issues">
42
+ <img src="https://img.shields.io/github/issues/hexfellow/hex_util_msg?style=flat-square&logo=github" />
43
+ </a>
44
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
45
+ <img src="https://img.shields.io/badge/python-≥3.8-blue?style=flat-square&logo=python" />
46
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
47
+ <img src="https://img.shields.io/badge/platform-Linux-orange?style=flat-square" />
48
+ </p>
49
+
50
+ ---
51
+
52
+ # 📖 Overview
53
+
54
+ ## What is `hex_util_msg`
55
+
56
+ `hex_util_msg` is a Python message library that provides [FlatBuffers](https://flatbuffers.dev/) message definitions and high-level dataclass-based helpers for robotics and teleoperation. It is part of the HEXFELLOW ecosystem.
57
+
58
+ The library consists of three layers:
59
+
60
+ | Layer | Subpackage | Purpose |
61
+ |-------|-----------|---------|
62
+ | **Dataclass** | `hex_util_msg.dataclass` | Type-safe Python `@dataclass` objects for all 28 message types (base geometry, robot arm/chassis/grip/lift/manip, teleoperation handle) |
63
+ | **Converters** | `hex_util_msg.trans` | Bidirectional `dc2fbs` / `fbs2dc` functions plus the `HexMsgTrans` high-level envelope-based dispatcher |
64
+ | **FlatBuffers** | `hex_util_msg.fbs` | Auto-generated FlatBuffers Python bindings for 4 namespaces (`msg_base`, `msg_robo`, `msg_teleop`, `msg_envelope`) |
65
+
66
+ ## Message Categories
67
+
68
+ | Category | Robot Subsystem | Message Pairs |
69
+ |----------|----------------|---------------|
70
+ | **Arm** | Robotic arm (7-DOF) | `Ctrl` / `State` (each with `Stamped` variant) |
71
+ | **Chassis** | Mobile base | `Ctrl` / `State` (each with `Stamped` variant) |
72
+ | **Grip** | Gripper/end-effector | `Ctrl` / `State` (each with `Stamped` variant) |
73
+ | **Lift** | Vertical lift | `Ctrl` / `State` (each with `Stamped` variant) |
74
+ | **Manip** | Composite arm+grip | `Ctrl` / `State` (each with `Stamped` variant) |
75
+ | **Teleop** | Teleoperation handle | `HandleCtrl` / `HandleState` (each with `Stamped` variant) |
76
+ | **Base** | Geometry & time | `Vector3`, `Quaternion`, `Pose`, `Twist`, `Time`, `Header`, `Odometry`, `JntState`, `JntFull` |
77
+
78
+ ## What problem it solves
79
+
80
+ - **Zero-copy deserialization**: FlatBuffers enables direct memory access on the receiving end without decode overhead.
81
+ - **Type-safe dataclass API**: Work with standard Python dataclasses and numpy arrays — no manual FlatBuffers table construction.
82
+ - **Envelope dispatch**: `HexMsgTrans.dc2fbs()` and `.fbs2dc()` wrap all messages in a self-describing envelope so the receiver auto-detects the message type.
83
+ - **NumPy integration**: Joint fields are `np.float64` / `np.uint8` arrays, natural for scientific and robotics workflows.
84
+
85
+ ## Target users
86
+
87
+ - Robotics engineers building control systems with structured inter-process communication.
88
+ - Developers producing or consuming FlatBuffers-encoded data in the HEXFELLOW ecosystem.
89
+ - Anyone needing a standardised, typed message format with zero-copy deserialization.
90
+
91
+ ## Project structure
92
+
93
+ ```
94
+ hex_util_msg/
95
+ ├── hex_util_msg/ # Python package
96
+ │ ├── __init__.py
97
+ │ ├── dataclass/ # Python dataclass definitions
98
+ │ │ ├── __init__.py
99
+ │ │ ├── dataclass_base.py # Base geometry/time/joint types
100
+ │ │ ├── dataclass_robo.py # Robot arm/chassis/grip/lift/manip types
101
+ │ │ └── dataclass_teleop.py # Teleoperation handle types
102
+ │ ├── fbs/ # FlatBuffers-generated Python code
103
+ │ │ ├── msg_base/
104
+ │ │ ├── msg_envelope/
105
+ │ │ ├── msg_robo/
106
+ │ │ └── msg_teleop/
107
+ │ └── trans/ # Dataclass <-> FlatBuffers converters
108
+ │ ├── __init__.py
109
+ │ ├── hex_msg_trans.py # HexMsgTrans class + dispatch tables
110
+ │ ├── trans_base.py
111
+ │ ├── trans_robo.py
112
+ │ └── trans_teleop.py
113
+ ├── msgs/ # FlatBuffers schema sources (.fbs)
114
+ │ ├── base.fbs
115
+ │ ├── msg_envelope.fbs
116
+ │ ├── robo_arm_*.fbs # 4 files
117
+ │ ├── robo_chs_*.fbs # 4 files
118
+ │ ├── robo_grip_*.fbs # 4 files
119
+ │ ├── robo_lift_*.fbs # 4 files
120
+ │ ├── robo_manip_*.fbs # 4 files
121
+ │ └── teleop_handle_*.fbs # 4 files
122
+ ├── docs/
123
+ │ └── api.md # Full API reference
124
+ ├── tests/ # pytest test suite
125
+ ├── generate.sh # Regenerate Python code from .fbs schemas
126
+ ├── venv.sh # Set up dev virtual environment
127
+ ├── pyproject.toml
128
+ └── LICENSE
129
+ ```
130
+
131
+ ---
132
+
133
+ # 📦 Installation
134
+
135
+ ## Requirements
136
+
137
+ - **Python** ≥ 3.8
138
+ - **OS**: Linux
139
+ - **Dependencies**:
140
+ - `flatbuffers ≥ 25.0.0`
141
+ - `numpy ≥ 1.17.4`
142
+
143
+ ## Install from Source
144
+
145
+ We use [**uv**](https://github.com/astral-sh/uv) to manage the Python environment. Please install it first.
146
+
147
+ 1. Clone and install in editable mode:
148
+
149
+ ```bash
150
+ git clone https://github.com/hexfellow/hex_util_msg.git
151
+ cd hex_util_msg
152
+ ./venv.sh
153
+ ```
154
+
155
+ 2. Activate before using:
156
+
157
+ ```bash
158
+ source .venv/bin/activate
159
+ ```
160
+
161
+ ---
162
+
163
+ # ⚡ Quick Start
164
+
165
+ ## Import and construct dataclasses
166
+
167
+ ```python
168
+ import numpy as np
169
+ from hex_util_msg.dataclass import (
170
+ HexBaseVector3, HexBaseQuaternion, HexBasePose, HexBaseTwist,
171
+ HexBaseTime, HexBaseHeader,
172
+ HexBaseJntState, HexBaseJntFull,
173
+ HexRoboArmCtrl, HexRoboArmCtrlMode, HexRoboArmCtrlStamped,
174
+ HexRoboArmState, HexRoboArmStateStamped,
175
+ HexRoboManipCtrl, HexRoboManipState,
176
+ HexTeleopHandleState,
177
+ )
178
+ ```
179
+
180
+ ## Serialize and deserialize with `HexMsgTrans`
181
+
182
+ ```python
183
+ from hex_util_msg.trans import HexMsgTrans
184
+
185
+ # --- Create a stamped arm control message ---
186
+ arm_ctrl = HexRoboArmCtrlStamped(
187
+ header=HexBaseHeader(
188
+ seq=1,
189
+ stamp=HexBaseTime(secs=123, nsecs=456_000_000),
190
+ frame_id="arm_base",
191
+ ),
192
+ arm_ctrl=HexRoboArmCtrl(
193
+ ctrl_mode=HexRoboArmCtrlMode.MIT,
194
+ grav=HexBaseVector3(x=0.0, y=0.0, z=9.81),
195
+ jnt=HexBaseJntFull(
196
+ pos=np.zeros(7, dtype=np.float64),
197
+ vel=np.zeros(7, dtype=np.float64),
198
+ eff=np.zeros(7, dtype=np.float64),
199
+ kp=np.full(7, 100.0, dtype=np.float64),
200
+ kd=np.full(7, 10.0, dtype=np.float64),
201
+ lim_vel=np.zeros(7, dtype=np.float64),
202
+ lim_acc=np.zeros(7, dtype=np.float64),
203
+ ),
204
+ pose=HexBasePose(
205
+ position=HexBaseVector3(x=0.5, y=0.0, z=1.0),
206
+ orientation=HexBaseQuaternion(x=0.0, y=0.0, z=0.0, w=1.0),
207
+ ),
208
+ ),
209
+ )
210
+
211
+ # Serialize to bytes
212
+ buf = HexMsgTrans.dc2fbs(arm_ctrl)
213
+
214
+ # Deserialize back — type is auto-detected from the envelope
215
+ restored = HexMsgTrans.fbs2dc(buf)
216
+
217
+ # restored is a HexRoboArmCtrlStamped dataclass
218
+ print(restored.header.seq) # 1
219
+ print(restored.arm_ctrl.ctrl_mode) # HexRoboArmCtrlMode.MIT
220
+ ```
221
+
222
+ ## Arm state
223
+
224
+ ```python
225
+ arm_state = HexRoboArmStateStamped(
226
+ header=HexBaseHeader(seq=0, stamp=HexBaseTime(secs=0), frame_id=""),
227
+ arm_state=HexRoboArmState(
228
+ jnt=HexBaseJntState(
229
+ position=np.array([0.0, 0.25, 0.5], dtype=np.float64),
230
+ velocity=np.array([0.0, 0.0, 0.0], dtype=np.float64),
231
+ effort=np.zeros(3, dtype=np.float64),
232
+ ),
233
+ pose=HexBasePose(
234
+ position=HexBaseVector3(x=1.0, y=2.0, z=3.0),
235
+ orientation=HexBaseQuaternion(x=0.0, y=0.0, z=0.707, w=0.707),
236
+ ),
237
+ ),
238
+ )
239
+ buf = HexMsgTrans.dc2fbs(arm_state)
240
+ restored = HexMsgTrans.fbs2dc(buf)
241
+ ```
242
+
243
+ ## Teleop handle state
244
+
245
+ ```python
246
+ handle = HexTeleopHandleState(
247
+ trigger=0.5,
248
+ axis_x=0.3,
249
+ axis_y=-0.2,
250
+ btn_w=True,
251
+ btn_x=False,
252
+ btn_y=False,
253
+ btn_z=False,
254
+ )
255
+ buf = HexMsgTrans.dc2fbs(handle)
256
+ restored = HexMsgTrans.fbs2dc(buf)
257
+ # restored.btn_w == True, restored.trigger == 0.5
258
+ ```
259
+
260
+ ## Manipulator (composite arm + grip)
261
+
262
+ ```python
263
+ manip_state = HexRoboManipState(
264
+ arm_state=HexRoboArmState(
265
+ jnt=HexBaseJntState(
266
+ position=np.zeros(7, dtype=np.float64),
267
+ ),
268
+ ),
269
+ grip_state=HexRoboGripState(
270
+ jnt=HexBaseJntState(
271
+ position=np.zeros(1, dtype=np.float64),
272
+ ),
273
+ ),
274
+ )
275
+ buf = HexMsgTrans.dc2fbs(manip_state)
276
+ restored = HexMsgTrans.fbs2dc(buf)
277
+ ```
278
+
279
+ ---
280
+
281
+ # 📑 Documentation
282
+
283
+ - [**API Reference**](docs/api.md) — Detailed documentation of all dataclasses, enums, and converter functions.
284
+
285
+ ---
286
+
287
+ # 🔧 Development
288
+
289
+ ## Environment setup
290
+
291
+ ```bash
292
+ ./venv.sh
293
+ source .venv/bin/activate
294
+ ```
295
+
296
+ ## Regenerating code from schemas
297
+
298
+ If you modify `.fbs` files under `msgs/`, regenerate the Python bindings:
299
+
300
+ ```bash
301
+ # Requires flatc (FlatBuffers compiler) on PATH
302
+ ./generate.sh
303
+ ```
304
+
305
+ This removes existing generated directories and re-runs `flatc --python` for all namespaces.
306
+
307
+ ## Testing
308
+
309
+ ```bash
310
+ pytest tests/ -v
311
+ ```
312
+
313
+ ---
314
+
315
+ # 📄 License
316
+
317
+ Apache License 2.0. See [LICENSE](LICENSE).
318
+
319
+ ---
320
+
321
+ # 👥 Authors & Maintainers
322
+
323
+ | Role | Name | Email |
324
+ |------|------|-------|
325
+ | **Author** | Dong Zhaorui | dzr159@gmail.com |
326
+ | **Maintainer** | jecjune (Chen Zejun) | zejun.chen@hexfellow.com |
327
+ | **Maintainer** | Dong Zhaorui | dzr159@gmail.com |
328
+
329
+ ---
330
+
331
+ # 🌟 Star History
332
+
333
+ [![Star History Chart](https://api.star-history.com/svg?repos=hexfellow/hex_util_msg&type=Date)](https://star-history.com/#hexfellow/hex_util_msg&Date)
334
+
335
+ ---
336
+
337
+ # 👥 Contributors
338
+
339
+ <a href="https://github.com/hexfellow/hex_util_msg/graphs/contributors">
340
+ <img src="https://contrib.rocks/image?repo=hexfellow/hex_util_msg" />
341
+ </a>
@@ -0,0 +1,311 @@
1
+ <h1 align="center">HEXFELLOW UTILITY MESSAGES</h1>
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/hexfellow/hex_util_msg/stargazers">
5
+ <img src="https://img.shields.io/github/stars/hexfellow/hex_util_msg?style=flat-square&logo=github" />
6
+ </a>
7
+ <a href="https://github.com/hexfellow/hex_util_msg/forks">
8
+ <img src="https://img.shields.io/github/forks/hexfellow/hex_util_msg?style=flat-square&logo=github" />
9
+ </a>
10
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
11
+ <a href="https://github.com/hexfellow/hex_util_msg/issues">
12
+ <img src="https://img.shields.io/github/issues/hexfellow/hex_util_msg?style=flat-square&logo=github" />
13
+ </a>
14
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
15
+ <img src="https://img.shields.io/badge/python-≥3.8-blue?style=flat-square&logo=python" />
16
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
17
+ <img src="https://img.shields.io/badge/platform-Linux-orange?style=flat-square" />
18
+ </p>
19
+
20
+ ---
21
+
22
+ # 📖 Overview
23
+
24
+ ## What is `hex_util_msg`
25
+
26
+ `hex_util_msg` is a Python message library that provides [FlatBuffers](https://flatbuffers.dev/) message definitions and high-level dataclass-based helpers for robotics and teleoperation. It is part of the HEXFELLOW ecosystem.
27
+
28
+ The library consists of three layers:
29
+
30
+ | Layer | Subpackage | Purpose |
31
+ |-------|-----------|---------|
32
+ | **Dataclass** | `hex_util_msg.dataclass` | Type-safe Python `@dataclass` objects for all 28 message types (base geometry, robot arm/chassis/grip/lift/manip, teleoperation handle) |
33
+ | **Converters** | `hex_util_msg.trans` | Bidirectional `dc2fbs` / `fbs2dc` functions plus the `HexMsgTrans` high-level envelope-based dispatcher |
34
+ | **FlatBuffers** | `hex_util_msg.fbs` | Auto-generated FlatBuffers Python bindings for 4 namespaces (`msg_base`, `msg_robo`, `msg_teleop`, `msg_envelope`) |
35
+
36
+ ## Message Categories
37
+
38
+ | Category | Robot Subsystem | Message Pairs |
39
+ |----------|----------------|---------------|
40
+ | **Arm** | Robotic arm (7-DOF) | `Ctrl` / `State` (each with `Stamped` variant) |
41
+ | **Chassis** | Mobile base | `Ctrl` / `State` (each with `Stamped` variant) |
42
+ | **Grip** | Gripper/end-effector | `Ctrl` / `State` (each with `Stamped` variant) |
43
+ | **Lift** | Vertical lift | `Ctrl` / `State` (each with `Stamped` variant) |
44
+ | **Manip** | Composite arm+grip | `Ctrl` / `State` (each with `Stamped` variant) |
45
+ | **Teleop** | Teleoperation handle | `HandleCtrl` / `HandleState` (each with `Stamped` variant) |
46
+ | **Base** | Geometry & time | `Vector3`, `Quaternion`, `Pose`, `Twist`, `Time`, `Header`, `Odometry`, `JntState`, `JntFull` |
47
+
48
+ ## What problem it solves
49
+
50
+ - **Zero-copy deserialization**: FlatBuffers enables direct memory access on the receiving end without decode overhead.
51
+ - **Type-safe dataclass API**: Work with standard Python dataclasses and numpy arrays — no manual FlatBuffers table construction.
52
+ - **Envelope dispatch**: `HexMsgTrans.dc2fbs()` and `.fbs2dc()` wrap all messages in a self-describing envelope so the receiver auto-detects the message type.
53
+ - **NumPy integration**: Joint fields are `np.float64` / `np.uint8` arrays, natural for scientific and robotics workflows.
54
+
55
+ ## Target users
56
+
57
+ - Robotics engineers building control systems with structured inter-process communication.
58
+ - Developers producing or consuming FlatBuffers-encoded data in the HEXFELLOW ecosystem.
59
+ - Anyone needing a standardised, typed message format with zero-copy deserialization.
60
+
61
+ ## Project structure
62
+
63
+ ```
64
+ hex_util_msg/
65
+ ├── hex_util_msg/ # Python package
66
+ │ ├── __init__.py
67
+ │ ├── dataclass/ # Python dataclass definitions
68
+ │ │ ├── __init__.py
69
+ │ │ ├── dataclass_base.py # Base geometry/time/joint types
70
+ │ │ ├── dataclass_robo.py # Robot arm/chassis/grip/lift/manip types
71
+ │ │ └── dataclass_teleop.py # Teleoperation handle types
72
+ │ ├── fbs/ # FlatBuffers-generated Python code
73
+ │ │ ├── msg_base/
74
+ │ │ ├── msg_envelope/
75
+ │ │ ├── msg_robo/
76
+ │ │ └── msg_teleop/
77
+ │ └── trans/ # Dataclass <-> FlatBuffers converters
78
+ │ ├── __init__.py
79
+ │ ├── hex_msg_trans.py # HexMsgTrans class + dispatch tables
80
+ │ ├── trans_base.py
81
+ │ ├── trans_robo.py
82
+ │ └── trans_teleop.py
83
+ ├── msgs/ # FlatBuffers schema sources (.fbs)
84
+ │ ├── base.fbs
85
+ │ ├── msg_envelope.fbs
86
+ │ ├── robo_arm_*.fbs # 4 files
87
+ │ ├── robo_chs_*.fbs # 4 files
88
+ │ ├── robo_grip_*.fbs # 4 files
89
+ │ ├── robo_lift_*.fbs # 4 files
90
+ │ ├── robo_manip_*.fbs # 4 files
91
+ │ └── teleop_handle_*.fbs # 4 files
92
+ ├── docs/
93
+ │ └── api.md # Full API reference
94
+ ├── tests/ # pytest test suite
95
+ ├── generate.sh # Regenerate Python code from .fbs schemas
96
+ ├── venv.sh # Set up dev virtual environment
97
+ ├── pyproject.toml
98
+ └── LICENSE
99
+ ```
100
+
101
+ ---
102
+
103
+ # 📦 Installation
104
+
105
+ ## Requirements
106
+
107
+ - **Python** ≥ 3.8
108
+ - **OS**: Linux
109
+ - **Dependencies**:
110
+ - `flatbuffers ≥ 25.0.0`
111
+ - `numpy ≥ 1.17.4`
112
+
113
+ ## Install from Source
114
+
115
+ We use [**uv**](https://github.com/astral-sh/uv) to manage the Python environment. Please install it first.
116
+
117
+ 1. Clone and install in editable mode:
118
+
119
+ ```bash
120
+ git clone https://github.com/hexfellow/hex_util_msg.git
121
+ cd hex_util_msg
122
+ ./venv.sh
123
+ ```
124
+
125
+ 2. Activate before using:
126
+
127
+ ```bash
128
+ source .venv/bin/activate
129
+ ```
130
+
131
+ ---
132
+
133
+ # ⚡ Quick Start
134
+
135
+ ## Import and construct dataclasses
136
+
137
+ ```python
138
+ import numpy as np
139
+ from hex_util_msg.dataclass import (
140
+ HexBaseVector3, HexBaseQuaternion, HexBasePose, HexBaseTwist,
141
+ HexBaseTime, HexBaseHeader,
142
+ HexBaseJntState, HexBaseJntFull,
143
+ HexRoboArmCtrl, HexRoboArmCtrlMode, HexRoboArmCtrlStamped,
144
+ HexRoboArmState, HexRoboArmStateStamped,
145
+ HexRoboManipCtrl, HexRoboManipState,
146
+ HexTeleopHandleState,
147
+ )
148
+ ```
149
+
150
+ ## Serialize and deserialize with `HexMsgTrans`
151
+
152
+ ```python
153
+ from hex_util_msg.trans import HexMsgTrans
154
+
155
+ # --- Create a stamped arm control message ---
156
+ arm_ctrl = HexRoboArmCtrlStamped(
157
+ header=HexBaseHeader(
158
+ seq=1,
159
+ stamp=HexBaseTime(secs=123, nsecs=456_000_000),
160
+ frame_id="arm_base",
161
+ ),
162
+ arm_ctrl=HexRoboArmCtrl(
163
+ ctrl_mode=HexRoboArmCtrlMode.MIT,
164
+ grav=HexBaseVector3(x=0.0, y=0.0, z=9.81),
165
+ jnt=HexBaseJntFull(
166
+ pos=np.zeros(7, dtype=np.float64),
167
+ vel=np.zeros(7, dtype=np.float64),
168
+ eff=np.zeros(7, dtype=np.float64),
169
+ kp=np.full(7, 100.0, dtype=np.float64),
170
+ kd=np.full(7, 10.0, dtype=np.float64),
171
+ lim_vel=np.zeros(7, dtype=np.float64),
172
+ lim_acc=np.zeros(7, dtype=np.float64),
173
+ ),
174
+ pose=HexBasePose(
175
+ position=HexBaseVector3(x=0.5, y=0.0, z=1.0),
176
+ orientation=HexBaseQuaternion(x=0.0, y=0.0, z=0.0, w=1.0),
177
+ ),
178
+ ),
179
+ )
180
+
181
+ # Serialize to bytes
182
+ buf = HexMsgTrans.dc2fbs(arm_ctrl)
183
+
184
+ # Deserialize back — type is auto-detected from the envelope
185
+ restored = HexMsgTrans.fbs2dc(buf)
186
+
187
+ # restored is a HexRoboArmCtrlStamped dataclass
188
+ print(restored.header.seq) # 1
189
+ print(restored.arm_ctrl.ctrl_mode) # HexRoboArmCtrlMode.MIT
190
+ ```
191
+
192
+ ## Arm state
193
+
194
+ ```python
195
+ arm_state = HexRoboArmStateStamped(
196
+ header=HexBaseHeader(seq=0, stamp=HexBaseTime(secs=0), frame_id=""),
197
+ arm_state=HexRoboArmState(
198
+ jnt=HexBaseJntState(
199
+ position=np.array([0.0, 0.25, 0.5], dtype=np.float64),
200
+ velocity=np.array([0.0, 0.0, 0.0], dtype=np.float64),
201
+ effort=np.zeros(3, dtype=np.float64),
202
+ ),
203
+ pose=HexBasePose(
204
+ position=HexBaseVector3(x=1.0, y=2.0, z=3.0),
205
+ orientation=HexBaseQuaternion(x=0.0, y=0.0, z=0.707, w=0.707),
206
+ ),
207
+ ),
208
+ )
209
+ buf = HexMsgTrans.dc2fbs(arm_state)
210
+ restored = HexMsgTrans.fbs2dc(buf)
211
+ ```
212
+
213
+ ## Teleop handle state
214
+
215
+ ```python
216
+ handle = HexTeleopHandleState(
217
+ trigger=0.5,
218
+ axis_x=0.3,
219
+ axis_y=-0.2,
220
+ btn_w=True,
221
+ btn_x=False,
222
+ btn_y=False,
223
+ btn_z=False,
224
+ )
225
+ buf = HexMsgTrans.dc2fbs(handle)
226
+ restored = HexMsgTrans.fbs2dc(buf)
227
+ # restored.btn_w == True, restored.trigger == 0.5
228
+ ```
229
+
230
+ ## Manipulator (composite arm + grip)
231
+
232
+ ```python
233
+ manip_state = HexRoboManipState(
234
+ arm_state=HexRoboArmState(
235
+ jnt=HexBaseJntState(
236
+ position=np.zeros(7, dtype=np.float64),
237
+ ),
238
+ ),
239
+ grip_state=HexRoboGripState(
240
+ jnt=HexBaseJntState(
241
+ position=np.zeros(1, dtype=np.float64),
242
+ ),
243
+ ),
244
+ )
245
+ buf = HexMsgTrans.dc2fbs(manip_state)
246
+ restored = HexMsgTrans.fbs2dc(buf)
247
+ ```
248
+
249
+ ---
250
+
251
+ # 📑 Documentation
252
+
253
+ - [**API Reference**](docs/api.md) — Detailed documentation of all dataclasses, enums, and converter functions.
254
+
255
+ ---
256
+
257
+ # 🔧 Development
258
+
259
+ ## Environment setup
260
+
261
+ ```bash
262
+ ./venv.sh
263
+ source .venv/bin/activate
264
+ ```
265
+
266
+ ## Regenerating code from schemas
267
+
268
+ If you modify `.fbs` files under `msgs/`, regenerate the Python bindings:
269
+
270
+ ```bash
271
+ # Requires flatc (FlatBuffers compiler) on PATH
272
+ ./generate.sh
273
+ ```
274
+
275
+ This removes existing generated directories and re-runs `flatc --python` for all namespaces.
276
+
277
+ ## Testing
278
+
279
+ ```bash
280
+ pytest tests/ -v
281
+ ```
282
+
283
+ ---
284
+
285
+ # 📄 License
286
+
287
+ Apache License 2.0. See [LICENSE](LICENSE).
288
+
289
+ ---
290
+
291
+ # 👥 Authors & Maintainers
292
+
293
+ | Role | Name | Email |
294
+ |------|------|-------|
295
+ | **Author** | Dong Zhaorui | dzr159@gmail.com |
296
+ | **Maintainer** | jecjune (Chen Zejun) | zejun.chen@hexfellow.com |
297
+ | **Maintainer** | Dong Zhaorui | dzr159@gmail.com |
298
+
299
+ ---
300
+
301
+ # 🌟 Star History
302
+
303
+ [![Star History Chart](https://api.star-history.com/svg?repos=hexfellow/hex_util_msg&type=Date)](https://star-history.com/#hexfellow/hex_util_msg&Date)
304
+
305
+ ---
306
+
307
+ # 👥 Contributors
308
+
309
+ <a href="https://github.com/hexfellow/hex_util_msg/graphs/contributors">
310
+ <img src="https://contrib.rocks/image?repo=hexfellow/hex_util_msg" />
311
+ </a>
@@ -8,28 +8,32 @@
8
8
 
9
9
  import sys
10
10
 
11
- # FlatBuffers-generated Python uses bare ``import msg_robo / msg_teleop / msg_ros``.
11
+ # FlatBuffers-generated Python uses bare ``import msg_robo / msg_teleop / msg_base``.
12
12
  from hex_util_msg.fbs import msg_envelope # noqa: E402
13
13
  from hex_util_msg.fbs import msg_robo # noqa: E402
14
14
  from hex_util_msg.fbs import msg_teleop # noqa: E402
15
- from hex_util_msg.fbs import msg_ros # noqa: E402
15
+ from hex_util_msg.fbs import msg_base # noqa: E402
16
16
 
17
17
  sys.modules.setdefault("msg_envelope", msg_envelope)
18
18
  sys.modules.setdefault("msg_robo", msg_robo)
19
19
  sys.modules.setdefault("msg_teleop", msg_teleop)
20
- sys.modules.setdefault("msg_ros", msg_ros)
20
+ sys.modules.setdefault("msg_base", msg_base)
21
21
 
22
+ from hex_util_msg.dataclass import dataclass_base # noqa: E402
22
23
  from hex_util_msg.dataclass import dataclass_robo # noqa: E402
23
24
  from hex_util_msg.dataclass import dataclass_teleop # noqa: E402
25
+ from hex_util_msg.trans import trans_base # noqa: E402
24
26
  from hex_util_msg.trans import trans_robo # noqa: E402
25
27
  from hex_util_msg.trans import trans_teleop # noqa: E402
26
28
 
27
29
  __all__ = [
30
+ "dataclass_base",
28
31
  "dataclass_robo",
29
32
  "dataclass_teleop",
30
33
  "msg_robo",
31
34
  "msg_teleop",
32
- "msg_ros",
35
+ "msg_base",
36
+ "trans_base",
33
37
  "trans_robo",
34
38
  "trans_teleop",
35
39
  ]