Skip to main content

🤖 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 studio to 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 pyzmq for 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.1

With uv, add it as a project dependency or install it into an existing environment:

uv add robot-msg-irsl==0.5.1
# Alternatively:
uv pip install robot-msg-irsl==0.5.1

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.1-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 28404 and the receiver's configured hand_id and 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.1-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

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.

Version 0.5.1 adds managed planning action/status types and deliberately replaces RobotAction's schema/binary layout for coordinated consumers. Mixed-version operation and backward-compatibility adapters are not supported. Deploy the matching package to all action producers/consumers. Protocol 2, existing wire IDs, state/model contracts and unrelated messages remain unchanged.

  • Physical geometry uses shared types rather than unrelated arrays/matrices.
  • Public message.metadata replaces _robot_msg_timestamp and the encoder's timestamp= 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.

Unmanaged RobotAction preserves the independent optional real-time and linear trajectory branches. End-effector trajectories are [arm][waypoint]; configuration trajectories are [waypoint][coordinate]. Managed execution uses exclusive world-frame quintic configuration trajectories, described below. 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.

Managed planning action/status (0.5.1)

RobotAction.trajectory_execution carries a typed TrajectoryExecution with submit | status | cancel | heartbeat, request/client/execution/session/model identity, controller generation and admission epoch. Submit includes ordered unique joint names and a quintic_stop_v1 q trajectory with 2–2000 original knots and positive per-segment durations. Their finite sum must match numeric traj_duration (default 2.0) within relative 1e-9. No real-time/EE branch is allowed on managed submits; other managed operations carry no motion branches.

PlanningStatus is a separate message on PLANNING_STATUS=28505; managed RobotAction uses PLANNING_ACTION=28502. Status advertises ordered names, SI units and limits, readiness, identity/generation/admission, timeout/lease settings, at most 32 execution records and an optional typed correlated response. status probes are read-only: they must not acquire ownership, renew leases or consume admission. A probe's response is separate from execution-owner records. No fields are added to RobotState, StateSnapshot or model descriptors.

See the exact Python/C++ planning contract for constructors, defaults, validation, ownership/probe rules and the receiver's 1 MiB transport admission obligation. The same document ships at robot_msg/_assets/internal/docs/planning_protocol.txt. These codecs validate messages; they neither bind sockets nor execute robot motion.

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.1-py3-none-any.whl
uv run python internal/tests/compatibility/test_studio_distribution.py \
  dist/robot_msg_irsl-0.5.1.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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robot-msg-irsl 0.5.1
File Size Uploaded Provenance Actions
robot_msg_irsl-0.5.1.tar.gz 371.2 kB Without provenance Details for robot_msg_irsl-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for robot-msg-irsl 0.5.1
File Interpreter ABI Platform Actions
robot_msg_irsl-0.5.1-py3-none-any.whl Python 3 none any Details for robot_msg_irsl-0.5.1-py3-none-any.whl

Total release size: 709.2 kB

Release files / robot_msg_irsl-0.5.1.tar.gz

Download URL robot_msg_irsl-0.5.1.tar.gz
Size 371.2 kB
Tags Source
SHA-256 checksum
How to use checksums
45911df4e93c290416430ad37dada6d8be13493f331060ecce2f0a0ec44daaac
BLAKE2b-256 checksum
How to use checksums
a345ec25253641c23aa85365ff4f36834f95db133584e565221fbce85fcfedd2
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.1-py3-none-any.whl

Download URL robot_msg_irsl-0.5.1-py3-none-any.whl
Size 338.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c1f32bc42616245986d2f4be1d0e1dcc8a63e3872265241f27b9029669ab924
BLAKE2b-256 checksum
How to use checksums
d098fba94b31730b22094e5d3ff634b5aafeb3c257fb7c7e9c4b9af1ec3e59c4
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.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page