def __init__(self): Rover20.__init__(self) self.quit = False self.lock = threading.Lock() self.treads = [0, 0] self.nn_treads = [0, 0] self.currentImage = None self.peripherals = {'lights': False, 'stealth': False, 'detect': True, 'camera': 0} self.action_choice = 1 self.action_labels = ['forward', 'backward', 'left', 'right'] self.action_vectors_motor = [[1, 1], [-1, -1], [-1, 1], [1, -1]] self.action_vectors_neuro = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.n1 = 32 * 24 * 3 # Number of neurons on the network self.number_of_neurons = 5 # Number of actions available, like forward, back , left and right. self.number_of_actions = 4 self.network_weight_one = 0.0001 * np.random.random((self.n1 + 1, self.number_of_neurons)) self.network_weight_two = 0.01 * np.random.random((self.number_of_neurons + 1, self.number_of_actions)) self.dw1 = np.zeros(self.network_weight_one.shape) self.dw2 = np.zeros(self.network_weight_two.shape) # learning rate of network self.network_learning_rate_one = 0.001 # learning rate of network self.network_learning_rate_two = 0.01 # Network Momemtum Value self.M = .5
def __init__(self): Rover20.__init__(self) self.quit = False self.lock = threading.Lock() self.treads = [0, 0] self.nn_treads = [0, 0] self.currentImage = None self.peripherals = {'lights': False, 'stealth': False, \ 'detect': True, 'camera': 0} self.action_choice = 1 self.action_labels = ['forward', 'backward', 'left', 'right'] self.action_vectors_motor = [[1, 1], [-1, -1], [-1, 1], [1, -1]] self.action_vectors_neuro = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.n1 = 32 * 24 * 3 self.n2 = 2 self.n3 = 4 self.w1 = 0.00001 * np.random.random((self.n1 + 1, self.n2)) self.w2 = 0.01 * np.random.random((self.n2 + 1, self.n3)) self.dw1 = np.zeros(self.w1.shape) self.dw2 = np.zeros(self.w2.shape) self.L1 = 0.000001 self.L2 = 0.001 self.M = 0.9
def __init__(self): Rover20.__init__(self) self.quit = False self.lightsAreOn = False self.stealthIsOn = False # each integer may be -1, 0, or 1 self.treads = [0,0] # window must be open and in focus for pygame to take input self.windowSize = [640, 480] # used to only refresh the video and not the unused pixels self.imageRect = (160,120,320,240) # Live video frames per second self.fps = 48 # stores what the camera currently sees self.currentImage = None self.displayCaption = "Keyboard Rover 2.0" pygame.init() pygame.display.init() pygame.display.set_caption(self.displayCaption) self.screen = pygame.display.set_mode(self.windowSize) self.clock = pygame.time.Clock()
def __init__(self): # Set up basics Rover20.__init__(self) self.wname = 'Rover 2.0: Hit ESC to quit' self.quit = False # Set up controller using PyGame pygame.display.init() pygame.joystick.init() self.controller = pygame.joystick.Joystick(0) self.controller.init() # Defaults on startup: lights off, ordinary camera self.lightsAreOn = False self.stealthIsOn = False # Tracks button-press times for debouncing self.lastButtonTime = 0 # Try to create OpenCV named window try: if cv: cv.NamedWindow(self.wname, cv.CV_WINDOW_AUTOSIZE ) else: pass except: pass self.pcmfile = open('rover20.pcm', 'w')
def initialize(self): print "Initializing Rover Module..." # Set up basics Rover20.__init__(self) self.wname = 'Rover 2.0: Hit ESC to quit' self.quit = False # Set up controller using PyGame pygame.display.init() pygame.joystick.init() print "Initializing Joystick..." self.controller = pygame.joystick.Joystick(0) self.controller.init() # Defaults on startup: lights off, ordinary camera self.lightsAreOn = False self.stealthIsOn = False # Tracks button-press times for debouncing self.lastButtonTime = 0 # Try to create OpenCV named window # print "Creating OpenCV Window..." # try: # if cv: # cv.NamedWindow(self.wname, cv.CV_WINDOW_AUTOSIZE ) # else: # pass # except: # pass self.pcmfile = open('rover20.pcm', 'w')
def __init__(self): Rover20.__init__(self) self.quit = False self.peripherals = {'lights': False, 'stealth': False, 'camera': 0} self.treads = [0,0] self.currentImage = None self.lock = threading.Lock()
def __init__(self): # Set up basics Rover20.__init__(self) self.wname = 'Rover 2.0: Hit ESC to quit' self.quit = Fsetalse # Set up controller using PyGame pygame.display.init() pygame.joystick.init() self.controller = pygame.joystick.Joystick(0) self.controller.init() # Defaults on startup: lights off, ordinary camera self.lightsAreOn = False self.stealthIsOn = False # Tracks button-press times for debouncing self.lastButtonTime = 0 # Try to create OpenCV named window try: if cv: cv.NamedWindow(self.wname, cv.CV_WINDOW_AUTOSIZE ) else: pass except: pass self.pcmfile = open('rover20.pcm', 'w')
def __init__(self): Rover20.__init__(self) self.currentImage = None self.quit = False self.action_choice = 1 self.action_labels = ['left', 'forward', 'right', 'backward'] self.action_vectors = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.data = np.ones(240 * 320 + 4)
def __init__(self): Rover20.__init__(self) self.quit = False self.orb = cv2.ORB() self.lock = threading.Lock() self.treads = [0, 0] self.currentImage = None self.peripherals = {"lights": False, "stealth": False, "detect": True, "camera": 0}
def __init__(self): Rover20.__init__(self) self.quit = False self.orb = cv2.ORB() self.lock = threading.Lock() self.treads = [0, 0] self.currentImage = None self.peripherals = {'lights': False, 'stealth': False, \ 'detect': True, 'camera': 0}
def __init__(self): Rover20.__init__(self) print self.get_battery_percentage() #self.rover = Rover20() pygame.init() #self.file_name = 'filename' self.quit = False self.image = None self.run() self.close()
def __init__(self): Rover20.__init__(self) self.quit = False self.lock = threading.Lock() self.treads = [0, 0] self.nn_treads = [0, 0] self.currentImage = None self.peripherals = {"lights": False, "stealth": False, "detect": True, "camera": 0} self.action_choice = 1 self.action_labels = ["forward", "backward", "left", "right"] self.action_vectors_motor = [[1, 1], [-1, -1], [-1, 1], [1, -1]] self.action_vectors_neuro = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] self.n1 = 32 * 24 * 3 # Number of neurons on the network self.number_of_neurons = 50 # Number of actions available, like forward, back , left and right. self.number_of_actions = 4 self.network_weight_one = 0.0001 * np.random.random((self.n1 + 1, self.number_of_neurons)) self.network_weight_two = 0.01 * np.random.random((self.number_of_neurons + 1, self.number_of_actions)) self.dw1 = np.zeros(self.network_weight_one.shape) self.dw2 = np.zeros(self.network_weight_two.shape) # learning rate of network self.network_learning_rate_one = 0.001 # learning rate of network self.network_learning_rate_two = 0.01 # Network Momemtum Value self.M = 0.5 self.currentImage = None self.act1 = None self.act2 = None self.act22 = None self.bias = None self.pattern = None self.delta_w1 = None self.delta_w2 = None self.category = None self.sse = None self.error = None
def main(): # defining the function called "main()" rover = Rover20() # redefine the module Rover20 so we can use "rover" instead. It makes things easier. rover.turnLightsOn() # turn on green lights time.sleep(1) # make the rover wait 1 second in its current state rover.turnLightsOff() # turn off green lights. Duh! time.sleep(1) # make the rover wait 1 second in its current state rover.close() # close rover
def main(): rover = Rover20() # create rover rover.turnLightsOn() # turn on green lights time.sleep(1) rover.turnLightsOff() time.sleep(1) rover.close() # close rover
def __init__(self): """Sign follower initiation.""" # Set up basics for Odometer self.state = (0, 0, 0) #x,y,theta self.path = [] #list will contain points of previous positions) Rover20.__init__(self) self.wname = 'Rover 2.0: Hit ESC to quit' self.quit = False self.fileIndex = 0 self.fname = 'filename' # Defaults on start-up: lights off, ordinary camera self.lightsAreOn = False self.stealthIsOn = False # Initiate My Turtle graphics to be used as a map. self.pcmfile = open('rover20.pcm', 'w') self.myturtle = Turtle() self.myturtle.speed(0) self.myturtle.pencolor("blue") self.nocommand_counter = 0
def main(): rover = Rover20() # create rover rover.setTreads(1, 1) # forwards time.sleep(1) # wait 1 second rover.setTreads(0, 0) # stop time.sleep(1) rover.setTreads(-1, -1) # backwards time.sleep(1) rover.setTreads(0, 0) time.sleep(1) rover.close() # close rover
def main(): # create a function called "main()" rover = Rover20() # create rover # The parenthesis is set up as (Left Tread, Right Tread). 1 is forwards, 0 is off, and -1 is backwards. rover.setTreads(1, 1) # forwards time.sleep(1) # wait 1 second rover.setTreads(0, 0) # stop time.sleep(1) rover.setTreads(-1, -1) # backwards time.sleep(1) rover.setTreads(0, 0) time.sleep(1) rover.close() # close rover
def main(): rover = Rover20() # create rover rover.setTreads(1, 1) # forwards time.sleep(1) # wait 1 second rover.setTreads(0, 0) # stop time.sleep(1) rover.setTreads(-1, -1) # backwards time.sleep(1) rover.setTreads(0, 0) time.sleep(1) rover.turnLightsOn() # turn on green lights time.sleep(1) rover.turnLightsOff() time.sleep(1) rover.close() # close rover
def __init__(self): Rover20.__init__(self) self.heard = False
#!/usr/bin/env python ''' rover20battery.py Check battery on Brookstone Rover 2.0. Copyright (C) 2014 Simon D. Levy This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ''' from rover import Rover20 tank = Rover20() print('Battery at %d%%' % tank.getBatteryPercentage()) tank.close()