mgbam commited on
Commit
40a7102
Β·
verified Β·
1 Parent(s): f953fe9

Update deployer/simulator_interface.py

Browse files
Files changed (1) hide show
  1. deployer/simulator_interface.py +24 -12
deployer/simulator_interface.py CHANGED
@@ -2,26 +2,38 @@ import time
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"
 
2
  import logging
3
 
4
  class VirtualRobot:
5
+ """Enhanced virtual robot with state management"""
6
+
7
  def __init__(self):
8
  self.state = "IDLE"
9
+ logging.info("πŸ€– Virtual Robot initialized")
10
+
11
+ def perform_action(self, command: str) -> str:
12
+ """Main action processor with validation"""
13
  command = (command or "").strip().lower()
14
 
15
+ if not command:
16
+ return "❌ Please enter a command"
17
+
18
+ try:
19
+ if command == "wave":
20
+ return self._wave()
21
+ elif command.startswith("say"):
22
+ return self._speak(command[3:].strip())
23
+ return "❓ Try 'wave' or 'say [message]'"
24
+ except Exception as e:
25
+ logging.error(f"Action failed: {str(e)}")
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: str) -> str:
36
+ """Handle speak action"""
37
  if not message:
38
  return "❌ No message provided"
39
  self.state = "SPEAKING"