Skip to main content

Universal robot description schema and format converters for Cyberwave

Project description

Cyberwave Robot Format

Universal robot description schema and format converters for Cyberwave.

Overview

This package provides:

  • Universal Schema: A canonical representation for robotic assets (CommonSchema)
  • Format Importers: Parse URDF, MJCF into the universal schema
  • Format Exporters: Export universal schema to URDF, MJCF
  • Validation: Schema validation and consistency checks

Structure

cyberwave_robot_format/
├── schema.py           # Core schema definitions (CommonSchema, Link, Joint, etc.)
├── core.py             # Base classes for parsers/exporters
├── urdf/               # URDF parser and exporter
├── mjcf/               # MJCF (MuJoCo) parser and exporter
├── mesh/               # Mesh processing utilities
├── math_utils.py       # Math utilities (Vector3, Quaternion, etc.)
└── utils.py            # General utilities

Usage

Parse URDF

from cyberwave_robot_format import CommonSchema
from cyberwave_robot_format.urdf import URDFParser

# Parse a URDF file
parser = URDFParser()
schema = parser.parse("path/to/robot.urdf")

# Validate the schema
issues = schema.validate()
if issues:
    print("Validation issues:", issues)

# Access robot components
for link in schema.links:
    print(f"Link: {link.name}, mass: {link.mass}")

for joint in schema.joints:
    print(f"Joint: {joint.name}, type: {joint.type}")

Parse MJCF (MuJoCo)

from cyberwave_robot_format.mjcf import MJCFParser

# Parse a MuJoCo XML file
parser = MJCFParser()
schema = parser.parse("path/to/robot.xml")

# Access actuators
for actuator in schema.actuators:
    print(f"Actuator: {actuator.name}, joint: {actuator.joint}")

Export to MJCF

from cyberwave_robot_format.mjcf import MJCFExporter

# Export schema to MuJoCo format
exporter = MJCFExporter()
exporter.export(schema, "output/robot.xml")

Infer URDF mimic joints (gripper coupling)

When a URDF has coupled finger / gripper joints but no <mimic> tags, infer pairs from kinematics and write a new {stem}-mimic-joint.urdf (the original file is never modified).

from pathlib import Path
from cyberwave_robot_format.urdf import (
    infer_mimic_joints,
    infer_and_patch_if_needed,
    write_mimic_patched_urdf,
)

result = infer_mimic_joints("robot.urdf")
for m in result.inferred_mimics:
    print(m.driver_joint, "→", m.slave_joint, "mult", m.multiplier, "conf", m.confidence)

# Write patched URDF when confidence ≥ 0.85 (default)
patched = infer_and_patch_if_needed(Path("robot.urdf"))
if patched.output_path:
    print("Wrote", patched.output_path)

Multiplier defaults

Context Default
URDF <mimic> if multiplier omitted 1
offset omitted 0
Inference for opposing prismatic jaws Often -1 when complementary limits validate

Inference checks opposing axes, complementary joint limits, and samples driver positions so slave = multiplier × driver + offset stays within slave limits. Pass an optional mjcf_path to seed coeffs from MuJoCo equality constraints.

Used by Cyberwave backend seed_controllers --infer-mimic-from-urdf and src/lib/urdf_mimic_utils.py. See cyberwave-backend/docs/mimic-joints.md for the full platform workflow (autogen, teleop, MQTT).

Cloud-Native Scene Export

Export complete scenes with meshes to ZIP files, supporting cloud storage and in-memory conversion:

from cyberwave_robot_format.mjcf import export_mujoco_zip_cloud
from cyberwave_robot_format.urdf import export_urdf_zip_cloud

# Cloud-safe resolver with in-memory DAE→OBJ conversion
def s3_resolver(filename: str) -> tuple[str, bytes] | None:
    """Download from S3 and convert in memory."""
    mesh_bytes = s3.get_object(Bucket='meshes', Key=filename)['Body'].read()

    if filename.endswith('.dae'):
        obj_bytes = convert_dae_to_obj_in_memory(mesh_bytes)
        return (filename.replace('.dae', '.obj'), obj_bytes)

    return (Path(filename).name, mesh_bytes)

# Export with cloud resolver (mesh_resolver is required)
mujoco_zip = export_mujoco_zip_cloud(
    schema,
    s3_resolver,
    strict_missing_meshes=True  # Fail fast on missing meshes
)

urdf_zip = export_urdf_zip_cloud(schema, s3_resolver)

Development

Install in editable mode:

pip install -e .

Run tests:

pytest

Acknowledgments

This project incorporates portions of code from [https://github.com/thanhndv212/robot_format_converter](Robot Format Converter) (Apache 2.0 licensed).

Original repository: https://github.com/thanhndv212/robot_format_converter

We thank the original authors for their initial work.

@software{robot_format_converter,
author = {Nguyen, Thanh},
title = {Robot Format Converter: Universal Robot Description Format Converter},
year = {2025},
url = {https://github.com/thanhndv212/robot_format_converter},
version = {1.0.0}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyberwave_robot_format-0.1.3.tar.gz (79.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cyberwave_robot_format-0.1.3-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file cyberwave_robot_format-0.1.3.tar.gz.

File metadata

  • Download URL: cyberwave_robot_format-0.1.3.tar.gz
  • Upload date:
  • Size: 79.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cyberwave_robot_format-0.1.3.tar.gz
Algorithm Hash digest
SHA256 20310341b6f971aea3e22a3f34c60217e541e134a47db1e4a100ce52dd08f428
MD5 e1951b4d6e60c0728742e4740ee941b6
BLAKE2b-256 601f56219687974e8232ea1ae87fb09d4f9b04f3159201d4852dd02b6652293a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cyberwave_robot_format-0.1.3.tar.gz:

Publisher: release-pypi.yml on cyberwave-os/cyberwave-robot-format

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cyberwave_robot_format-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cyberwave_robot_format-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b803dc78e148d56f7ddf01e6abd76ff102a8a29dc5b0ee2069baaa12bca2b287
MD5 1e7b4abacf4e61f6af57fed7a86491c1
BLAKE2b-256 5ff0cfbfe6a49def034d3a63d383ca4d684a198850ecd1898e46af1af6b6636f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cyberwave_robot_format-0.1.3-py3-none-any.whl:

Publisher: release-pypi.yml on cyberwave-os/cyberwave-robot-format

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page