Update deployer/simulator_interface.py
Browse files- deployer/simulator_interface.py +15 -19
deployer/simulator_interface.py
CHANGED
@@ -2,38 +2,34 @@ import time
|
|
2 |
import logging
|
3 |
|
4 |
class VirtualRobot:
|
5 |
-
"""
|
6 |
|
7 |
def __init__(self):
|
8 |
self.state = "IDLE"
|
9 |
logging.info("π€ Virtual Robot initialized")
|
10 |
-
|
11 |
-
def perform_action(self, command
|
12 |
-
"""Main
|
13 |
command = (command or "").strip().lower()
|
14 |
|
15 |
if not command:
|
16 |
return "β Please enter a command"
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
return f"β οΈ Error: {str(e)}"
|
27 |
-
|
28 |
-
def _wave(self) -> str:
|
29 |
-
"""Handle wave action"""
|
30 |
self.state = "WAVING"
|
31 |
time.sleep(0.5)
|
32 |
self.state = "IDLE"
|
33 |
return "π Wave complete!"
|
34 |
-
|
35 |
-
def _speak(self, message
|
36 |
-
"""
|
37 |
if not message:
|
38 |
return "β No message provided"
|
39 |
self.state = "SPEAKING"
|
|
|
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.info("π€ Virtual Robot initialized")
|
10 |
+
|
11 |
+
def perform_action(self, command):
|
12 |
+
"""Main command processor with validation"""
|
13 |
command = (command or "").strip().lower()
|
14 |
|
15 |
if not command:
|
16 |
return "β Please enter a command"
|
17 |
|
18 |
+
if command == "wave":
|
19 |
+
return self._wave()
|
20 |
+
elif command.startswith("say"):
|
21 |
+
return self._speak(command[3:].strip())
|
22 |
+
return "β Try 'wave' or 'say [message]'"
|
23 |
+
|
24 |
+
def _wave(self):
|
25 |
+
"""Wave action handler"""
|
|
|
|
|
|
|
|
|
26 |
self.state = "WAVING"
|
27 |
time.sleep(0.5)
|
28 |
self.state = "IDLE"
|
29 |
return "π Wave complete!"
|
30 |
+
|
31 |
+
def _speak(self, message):
|
32 |
+
"""Speak action handler"""
|
33 |
if not message:
|
34 |
return "β No message provided"
|
35 |
self.state = "SPEAKING"
|