Example #1
0
	def run(self):
		while 1:
			self.__flag.wait()
			if self.CVMode == 'none':
				move.commandInput('stand')
				move.commandInput('no')
				continue
			elif self.CVMode == 'findColor':
				self.CVThreading = 1
				self.findColor(self.imgCV)
				self.CVThreading = 0
			elif self.CVMode == 'findlineCV':
				self.CVThreading = 1
				self.findlineCV(self.imgCV)
				self.CVThreading = 0
			elif self.CVMode == 'watchDog':
				self.CVThreading = 1
				self.watchDog(self.imgCV)
				self.CVThreading = 0
			pass
Example #2
0
	def findLineCtrl(self, posInput, setCenter):#2
		if posInput and setCenter:
			if posInput > (setCenter + findLineError):
				#turnRight
				move.commandInput('right')
				print('right')
				pass
			elif posInput < (setCenter - findLineError):
				#turnLeft
				move.commandInput('left')
				print('left')
				pass
			else:
				move.commandInput('forward')
				time.sleep(1)
				pass
Example #3
0
def functionSelect(command_input, response):
    global direction_command, turn_command, SmoothMode, steadyMode, functionMode

    if 'scan' == command_input:
        pass

    elif 'findColor' == command_input:
        flask_app.modeselect('findColor')

    elif 'motionGet' == command_input:
        flask_app.modeselect('watchDog')

    elif 'stopCV' == command_input:
        flask_app.modeselect('none')
        switch.switch(1, 0)
        switch.switch(2, 0)
        switch.switch(3, 0)

    elif 'KD' == command_input:
        move.commandInput(command_input)

    elif 'automaticOff' == command_input:
        move.commandInput(command_input)

    elif 'automatic' == command_input:
        move.commandInput(command_input)

    elif 'trackLine' == command_input:
        flask_app.modeselect('findlineCV')

    elif 'trackLineOff' == command_input:
        flask_app.modeselect('none')

    elif 'police' == command_input:
        RL.police()

    elif 'policeOff' == command_input:
        RL.pause()
Example #4
0
def robotCtrl(command_input, response):
    global direction_command, turn_command
    if 'forward' == command_input:
        direction_command = 'forward'
        move.commandInput(direction_command)

    elif 'backward' == command_input:
        direction_command = 'backward'
        move.commandInput(direction_command)

    elif 'DS' in command_input:
        direction_command = 'stand'
        move.commandInput(direction_command)

    elif 'left' == command_input:
        turn_command = 'left'
        move.commandInput(turn_command)

    elif 'right' == command_input:
        turn_command = 'right'
        move.commandInput(turn_command)

    elif 'TS' in command_input:
        turn_command = 'no'
        move.commandInput(turn_command)

    elif 'lookleft' == command_input:
        P_sc.singleServo(12, 1, 7)

    elif 'lookright' == command_input:
        P_sc.singleServo(12, -1, 7)

    elif 'LRstop' in command_input:
        P_sc.stopWiggle()

    elif 'up' == command_input:
        T_sc.singleServo(13, 1, 7)

    elif 'down' == command_input:
        T_sc.singleServo(13, -1, 7)

    elif 'UDstop' in command_input:
        T_sc.stopWiggle()