Over the next 10 patrols you and a partner will teach a VEX AIM robot to see. Drive it in any direction, spot balls, barrels and AprilTags with its AI Vision Sensor, move from Blocks to Python, and code it to deliver cargo on its own at the Delivery Dash.
Need to log into Minecraft Education, Canva, or any other app that asks you to sign in? Most school and app accounts use the same login: your username is [email protected] (add a number if your name needs one, e.g. firstname.lastname2), and your password is the same one you use to log into your school computer.
Every project has at least one thing to hand in. Log into connect.det.wa.edu.au with your firstname.lastname and computer password, then head to your class and open the Submission section. Handing in more than one file? Zip them together first - total size must stay under 50MB.
With a partner, teach a VEX AIM robot to see, chase and deliver cargo on its own, moving from Blocks to Python, and prove it at the Delivery Dash.
| Criteria | Rookie (0-1) |
Cadet (2-3) |
Agent (4) |
Squad Lead (5) |
Score |
|---|---|---|---|---|---|
| Coding | Programs copied without changes, or do not run | Blocks programs work, Python runs with help | Working Blocks and Python, with loops, if/else and functions used correctly | Code is clear, settings are named, and you can explain every line | / 5 |
| AI Vision | Vision not used | Robot reacts to a ball in view | Robot tracks a ball by bearing and finds the zone tag by ID | Robot tells delivered from new cargo and recovers when it sees nothing | / 5 |
| Testing & Tuning | No test results recorded | Some test results, at least one change made | Kick tests, approach tests and rehearsal runs logged, settings tuned with evidence | Every fix written as evidence, change and reason, and proven by a better run | / 5 |
| Dash & Teamwork | Did not run in the Delivery Dash, or very uneven teamwork | Ran in the Dash with help | Robot ran hands off, both partners coded and tested, feedback given | Reliable delivery on the day, calm fixes between runs, feedback acted on | / 5 |
| Total | / 20 | ||||
when started
move [forward] for (300) [mm] ▶
turn [right] for (90) degrees ▶
show [emoji_happy] looking [forward]
play sound [act happy] ▶
move at (angle) degrees, 0 is forward, 90 is right, 180 is backward and 270 is leftmove [forward] for (200) [mm] then turn [right] for (90) degreesmove at (0), (90), (180) and (270) degrees for (200) [mm]. Watch which way the screen faceswhen started
move at (45) degrees for (200) [mm] ▶
move at (135) degrees for (200) [mm] ▶
move at (225) degrees for (200) [mm] ▶
move at (315) degrees for (200) [mm] ▶
AI Vision [show] viewer on screen and watch the robot's screen as you move a ball and a barrel in front of it. Note how close and how far it still sees them[sports ball] to [blue barrel] and test again. What does the robot ignore now?when started
AI Vision [show] viewer on screen
wait (3) seconds
AI Vision [hide] viewer on screen
forever
get [sports ball] data from AI Vision
if <AI Vision object exists?> then
show [emoji_excited] looking [forward]
else
hide emoji
[blue barrel] is in view, play sound [act happy]. Now your robot reacts to two kinds of cargo.kick object [soft], [medium] or [hard], and place object to set it down gently<has [sports ball] ?> is true once the robot is holding a ballplace object as well. When would a delivery need place instead of kick?when started
forever
if <has [sports ball] ?> then
kick object [medium]
| Soft | Three distances, then the average |
| Medium | Three distances, then the average |
| Hard | Three distances, then the average |
| Place | Where does the ball end up? Just in front, or further? |
play sound [act happy] after the kick and make the robot show a different emoji for each kick strength you test.# Begin project code# Begin project code, select the sample line there and press Ctrl+V. Never select all: the folded Robot Configuration section at the top must stay. Then Run# Patrol a square, then celebrate
for side in range(4):
robot.move_for(300, 0)
robot.turn_for(RIGHT, 90)
robot.screen.show_emoji(HAPPY)
robot.sound.play(CHEER)
# Excited face while a sports ball is in view
robot.screen.show_aivision()
wait(2, SECONDS)
robot.screen.hide_aivision()
while True:
ball = robot.vision.get_data(SPORTS_BALL)
if ball and ball[0].exists:
robot.screen.show_emoji(EXCITED)
else:
robot.screen.show_emoji(THINKING)
wait(100, MSEC)
| move for | robot.move_for(300, 0): distance in mm, then angle |
| turn for | robot.turn_for(RIGHT, 90) |
| get data | robot.vision.get_data(SPORTS_BALL) gives a list of what it sees, biggest first |
| if / else | A colon at the end, and the lines inside are indented 4 spaces |
robot.has_sports_ball() is true# Begin project code, select the sample line there and press Ctrl+V. Never select all: the folded Robot Configuration section at the top must stay. Then Runrobot.move_at(0, 30) to a higher speed. Does it still catch the ball, or overshoot it?# Turn to face a sports ball, then drive to it
robot.set_turn_velocity(40)
while not robot.has_sports_ball():
ball = robot.vision.get_data(SPORTS_BALL)
if ball and ball[0].exists:
if ball[0].bearing > 5:
robot.turn(RIGHT)
elif ball[0].bearing < -5:
robot.turn(LEFT)
else:
robot.move_at(0, 30)
else:
robot.turn(RIGHT)
wait(50, MSEC)
robot.stop_all_movement()
robot.screen.show_emoji(EXCITED)
SPORTS_BALL to BLUE_BARREL and robot.has_sports_ball() to robot.has_blue_barrel(). Test it.robot.vision.tag_detection(True) then robot.screen.show_aivision(), and hold the tag in front of the robot. The viewer shows its IDZONE_TAG to that ID. Then paste and run it: the robot turns until it sees the tag, centres it, and drives until the tag looks big enoughSTOP_WIDTH: if the robot stops too far away, raise it. If it bumps the wall, lower it. Record each number you trydef zone_tag():. That is a function: a named set of steps you can use again# Find your zone's AprilTag and drive up to it
ZONE_TAG = 1 # the ID of your zone tag
STOP_WIDTH = 80 # tag width when you are close: tune it
def zone_tag():
for tag in robot.vision.get_data(ALL_TAGS):
if tag.exists and tag.id == ZONE_TAG:
return tag
return None
robot.vision.tag_detection(True)
robot.set_turn_velocity(30)
while True:
tag = zone_tag()
if tag is None:
robot.turn(RIGHT)
elif tag.width >= STOP_WIDTH:
break
elif tag.bearing > 5:
robot.turn(RIGHT)
elif tag.bearing < -5:
robot.turn(LEFT)
else:
robot.move_at(0, 30)
wait(50, MSEC)
robot.stop_all_movement()
robot.screen.print("Zone reached")
robot.screen.print(tag.width) while you drive it closer by hand. Use the numbers to choose STOP_WIDTH.pick_ball, get_ball, go_to_zone and deliverpick_ball skips any ball sitting at the zone, so the robot never fetches a ball it already delivered. get_ball turns exactly by the bearing with turn_for, which stops it wobbling between two ballsZONE_TAG and your tuned STOP_WIDTH, and set TRIPS to the number of balls on your field. Paste and run it on a full field# Delivery loop: fetch a ball, take it to the zone, place it
ZONE_TAG = 1 # the ID of your zone tag
STOP_WIDTH = 80 # tag width when you are close: tune it
TRIPS = 3 # how many balls to deliver
NEAR_RATIO = 2 # ball this close to tag size = delivered: tune it
SCAN_STEP = 20 # degrees to turn when nothing is worth fetching
def zone_tag():
for tag in robot.vision.get_data(ALL_TAGS):
if tag.exists and tag.id == ZONE_TAG:
return tag
return None
def pick_ball():
# skip balls sitting at the zone: already delivered
tag = zone_tag()
for ball in robot.vision.get_data(SPORTS_BALL):
if not ball.exists:
continue
if tag is None:
return ball
in_line = abs(ball.bearing - tag.bearing) < 20
at_zone = ball.width < tag.width * NEAR_RATIO
if not (in_line and at_zone):
return ball
return None
def get_ball():
while not robot.has_sports_ball():
ball = pick_ball()
if ball is None:
robot.turn_for(RIGHT, SCAN_STEP)
elif ball.bearing > 5:
robot.turn_for(RIGHT, ball.bearing)
elif ball.bearing < -5:
robot.turn_for(LEFT, -ball.bearing)
else:
robot.move_at(0, 30)
wait(50, MSEC)
robot.stop_all_movement()
def go_to_zone():
while True:
tag = zone_tag()
if tag is None:
robot.turn(RIGHT)
elif tag.width >= STOP_WIDTH:
break
elif tag.bearing > 5:
robot.turn(RIGHT)
elif tag.bearing < -5:
robot.turn(LEFT)
else:
robot.move_at(0, 30)
wait(50, MSEC)
robot.stop_all_movement()
def deliver():
robot.kicker.place()
robot.move_for(300, 180)
robot.turn_for(RIGHT, 180)
robot.vision.tag_detection(True)
robot.set_turn_velocity(40)
for trip in range(TRIPS):
get_ball()
go_to_zone()
deliver()
robot.screen.show_emoji(HAPPY)
robot.sound.play(CHEER)
TRIPS to 5 on a field with 5 balls. Does it still deliver every one? Which setting did you have to change?STOP_WIDTH (how close to the zone), NEAR_RATIO (what counts as already delivered) and SCAN_STEP (how far it turns when it sees nothing worth fetching)| STOP_WIDTH | Raise it if the robot places the ball short of the zone. Lower it if it hits the wall |
| NEAR_RATIO | Raise it if the robot goes back for delivered balls. Lower it if it ignores balls near the zone |
| SCAN_STEP | Lower it if the robot turns past balls without seeing them |
| TRIPS | The number of balls on the field |
ZONE_TAG and TRIPSAfter 10 patrols of driving, seeing, coding and tuning, your robot runs on its own for 90 seconds, finding balls and delivering them to the zone. Two runs, best one counts, then the class votes for the awards.
Power on, then connect // Patrol 01