Last active
April 19, 2019 11:28
-
-
Save pteacher/10df620dc58c745aa7900b6b7155faee to your computer and use it in GitHub Desktop.
An autonomous system for Drone Competition on AgroBum Robotics Olympiad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# VEX IQ Python-Project | |
import sys | |
import vexiq | |
#region config | |
bumper_1 = vexiq.Bumper(1) | |
touch_led_2 = vexiq.TouchLed(2) | |
bumper_3 = vexiq.Bumper(3) | |
bumper_4 = vexiq.Bumper(4) | |
distance_9 = vexiq.DistanceSensor(9, vexiq.UNIT_CM) | |
touch_led_10 = vexiq.TouchLed(10) | |
motor_11 = vexiq.Motor(11) | |
joystick = vexiq.Joystick() | |
#endregion config | |
touch_led_2.off() | |
touch_led_10.off() | |
hover_ok = False | |
hover_time = 0 | |
while True: | |
if bumper_1.is_pressed() and bumper_3.is_pressed() or bumper_1.is_pressed() and bumper_4.is_pressed(): | |
touch_led_2.color(0, 100, 0) | |
elif bumper_3.is_pressed() or bumper_4.is_pressed(): | |
touch_led_2.color(100, 0, 0) | |
sys.sleep(2) | |
motor_11.run_to_position(60, 90) | |
sys.sleep(2) | |
motor_11.run_to_position(60, 0) | |
if joystick.bEdown(): | |
touch_led_2.off() | |
touch_led_10.off() | |
vexiq.lcd_write(distance_9.distance(), 1) | |
#vexiq.lcd_write(distance_12.distance(), 2) | |
if 45 >= distance_9.distance() >= 20: | |
if hover_ok is False: | |
hover_time = sys.clock() | |
hover_ok = True | |
else: | |
hover_ok = False | |
if hover_ok is True: | |
if (sys.clock() - hover_time < 3 and sys.clock() - hover_time >= 1): | |
touch_led_10.color(100, 0, 0) | |
elif (sys.clock() - hover_time < 5 and sys.clock() - hover_time >= 3): | |
touch_led_10.color(0, 0, 100) | |
elif (sys.clock() - hover_time >= 5): | |
touch_led_10.color(0, 100, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment