Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def reset_motors():
- m1.off()
- m2.off()
- m4.off()
- def color_map():
- if c_exists:
- if c.value() > 1:
- return "White"
- else:
- return "Black"
- else:
- return "No reading"
- def move_and_scan():
- c.mode='COL-COLOR'
- i = 0; cols = []
- while len(cols) != 4:
- reset_motors()
- time.sleep(0.5)
- cols.append(color_map())
- if len(cols) == 4:
- break
- m1.on(-3)
- m2.on(-3)
- time.sleep(0.7)
- reset_motors()
- print(cols)
- def iGPS_math(a, c, d):
- """Returns the x and y coordinates relative to
- the origin, given radial distances a, b, and d"""
- C_TO_A = 120 # the absolute distance between tower C and tower A
- C_TO_D = 96 # the absolute distance between tower C and tower D
- _theta = law_of_cosines(a,C_TO_A,c)
- _lambda = law_of_cosines(d,C_TO_D,c)
- print(_lambda)
- x = (math.sin(_theta) * a) + 6
- y = 108 - math.sin(_lambda) * d + 6
- return x, y
- def iGPS():
- a = float(input("[a?]>"))
- c = float(input("[c?]>"))
- d = float(input("[d?]>"))
- loc = iGPS_math(a,c,d)
- print("x: {}, y: {}".format(loc[0], loc[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement