Changeset 459
- Timestamp:
- 03/14/09 17:41:06 (3 years ago)
- Location:
- trunk/software
- Files:
-
- 4 modified
-
rb/drive.py (modified) (1 diff)
-
rb/gui/gui.py (modified) (3 diffs)
-
rb/shell.py (modified) (5 diffs)
-
shell (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/software/rb/drive.py
r458 r459 244 244 v1 = sin(time.time()) * .05 - random.random() * .01 245 245 v2 = cos(time.time()) * .05 - random.random() * .01 246 return (self.left.target + v1, self.right.target + v2) 246 return ( 247 clip(self.left.target + v1, -1.0, 1.0), 248 clip(self.right.target + v2, -1.0, 1.0) 249 ) 247 250 248 251 -
trunk/software/rb/gui/gui.py
r458 r459 3 3 import gtk 4 4 5 import os.path 6 from thread import start_new_thread 7 5 8 import rbconfig 6 from rb. core.event import connect9 from rb.shell import Shell 7 10 from rb.core.logging import log_debug, log_info 8 11 from rb.controller import Controller … … 12 15 from rb.transcript import TranscriptLogger 13 16 14 import os.path15 17 16 18 # Full path to the GUI definition file … … 71 73 self.set_navigator('analog') 72 74 75 start_new_thread(self._run_shell, ()) 73 76 gtk.main() 77 78 def _run_shell(self): 79 Shell(self).cmdloop() 80 gobject.idle_add(gtk.main_quit) 74 81 75 82 def process(self, type, data): -
trunk/software/rb/shell.py
r458 r459 28 28 from rb.transcript import TranscriptLogger 29 29 30 class Shell(cmd.Cmd, Controller): 30 31 class Shell(cmd.Cmd): 31 32 ''' 32 33 A robot control shell. … … 35 36 prompt = getattr(rbconfig, 'name', 'robot').lower() + '> ' 36 37 37 def __init__(self): 38 def __init__(self, controller): 39 self.controller = controller 38 40 cmd.Cmd.__init__(self) 39 Controller.__init__(self)40 self.set_navigator('shell')41 try:42 self.cmdloop()43 except:44 self.drive.running = False45 41 46 42 def preloop(self): 47 43 self.eval_locals = { 48 'drive': self. drive44 'drive': self.controller.drive 49 45 } 50 self.init_drive()51 46 52 47 try: … … 116 111 try: 117 112 lspeed, rspeed = unpack(cmd, (0.0, float), (0.0, float)) 118 self. drive.setspeed(lspeed, rspeed)113 self.controller.drive.setspeed(lspeed, rspeed) 119 114 except ValueError: 120 115 print "Invalid parameters" 121 116 122 117 def do_getspeed(self, cmd): 123 self. drive.getspeed()118 self.controller.drive.getspeed() 124 119 125 120 def do_setgain(self, cmd): … … 127 122 kp, ki, kd, m = unpack(cmd, (0, int), (0, int), (0, int), ('b', str)) 128 123 if m == 'l': 129 self. drive.setgain((kp,ki,kd),None)124 self.controller.drive.setgain((kp,ki,kd),None) 130 125 elif m == 'r': 131 self. drive.setgain(None,(kp,ki,kd))126 self.controller.drive.setgain(None,(kp,ki,kd)) 132 127 else: 133 self. drive.setgain((kp,ki,kd),(kp,ki,kd))128 self.controller.drive.setgain((kp,ki,kd),(kp,ki,kd)) 134 129 except ValueError: 135 130 print "Invalid Parameters" 136 131 137 132 def do_getspeed(self, cmd): 138 print self. drive.getspeed()133 print self.controller.drive.getspeed() 139 134 140 135 def do_setdc(self, cmd): 141 136 ldc, rdc = unpack(cmd, (0, int), (0, int)) 142 print self. drive.setdc(ldc, rdc)137 print self.controller.drive.setdc(ldc, rdc) 143 138 144 139 def do_disable(self, cmd): 145 print self. drive.disable()140 print self.controller.drive.disable() 146 141 def help_disable(self): 147 142 print "Disable the drive" 148 143 149 144 def do_enable(self, cmd): 150 print self. drive.enable()145 print self.controller.drive.enable() 151 146 def help_enable(self): 152 147 print "Enable the drive" 153 148 154 149 def do_getdc(self, cmd): 155 print self. drive.getdc()150 print self.controller.drive.getdc() 156 151 157 152 def do_getgain(self, cmd): 158 print self. drive.getgain()153 print self.controller.drive.getgain() 159 154 160 155 def do_getstat(self, cmd): 161 print self. drive.getstat()156 print self.controller.drive.getstat() 162 157 163 158 def do_eewrite(self, cmd): 164 print self. drive.eewrite()159 print self.controller.drive.eewrite() 165 160 166 161 def do_stop(self, cmd): 167 self. drive.set_speeds(0.0, 0.0)162 self.controller.drive.set_speeds(0.0, 0.0) 168 163 169 164 def help_stop(self): … … 186 181 print ("Without arguments, list available commands. With a command " 187 182 "name as an argument, get more information on that command") 183 184 185 class ShellController(Controller): 186 def __init__(self): 187 Controller.__init__(self) 188 self.init_drive() 189 self.set_navigator('shell') 190 try: 191 Shell(self).cmdloop() 192 finally: 193 self.drive.running = False 194 188 195 189 196 def unpack(str, *specs): -
trunk/software/shell
r398 r459 1 1 #!/usr/bin/python2.5 2 2 3 from rb.shell import Shell 4 Shell ()3 from rb.shell import ShellController 4 ShellController()

