reefboy1
Feb 15, 2015 - 17:10
I'm trying to make a little flight simulator and I was wondering with motion.get_aditude() I. Old make an if statement to make the lane go up down or turn. Is this possible? If so, how?
I'm trying to make a little flight simulator and I was wondering with motion.get_aditude() I. Old make an if statement to make the lane go up down or turn. Is this possible? If so, how?
import motion
reload(motion) # make sure pitch is reset to zero
print('''Pythonista's motion.get_attitude() function provides access to the
roll, pitch, and yaw of your device. This script uses only the pitch
and it will run until you tip up your device enough...''')
desired_pitch = int(raw_input('\nEnter pitch angle between 1 and 90: ')) or 45
fmt = 'Desired pitch must be between 1 and 90 (default: 45): {}'
assert 1 <= desired_pitch <= 90, fmt.format(desired_pitch)
fmt = 'OK, tilt your device so its pitch is equal to more than {}.'
print(fmt.format(desired_pitch))
previous_pitch = pitch = -370 # start with an impossible angle
motion.start_updates()
while pitch < desired_pitch:
pitch = float(motion.get_attitude()[1]) * 90
if previous_pitch != int(pitch):
previous_pitch = int(pitch)
print('pitch: {}'.format(pitch))
motion.stop_updates()
Ok thanks! This is really helpful!