huggingface / gym-aloha

A gym environment for ALOHA
Apache License 2.0
59 stars 19 forks source link

gym-aloha

A gym environment for ALOHA

ACT policy on ALOHA env

Installation

Create a virtual environment with Python 3.10 and activate it, e.g. with miniconda:

conda create -y -n aloha python=3.10 && conda activate aloha

Install gym-aloha:

pip install gym-aloha

Quickstart

# example.py
import imageio
import gymnasium as gym
import numpy as np
import gym_aloha

env = gym.make("gym_aloha/AlohaInsertion-v0")
observation, info = env.reset()
frames = []

for _ in range(1000):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)
    image = env.render()
    frames.append(image)

    if terminated or truncated:
        observation, info = env.reset()

env.close()
imageio.mimsave("example.mp4", np.stack(frames), fps=25)

Description

Aloha environment.

Two tasks are available:

Action Space

The action space consists of continuous values for each arm and gripper, resulting in a 14-dimensional vector:

Observation Space

Observations are provided as a dictionary with the following keys:

Rewards

Success Criteria

Achieving the maximum reward of 4 points.

Starting State

The arms and the items (block, peg, socket) start at a random position and angle.

Arguments

>>> import gymnasium as gym
>>> import gym_aloha
>>> env = gym.make("gym_aloha/AlohaInsertion-v0", obs_type="pixels", render_mode="rgb_array")
>>> env
<TimeLimit<OrderEnforcing<PassiveEnvChecker<AlohaEnv<gym_aloha/AlohaInsertion-v0>>>>>

Contribute

Instead of using pip directly, we use poetry for development purposes to easily track our dependencies. If you don't have it already, follow the instructions to install it.

Install the project with dev dependencies:

poetry install --all-extras

Follow our style

# install pre-commit hooks
pre-commit install

# apply style and linter checks on staged files
pre-commit

Acknowledgment

gym-aloha is adapted from ALOHA