https://github.com/huggingface/gym-aloha

A gym environment for ALOHA

https://github.com/huggingface/gym-aloha

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.7%) to scientific vocabulary
Last synced: 4 months ago · JSON representation

Repository

A gym environment for ALOHA

Basic Info
  • Host: GitHub
  • Owner: huggingface
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 432 KB
Statistics
  • Stars: 158
  • Watchers: 8
  • Forks: 46
  • Open Issues: 9
  • Releases: 0
Created almost 2 years ago · Last pushed 5 months ago
Metadata Files
Readme License

README.md

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: bash conda create -y -n aloha python=3.10 && conda activate aloha

Install gym-aloha: bash pip install gym-aloha

Quickstart

```python

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: - TransferCubeTask: The right arm needs to first pick up the red cube lying on the table, then place it inside the gripper of the other arm. - InsertionTask: The left and right arms need to pick up the socket and peg respectively, and then insert in mid-air so the peg touches the “pins” inside the socket.

Action Space

The action space consists of continuous values for each arm and gripper, resulting in a 14-dimensional vector: - Six values for each arm's joint positions (absolute values). - One value for each gripper's position, normalized between 0 (closed) and 1 (open).

Observation Space

Observations are provided as a dictionary with the following keys:

  • qpos and qvel: Position and velocity data for the arms and grippers.
  • images: Camera feeds from different angles.
  • env_state: Additional environment state information, such as positions of the peg and sockets.

Rewards

  • TransferCubeTask:
    • 1 point for holding the box with the right gripper.
    • 2 points if the box is lifted with the right gripper.
    • 3 points for transferring the box to the left gripper.
    • 4 points for a successful transfer without touching the table.
  • InsertionTask:
    • 1 point for touching both the peg and a socket with the grippers.
    • 2 points for grasping both without dropping them.
    • 3 points if the peg is aligned with and touching the socket.
    • 4 points for successful insertion of the peg into the socket.

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

```python

import gymnasium as gym import gymaloha env = gym.make("gymaloha/AlohaInsertion-v0", obstype="pixels", rendermode="rgbarray") env <TimeLimit<OrderEnforcing<PassiveEnvChecker<AlohaEnv<gymaloha/AlohaInsertion-v0>>>>> ```

  • obs_type: (str) The observation type. Can be either pixels or pixels_agent_pos. Default is pixels.

  • render_mode: (str) The rendering mode. Only rgb_array is supported for now.

  • observation_width: (int) The width of the observed image. Default is 640.

  • observation_height: (int) The height of the observed image. Default is 480.

  • visualization_width: (int) The width of the visualized image. Default is 640.

  • visualization_height: (int) The height of the visualized image. Default is 480.

🔧 GPU Rendering (EGL)

Rendering on the GPU can be significantly faster than CPU. However, MuJoCo may silently fall back to CPU rendering if EGL is not properly configured. To force GPU rendering and avoid fallback issues, you can use the following snippet:

```python import distutils.util import os import subprocess

if subprocess.run('nvidia-smi').returncode: raise RuntimeError( 'Cannot communicate with GPU. ' 'Make sure you are using a GPU runtime. ' 'Go to the Runtime menu and select Choose runtime type.' )

Add an ICD config so that glvnd can pick up the Nvidia EGL driver.

This is usually installed as part of an Nvidia driver package, but the

kernel doesn't install its driver via APT, and as a result the ICD is missing.

(https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md)

NVIDIAICDCONFIGPATH = '/usr/share/glvnd/eglvendor.d/10nvidia.json' if not os.path.exists(NVIDIAICDCONFIGPATH): with open(NVIDIAICDCONFIGPATH, 'w') as f: f.write("""{ "fileformatversion" : "1.0.0", "ICD" : { "librarypath" : "libEGL_nvidia.so.0" } } """)

Check if installation was successful.

try: print('Checking that the installation succeeded:') import mujoco from mujoco import rollout mujoco.MjModel.fromxmlstring('') except Exception as e: raise e from RuntimeError( 'Something went wrong during installation. Check the shell output above ' 'for more information.\n' 'If using a hosted Colab runtime, make sure you enable GPU acceleration ' 'by going to the Runtime menu and selecting "Choose runtime type".')

print('Installation successful.')

Tell XLA to use Triton GEMM, this improves steps/sec by ~30% on some GPUs

xlaflags = os.environ.get('XLAFLAGS', '') xlaflags += ' --xlagputritongemmany=True' os.environ['XLAFLAGS'] = xla_flags ```

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: bash poetry install --all-extras

Follow our style

```bash

install pre-commit hooks

pre-commit install

apply style and linter checks on staged files

pre-commit ```

Acknowledgment

gym-aloha is adapted from ALOHA

Owner

  • Name: Hugging Face
  • Login: huggingface
  • Kind: organization
  • Location: NYC + Paris

The AI community building the future.

GitHub Events

Total
  • Issues event: 3
  • Watch event: 90
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 3
  • Pull request review event: 3
  • Pull request event: 9
  • Fork event: 31
  • Create event: 1
Last Year
  • Issues event: 3
  • Watch event: 90
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 3
  • Pull request review event: 3
  • Pull request event: 9
  • Fork event: 30
  • Create event: 1

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 5
  • Total pull requests: 8
  • Average time to close issues: N/A
  • Average time to close pull requests: about 10 hours
  • Total issue authors: 5
  • Total pull request authors: 6
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: about 13 hours
  • Issue authors: 3
  • Pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • alexander-soare (1)
  • ssvision (1)
  • FanZhang91 (1)
  • raul-machine-learning (1)
  • LiZhYun (1)
Pull Request Authors
  • jadechoghari (2)
  • aliberts (2)
  • xuaner233 (1)
  • danaaubakirova (1)
  • aod321 (1)
  • WangYixuan12 (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/test.yml actions
  • actions/cache/restore v3 composite
  • actions/cache/save v3 composite
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • snok/install-poetry v1 composite
poetry.lock pypi
  • absl-py 2.1.0
  • certifi 2024.2.2
  • cfgv 3.4.0
  • charset-normalizer 3.3.2
  • cloudpickle 3.0.0
  • colorama 0.4.6
  • coverage 7.4.4
  • debugpy 1.8.1
  • distlib 0.3.8
  • dm-control 1.0.14
  • dm-env 1.6
  • dm-tree 0.1.8
  • exceptiongroup 1.2.0
  • farama-notifications 0.0.4
  • filelock 3.13.3
  • glfw 2.7.0
  • gymnasium 0.29.1
  • identify 2.5.35
  • idna 3.6
  • iniconfig 2.0.0
  • labmaze 1.0.6
  • lxml 5.2.1
  • mujoco 2.3.7
  • nodeenv 1.8.0
  • numpy 1.26.4
  • packaging 24.0
  • platformdirs 4.2.0
  • pluggy 1.4.0
  • pre-commit 3.7.0
  • protobuf 5.26.1
  • pyopengl 3.1.7
  • pyparsing 3.1.2
  • pytest 8.1.1
  • pytest-cov 5.0.0
  • pyyaml 6.0.1
  • requests 2.31.0
  • scipy 1.13.0
  • setuptools 69.2.0
  • tomli 2.0.1
  • tqdm 4.66.2
  • typing-extensions 4.11.0
  • urllib3 2.2.1
  • virtualenv 20.25.1
pyproject.toml pypi
  • debugpy ^1.8.1 develop
  • pre-commit ^3.6.2 develop
  • dm-control 1.0.14
  • gymnasium ^0.29.1
  • mujoco ^2.3.7
  • python ^3.10
  • pytest ^8.1.0 test
  • pytest-cov ^5.0.0 test
.github/workflows/quality.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite