Skip to content

Instantly share code, notes, and snippets.

@pteacher
Last active April 19, 2019 11:38
Show Gist options
  • Save pteacher/10d461a0bff2fc19585d761db5d4cc9f to your computer and use it in GitHub Desktop.
Save pteacher/10d461a0bff2fc19585d761db5d4cc9f to your computer and use it in GitHub Desktop.
AgroBot for AgroBum olympiad Drone section task. Moves on snake like trajectory so drone should follow the same, but flying right above this robot.
# Python-проект для VEX IQ
import sys
import vexiq
#region config
motor_1 = vexiq.Motor(1)
distance_2 = vexiq.DistanceSensor(2, vexiq.UNIT_CM)
bumper_5 = vexiq.Bumper(5)
motor_6 = vexiq.Motor(6, True) # реверс
touch_led_7 = vexiq.TouchLed(7)
import drivetrain
dt = drivetrain.Drivetrain(motor_1, motor_6, 194, 165)
#endregion config
pts = 0
distance_per_row = 1000
row_width = 250
job_is_over = False
def check_pos():
global pts
global job_is_over
while not job_is_over:
if distance_2.distance() < 80:
pts+=1
vexiq.lcd_write(pts, 1)
if pts > 1000 and pts < 2000:
touch_led_7.color(100, 0, 0)
elif pts >= 2000 and pts < 3000:
touch_led_7.color(0, 0, 100)
elif pts >= 3000:
touch_led_7.color(0, 100, 0)
while True:
while not bumper_5.is_pressed():
pass
sys.sleep(3)
sys.run_in_thread(check_pos)
dt.drive_until(30, distance_per_row)
dt.turn_until(60, 94)
dt.drive_until(30, row_width)
dt.turn_until(60, 94)
dt.drive_until(30, distance_per_row)
dt.turn_until(60, -96)
dt.drive_until(30, row_width)
dt.turn_until(60, -96)
dt.drive_until(30, distance_per_row)
job_is_over = True
sys.sleep(5)
dt.drive_until(-80, distance_per_row)
dt.turn_until(60, 94)
dt.drive_until(-80, row_width * 1.7)
dt.turn_until(60, -96)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment