Implementation:Haosulab ManiSkill PegInsertionSide
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Tabletop_Manipulation |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete implementation of the side peg insertion task environment in ManiSkill.
Description
The PegInsertionSideEnv requires a robot to pick up a peg and insert it sideways into a box with a hole. The box is constructed with four walls forming a square hole, and the peg must be aligned and inserted through the hole along the x-axis.
Registered as PegInsertionSide-v1 with max_episode_steps=100. The supported robot is panda_wristcam (PandaWristCam). Reward modes include "normalized_dense", "dense", "sparse", and "none".
Randomizations include the peg's xy position and z-rotation on the table, and the box's xy position and z-rotation. The peg has configurable half-length (default 0.12) and half-width. Success is determined by the peg being inserted deep enough into the hole.
Usage
Use this environment for precision manipulation research involving alignment and insertion tasks. It tests fine motor control and spatial reasoning abilities.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/envs/tasks/tabletop/peg_insertion_side.py
Signature
@register_env("PegInsertionSide-v1", max_episode_steps=100)
class PegInsertionSideEnv(BaseEnv):
SUPPORTED_ROBOTS = ["panda_wristcam"]
agent: Union[PandaWristCam]
peg_half_width = 0.025
peg_half_length = 0.12
Import
import gymnasium as gym
import mani_skill.envs
env = gym.make("PegInsertionSide-v1")
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| obs_mode | str | No | Observation mode |
| reward_mode | str | No | Reward mode: "normalized_dense", "dense", "sparse", "none" |
| control_mode | str | No | Control mode for the Panda robot |
Outputs
| Name | Type | Description |
|---|---|---|
| obs | dict/array | Observation including peg pose, box pose, TCP pose |
| reward | float | Reward based on reaching, grasping, alignment, and insertion |
| terminated | bool | Whether episode ended by success/failure |
| truncated | bool | Whether episode hit max steps (100) |
| info | dict | Contains success flag |
Usage Examples
Basic Usage
import gymnasium as gym
import mani_skill.envs
env = gym.make("PegInsertionSide-v1", obs_mode="state", render_mode="rgb_array")
obs, info = env.reset()
for _ in range(100):
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
obs, info = env.reset()
env.close()