Skip to main content

RoCoDA Alpha 0.1

Counterfactual Data Augmentation for Data-Efficient Robot Learning from Demonstrations

Project Description for RoCoDA here

To install via uv (recommend)

uv venv
source .venv/bin/activate
uv pip install rocoda

Examples

Instantiate DataPrep Object:

#NOTE: all data preparation is done in-place on disk
from rocoda.data.prep import DataPrep
from task import StackThree_D0 #registers the task

data = DataPrep(
    hdf5_path="stack_three.hdf5", 
    env_type="robosuite")

Render a Frame:

from PIL import Image

img = data.render_demo_state(0, 10, camera_name="agentview")
img = Image.fromarray(img)
img = img.transpose(Image.FLIP_TOP_BOTTOM)
display(img)

Define Subtask Boundaries via Heuristic:

from rocoda.environments.robosuite import RobosuiteEnvironment
from typing import Mapping

# Define subtask heuristic for StackThree
def heuristic(rocoda_env:RobosuiteEnvironment)->Mapping[str,bool]:

    env = rocoda_env.get_underlying_env() #gets the robosuite env

    signals = {
        "grasp_1": False,
        "stack_1": False,
        "grasp_2": False,
        "stack_2": False
    }

    signals["grasp_1"] = env._check_grasp(gripper=env.robots[0].gripper, object_geoms=env.cubeA)

    signals["stack_1"] = env._check_cubeA_stacked()

    signals["grasp_2"] = env._check_grasp(gripper=env.robots[0].gripper, object_geoms=env.cubeC)

    return signals
            
# Apply subtask termination heuristic
data.apply_subtask_term_heuristic( ["grasp_1","stack_1","grasp_2","stack_2"], heuristic )

Define the Causal Groups:

# Expects [{subtask_name: {object_name: [object_name, ...]}}] * num_robots

causality = {
    "grasp_1": [("robot0", "cubeA")],
    "stack_1": [("robot0", "cubeA", "cubeB")],
    "grasp_2": [("robot0", "cubeC"),("cubeA","cubeB")],
    "stack_2": [("robot0", "cubeA", "cubeB", "cubeC")]
}

# Set the causality groups for the dataset
data.set_causal_groups(causality)

Run Causal Augmentation:

from rocoda.augments import causal

causal.augment(
    filepath="stack_three.hdf5",
    num_new_episodes=10,
    across_demos=True)

Release files for rocoda 0.1.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 rocoda 0.1.1
File Size Uploaded
rocoda-0.1.1.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rocoda 0.1.1
File Interpreter ABI Platform
rocoda-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.9 kB

Release files / rocoda-0.1.1.tar.gz

Download URL rocoda-0.1.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ae9f5b2084767c2358029fec0401b60adb4540657f85a63ae0c3be77871165d
BLAKE2b-256 checksum
How to use checksums
153a126ec7f9ff61c96a1c146f4360ca944bcb28db5b2e8fac6f36a8158f9f87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.5

Release files / rocoda-0.1.1-py3-none-any.whl

Download URL rocoda-0.1.1-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f9618d99cf2b0a55250e48bae17ad87120b6e611fa213b33b05af3e13457fd9
BLAKE2b-256 checksum
How to use checksums
f9f27f01f650b10742ac83efedd2a9544d4a226d3f1fe5b5d593aba0f525d301
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.5

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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