🤖 Robot Msg
Typed, transport-independent robot messages for Python and C++, with shared models, validation, and JSON/binary codecs generated from JSON schemas. The distribution is robot-msg-irsl; the Python import and CMake target remain robot_msg and robot_msg::robot_msg.
✨ Features
- 🗂️ Shared types — consistent geometry, controller, SMPL-X, and viewer messages across Python and C++.
- Validated codecs — JSON and binary envelopes with explicit protocol identity.
- Message metadata — typed timestamps, clock identities, and diagnostic arrays.
- 📦 Installed schemas — message registry and schema introspection without a source checkout.
- Studio included — run
uv run studioto monitor, plot, and publish messages in a browser. - Independent message core — codecs and C++ resources do not import Studio or ZeroMQ. Normal Python installation includes
pyzmqfor Studio.
📦 Installation
Requires Python 3.11 or later (no upper version bound). C++ consumers require C++14 and CMake 3.10 or later.
Wheel construction uses setuptools. uv is required only for the optional CMake bootstrap and uv-based installation commands.
The wheel includes Python code, C++ sources and headers, CMake configurations, schemas and typing information. It does not contain a platform-specific C++ binary or compile C++ at installation time. The consuming CMake project builds these sources with its own compiler. Generated sources are included, so ordinary consumers do not run the generator.
Install from PyPI
Install the published release into your Python environment:
python -m pip install robot-msg-irsl==0.5.0
With uv, add it as a project dependency or install it into an existing environment:
uv add robot-msg-irsl==0.5.0
# Alternatively:
uv pip install robot-msg-irsl==0.5.0
The distribution name is robot-msg-irsl, but Python code imports robot_msg:
python -c "import robot_msg; from importlib.metadata import version; print(version('robot-msg-irsl'))"
python -m robot_msg --cmake-dir
To install a locally built wheel instead:
python -m pip install /path/to/robot_msg_irsl-0.5.0-py3-none-any.whl
🚀 Usage
Studio
In a uv project with robot-msg-irsl installed, run:
uv run studio
Studio opens the browser at http://127.0.0.1:8765. No separate
robot-msg-studio package, Node.js build, or source checkout is required.
The application is integrated from the robot_msg_studio project.
- Monitor: connect ZeroMQ sources, inspect binary/JSON and batched messages, view message rates, and plot numeric fields.
- Publish: select a message from the installed catalog, edit its schema-based form or JSON payload, and send through a persistent bind/connect publisher.
- HandAction: use port
28404and the receiver's configuredhand_idand joint/actuator ordering. The UI requires acknowledgment for robot commands; this is not a hardware safety interlock or a delivery guarantee.
uv run studio --no-browser --port 8766
uv run studio --source 'state,tcp://127.0.0.1:28400'
uv run python -m robot_msg.studio --help
The package must be installed in the environment selected by uv run, not just
an unrelated active environment. To test a local build, install its wheel into
the uv project:
uv add /absolute/path/to/robot_msg_irsl-0.5.0-py3-none-any.whl
uv run studio
Keep the default loopback HTTP binding: Studio has no authentication and its
publisher can send robot commands. The library's core imports and CMake-only
--no-deps bootstrap do not load Studio or require pyzmq; such minimal
installations cannot launch Studio.
Python and C++ examples
- Python usage
- C++ and CMake usage
- Runnable examples: Python, C++
Use from CMake
cmake -S . -B build \
-Drobot_msg_DIR="$(uv run python -m robot_msg --cmake-dir)"
cmake --build build
find_package(robot_msg CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE robot_msg::robot_msg)
Source-tree add_subdirectory and conventional CMake install/find_package remain
supported. Plain find_package does not download dependencies. The opt-in uv
bootstrap described in the C++ guide installs a pinned package into a build-local
environment; it does not change system Python or the application's existing venv.
⚠️ Protocol 2 is a breaking release
Distribution version, envelope protocol version 2, binary magic R2, and the
message's string/FNV-1a wire ID are separate concepts. Version 0.3.0 introduced
protocol 2 and requires updated consumer adapters; it does not transparently
replace protocol 1 submodules. Version 0.4.0 adds HandAction and its default
port without changing protocol 2 or any existing message's wire ID, schema
contract or encoded bytes. Version 0.5.0 adds the five state/model messages
below, with the same additive compatibility policy. Older readers still reject
unknown new message types.
- Physical geometry uses shared types rather than unrelated arrays/matrices.
- Public
message.metadatareplaces_robot_msg_timestampand the encoder'stimestamp=argument. - Native SMPL-X parameters use
SmplState, not the Meta-specific old class. - Viewer legacy duplicates are removed, batches use paired items, and lifetime semantics are explicit.
Both decoders reject protocol 1 before decoding its changed payload. The earlier
RM to R2 magic change already separated the old bit-packed format from the
byte-aligned format; keeping that historical envelope version at 1 did not cause
old binary frames to be interpreted as the new layout.
🪢 Shared geometry and coordinate meaning
Import common models from robot_msg.types or include <robot_msg/types.hpp>.
| Type | Meaning |
|---|---|
Vec2(x,y), Vec3(x,y,z) |
Ordered Cartesian components |
Quaternion(x,y,z,w) |
XYZW unit rotation; finite, abs(norm²-1) <= 1e-6 |
Pose(position,orientation) |
Child-to-reference transform, p_ref = R p_child + position |
Wrench(force,torque) |
Force in N and moment in N·m; the containing field defines axes and moment origin |
RotationVector(x,y,z) |
Axis-angle model parameter in radians, not necessarily an absolute physical rotation |
ColorRGBA(r,g,b,a) |
Four components in [0,1] |
Quaternions are validated, never silently normalized or sign-flipped. Sender
adapters convert matrices or internal WXYZ values to wire XYZW. Frame identifiers
name coordinate systems; they do not establish calibration, transform discovery,
or a common world origin. Do not relabel an unknown device frame as world.
Distances are meters and times are seconds. q, dq, and viewer qpos remain
model-coordinate arrays: nq may differ from nv, and their components are not all
necessarily revolute joint angles. Matrix-shaped numerical auxiliary arrays use
row-major flattening.
Controller messages
RobotState carries q, dq, tau_ext, a publication sequence, named joint
and end-effector poses in frame_id, and base_wrench_ext. The latter's torque
is about the reference-frame origin, not automatically the sensor or center of
mass. A publication counter is not a clock.
RobotAction preserves the independent optional real-time and trajectory
branches. End-effector trajectories are [arm][waypoint]; configuration
trajectories are [waypoint][coordinate]. Contact link IDs are one-based; contact
points and forces are expressed in the referenced joint frame.
Optional command fields preserve presence. In particular, the existing
controller treats the presence of ctrl_update as an event; changing its bool
interpretation requires an explicit consumer migration. The message library
adds no acknowledgement or delivery guarantee.
Measured hands, whole-frame state and model transfer (0.5.0)
HandState is a standalone message carrying session/model identity and one
HandSample. StateSnapshot carries a whole logical frame: independent compact
arm q/dq samples, hand feedback, and optional full native MuJoCo qpos/mocap/time.
Measured joint and actuator coordinates remain distinct (Shadow 24/20; NERO real
empty joint coordinates with opening in m and effort in N). Component timestamps
preserve actual source clocks; transport membership does not imply simultaneous
physical sampling. enabled is a software gate, not proof of powered hardware.
ModelRequest, ModelDescriptor and ModelChunk transfer immutable MJB or MJCF
plus assets using a bounded relative-path file table and <=64 KiB integer-byte
chunks. MJB requires exact engine compatibility; source-only real producers need
no MuJoCo dependency. New ports are STATE_SNAPSHOT=28405 and ROBOT_MODEL=28430;
legacy ROBOT_STATE=28400 remains unchanged. Consumers enforce a 1 MiB frame cap.
import robot_msg as rm
state = rm.HandState(
session_id="0123456789abcdef0123456789abcdef", model_id="a" * 64,
sample=rm.HandSample(
hand_id="left", has_state=True, availability="available", enabled=False,
sample_time=rm.Timestamp(seconds=12.5, clock_kind="monotonic", clock_id="host"),
joint_position=[], actuator_position=[0.04], actuator_effort=[2.0]))
assert rm.decode(rm.encode(state)) == state
request = rm.ModelRequest(request_id="describe-1", operation="descriptor")
# Stable content identity (after independently hashing immutable served files):
# model_id = rm.model_content_id(descriptor.content)
See the complete state/model contract
for exact fields, presence/status rules, coordinate mapping/default policy and
cross-language canonical identity bytes. The same document ships in the wheel
at robot_msg/_assets/internal/docs/state_model_protocol.md. Schema resources
are available through message_catalog() and get_payload_schema().
Hand commands (0.4.0)
HandAction (switch_controller.hand_action) targets one consumer-configured
hand_id of 1–64 Unicode characters. It is independent of RobotAction and
ControllerCommand and defaults to port HAND_ACTION (28404).
operation |
Required vector | Forbidden vector(s) |
|---|---|---|
stop |
None | Both |
joint_position |
joint_position |
actuator_position |
actuator_position |
actuator_position |
joint_position |
Present vectors contain 1–256 finite float64-compatible numbers. Omission is not
an empty vector; null, extra fields and unknown operations are rejected.
The built-in x-semantic: hand_action validator enforces these cross-field rules
in both languages and codecs; generic JSON Schema tools must also implement that
extension. The receiving adapter defines coordinate ordering, units, supported
operations, dimensions and limits. No joint-to-actuator conversion or hand
hardware dependency is included in this library.
import robot_msg as rm
command = rm.HandAction(hand_id="left", operation="joint_position",
joint_position=[0.1, 0.2])
assert rm.decode(rm.encode(command)) == command
stop = rm.HandAction(hand_id="left", operation="stop")
#include <robot_msg/robot_msg.hpp>
robot_msg::HandAction command;
command.hand_id = "left";
command.operation = "actuator_position";
command.actuator_position = std::vector<double>{0.1, 0.2};
auto bytes = robot_msg::encode(command);
stop requests a consumer stop; it is not a safety-rated emergency stop or a
delivery guarantee. Receivers must provide their own watchdogs and safe behavior
on invalid, stale or missing commands.
SMPL-X parameters
SmplState separates root orientation, 21 body rotation vectors, 15 left-hand
and 15 right-hand rotation vectors, translation, optional 10 betas and gender.
hand_pose_convention distinguishes absolute from mean_offset. A mean-offset
parameter must not be converted into an absolute quaternion without the model's
hand-mean information.
root_orientation_valid and translation_valid distinguish measured estimates
from deliberately unspecified model parameters. In particular, a camera pipeline
that zeroes root/translation does not thereby estimate a world pelvis pose.
Translation remains the SMPL-X model translation parameter. Missing betas are
different from explicitly supplied zeros. The prior 169-value storage layout can
be reconstructed at the adapter boundary without changing model assets or
recording formats. No SMPL-X, Torch, NumPy or model files are dependencies here.
Viewer messages
Geometric messages identify their reference frame. Box dimensions are
half_extents, ellipsoid dimensions are axis radii, and arrow direction is a
full displacement vector from its origin. The previous viewer multiplied vector
length by two; preserving an old visualization therefore requires an explicit
adapter conversion, not an undocumented factor in the new message.
Lifetime has one_frame, persistent, or seconds modes. Only seconds
requires a positive seconds value. Old marker timeout zero maps to one-frame;
mesh colors that previously persisted map to persistent. Lifetimes begin at
receiver receipt on its local monotonic clock, not at the sender's timestamp.
Joint updates have separate queue-age semantics; expiration does not remove the
last applied robot pose.
Batch items keep associated geometry together, with shared appearance where
applicable. Preserve order, ID replacement, visible=false removal and empty
batch removal. Clear clears markers and message-applied colors, not the robot
model or last joint state. In MessageBatch, clear/update order is significant.
🗂️ Metadata and optional diagnostic arrays
Every message has independent public metadata. Payload conversion intentionally excludes it.
import robot_msg as rm
from robot_msg.types import MessageMetadata, NamedArray, Timestamp
message = rm.ControllerCommand(
ctrl_mode=2,
metadata=MessageMetadata(
sample_time=Timestamp(seconds=2.5, clock_kind="simulation", clock_id="sim-run-1"),
send_time=Timestamp(seconds=1730000000.25, clock_kind="unix"),
aux=[NamedArray(name="joint_error", shape=[2], data=[0.02, -0.01], unit="rad")],
),
)
restored = rm.decode(rm.encode(message))
assert restored.metadata == message.metadata
sample_time: source sample time, if known.receive_time: time at which the sender received upstream data; not the recipient's current receive time.send_time: time selected by the sender for transmission.
Each Timestamp declares unix, monotonic, simulation, or device clock
kind. Non-Unix clocks require a clock_id. Identical IDs do not imply a clock
synchronization accuracy guarantee. Encoding/decoding never stamps automatically
or overwrites metadata. Batch children retain their complete envelopes and
independent metadata; the outer envelope is not an implicit override.
NamedArray(name,shape,data,unit?,frame_id?) carries float64 diagnostics without
JSON strings or schema changes for each new name. shape=[] means one scalar;
a shape containing zero requires empty data. Names are unique per message.
Limits are 64 arrays, rank 8, 65,536 total values and bounded labels. Dimension
products, finite values and array lengths are validated. Integers and booleans
that require exact typed meaning belong in the payload, not float64 aux.
The aux limit is not a guarantee that the full payload or batch fits a consumer's 1 MiB frame limit. Check the complete encoded frame size at the transport boundary; batching several individually valid envelopes adds their sizes.
📡 Ports, not sockets or hosts
Python: from robot_msg import ports. C++: <robot_msg/ports.hpp>.
| Constant | TCP port |
|---|---|
ROBOT_STATE |
28400 |
CONTROLLER_COMMAND |
28401 |
ROBOT_ACTION |
28402 |
CONTACT_INFO |
28403 |
HAND_ACTION |
28404 |
VIEWER |
28410 |
META |
28420 |
SMPL_STATE |
28421 |
schemas/ports.json generates both languages. These are project defaults, not
IANA/OS reservations. Consumers choose hosts, bind/connect roles and explicit
overrides. External VR input and Viewer HTTP ports are separate. No port scan,
collision fallback, address discovery or socket dependency is provided.
ZMQ PUB/SUB does not guarantee every message or deadline. CONFLATE keeps the latest socket message, not the latest message per type. Use complete batch snapshots when related data must survive together, or separate traffic policies. Reliable commands require acknowledgements/retries outside this library.
🔍 Installed schema introspection
from robot_msg import message_catalog, get_payload_schema, get_envelope_schema
for info in message_catalog():
print(info.msg_type, info.wire_id, info.message_class, info.schema_id)
payload_schema = get_payload_schema(info.msg_type)
envelope_schema = get_envelope_schema(info.msg_type)
The default resolved schemas contain no $ref, and defaults are JSON-compatible
objects. resolved=False returns the original form. Returned dictionaries are
independent copies. Resources come from the installed package, not a search for
a source checkout. Concrete dataclasses, type hints, to_payload and
from_payload remain available for editors and adapters.
🏗️ Schema development
Canonical message schemas live in schemas/messages/, shared types in
schemas/types/, and the envelope in schemas/envelope.json. The generator uses
only the standard library. Modify schemas, not generated files.
./internal/tools/generate
./internal/tools/check-generated
Supported types are object, array, string, signed int64, float64 and boolean; constraints include ranges, lengths and string enums. Objects forbid additional properties. Optional fields without defaults use None/optional; null values are not accepted. Required fields cannot declare defaults. Recursive object defaults produce independent objects and are compared bit-exactly for binary omission.
Shared $ref is restricted to relative file-root references inside the shared
types directory, with description/default annotations. Remote references,
fragments, path escapes and cycles are rejected. x-field-order explicitly fixes
shared constructor/wire component order; otherwise fields are sorted by name.
x-semantic selects the small set of built-in cross-field checks. Unsupported
keywords are errors, not silently ignored rules.
The compatibility manifest detects unintended changes to field layout, constraints/defaults and shared dependencies under the same protocol identity. Updating a released contract requires an explicit version/release decision; ordinary generation must not silently accept a new baseline.
📦 Wire format
JSON uses {version,msg_type,metadata?,payload}. Duplicate keys, extra fields,
invalid Unicode, nonfinite numbers and unsupported versions/types are rejected.
to_payload/from_payload operate only on the payload. Public validate and both
codecs validate the metadata as well.
The byte-aligned little-endian binary format starts with:
2 bytes magic R2
2 bytes protocol version 2
4 bytes FNV-1a message ID
1 byte metadata presence flags: sample, receive, send, aux (bits 0..3)
N bytes present metadata fields, in that order
M bytes schema-driven payload
Fields use float64 numbers, bounded integer/enum/length widths, object flag bits for presence/boolean values, and no names on the wire. Defaults are omitted only when bit-exactly equal, including signed zero. Unknown flags, truncation, invalid lengths/values and trailing bytes are rejected. One decoder call consumes exactly one complete envelope; framing and transport are the caller's responsibility.
🧪 Testing
The test suite additionally needs pip, setuptools and wheel in its selected Python environment; offline bootstrap tests also need uv. These are development tools, not runtime dependencies.
uv venv .venv --python 3.11
uv pip install --python .venv/bin/python pip 'setuptools>=77.0.3' wheel
cmake -S . -B build -DPython3_EXECUTABLE="$(pwd)/.venv/bin/python"
cmake --build build
ctest --test-dir build --output-on-failure
Tests cover deterministic generation, shared references/defaults, JSON/binary validation, cross-language byte equality, metadata/aux boundaries, consumer semantic contracts, installed schema APIs, wheel/sdist and external CMake consumption. Packaging tests use isolated environments and the local wheel; no robot or model inference is required.
Studio has an additional pytest suite (Node.js exercises browser-side form logic) and installed-application checks. Use a separate testing environment with pytest, pyzmq, and build tools; browser testing additionally needs Playwright and Chrome. These checks use only test-owned loopback endpoints:
uv sync --group dev
uv run pytest internal/tests/studio
uv build
uv run python internal/tests/compatibility/test_studio_distribution.py \
dist/robot_msg_irsl-0.5.0-py3-none-any.whl
uv run python internal/tests/compatibility/test_studio_distribution.py \
dist/robot_msg_irsl-0.5.0.tar.gz
The source-mode suite explicitly skips its installed-wheel-only case. Run the
suite again with the wheel installed non-editably in the test interpreter to
exercise that case. test_studio_browser.py --output PATH uses the interpreter's
installed studio command and saves actual Monitor/Publish screenshots; run it
with the wheel installed, not a checkout-only import.
🛠️ Dependencies
| Component | Requirements |
|---|---|
| Message core | Python 3.11+ standard library |
| Studio (included in normal installation) | pyzmq 27+ and a web browser |
| C++ consumer build | C++14 compiler and CMake 3.10+ |
| Wheel construction | setuptools |
| Verification environment | pip, setuptools, wheel, and uv for offline bootstrap tests |
The message core provides no transport, robot control, calibration, model loading, or delivery scheduling. Studio adds user-configured ZeroMQ monitoring/publishing, not a controller backend or delivery guarantee. Consumer migrations remain separate changes.
📄 License
Licensed under the MIT License.
Metadata
Release files for robot-msg-irsl 0.5.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 |
|---|---|---|---|---|
| robot_msg_irsl-0.5.0.tar.gz | 338.6 kB | Without provenance | Details for robot_msg_irsl-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robot_msg_irsl-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for robot_msg_irsl-0.5.0-py3-none-any.whl |
Total release size: 646.1 kB
Release files / robot_msg_irsl-0.5.0.tar.gz
| Download URL | robot_msg_irsl-0.5.0.tar.gz |
|---|---|
| Size | 338.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2ff38b6efa3aa1e4ce32d0f72b239c33d989a197fcbfade33b302c073e30776
|
|
BLAKE2b-256 checksum How to use checksums |
a8c2266d003863f54da8618cd418e81a5e992b37ae2d343cfe0d7c5eba1cde5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.14
|
Release files / robot_msg_irsl-0.5.0-py3-none-any.whl
| Download URL | robot_msg_irsl-0.5.0-py3-none-any.whl |
|---|---|
| Size | 307.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13eec3016acdc28ea702c695398281331e1a1d48fbd4aa42b57007fc7c445dbd
|
|
BLAKE2b-256 checksum How to use checksums |
8cab51cd4c48f2b986a6fab32d37ae16034b9582c3c88496071b08b9cfc0b103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.14
|
Security for robot-msg-irsl 0.5.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.