-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_api.py
More file actions
63 lines (50 loc) · 1.47 KB
/
Copy pathbenchmark_api.py
File metadata and controls
63 lines (50 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from __future__ import annotations
from dataclasses import dataclass
from enum import IntEnum
from typing import Any, Optional, Protocol, runtime_checkable
import numpy as np
class Action(IntEnum):
"""Benchmark action ids returned by agents."""
FINISH = 0
STOP = 0
MOVE_FORWARD = 1
TURN_LEFT = 2
TURN_RIGHT = 3
LOOK_UP = 4
LOOK_DOWN = 5
TARGET_FOUND = 6
SUBTASK_STOP = 6
LEGACY_FINISH = 9
@dataclass(frozen=True)
class Observation:
"""Observation passed to custom benchmark agents.
Custom agents loaded with `run_eval.py --agent module:ClassName` receive one
instance of this dataclass at every step and should return an int action id.
"""
rgb: np.ndarray
depth: Optional[np.ndarray]
goal_text: str
goal_embedding: Optional[np.ndarray]
goal_image: Optional[np.ndarray]
goal_type: str
subtask_type: str
target_mode: str
target_count: Optional[int]
episode_id: str
scene_id: str
step_count: int
gps: np.ndarray
compass: float
max_steps: int
task_prompt: Optional[str] = None
previous_action: Optional[int] = None
extras: Optional[dict[str, Any]] = None
@runtime_checkable
class AgentProtocol(Protocol):
"""Minimal interface for a custom navigation agent."""
def act(self, observation: Observation) -> int:
"""Return one benchmark action id."""
...
def reset(self) -> None:
"""Optional episode-level state reset."""
...