Changeset 431
- Timestamp:
- 02/25/09 23:53:02 (3 years ago)
- Location:
- trunk/software/rb
- Files:
-
- 5 modified
-
controller.py (modified) (1 diff)
-
drive.py (modified) (1 diff)
-
gui/analog.py (modified) (5 diffs)
-
gui/gui.py (modified) (2 diffs)
-
shell.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/software/rb/controller.py
r430 r431 4 4 class Controller(): 5 5 def __init__(self): 6 self.mode = "stop"7 #self.drive = rb.drive.FakeDrive(rbconfig.left_motor_port,8 #rbconfig.right_motor_port)9 self.drive = rb.drive.Drive(rbconfig.left_motor_port,10 rbconfig.right_motor_port)6 self.mode = None 7 self.drive = rb.drive.FakeDrive(rbconfig.left_motor_port, 8 rbconfig.right_motor_port) 9 #self.drive = rb.drive.Drive(rbconfig.left_motor_port, 10 # rbconfig.right_motor_port) 11 11 12 12 def set_mode(self, mode): -
trunk/software/rb/drive.py
r424 r431 221 221 log_debug("MockDrive: left motor speed % 3.03f" % left) 222 222 log_debug("MockDrive: right motor speed % 3.03f" % right) 223 self.left.target = left224 self.right.target = right223 self.left.target = clip(left, -1.0, 1.0) 224 self.right.target = clip(right, -1.0, 1.0) 225 225 226 226 def getspeed(self): -
trunk/software/rb/gui/analog.py
r425 r431 9 9 10 10 self.controller = controller 11 11 self.enabled = False 12 12 # Register callbacks 13 13 #connect("motor:speed_changed", self.redraw) … … 34 34 context = self.window.cairo_create() 35 35 36 # Draw di mond36 # Draw diamond 37 37 context.set_source_rgb(0, 254, 0) 38 38 context.move_to(w/2, 0) … … 41 41 context.line_to(w, h/2) 42 42 context.fill() 43 44 # Draw Target Speed 45 x = float(self.controller.drive.left.target - self.controller.drive.right.target) 46 y = float(self.controller.drive.left.target + self.controller.drive.right.target) 47 #~ log_debug("left=%f, right=%f, x=%f, y=%f" % 48 #~ (self.controller.drive.left.target, self.controller.drive.right.target, 49 #~ ( x/4+0.5), (-y/4+0.5))) 50 x = ( x/4+0.5) * w 51 y = (-y/4+0.5) * h 52 context.set_source_rgb(0,0,255) 53 context.arc(x, y, 5, 0, 2*pi) 54 context.fill() 43 44 if self.enabled: 45 # Draw Target Speed 46 x = float(self.controller.drive.left.target - self.controller.drive.right.target) 47 y = float(self.controller.drive.left.target + self.controller.drive.right.target) 48 #log_debug("left=%f, right=%f, x=%f, y=%f" % 49 #(self.controller.drive.left.target, self.controller.drive.right.target, 50 #( x/4+0.5), (-y/4+0.5))) 51 x = ( x/4+0.5) * w 52 y = (-y/4+0.5) * h 53 context.set_source_rgb(0,0,255) 54 context.arc(x, y, 5, 0, 2*pi) 55 context.fill() 55 56 56 57 # Draw Current Speed … … 65 66 66 67 def motion_cb(self, da, event): 68 if not self.enabled: 69 return 67 70 if (event.type != gtk.gdk.BUTTON_PRESS and 68 71 event.state & gtk.gdk.BUTTON1_MASK == 0): … … 78 81 r = y-x 79 82 80 log_debug("\tgui: x=%f, y=%f, l=%f, r=%f" % (x,y,l,r))83 #log_debug("\tgui: x=%f, y=%f, l=%f, r=%f" % (x,y,l,r)) 81 84 self.controller.set_speed(l, r) -
trunk/software/rb/gui/gui.py
r430 r431 51 51 52 52 self.window.show_all() 53 self.set_mode('manual') 53 54 gtk.main() 54 55 … … 62 63 elif mode == 'manual': 63 64 print "Switching to manual mode" 65 66 self.analog.enabled = (mode == 'manual') 67 64 68 65 69 def key_press_cb(self, widget, event): -
trunk/software/rb/shell.py
r420 r431 30 30 ''' 31 31 A robot control shell. 32 33 The rbconfig variable ``shell_components`` permits automatic loading34 of certain components when the shell is started.35 36 TODO: Needs some way of loading sets of commands dynamically, e.g.,37 so that motor-related commands can be made present only when their38 dependencies are running.39 32 ''' 40 33 … … 44 37 cmd.Cmd.__init__(self) 45 38 Controller.__init__(self) 39 self.set_mode('manual') 46 40 try: 47 41 self.cmdloop() … … 66 60 67 61 def do_exit(self, cmd): 68 print "Goodbye. :("62 print "Goodbye." 69 63 return True 70 64 71 65 def help_exit(self): 72 66 print "Exit the shell." 67 68 do_quit = do_exit 69 help_quit = help_exit 73 70 74 71 # Loading commands from a file … … 145 142 def do_disable(self, cmd): 146 143 print self.drive.disable() 144 def help_disable(self): 145 print "Disable the drive" 147 146 148 147 def do_enable(self, cmd): 149 148 print self.drive.enable() 149 def help_enable(self): 150 print "Enable the drive" 150 151 151 152 def do_getdc(self, cmd): … … 158 159 print self.drive.getstat() 159 160 160 def do_eewrite(self, cmd):161 def do_eewrite(self, cmd): 161 162 print self.drive.eewrite() 162 163

