A gym environment for ALOHA
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
# 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)
Aloha environment.
Two tasks are available:
The action space consists of continuous values for each arm and gripper, resulting in a 14-dimensional vector:
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.Achieving the maximum reward of 4 points.
The arms and the items (block, peg, socket) start at a random position and angle.
>>> 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 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
.
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
# install pre-commit hooks
pre-commit install
# apply style and linter checks on staged files
pre-commit
gym-aloha is adapted from ALOHA