Update deployer/simulator_interface.py
Browse files- deployer/simulator_interface.py +12 -29
deployer/simulator_interface.py
CHANGED
@@ -2,45 +2,28 @@ import time
|
|
2 |
import logging
|
3 |
|
4 |
class VirtualRobot:
|
5 |
-
"""Simplified but robust virtual robot implementation"""
|
6 |
-
|
7 |
def __init__(self):
|
8 |
self.state = "IDLE"
|
9 |
-
logging.
|
10 |
-
level=logging.INFO,
|
11 |
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
12 |
-
)
|
13 |
-
self.logger = logging.getLogger("VirtualRobot")
|
14 |
-
self.logger.info("Robot initialized")
|
15 |
|
16 |
-
def perform_action(self, command
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
return self._handle_wave()
|
25 |
-
elif command.startswith("say"):
|
26 |
-
return self._handle_speak(command[3:].strip())
|
27 |
-
else:
|
28 |
-
return "Unknown command. Try 'wave' or 'say [message]'"
|
29 |
-
except Exception as e:
|
30 |
-
self.logger.error(f"Command failed: {str(e)}")
|
31 |
-
return f"Error: {str(e)}"
|
32 |
|
33 |
-
def
|
34 |
-
"""Wave action handler"""
|
35 |
self.state = "WAVING"
|
36 |
time.sleep(0.5)
|
37 |
self.state = "IDLE"
|
38 |
return "π Wave complete!"
|
39 |
|
40 |
-
def
|
41 |
-
"""Speak action handler"""
|
42 |
if not message:
|
43 |
-
return "No message provided"
|
44 |
self.state = "SPEAKING"
|
45 |
time.sleep(max(0.3, len(message)*0.05))
|
46 |
self.state = "IDLE"
|
|
|
2 |
import logging
|
3 |
|
4 |
class VirtualRobot:
|
|
|
|
|
5 |
def __init__(self):
|
6 |
self.state = "IDLE"
|
7 |
+
logging.info("π€ Robot initialized")
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
def perform_action(self, command):
|
10 |
+
command = (command or "").strip().lower()
|
11 |
+
|
12 |
+
if command == "wave":
|
13 |
+
return self._wave()
|
14 |
+
elif command.startswith("say"):
|
15 |
+
return self._speak(command[3:].strip())
|
16 |
+
return "β Try 'wave' or 'say [message]'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
def _wave(self):
|
|
|
19 |
self.state = "WAVING"
|
20 |
time.sleep(0.5)
|
21 |
self.state = "IDLE"
|
22 |
return "π Wave complete!"
|
23 |
|
24 |
+
def _speak(self, message):
|
|
|
25 |
if not message:
|
26 |
+
return "β No message provided"
|
27 |
self.state = "SPEAKING"
|
28 |
time.sleep(max(0.3, len(message)*0.05))
|
29 |
self.state = "IDLE"
|