haixuantao's picture
Fix demo testing
23f48d8
raw
history blame
857 Bytes
import numpy as np
import pyarrow as pa
from dora import DoraStatus
from utils import ask_vlm, speak
COUCH = np.array([[0.5, 0], [0.5, 0.5]]).ravel()
KITCHEN = np.array([[0.5, 0.0], [1.0, -1.0]]).ravel()
HOME = np.array([[0.5, 0.0], [0.0, 0.0]]).ravel()
## Policy Operator
class Operator:
def speak(text: str):
speak(text)
def ask_model(self, image, text: str) -> bool:
text = ask_vlm(image, text)
return "Yes, " in text
def on_event(self, dora_event: dict, send_output) -> DoraStatus:
if dora_event["type"] == "INPUT":
id = dora_event["id"]
if id == "init":
send_output("go_to", pa.array([]))
elif id == "goal_reached":
image = dora_event["value"].to_numpy().reshape((540, 960, 3))
pass
return DoraStatus.CONTINUE