HEXFELLOW UTILITY MESSAGES
📖 Overview
What is hex_util_msg
hex_util_msg is a Python message library that provides FlatBuffers message definitions and high-level dataclass-based helpers for robotics and teleoperation. It is part of the HEXFELLOW ecosystem.
The library consists of three layers:
| Layer | Subpackage | Purpose |
|---|---|---|
| Dataclass | hex_util_msg.dataclass |
Type-safe Python @dataclass objects for all 32 message types (base geometry, robot arm/chassis/grip/lift/manip, teleoperation handle/joystick/keyboard) — classes use HexDc* naming |
| Converters | hex_util_msg.trans |
Bidirectional dc2fbs / fbs2dc functions plus the HexMsgTrans high-level envelope-based dispatcher — FBS classes use HexFbs* naming |
| FlatBuffers | hex_util_msg.fbs |
Auto-generated FlatBuffers Python bindings for 4 namespaces (msg_base, msg_robo, msg_teleop, msg_envelope) |
Message Categories
| Category | Robot Subsystem | Message Pairs |
|---|---|---|
| Arm | Robotic arm (7-DOF) | Ctrl / State (each with Stamped variant) |
| Chassis | Mobile base | Ctrl / State (each with Stamped variant) |
| Grip | Gripper/end-effector | Ctrl / State (each with Stamped variant) |
| Lift | Vertical lift | Ctrl / State (each with Stamped variant) |
| Manip | Composite arm+grip | Ctrl / State (each with Stamped variant) |
| Teleop | Teleoperation handle | HandleCtrl / HandleState (each with Stamped variant) |
| Joystick | Teleoperation joystick | JoystickState / JoystickStateStamped |
| Keyboard | Teleoperation keyboard | KeyboardState / KeyboardStateStamped |
| Base | Geometry & time | Vector3, Quaternion, Pose, Twist, Time, Header, Odometry, JntState, JntFull |
What problem it solves
- Zero-copy deserialization: FlatBuffers enables direct memory access on the receiving end without decode overhead.
- Type-safe dataclass API: Work with standard Python dataclasses and numpy arrays — no manual FlatBuffers table construction.
- Envelope dispatch:
HexMsgTrans.dc2fbs()and.fbs2dc()wrap all messages in a self-describingHexFbsMsgEnvelopeso the receiver auto-detects the message type. - NumPy integration: Joint fields are
np.float64/np.uint8arrays, natural for scientific and robotics workflows.
Target users
- Robotics engineers building control systems with structured inter-process communication.
- Developers producing or consuming FlatBuffers-encoded data in the HEXFELLOW ecosystem.
- Anyone needing a standardised, typed message format with zero-copy deserialization.
Project structure
hex_util_msg/
├── hex_util_msg/ # Python package
│ ├── __init__.py
│ ├── dataclass/ # Python dataclass definitions
│ │ ├── __init__.py
│ │ ├── dataclass_base.py # Base geometry/time/joint types
│ │ ├── dataclass_robo.py # Robot arm/chassis/grip/lift/manip types
│ │ └── dataclass_teleop.py # Teleoperation handle types
│ ├── fbs/ # FlatBuffers-generated Python code
│ │ ├── msg_base/
│ │ ├── msg_envelope/
│ │ ├── msg_robo/
│ │ └── msg_teleop/
│ └── trans/ # Dataclass <-> FlatBuffers converters
│ ├── __init__.py
│ ├── hex_msg_trans.py # HexMsgTrans class + dispatch tables
│ ├── trans_base.py
│ ├── trans_robo.py
│ └── trans_teleop.py
├── msgs/ # FlatBuffers schema sources (.fbs)
│ ├── base.fbs
│ ├── msg_envelope.fbs
│ ├── robo_arm_*.fbs # 4 files
│ ├── robo_chs_*.fbs # 4 files
│ ├── robo_grip_*.fbs # 4 files
│ ├── robo_lift_*.fbs # 4 files
│ ├── robo_manip_*.fbs # 4 files
│ └── teleop_handle_*.fbs # 4 files
│ ├── teleop_joystick_state.fbs
│ ├── teleop_joystick_state_stamped.fbs
│ ├── teleop_keyboard_state.fbs
│ └── teleop_keyboard_state_stamped.fbs
├── docs/
│ └── api.md # Full API reference
├── tests/ # pytest test suite
├── generate.sh # Regenerate Python code from .fbs schemas
├── venv.sh # Set up dev virtual environment
├── pyproject.toml
└── LICENSE
📦 Installation
Requirements
- Python ≥ 3.8
- OS: Linux
- Dependencies:
flatbuffers ≥ 25.0.0numpy ≥ 1.17.4
Install from Source
We use uv to manage the Python environment. Please install it first.
- Clone and install in editable mode:
git clone https://github.com/hexfellow/hex_util_msg.git
cd hex_util_msg
./venv.sh
- Activate before using:
source .venv/bin/activate
⚡ Quick Start
Import and construct dataclasses
import numpy as np
from hex_util_msg.dataclass import (
HexDcBaseVector3, HexDcBaseQuaternion, HexDcBasePose, HexDcBaseTwist,
HexDcBaseTime, HexDcBaseHeader,
HexDcBaseJntState, HexDcBaseJntFull,
HexDcRoboArmCtrl, HexDcRoboArmCtrlMode, HexDcRoboArmCtrlStamped,
HexDcRoboArmState, HexDcRoboArmStateStamped,
HexDcRoboManipCtrl, HexDcRoboManipState,
HexDcTeleopHandleState,
)
Serialize and deserialize with HexMsgTrans
from hex_util_msg.trans import HexMsgTrans
# --- Create a stamped arm control message ---
arm_ctrl = HexDcRoboArmCtrlStamped(
header=HexDcBaseHeader(
seq=1,
stamp=HexDcBaseTime(secs=123, nsecs=456_000_000),
frame_id="arm_base",
),
arm_ctrl=HexDcRoboArmCtrl(
ctrl_mode=HexDcRoboArmCtrlMode.MIT,
grav=HexDcBaseVector3(x=0.0, y=0.0, z=9.81),
jnt=HexDcBaseJntFull(
pos=np.zeros(7, dtype=np.float64),
vel=np.zeros(7, dtype=np.float64),
eff=np.zeros(7, dtype=np.float64),
kp=np.full(7, 100.0, dtype=np.float64),
kd=np.full(7, 10.0, dtype=np.float64),
lim_vel=np.zeros(7, dtype=np.float64),
lim_acc=np.zeros(7, dtype=np.float64),
),
pose=HexDcBasePose(
position=HexDcBaseVector3(x=0.5, y=0.0, z=1.0),
orientation=HexDcBaseQuaternion(x=0.0, y=0.0, z=0.0, w=1.0),
),
),
)
# Serialize to bytes
buf = HexMsgTrans.dc2fbs(arm_ctrl)
# Deserialize back — type is auto-detected from the envelope
restored = HexMsgTrans.fbs2dc(buf)
# restored is a HexDcRoboArmCtrlStamped dataclass
print(restored.header.seq) # 1
print(restored.arm_ctrl.ctrl_mode) # HexDcRoboArmCtrlMode.MIT
Arm state
arm_state = HexDcRoboArmStateStamped(
header=HexDcBaseHeader(seq=0, stamp=HexDcBaseTime(secs=0), frame_id=""),
arm_state=HexDcRoboArmState(
jnt=HexDcBaseJntState(
position=np.array([0.0, 0.25, 0.5], dtype=np.float64),
velocity=np.array([0.0, 0.0, 0.0], dtype=np.float64),
effort=np.zeros(3, dtype=np.float64),
),
pose=HexDcBasePose(
position=HexDcBaseVector3(x=1.0, y=2.0, z=3.0),
orientation=HexDcBaseQuaternion(x=0.0, y=0.0, z=0.707, w=0.707),
),
),
)
buf = HexMsgTrans.dc2fbs(arm_state)
restored = HexMsgTrans.fbs2dc(buf)
Teleop handle state
handle = HexDcTeleopHandleState(
trigger=0.5,
axis_x=0.3,
axis_y=-0.2,
btn_w=True,
btn_x=False,
btn_y=False,
btn_z=False,
)
buf = HexMsgTrans.dc2fbs(handle)
restored = HexMsgTrans.fbs2dc(buf)
# restored.btn_w == True, restored.trigger == 0.5
Manipulator (composite arm + grip)
manip_state = HexDcRoboManipState(
arm_state=HexDcRoboArmState(
jnt=HexDcBaseJntState(
position=np.zeros(7, dtype=np.float64),
),
),
grip_state=HexDcRoboGripState(
jnt=HexDcBaseJntState(
position=np.zeros(1, dtype=np.float64),
),
),
)
buf = HexMsgTrans.dc2fbs(manip_state)
restored = HexMsgTrans.fbs2dc(buf)
📑 Documentation
- API Reference — Detailed documentation of all dataclasses, enums, and converter functions.
🔧 Development
Environment setup
./venv.sh
source .venv/bin/activate
Regenerating code from schemas
If you modify .fbs files under msgs/, regenerate the Python bindings:
# Requires flatc (FlatBuffers compiler) on PATH
./generate.sh
This removes existing generated directories and re-runs flatc --python for all namespaces.
Testing
pytest tests/ -v
📄 License
Apache License 2.0. See LICENSE.
👥 Authors & Maintainers
| Role | Name | |
|---|---|---|
| Author | Dong Zhaorui | dzr159@gmail.com |
| Maintainer | jecjune (Chen Zejun) | zejun.chen@hexfellow.com |
| Maintainer | Dong Zhaorui | dzr159@gmail.com |
🌟 Star History
👥 Contributors
Metadata
Release files for hex-util-msg 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hex_util_msg-0.1.0.tar.gz | 38.5 kB | Without provenance | Details for hex_util_msg-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hex_util_msg-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hex_util_msg-0.1.0-py3-none-any.whl |
Total release size: 95.6 kB
Release files / hex_util_msg-0.1.0.tar.gz
| Download URL | hex_util_msg-0.1.0.tar.gz |
|---|---|
| Size | 38.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
499bec792f1ab1e1a7844a1a6c9600caa70831a0c9326b828b9ebc5291a4128e
|
|
BLAKE2b-256 checksum How to use checksums |
d8c22406127a5590b7ada57ac39aff5f735dd00f8e8d40f4ff13450736a7b291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.18
|
Release files / hex_util_msg-0.1.0-py3-none-any.whl
| Download URL | hex_util_msg-0.1.0-py3-none-any.whl |
|---|---|
| Size | 57.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2128f69ddb7832c4766cac6502c80a6a9d5d828db34b2ee94731f5785d6cace2
|
|
BLAKE2b-256 checksum How to use checksums |
7404149e1927a86a22bd5970ce42f46ff6ec3cc1f1c5dc0ba117789826d56823
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.18
|
Security for hex-util-msg 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.