if accumulatedOffset270 > 270: accumulatedOffset270 = (270 - accumulatedOffset270) * -1 # → subtract this offset from the animal's heading in a 270° world animal_heading_270 = animal_heading_360 * (270 / 360) current_bar_pos_270 = animal_heading_270 # → to get the corresponding xpos voltage, normalize to 10V and then subtract from 10V # so that the bar moves opposite of the fly's change in heading - i.e. the bar moves # in the same direction as the ball. xout = (current_bar_pos_270 / 270) * 10 xout = 10 - xout # wrap xpos command if it's out of range if xout > 10: xout = (10 - xout) * -1 elif xout < 0: xout = 10 - (xout * -1) # send outputs to Phidget aout_yposcmd.setVoltage(10.0) aout_xposcmd.setVoltage(xout) aout_animalheading360.setVoltage(flyheading) aout_runSpeed.setVoltage(scaled_runSpeed) # When finished, close the outputs (this sets voltages to 0) aout_runSpeed.close() aout_animalheading360.close() aout_xposcmd.close() aout_yposcmd.close()
def endheatersignal(): voltageOutput0 = VoltageOutput() voltageOutput0.close()