A gym environment for ALOHA
Project description
gym-aloha
A gym environment for ALOHA
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:
- 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
andqvel
: 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
>>> 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>>>>>
-
obs_type
: (str) The observation type. Can be eitherpixels
orpixels_agent_pos
. Default ispixels
. -
render_mode
: (str) The rendering mode. Onlyrgb_array
is supported for now. -
observation_width
: (int) The width of the observed image. Default is640
. -
observation_height
: (int) The height of the observed image. Default is480
. -
visualization_width
: (int) The width of the visualized image. Default is640
. -
visualization_height
: (int) The height of the visualized image. Default is480
.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gym_aloha-0.1.1.tar.gz
.
File metadata
- Download URL: gym_aloha-0.1.1.tar.gz
- Upload date:
- Size: 443.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 614ae1cf116323e7b5ae2f0e9bd282c4f052aee15e839e5587ddce45995359bc |
|
MD5 | 486d2b7f0c152f8754803f97e5b90f2f |
|
BLAKE2b-256 | 5b540d386001505d0e64cb52c4ec4f4ac29c2259a6dda7032f2854c8b2bac9c9 |
File details
Details for the file gym_aloha-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: gym_aloha-0.1.1-py3-none-any.whl
- Upload date:
- Size: 446.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2698037246dbb106828f0bc229b61007b0a21d5967c72cc373f7bc1083203584 |
|
MD5 | 9454e8c4b5581373eddc0a467803c645 |
|
BLAKE2b-256 | d7ac8df1fe5462c068132688897a3f3d62fbede48c674026baecb1012c585cfc |