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 DrawTriangle

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

Overview

Concrete implementation of the triangle drawing task environment in ManiSkill.

Description

The DrawTriangleEnv instantiates a table with a white canvas and a robot with a stick that must trace a triangle outline. The robot draws red lines by placing colored dots on the canvas. Key parameters include MAX_DOTS=300, BRUSH_RADIUS=0.01, and a success THRESHOLD of 0.025.

Registered as DrawTriangle-v1 with max_episode_steps=300. The supported robot is panda_stick (PandaStick). The reward mode is "sparse" and success is measured by how well drawn points cover the goal triangle edges within the distance threshold.

Randomizations include the triangle position on the xy-plane and its z-rotation in range [0, 2*pi]. The triangle is constructed from three vertices connected by line segments.

Usage

Use this environment for learning geometric drawing behaviors. It provides a simpler target shape compared to DrawSVG, making it a good starting point for drawing task research.

Code Reference

Source Location

Signature

@register_env("DrawTriangle-v1", max_episode_steps=300)
class DrawTriangleEnv(BaseEnv):
    SUPPORTED_REWARD_MODES = ["sparse"]
    SUPPORTED_ROBOTS: ["panda_stick"]
    agent: PandaStick
    MAX_DOTS = 300
    BRUSH_RADIUS = 0.01
    THRESHOLD = 0.025

Import

import gymnasium as gym
import mani_skill.envs
env = gym.make("DrawTriangle-v1")

I/O Contract

Inputs

Name Type Required Description
obs_mode str No Observation mode
reward_mode str No Reward mode: "sparse"
control_mode str No Control mode for panda_stick robot

Outputs

Name Type Description
obs dict/array Observation including TCP pose and triangle goal positions
reward float Sparse reward based on coverage of triangle edges
terminated bool Whether episode ended by success/failure
truncated bool Whether episode hit max steps (300)
info dict Contains success flag and coverage metrics

Usage Examples

Basic Usage

import gymnasium as gym
import mani_skill.envs

env = gym.make("DrawTriangle-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()

Related Pages

Page Connections

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