add controller
This commit is contained in:
17
controller.py
Normal file
17
controller.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
from simulator import EmulatorSimulator
|
||||
|
||||
class Controller:
|
||||
def __init__(self, vm_name: str, username: str, password: str, host: str) -> None:
|
||||
self.simulator = EmulatorSimulator(vm_name=vm_name, username=username,
|
||||
password=password, host=host)
|
||||
|
||||
def get_state(self) -> np.ndarray:
|
||||
image_path = self.simulator.get_screenshot()
|
||||
with Image.open(image_path) as img:
|
||||
return np.array(img)
|
||||
|
||||
def step(self) -> None:
|
||||
self.simulator.keyboard_type("hello word")
|
||||
Reference in New Issue
Block a user