Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Haosulab ManiSkill LiftPegUpright

From Leeroopedia
Knowledge Sources
Domains Robotics, Simulation, Tabletop_Manipulation
Last Updated 2026-02-15 08:00 GMT

Overview

Concrete implementation of the peg lifting task environment in ManiSkill.

Description

The LiftPegUprightEnv requires a robot to move a peg lying flat on the table to an upright position. The peg is a two-colored cylinder (red and blue halves) with half-width 0.025m and half-length 0.12m.

Registered as LiftPegUpright-v1 with max_episode_steps=50. Supported robots are panda and fetch. Reward modes include "normalized_dense", "dense", "sparse", and "none".

Randomizations include the peg's xy position in the region [-0.1, 0.1]. Success requires the peg's y euler angle to be within 0.08 radians of pi/2 and the z position to be within 0.005m of the peg half-length (0.12m). The dense reward combines rotation alignment, z-position reward, and a reaching/grasping component.

Usage

Use this environment for testing orientation manipulation skills. The task requires grasping and reorienting an object from horizontal to vertical.

Code Reference

Source Location

Signature

@register_env("LiftPegUpright-v1", max_episode_steps=50)
class LiftPegUprightEnv(BaseEnv):
    SUPPORTED_ROBOTS = ["panda", "fetch"]
    agent: Union[Panda, Fetch]
    peg_half_width = 0.025
    peg_half_length = 0.12

Import

import gymnasium as gym
import mani_skill.envs
env = gym.make("LiftPegUpright-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 robot

Outputs

Name Type Description
obs dict/array Observation including TCP pose, peg pose
reward float Dense reward from rotation alignment + z-position + reaching
terminated bool Whether episode ended by success
truncated bool Whether episode hit max steps (50)
info dict Contains success flag

Usage Examples

Basic Usage

import gymnasium as gym
import mani_skill.envs

env = gym.make("LiftPegUpright-v1", obs_mode="state", render_mode="rgb_array")
obs, info = env.reset()
for _ in range(50):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()
env.close()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment