Home
// Digital Technology - Year 9 & 10 //

AIM VISION
SQUAD

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.

🤖 VEX AIM
👁️ AI Vision
🐍 Python Code
🏁 Delivery Dash
Squad Kit
💻
VEXcode AIM
Open codeaim.vex.com in Chrome or Edge. Blocks first, then File, then New Python Project from Patrol 05. Connect with the Robot menu: Connect via Bluetooth or Connect via USB.
🤖
The Robot
VEX AIM: omni drive (moves in any direction without turning), a kicker (kick soft, medium or hard, or place) and an AI Vision Sensor that recognises sports balls, blue and orange barrels, other AIM robots and AprilTags.
🟩
The Fields
12 robots, one per pair, and 6 walled fields, so two pairs share a field and take turns. Each field has balls, barrels and a zone AprilTag on its wall.
⚠ Nobody lifts or touches a robot while its program is running.
💾
Saving
File, then Save, into your Desktop or Downloads (they follow you to any laptop). Blocks projects save as .aimblocks and Python as .aimpython. Next lesson: File, then Open.
🧠
AI Assistant
copilot.microsoft.com - ask it to explain a line of Python, or why your robot does something odd. The VEX AIM Python reference has every command.
⚠ AI often invents robot commands - only use commands from the VEX reference or this page!
🏁
Delivery Dash
On the final day your robot runs on its own for 90 seconds, finding balls and delivering them to the zone. Two runs, best one counts. Then vote: Fastest Delivery, Smartest Code, Most Reliable and People's Choice.
// Primary Objective

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.

Drive with omni movement, angles and distances in Blocks
See balls, barrels and AprilTags with the AI Vision Sensor
Code an autonomous delivery loop in Python with functions
Tune your settings with evidence and run the Delivery Dash
// Marking Key & Rubric
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
Scroll sideways to see every column
Patrol Log
Week 1
01
🤖 Meet AIM
▾
// PATROL OBJECTIVERobot connected to VEXcode AIM, a first Blocks program that moves, turns, shows an emoji and plays a sound, and the project saved to your Desktop or Downloads.
  • Meet the squad: in pairs you will program a VEX AIM robot that sees with its AI Vision Sensor, then teach it to deliver cargo on its own for the Delivery Dash
  • Field rules: robots stay on the field, two pairs share a field and take turns, and nobody lifts a robot while a program is running
  • Press the power button on the back of the robot. Open codeaim.vex.com in Chrome or Edge. It opens a new Blocks project
  • Click the Robot menu at the top right and choose Connect via Bluetooth (or plug in the USB-C cable and choose Connect via USB). The robot icon turns green when it is connected
  • Build the program below from the Motion, Emoji and Sound blocks, then press Run. Change the numbers and run it again
  • Save it: File, then Save, into your Desktop or Downloads (they follow you to any laptop). Next lesson, File, then Open
// Blocks: first moves (build it, no Copy)
when started
move [forward] for (300) [mm] ▶
turn [right] for (90) degrees ▶
show [emoji_happy] looking [forward]
play sound [act happy] ▶
💡 HintIf the robot will not connect, check it is switched on and that you picked your own robot's name from the list. Once paired, the list shows Paired next to it.
🔍 Google Image Search"vex aim coding robot ai vision"
// ASK AI"What is an AI Vision Sensor and how can a robot use a camera to recognise objects?"
02
🧭 Any Direction
▾
// PATROL OBJECTIVEA square driven two ways (turning and strafing), a diamond driven without turning once, and your angle table (0, 90, 180, 270) written down.
  • AIM has omni drive: it can move in any direction without turning. In move at (angle) degrees, 0 is forward, 90 is right, 180 is backward and 270 is left
  • Drive a square the turning way: repeat 4 times move [forward] for (200) [mm] then turn [right] for (90) degrees
  • Drive the same square the strafing way: move at (0), (90), (180) and (270) degrees for (200) [mm]. Watch which way the screen faces
  • Build the diamond below. It never turns, but it ends where it started
  • Write an angle table in your notes: forward, right, backward, left, and the four diagonals
  • Save your project
// Blocks: diamond without turning (build it, no Copy)
when 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] ▶
💡 HintPut a sticky note on the floor at the start. A closed shape should finish right back on it. If it drifts, slow it down with set move velocity to (30)%.
// ASK AI"How do omni wheels let a robot drive sideways without turning?"
// LEVEL UPDrive a hexagon without turning: six moves of the same distance, each 60 degrees apart (0, 60, 120, 180, 240, 300). Does it close?
Week 2
03
👁️ Eyes On
▾
// PATROL OBJECTIVEThe AI Vision viewer used to watch the robot detect cargo, and a Blocks program whose face changes when a sports ball is in view.
  • AI Vision: the sensor sees a 320 x 240 pixel picture and recognises sports balls, blue barrels, orange barrels, other AIM robots and AprilTags
  • Use 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
  • Every detected object has data: centerX (0 is the left edge, 160 the middle, 320 the right), width (bigger means closer) and more
  • Build the program below. The face shows excited while a ball is in view and hides when it is not. Test it with a ball, a barrel and nothing
  • Change [sports ball] to [blue barrel] and test again. What does the robot ignore now?
  • Save your project
// Blocks: ball spotter (build it, no Copy)
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
💡 HintThe viewer covers the whole screen, so the program hides it before it starts showing faces.
// ASK AI"How does an object detection camera decide that something is a ball and not a barrel?"
// LEVEL UPAdd a second if: when a [blue barrel] is in view, play sound [act happy]. Now your robot reacts to two kinds of cargo.
04
⚽ Kick & Place
▾
// PATROL OBJECTIVEA Blocks program that kicks or places a ball once the robot has it, and soft, medium and hard kicks each measured three times.
  • The kicker pushes cargo out: kick object [soft], [medium] or [hard], and place object to set it down gently
  • The robot can tell when it is holding something: <has [sports ball] ?> is true once the robot is holding a ball
  • Build the program below, run it, and roll a ball into the front of the robot
  • Kick test: kick a ball soft, medium and hard, three times each. Mark where it stops with a sticky note and measure the distance with a ruler. Record every result
  • Try place object as well. When would a delivery need place instead of kick?
  • Save your project
// Blocks: kick when holding a ball (build it, no Copy)
when started
forever
    if <has [sports ball] ?> then
        kick object [medium]
⚽ Kick Test Table
SoftThree distances, then the average
MediumThree distances, then the average
HardThree distances, then the average
PlaceWhere does the ball end up? Just in front, or further?
💡 HintThe same kick will not land in exactly the same spot every time. Three tries and an average is a fairer answer than one lucky kick.
🔍 Google Image Search"robot kicker mechanism sports ball"
// ASK AI"Why do engineers repeat a test three times and take the average?"
// LEVEL UPAdd play sound [act happy] after the kick and make the robot show a different emoji for each kick strength you test.
Week 3
05
🐍 Switch to Python
▾
// PATROL OBJECTIVEThe square and the ball spotter rebuilt in Python, pasted under the Begin project code line, run, and saved as a Python project.
  • Same robot, new language. Python is typed code, and every Blocks idea you have used has a Python twin
  • In VEXcode AIM: File, then New Python Project. At the top is a folded Robot Configuration section, then a line that says # Begin project code
  • In VEXcode AIM: File, then New Python Project. Click Copy below, then click in the editor under the line # 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
  • Run the square below, then the ball spotter. Compare each line with the Blocks you built
  • Save it as a Python project: File, then Save, into your Desktop or Downloads
// Python: square patrol
# 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)
// Python: ball spotter
# 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)
🐍 Blocks to Python
move forrobot.move_for(300, 0): distance in mm, then angle
turn forrobot.turn_for(RIGHT, 90)
get datarobot.vision.get_data(SPORTS_BALL) gives a list of what it sees, biggest first
if / elseA colon at the end, and the lines inside are indented 4 spaces
💡 HintPython cares about spaces. Every line inside a for, while or if must be indented the same amount, or the program will not run.
🔍 Google Image Search"python code indentation example"
// ASK AI"Explain this Python line by line for a beginner: for side in range(4): robot.move_for(300, 0)"
📤 Submit via ConnectYour square and spotter Python projects (.aimpython)
// LEVEL UPChange the square into a hexagon: 6 sides and turns of 60 degrees. Does it finish where it started?
06
🎯 Track & Approach
▾
// PATROL OBJECTIVEA Python program that turns until a sports ball is centred, drives to it and stops once the robot has it, tested from three starts.
  • Each detected object has a bearing: how many degrees it is left or right of the centre of the view. 0 is dead ahead, positive is to the right, negative is to the left
  • The program below turns towards the ball until its bearing is between -5 and 5, then drives forward until robot.has_sports_ball() is true
  • In VEXcode AIM: File, then New Python Project. Click Copy below, then click in the editor under the line # 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
  • Test from three starts: ball straight ahead, ball off to the left, ball behind the robot. Record whether it got the ball each time
  • Change robot.move_at(0, 30) to a higher speed. Does it still catch the ball, or overshoot it?
// Python: track and approach a ball
# 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)
💡 HintNo ball in view? The robot keeps turning right until it finds one. That is a search, and every delivery robot needs one.
// ASK AI"Why does this robot code turn right when the bearing is positive and left when it is negative?"
📤 Submit via ConnectYour approach program (.aimpython) and your three-start test results
// LEVEL UPFetch a blue barrel instead: change every SPORTS_BALL to BLUE_BARREL and robot.has_sports_ball() to robot.has_blue_barrel(). Test it.
Week 4
07
🏷️ AprilTag Targets
▾
// PATROL OBJECTIVEYour zone tag's ID found, and a Python program that finds that AprilTag and stops close in front of it, tuned on your field.
  • An AprilTag is a black and white square with an ID number the robot can read. Your teacher puts one on a wall of each field to mark the delivery zone
  • Find your zone tag's ID: run robot.vision.tag_detection(True) then robot.screen.show_aivision(), and hold the tag in front of the robot. The viewer shows its ID
  • In the program below set ZONE_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 enough
  • Tune STOP_WIDTH: if the robot stops too far away, raise it. If it bumps the wall, lower it. Record each number you try
  • Notice def zone_tag():. That is a function: a named set of steps you can use again
// Python: drive to your zone tag
# 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")
💡 HintOther tags on the field have different IDs. The function checks the ID, so the robot ignores every tag except yours.
🔍 Google Image Search"apriltag robot navigation marker"
// ASK AI"What is an AprilTag and why do robots use them to find places?"
// LEVEL UPMake the robot print the tag's width on its screen every loop with robot.screen.print(tag.width) while you drive it closer by hand. Use the numbers to choose STOP_WIDTH.
08
🔁 Delivery Loop
▾
// PATROL OBJECTIVEOne Python program that fetches a ball, takes it to the zone, places it and repeats, built from functions and tested on a full field.
  • Put it together: one program that fetches a ball, takes it to the zone, places it, and repeats
  • Read the four functions in the program below before you run it: pick_ball, get_ball, go_to_zone and deliver
  • pick_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 balls
  • Set ZONE_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
  • Record each run: balls delivered, time taken, and where it went wrong
// Python: the delivery loop
# 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)
💡 HintTest one function at a time. Comment out the loop and call just get_ball() first. Once that works every time, add go_to_zone(), then deliver().
// ASK AI"Explain what each function in this robot delivery program does, in one sentence each"
📤 Submit via ConnectYour delivery loop (.aimpython) and your run results
// LEVEL UPSet TRIPS to 5 on a field with 5 balls. Does it still deliver every one? Which setting did you have to change?
Week 5
09
⏱️ Dash Rehearsal
▾
// PATROL OBJECTIVEThree timed rehearsal runs logged, your three settings tuned with evidence, and a fix written up as evidence, change and reason.
  • Do three timed rehearsal runs on a full field, hands off from the moment you press Run
  • Log each run: balls delivered, time, and the moment anything went wrong
  • Tune your three settings with evidence: 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)
  • Write your biggest fix as evidence, change, reason
  • Swap with the other pair on your field and watch each other's run. Give one specific suggestion
⏱️ Settings to Tune
STOP_WIDTHRaise it if the robot places the ball short of the zone. Lower it if it hits the wall
NEAR_RATIORaise it if the robot goes back for delivered balls. Lower it if it ignores balls near the zone
SCAN_STEPLower it if the robot turns past balls without seeing them
TRIPSThe number of balls on the field
💡 HintChange one setting at a time and do a full run after each change. Change three at once and you will never know which one helped.
// ASK AI"How should a team decide which robot setting to change first after a failed test run?"
📤 Submit via ConnectYour rehearsal log and your evidence, change, reason fix
10
🏁 Delivery Dash
▾
// PATROL OBJECTIVEYour robot's two Delivery Dash runs completed hands off, scores recorded, and your Python file and reflection submitted.
  • Set up: zone tag on the wall, balls on their marked spots, your robot in the start corner facing the field. Open your final program, connect, and check ZONE_TAG and TRIPS
  • Rules: 90 seconds, hands off once you press Run. 2 points for each ball in the zone when time is up. Touch the robot and the run ends there
  • Each pair gets two runs. Your best run counts
  • Between runs you may change settings, but not the field
  • The class votes: Fastest Delivery, Smartest Code, Most Reliable and People's Choice
  • Write your reflection: what your code did well, what failed and why, and what you would change with more time
  • Submit your final .aimpython file and your reflection
💡 HintBreathe and check the basics before Run: the right program open and connected, the robot in the start corner, ZONE_TAG set to your field's tag.
// ASK AI"Help me write a short reflection about programming an autonomous robot with computer vision"
📤 Submit via ConnectYour final Python project (.aimpython) and your reflection
🏁

The Delivery Dash Awaits

After 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.

🤖 Fully autonomous
⏱️ 90 second runs
🏆 Four titles to win

Power on, then connect // Patrol 01

SYSTEM ONLINE // YEAR 9 & 10 DIGITAL TECHNOLOGY AIM SQUAD // 10 PATROLS