def Connect(): #a function that connects the finch to the python methods for i in range (2): #loop of two try: #first attempt newFinch=Finch() #sets a variable equal to connection return newFinch except: if i==0: print "Failed to connect to Finch on the first try" #prints a statement that the finch failed to connect the first time Quit(newFinch) newFinch=0 #resets newFinch varv - iable to 0 print "Failed to connect to Finch on the second try" #prints a statement that the finch failed to connect the second time return newFinch #returns the value of newFinch
def Connect(): for i in range (2): try: newFinch = Finch() return newFinch except: if i == 0: print "Failed to connect to Finch on the first try" Quit(newFinch) newFinch = 0 print "Failed to connect to Finch on the second try" return newFinch
def __init__(self): self.tweety = Finch() # Set obstacle sensors self.left_obst, self.right_obst = self.tweety.obstacle() # Setting initial lighting self.myLights = lighting(self.tweety) # Setting initial acceleration settings self.x, self.y, self.z, self.tap, self.shake = self.tweety.acceleration() # Setting initial wheel speed self.left_wheel = 0.0 self.right_wheel = 0.0 self.tweety.wheels(self.left_wheel, self.right_wheel)
def dance2(): snakyFinch = Finch() for i in range(5): snakyFinch.wheels(1, 1) sleep(1) snakyFinch.wheels(0, -1) sleep(1) snakyFinch.wheels(1, 0) sleep(1) snakyFinch.wheels(1, -1) sleep(0.5) snakyFinch.wheels(0.5, 1) sleep(1) snakyFinch.wheels(0.75, -0.3) sleep(2.5) if i == 4: snakyFinch.close();
def dance3(): snakyFinch = Finch() for i in range(5): snakyFinch.wheels(1, 0) sleep(1) snakyFinch.wheels(-1, 1) sleep(1) snakyFinch.wheels(1, 0) sleep(1) snakyFinch.wheels(-1, 0) sleep(0.5) snakyFinch.wheels(-0.9, 1) sleep(1) snakyFinch.wheels(0.75, 0.2) sleep(2.5) if i == 4: snakyFinch.close();
def dance1(): snakyFinch = Finch() for i in range(5): snakyFinch.wheels(1, 1) sleep(1) snakyFinch.wheels(0, 1) sleep(1) snakyFinch.wheels(1, 0) sleep(1) snakyFinch.wheels(-1, -1) sleep(0.5) snakyFinch.wheels(0.2, -1) sleep(1) snakyFinch.wheels(0.3, 0.3) sleep(2.5) if i == 4: snakyFinch.close();
def __init__(self, left, right, inAdjustmentMode=False): self.leftWheel = left self.rightWheel = right self.myBot = Finch() # Keep track of the direction you should try on obstacles self.obstacleDirectionToTry = finchConstants.LEFT self.lastScrapedSide = " " # Keep track of when the last time you moved forward, we use that # to identify sensors self.lastTimeIMovedForward = -1 # Use vars below for logging when self.lastPersistedLeftObstacleState = False self.lastPersistedRightObstacleState = False # Obstacle reading goes haywire... we'll count up readings within # an interval and use the overall score to report self.lastObstacleReading = 0.0 self.lastObstacleReadingLeftScores = [0, 0, 0, 0, 0] self.lastObstacleReadingRightScores = [0, 0, 0, 0, 0] self.scorePosition = 0 self.obstacleNumberOfScores = len(self.lastObstacleReadingLeftScores) self.obstacleState = { "left": False, "leftStateTime": 0.0, "leftElapsedTime": 0.0, "right": False, "rightStateTime": 0.0, "rightElapsedTime": 0.0 } # If true then wheel speed will be adjusted by the constants self.inWheelAdjustmentMode = inAdjustmentMode self.lasttime = time.time() self.update(self.inWheelAdjustmentMode)
# Car alarm # The finch sounds an alarm, alternating high pitch sounds and # flashing red abd blue lights, until its nose is turned up from time import sleep from finch import Finch from msvcrt import getch finch = Finch() def main(): #while(1): key = 0 ultrasound_value = 0 while (1): ultrasound_value = finch.new_obstacle() if (ultrasound_value > 2000): finch.wheels(0.5, 0.5) else: finch.wheels(0, 0.5) sleep(0.1) #print (ultrasound_value #key = ord(getch()) finch.halt() finch.close()
from finch import Finch from time import sleep f = Finch() zAccel = f.acceleration()[2] i_temp = f.temperature() i_l_light, i_r_light = f.light() alpha_light = 0.20 alpha2_light = 0.25 alpha_temp = 0.65 while zAccel > -0.7: left_obstacle, right_obstacle = f.obstacle() l_light, r_light = f.light() temp = f.temperature() print(temp) if temp > i_temp + alpha_temp: k = 1 while k < 11: f.led(141, 21, 165) f.wheels(-1, -1) sleep(0.2) f.led(255, 255, 255) f.wheels(1, 1) sleep(0.2)
def Connect(): newFinch = Finch() return newFinch
def __init__(self): self.tweety = Finch() self.left_wheel = 0.0 self.right_wheel = 0.0 self.tweety.wheels(self.left_wheel, self.right_wheel) self.left_obst, self.right_obst = self.tweety.obstacle()
if (side == RIGHT): wheels(0.0, R_INITIAL) else: wheels(L_INITIAL, 0.0) #BREAK OUT OF LOOP IF INFINITE SPINNING? while not left_obst or not right_obst: left_obst, right_obst = finchy.obstacle() if right_obst: return RIGHT else: return LEFT ########################################### # # MAIN # ########################################### #initialize the finch & data finchy = Finch() #MENU #function calls here multithread here startFinch(finchy) finchy.close()
Obstacle program for the Finch robot Written by Wyatt Miller Copyright (c) 2017, MIT Read the intro message to get a breif run down what this program does. This does somewhat the wanderer.py file does, but with FUNCTIONS! And other added stuff... You need Python 3 and the Finch robot! Don't have a Finch? http://www.finchrobot.com Don't have Python?? www.python.org ''' from finch import Finch from time import time, sleep finch = Finch() # Initialize! # Blinking blue lights! finch.led(0, 0, 255) sleep(0.2) finch.led(0, 0, 0) sleep(0.2) finch.led(0, 0, 255) sleep(0.2) finch.led(0, 0, 0) sleep(0.2) finch.led(0, 0, 255) sleep(0.2) finch.led(0, 0, 0) sleep(0.2) finch.led(0, 0, 255)
right_minimum, right_maximum = right_sensor[0], right_sensor[-1] target = open(filename, 'w') target.truncate() s = 'left max: ' + str(left_maximum) + '\n' target.write(str(s)) s = 'left min: ' + str(left_minimum) + '\n' target.write(str(s)) s = 'left diff: ' + str(left_maximum - left_minimum) + '\n' target.write(str(s)) s = 'left avg: ' + str(float(sum(left_sensor) / len(left_sensor))) + '\n\n' target.write(str(s)) s = 'right max: ' + str(right_maximum) + '\n' target.write(str(s)) s = 'right min: ' + str(right_minimum) + '\n' target.write(str(s)) s = 'right diff: ' + str(right_maximum - right_minimum) + '\n' target.write(str(s)) s = 'right avg: ' + str(float( sum(right_sensor) / len(right_sensor))) + '\n\n' target.write(str(s)) target.close() return newFinch = Finch() #calibrateLights(newFinch, "calib.txt") tweety = myFinch(newFinch) tweety.scurryTowardsLights()
# Lap Swimmer, an example program for the Finch # Tell the Finch how many laps to do, set it down on the ground # Finch goes forward until it sees an obstacle # Then goes back the same distance. It'll then repeat this lap as many times # as the user requested from finch import Finch from time import sleep, time # Main function for the lap swimmer example program finch = Finch() # Initialize the finch finch.led(255, 255, 0) laps = 0 # Get the number of laps Finch will swim: while laps <= 0: laps = int(input('Enter number of laps: ')) if laps < 0: print('Cannot swim a negative number of laps!') elif laps == 0: print('Zero laps? I want to swim!') # Move forward until an obstacle is present and measure the time: start = time() finch.wheels(0.5, 0.5) sleep(0.1)
#Michael Lannon from finch import Finch from time import sleep from Finch_project_dance import dance1,dance2,dance3 from Finch_project_loggig import show_log file = open('finchlog.txt', 'a+') logging = open('finchlog.txt', 'r') log = logging.readlines() myFinch = Finch() a = 220 #keeping this here just in case bflat = 233 hbflat=466 asharp = bflat fsharp=370 gflat=fsharp b = 247 c = 262 d = 294 e = 330 f = 349 g = 392 ha=int(2*a) #this is an 'a' note one octave above the other hb=int(2*b) #this is a 'b' note one octave above the other, etc.... hc=int(2*c) hd=int(2*d) he=int(2*e) hf=int(2*f)
# A simple Finch dance in Python from finch import Finch from time import sleep print("Finch's First Python program.") # Instantiate the Finch object snakyFinch = Finch() # Do a six step dance snakyFinch.led(254, 0, 0) snakyFinch.wheels(1, 1) sleep(2) print("second line") snakyFinch.led(0, 254, 0) snakyFinch.wheels(0, 1) sleep(2) print("third line") snakyFinch.led(0, 0, 254) snakyFinch.wheels(1, 0) sleep(2) print("third line") snakyFinch.led(254, 0, 254) snakyFinch.wheels(-1, -1) sleep(2) print("third line")
# Finch Testing Script for initiating evasive maneuvers based on ultrasonic # range finder PROXIMITY data # # There will be 2 main test scripts for sonar based colision avoidance, one for # proximity (how far objects are relative to Finch) # speed (how quickly objects are approaching Finch) import ultrasonicRangeRpi from finch import Finch from time import sleep #Instantiate the Finch Object TestFinch = Finch() #Details about the Finch FinchWidth = 20 #Distance between mid points of two tires TireCircumf = 20.797 #Circumference of Finch Wheels l, ril, rel = ultrasonicRangeRpi.lists() #Starting Speed (0.5 on each wheel) TestFinch.wheels(0.5, 0.5) while True: # Find the distances from each sensor sensor1 = ultrasonicRangeRpi.ultrasound(26, 19, 3) #Left Ultrasound sensor2 = ultrasonicRangeRpi.ultrasound(20, 21, 2) #Rear Ultrasound sensor3 = ultrasonicRangeRpi.ultrasound(23, 24, 1) #Right Ultrasound # Enter a number between 0-1, with 0.1 increments (example: 0.2, 0.5, 0.6, 0.9 etc.)
# A simple program that wanders and avoids obstacles from finch import Finch from time import sleep import notes #Main function for the music player example program""" #Initialize the finch finch = Finch() songList = [ 'E5 C D E C D E F D E F D E F G A GE F C D E G E D C ', 'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 ' 'E D5 A4 G G5 A4 F5# A4 E D5 A4 G G5 A4 F5# A4 ' 'G D5 A4 G G5 A4 F5# A4 G D5 A4 G G5 A4 F5# A4 ' 'D D5 A4 G G5 A4 F5# A4 D D5 A4 G G5 A4 F5# A4 ', 'E5 E E C E G ', 'C E5 G' ] timeList = [0.18, 0.1, 0.1] song = 1 #get which song song = 3 if song >= 1 and song <= 3: print("It's GO time!!!") Finch.led(255, 0, 0) notes.sing(finch, songList[song - 1], timeList[song - 1]) else:
from finch import Finch #Here we start using the robot robot = Finch() notes = [880, 988, 523, 587, 659, 698] length = 1.2 #let's use a default length of the note for note in notes: print("Note is", note) #QUESTION: What happens if I *remove* the indentation for the next line? robot.buzzer_with_delay(length, note) print("The last note was ", note) print("All notes played!")
def mathr(): if (True): WASD("r") WASD("ht") # to = input("if your equation is in ax**2 + bx +c, type 1. If it is in d(x + a)**2 + b = c, type 2. If you want to use the normal calculator, do not type in anything.") a = input() ot = input() b = input() ot = ot.lower() if (ot == "1"): a = (input("What is the A value?")) b = ((input("What is the B value?"))) c = (input("What is the C Value?")) if (type(a) or type(b) or type(c) != float) and (len(a) and len(b) > 0): a = float(a) b = float(b) c = float(c) wer = 0 WASD("st") while (wer < 10): WASD("a") wer = (wer + 1) WASD("ht") dis = str(b**2 - (4 * a * c)) print("The Discriminent is " + dis + ".") v = ((0 - b) / (2 * a)) d = v ve = ((a * (v**2)) + (b * d) + c) print("The axis of symmetry is:") print("x = ") print(v) print("The vertex is ") print(v) print(",") print(ve) anso = (0 - b) ansoer = (b**2 - (4 * a * c)) if (ansoer < 0): print("The answer is no solution") else: anso = (anso + sqrt(ansoer)) anso = (anso / (2 * a)) anst = (0 - b) anst = (anst - sqrt(b**2 - 4 * a * c)) anst = (anst / (2 * a)) print("The answers are:") print(anso) print("and") print(anst) anso = (0 - b) ansoer = (b**2 - (4 * a * c)) ansot = (0 - anso) ansto = (0 - anst) # print ("The factored form is:") # print ("(x + ") # print (ansot) # print (")") # print ("(x + ") # print(ansto) # print (")") qrs = input("do you want to plug in a point?") if (qrs == "y"): v = input("What x value?") WASD("ht") v = float(v) ve = ((a * (v**2)) + (b * v) + c) print(ve) ve = (v**2) ve = (ve * a) xe = (b * v) ve = (ve + xe) ve = (ve + c) print(ve) WASD("st") WASD("r") turtle.setpos(v, ve) WASD("c") vor = input("another?") if (vor == "y"): v = input("What x value?") v = float(v) ve = ((a * (v**2)) + (b * v) + c) print(ve) WASD("st") turtle.pendown() turtle.setpos(v, ve) WASD("ht") input() else: print("OK") else: print("OK") else: s = 1 elif (ot == "How are you?"): print("I am good.") elif (ot == "lines n arrows"): WASD("st") wer = 0 while (wer < 5): WASD("a") wer = (wer + 1) WASD("r") lines_n_arrows() WASD("ht") WASD("r") elif (ot == "ps"): print(perfect_square(a)) elif (ot == "h. asymptote"): n = input("What is the degree of the numerator?") m = input("What is the degree of the denomonator?") if (n < m): print("The horizontal asymptote is at the x-axis.") elif (n == m): a = input("What is a?") b = input("What is b?") print("The horizontal assymtote is") print(a / b) else: print("There is no horizontal assymtote") elif (ot == "trivia"): fo = input("Who is the first compeditor?") ft = input("Who is the second compeditor?") trivia(fo, ft) WASD("r") WASD("ht") elif (ot == "you are a"): print("takes one to know one " + person + ".") elif (ot == "sq"): a = float(a) print(a**2) elif (ot == "dinner"): dinner() elif (ot == "sleep"): WASD("sleep") elif (ot == "2"): a = input("What is the A value?") b = (input("What is the B value?")) c = (input("What is the C Value?")) d = input("What is the d value?") a = int(a) b = int(b) c = int(c) c = (c - b) c = sqrt(c) c = (c / d) anso = (0 - a) anso = (anso + c) anst = (0 - c) anst = (anst - a) print("The answers are:") print(anso) print("and") print(anst) print("and") print(anst) elif (ot == "s.i. linear"): m = float(input("What is m?")) b = float(input("Whar is b?")) again = input("Wanna plug in a point") if (again == "y"): # y = mx + b x = float(input("What to plug in for x?")) y = (m * x) y = (y + b) WASD("st") WASD("r") turtle.setpos(x, y) WASD("c") print(y) again = input("another?") if (again == "y"): x = float(input("What to plug in for x?")) y = (m * x) y = (y + b) print(y) WASD("st") turtle.pendown() turtle.setpos(x, y) again = input("another?") if (again == "y"): x = float(input("What to plug in for x?")) y = (m * x) y = (y + b) print(y) WASD("st") turtle.pendown() turtle.setpos(x, y) again = input("another?") if (again == "y"): x = float(input("What to plug in for x?")) y = (m * x) y = (y + b) print(y) WASD("st") turtle.pendown() turtle.setpos(x, y) WASD("ht") input() elif (ot == "midpoint"): xo = int(input("What is x1?")) yo = int(input("What is y1?")) xt = int(input("What is x2?")) yt = int(input("What is y2?")) anso = (xo + xt) anso = (anso / 2) anst = float(yo + yt) anst = (anst / 2) print("The answer is ") print(anso) print(",") print(anst) elif (ot == "print"): prin = input() pri = input() pr = input() prin = float(prin) pri = float(pri) pr = float(pr) print(prin + pri + pr) elif (ot == "what to do"): doorator() elif (ot == "type"): inp = input() print(type(inp)) elif (ot == "pyg"): pyg() elif (ot == "sqrtfac"): ratfac2(a) elif (ot == "ratfac"): ratfac2(a) elif (ot == "isprime"): if (len(a) > 0): n = a n = int(n) b = (n + 1) for n in range(n, b): for x in range(2, n): n = int(n) if n % x == 0: x = int(x) y = (n // x) n = str(n) x = str(x) y = str(y) print(n + ' equals ' + x + '*' + y) break else: # loop fell through without finding a factor print(n, 'is a prime number') elif (ot == "lines n arrows"): lines_n_arrows() elif (ot == "document"): documents() elif (ot == "tp"): di = int(input("what is the diagonal?")) point = int(input("What is the pointy edge?")) bt = int( input( "What is the leg of the triangle adjasent to the pointy edge?" )) st = int(input("What is the other leg of the triangle?")) ans = (st * bt) answ = (di * point) answe = (bt * point) answer = (st * point) anso = (ans + answ + answe + answer) print(anso) elif (ot == ".1"): a = (input("What is the A value?")) b = ((input("What is the B value?"))) c = (input("What is the C Value?")) if (type(a) or type(b) or type(c) != float) and (len(a) and len(b) > 0): a = float(a) b = float(b) c = float(c) dis = str(b**2 - (4 * a * c)) print("The Discriminent is " + dis + ".") v = ((0 - b) / (2 * a)) d = v ve = ((a * (v**2)) + (b * d) + c) print("The axis of symmetry is:") print("x = ") print(v) print("The vertex is ") print(v) print(",") print(ve) anso = (0 - b) ansoer = (b**2 - (4 * a * c)) if (ansoer < 0): print("The answer is no solution") else: anso = (anso + sqrt(ansoer)) anso = (anso / (2 * a)) anst = (0 - b) anst = (anst - sqrt(b**2 - 4 * a * c)) anst = (anst / (2 * a)) print("The answers are:") print(anso) print("and") print(anst) anso = (0 - b) ansoer = (b**2 - (4 * a * c)) ansot = (0 - anso) ansto = (0 - anst) # print ("The factored form is:") # print ("(x + ") # print (ansot) # print (")") # print ("(x + ") # print(ansto) # print (")") qrs = input("do you want to plug in a point?") if (qrs == "y"): v = input("What x value?") v = float(v) ve = ((a * (v**2)) + (b * v) + c) print(ve) ve = (v**2) ve = (ve * a) xe = (b * v) ve = (ve + xe) ve = (ve + c) print(ve) vor = input("another?") if (vor == "y"): v = input("What x value?") v = float(v) ve = ((a * (v**2)) + (b * v) + c) print(ve) else: print("OK") else: print("OK") else: s = 1 elif (ot == "+"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = int(a) b = int(b) ans = (a + b) print(ans) else: print("invalid #") elif (ot == "thats wrong"): print("No way! I am always right!") elif (ot == "i like pi"): print("Really? so do I!") elif (ot == "no way!"): print("yes way!") elif (ot == "sin"): a = float(a) print(sin(a)) elif (ot == "tan"): a = float(a) print(tan(a)) elif (ot == "cos"): a = float(a) print(cos(a)) elif (ot == "hi"): name = print("Hello, " + person + ", i'm Alcal.") feeling = input("How are you?") feeling = feeling.lower() if (feeling == "good"): print("Happy to hear that, " + person + ".") elif (feeling == "not so good"): print("I hope you feel better soon.") else: print("I don't understand...") elif (ot == ".+"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = float(a) b = float(b) print(a + b) elif (ot == "*"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) if (len(a) and len(b) > 0): a = int(a) b = int(b) print(a * b) else: print("invalid #") elif (ot == "turtle"): q = 1 WASD("st") turtle.forward(1) while (q == 1): WASD(input()) q = WASD(input()) WASD("r") WASD("ht") #elif (ot == "*"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) # a = float(a) # b = float(b) # print (a * b) elif (ot == "shut down"): return (False) elif (ot == "/"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = int(a) b = int(b) print(a / b) elif (ot == "./"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) a = float(a) b = float(b) print(a / b) elif (ot == "factorial"): # a = (input("What factorial?")) if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = int(a) print(factorial(a)) else: print("invalid #") elif (ot == "porportion"): print( "This is the porportion solver #1. Use it only if the second numerator is the only x. (The equasion must look like this: #/# = x/#)" ) num = input("what is the first numerator?") deno = input("What is the first denomonator?") dent = input("What is the 2nd denomonator?") numb = (int(num) * int(dent)) ans = (int(numb) / int(deno)) print("x = " + str(ans)) elif (ot == "-"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = int(a) b = int(b) print(a - b) elif (ot == ".-"): # a = (input("What is the 1st #?")) # b = (input("What is the second #?")) a = float(a) b = float(b) print(a - b) elif (ot == "sqrt"): # a = input("What do you want to square root?") if (type(a) != "float"): a = int(a) print(sqrt(a)) else: print("invalad #") elif (ot == ".sqrt"): # a = input("What do you want to square root?") a = float(a) print(sqrt(a)) elif (ot == "finch"): if (finch == True): q = 1 while q == 1 and zAccel > -0.7: Finch() elif (ot == "**"): # a = input("What is the base?") # b = input("What is the exponent?") if (type(a) or type(b) != float) and (len(a) and len(b) > 0): a = int(a) b = int(b) print(a**b) elif (ot == "who am i?"): print("Why, you are " + person + " of course!") elif (ot == ".**"): # a = input("What is the base?") # b = input("What is the exponent?") a = float(a) b = float(b) print(a**b) elif (ot == "pledge"): print("I plege alligence") print("to the flag") print("of the United States of America") print("and to the republic") print("of which it stands") print("one nation") print("Under God") print("Indivisible") print("With liberty and justice for all.") elif (ot == "document1"): print("SubotomicOffice Character") # print ("Loading...") doc1 = input() print("document1 is " + doc1) ques = input("Woud you like to print that?") if (ques == "y"): print(doc1) else: print("OK") elif (ot == "document2"): print("SubotomicOffice Character") # print ("Loading...") doc2 = input() print("document2 is " + doc2) ques = input("Woud you like to print that?") if (ques == "y"): print(doc1) else: print("OK") elif (ot == "document3"): print("SubotomicOffice Character") # print ("Loading...") doc3 = input() print("document3 is " + doc3) ques = input("Woud you like to print that?") if (ques == "y"): print(doc3) else: print("OK") elif (ot == "dir math"): print(dir(math)) elif (ot == "dir turtle"): print(dir(turtle)) elif (ot == "distance"): xo = int(input("What is x1?")) yo = int(input("What is y1?")) xt = int(input("What is x2?")) yt = int(input("What is y2?")) ans = (xt - xo) ans = (ans**2) anst = (yt - yo) anst = (anst**2) anso = (ans + anst) ansto = (sqrt(anso)) print(ansto) print("or") anso = str(anso) print("the suare root of " + anso) # elif (ot == "sin"): # print sin(a) elif (ot == "slope"): xo = float(input("What is x1?")) yo = float(input("What is y1?")) xt = float(input("What is x2?")) yt = float(input("What is y2?")) slope = (yt - yo) slop = (xt - xo) ans = (slope / slop) print(ans) else: print("invalid answer for the type of equasion.") return (True)
'Yes.', 'Signs point to yes.', 'Reply hazy try again.', 'Ask again later.', 'Better not tell you now.', 'Cannot predict now.' 'Concentrate and ask again.', 'Don\'t count on it.', 'My reply is no.', 'My sources say no.', 'Outlook not so good.', 'Very doubtful.', ] # Always the first step: Create a Finch object we can use. tweety = Finch() # Tell the user how to use our program. print('I\'m a "Magic 8"-Finch!' '\n\nAsk me a question, shake me, and turn me upside down to get ' 'your answer.') # Create the variables we will use to track our state across multiple # executions of the loop: # Remember if we were upside down the last time the loop ran or not. We # want to print our answer the first moment we detect that the user # flipped us upside down. Then, we don't want to print another answer # until we can tell that the user has flipped us right-side up and then # upside down again. was_upside_down_before = False
# Test Script for Ultrasonic Range Finder Adjusting the wheel speed # (to be run on the SERVER/REMOTE PC) import socket from rpidatareceivetest import SocketReceive from finch import Finch from time import sleep import numpy as np # Before you begin this test script make sure you comment # out the test codes in all of the import python files sket = dataSocketSettings() #Instantiate the Finch object autopilotFinch = Finch() k = 0 while True: # just testing for 50 samples if (k == 50): break # receive ultrasonic range finder data from the raspberry pi d = dataReceiveSocket(sket, 1) # define the left, right wheel speeds leftWheel = d[0] rightWheel = d[1] # Before you send the instructions to the wheels, make sure that # they are converted into 0.1 -> 1.0 values