def addGyro(serverChannel): global msg, startingX, startingY while True: dataVals = compileData() # print(dataVals) x = float(dataVals[0]) y = float(dataVals[1]) yaw = float(dataVals[2]) msg["gyroX"] = x # - startingX msg["gyroY"] = y #- startingY msg["yaw"] = yaw - startingYaw
#sets up the ultrasonic sensors # TRIG = 11 #18 # ECHO = 12 #17 TRIG = 13 ECHO = 7 GPIO.setup(TRIG, GPIO.OUT) GPIO.output(TRIG, 0) GPIO.setup(ECHO, GPIO.IN) #this is the initial starting position of the copter. I implement this #because the gyroscope doesn't read the rest position as perfectly 0,0 #so this basically can account for any slight error in the gyro readings startingGyroValues = compileData() startingX = startingGyroValues[0] startingY = startingGyroValues[1] startingYaw = startingGyroValues[2] print('start', startingX, startingY) #################################### # Initializing global data structures #################################### keyInputs = { "w": False, "s": False, "d": False, "a": False, "u": False,
#sets up the ultrasonic sensors # TRIG = 11 #18 # ECHO = 12 #17 TRIG = 13 ECHO = 7 GPIO.setup(TRIG, GPIO.OUT) GPIO.output(TRIG, 0) GPIO.setup(ECHO, GPIO.IN) #this is the initial starting position of the copter. I implement this #because the gyroscope doesn't read the rest position as perfectly 0,0 #so this basically can account for any slight error in the gyro readings startingGyroValues = compileData() startingX = startingGyroValues[0] startingY = startingGyroValues[1] startingYaw = startingGyroValues[2] print('start', startingX, startingY) #################################### # Initializing global data structures #################################### keyInputs = {"w": False, "s": False, "d": False, "a": False, "u":False, "e":False, "r": False, "l": False, "g": True} msg = {"distance": 0, "ail": 0, "ele": 0, "thr": 0, "rud": 0, "gyroX": 0, "gyroY": 0, "yaw":0}