from metasim.cfg.checkers import DetectedChecker, OrOp, RelativeBboxDetector
from metasim.cfg.tasks.base_task_metacfg import BaseTaskMetaCfg
from metasim.constants import BenchmarkType, TaskType
from metasim.utils import configclass

slider_detector = RelativeBboxDetector(
    base_obj_name="table",
    relative_pos=(-0.181, 0.062, 0.501),
    relative_quat=(1.0, 0.0, 0.0, 0.0),
    checker_lower=(-0.3, -0.075, -0.05),
    checker_upper=(0.3, 0.075, 0.05),
    # debug_vis=True,
)


@configclass
class PlaceInSliderMetaCfg(BaseTaskMetaCfg):
    source_benchmark = BenchmarkType.CALVIN
    task_type = TaskType.TABLETOP_MANIPULATION
    episode_length = 600
    checker = OrOp([
        DetectedChecker(
            obj_name="block_pink",
            detector=slider_detector,
            ignore_if_first_check_success=True,
        ),
        DetectedChecker(
            obj_name="block_blue",
            detector=slider_detector,
            ignore_if_first_check_success=True,
        ),
        DetectedChecker(
            obj_name="block_red",
            detector=slider_detector,
            ignore_if_first_check_success=True,
        ),
    ])
