# simulator_interface.py - Robot app simulator for Hugging Face Spaces (CPU only) import time import logging logging.basicConfig(level=logging.INFO) class VirtualRobot: """ Simulated robot that can wave, speak, and perform simple commands. Useful for prototyping in CPU-only environments like Hugging Face Spaces. """ def __init__(self): self.state = "IDLE" logging.info("[🤖] VirtualRobot initialized: state=IDLE") def wave(self) -> str: """ Simulate an arm wave action. """ logging.info("[🖐️] VirtualRobot: waving") self.state = "WAVING" time.sleep(0.5) self.state = "IDLE" return "🤖 *waves*" def speak(self, text: str) -> str: """ Simulate robot speech. """ logging.info(f"[💬] VirtualRobot: speaking -> '{text}'") self.state = "SPEAKING" time.sleep(0.5) self.state = "IDLE" return f"🗣️ {text}" def perform_action(self, command: str) -> str: """ Parse and execute a command. Supports: - "wave": calls wave() - "say ": calls speak(message) Returns an error message for unknown commands. """ parts = command.strip().split(" ", 1) action = parts[0].lower() arg = parts[1] if len(parts) > 1 else "" if action == "wave": return self.wave() elif action == "say" and arg: return self.speak(arg) else: logging.warning(f"[⚠️] VirtualRobot: unknown command '{command}'") return f"❓ Unknown action: {command}"