mgbam commited on
Commit
f6da057
Β·
verified Β·
1 Parent(s): 95277c7

Update deployer/simulator_interface.py

Browse files
Files changed (1) hide show
  1. 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.basicConfig(
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: str) -> str:
17
- """Main command processor with error handling"""
18
- try:
19
- command = command.strip().lower()
20
- if not command:
21
- return "Please enter a command"
22
-
23
- if command == "wave":
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 _handle_wave(self) -> str:
34
- """Wave action handler"""
35
  self.state = "WAVING"
36
  time.sleep(0.5)
37
  self.state = "IDLE"
38
  return "πŸ‘‹ Wave complete!"
39
 
40
- def _handle_speak(self, message: str) -> str:
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"