haixuantao
commited on
Commit
•
3eab118
1
Parent(s):
8852f54
Changing policy destination to keyword
Browse files- operators/policy.py +8 -4
operators/policy.py
CHANGED
@@ -4,8 +4,7 @@ from dora import DoraStatus
|
|
4 |
from utils import ask_vlm, speak
|
5 |
from time import sleep
|
6 |
|
7 |
-
|
8 |
-
KITCHEN = np.array([[0.0, -0.2], [-1.0, -0.3], [-2.0, -0.5]]).ravel()
|
9 |
|
10 |
|
11 |
## Policy Operator
|
@@ -13,18 +12,23 @@ class Operator:
|
|
13 |
def __init__(self):
|
14 |
pass
|
15 |
|
|
|
|
|
|
|
|
|
16 |
def speak(self, text: str):
|
17 |
speak(text)
|
18 |
|
19 |
-
def
|
20 |
text = ask_vlm(image, text)
|
21 |
return "Yes, " in text
|
22 |
|
23 |
def on_event(self, event: dict, send_output) -> DoraStatus:
|
24 |
if event["type"] == "INPUT":
|
25 |
id = event["id"]
|
|
|
26 |
if id == "init":
|
27 |
-
send_output("go_to", pa.array([]))
|
28 |
elif id == "reached_living_room":
|
29 |
image = event["value"].to_numpy().reshape((540, 960, 3))
|
30 |
pass
|
|
|
4 |
from utils import ask_vlm, speak
|
5 |
from time import sleep
|
6 |
|
7 |
+
LOCATION = ["LIVING_ROOM", "KITCHEN"]
|
|
|
8 |
|
9 |
|
10 |
## Policy Operator
|
|
|
12 |
def __init__(self):
|
13 |
pass
|
14 |
|
15 |
+
def read(self, image, text: str) -> str:
|
16 |
+
text = ask_vlm(image, text)
|
17 |
+
return text
|
18 |
+
|
19 |
def speak(self, text: str):
|
20 |
speak(text)
|
21 |
|
22 |
+
def check(self, image, text: str) -> bool:
|
23 |
text = ask_vlm(image, text)
|
24 |
return "Yes, " in text
|
25 |
|
26 |
def on_event(self, event: dict, send_output) -> DoraStatus:
|
27 |
if event["type"] == "INPUT":
|
28 |
id = event["id"]
|
29 |
+
# On initialization
|
30 |
if id == "init":
|
31 |
+
send_output("go_to", pa.array([""]))
|
32 |
elif id == "reached_living_room":
|
33 |
image = event["value"].to_numpy().reshape((540, 960, 3))
|
34 |
pass
|