For a teacher with a class? The classroom edition has the full plan, slides and standards.

Homeschooling PDF

Family edition

Robot Soccer Lab: Read the Ring, Adding Sensor Readings as Vectors

Ages 14-18 ยท about 45 minutes, in one sitting

In Robot Soccer Lab your child adds a soccer robot's sensor readings as vectors, the way the robot finds the ball.

What you need

Before you start: try it once yourself

Open mytekdev.com/try/robotsoccerlab?lesson=read-the-ring-adding-sensor-readings-as-vectors&ref=fam-robotsoccerlab-3. A short guide opens over Level 7, Read the ring, with the program in the Python tab. The field is in the middle: green carpet, white lines, the yellow goal (the robot's own) and the blue goal it attacks. The red robot is round, with an arrow on top for its front, and the orange ball glows so the robot can find it. The box on the field says the level's goal and, after each run, what happened and why. The readings beside it show the ball clock, the heading, the speed and how far away the ball is.

  1. The ring. Sixteen receivers, receiver 1 facing straight ahead and the rest every 22.5 degrees clockwise. robot.sensors() is the list of readings, robot.ball_strength() the biggest, and robot.ball_angle() the direction of all of them added as vectors. Each reading falls with distance and with how far the receiver faces away from the ball; one facing more than 90 degrees away reads 0 (plus a little noise).
  2. The rays. Robot, Show the receivers' rays (or the box under the readings) draws each reading as a red line from the robot in its receiver's direction.
  3. The program. It prints the brightest receiver's direction (its place in the list times 22.5), the summed direction and the strength, before moving. Then it drives at the summed direction at speed 40 and stops when the strength reaches 95. The box on the field gives the distance at each stop.
  4. Speed. Each level starts in real time. Speed up and Slower, under the field, change the speed; the round play button starts the level again from the beginning, with the program as it is now. Each press of play takes the next seed for the receivers' small noise, so times can differ by a few hundredths of a second between runs.
  5. Numbers to expect. The print line: brightest 45.0, sum about 51 (51.0 to 51.9 between runs), strength about 38. The ball is truly at 51.3 degrees, 64 cm away center to center. Threshold 95: bumps the ball at 1.3 s. 90: usually bumps it. 85: it stops about 5 cm away, at the near edge, and time runs out with 1 of 3. 80: passes, 8 to 10 cm. 75: passes, 12 to 13 cm. 70: passes, 16 to 17 cm. 65: it stops 20 to 21 cm away, at the far edge, and time runs out with 0 or 1. 60 and 50: time runs out, 0 of 3.
The worksheet's eight readings are the model's values at the start with the noise taken out, so every child gets the same answer: 23.7, 33.2, 37.6, 36.4, 29.6, 18.3 and 4.2 for receivers 1 to 7, and 10.5 for receiver 16 (at 337.5 degrees). The other eight read 0. Their sum points at 51.4 degrees with magnitude 151.5. A child's own printed readings differ in the first decimal.

The ideas, in plain words

Robots built for junior robot soccer find the ball with a ring of infrared receivers. The simple way is to take the brightest receiver, which says where the ball is only to the nearest receiver. Real teams add the readings as vectors: each receiver contributes an arrow in its own direction as long as its reading, and the resultant points between receivers, at the ball. The app's ball_angle() is that sum. The field and rules are modeled on the RoboCupJunior Soccer rules; the app is not affiliated with or endorsed by the RoboCup Federation.

The strongest reading grows as the ball gets closer, roughly: in the app it is 100 / (1 + d squared / 0.25) for a receiver facing the ball squarely, with d the distance between centers in meters. It is a rough distance sensor, which is why the lesson finds a working threshold by testing.

Robot soccer has led to real companies: Raffaello D'Andrea, who coached Cornell's robot soccer team, went on to co-found Kiva Systems, whose warehouse robots Amazon bought in 2012. Robotics, mechanical, electrical and software engineers all work on robots like these.

Do it together

  1. Open mytekdev.com/try/robotsoccerlab?lesson=read-the-ring-adding-sensor-readings-as-vectors&ref=fam-robotsoccerlab-3, tick Show the receivers' rays under the readings, and press play. Read the line that starts print:.

    You'll know it worked when: About "brightest: 45.0 sum: 51.3 strength: 37.9". Then the robot bumps the ball.

  2. Add two readings as vectors: 37.6 at 45 degrees and 36.4 at 67.5 degrees. Right part = reading x sin(angle), forward part = reading x cos(angle).

    You'll know it worked when: Right 60.2, forward 40.5: length about 72.6, direction about 56 degrees.

  3. Add all eight from the worksheet the same way, and compare the direction with the print: line.

    You'll know it worked when: About 51.4 degrees and length 151.5, while the readings themselves add up to 193.5.

  4. Open Python, change 95 to 75, go back to Simulator and press play.

    You'll know it worked when: The robot stops 12 to 13 cm from each of the three balls.

  5. Try 85, 80, 70 and 65, and write how far it stops each time.

    You'll know it worked when: 80 stops about 9 cm away, 70 about 17 cm; 85 stops about 5 cm away, too close to count every time, and 65 about 21 cm, just too far.

Talk about it

Ask these while you work together. A child who has understood it can answer them without help:

The third question is the one that matters. A child who says "receivers 3 and 4 read almost the same, so their arrows pull the sum between them" understands the resultant. A child who says "the program says 51" has the result but not the idea.

For younger and older kids

Younger: For a younger child, draw the arrows tip to tail on graph paper and measure the sum with a ruler.

Older: For an older child, write the sum in Python with import math and compare it with robot.ball_angle().

Keep going

Bring it into other subjects

For your records

Ready to copy into an hour log, a portfolio or a transcript.

LessonRobot Soccer Lab: Read the Ring, Adding Sensor Readings as Vectors
SubjectsMath
Time45 minutes
What we didAdded a robot's 16 sensor readings as vectors by components, compared the sum with the largest reading, and chose a sensor threshold from test runs.
Skills practicedAdding vectors by components; Magnitude and direction; Testing values

Robot Soccer Lab: Read the Ring, Adding Sensor Readings as Vectors

Activity sheet (optional)

Name: ______________________________ Date: ______________

Open the app: scan the QR code, or go to mytekdev.com/try/robotsoccerlab?lesson=read-the-ring-adding-sensor-readings-as-vectors

Essential question: How do many small readings add up to one direction?

Warm-up: 3 blocks north, then 4 east: how far, and which direction? ________________________

  1. Vocabulary. Vector, component, magnitude, resultant, receiver, threshold: write each in your own words.
  2. The print line. brightest: ________ sum: ________ strength: ________
  3. Two vectors. Receiver 3, 37.6 at 45 degrees, plus receiver 4, 36.4 at 67.5 degrees. Right: ______ Forward: ______ Magnitude: ______ Direction: ______
  4. Eight vectors. Receivers 1 to 7 (0, 22.5, 45, 67.5, 90, 112.5, 135 degrees): 23.7, 33.2, 37.6, 36.4, 29.6, 18.3, 4.2. Receiver 16 (337.5 degrees): 10.5. Sum: right ______ forward ______ magnitude ______ direction ______. The readings added: ______
  5. Thresholds. Stopped how far from the balls? 85: ______ 80: ______ 75: ______ 70: ______ 65: ______

1. Why is the sum closer to the ball's direction than the brightest receiver?

2. Why is the magnitude of the sum less than the readings added?

Quick check

Name: ______________________________

1. Two vectors of length 10, one pointing at 0 degrees and one at 90 degrees, add to a vector of length: (A) 20 (B) about 14.1 (C) 10

2. A reading of 30 from a receiver at 90 degrees (straight right) has components: (A) right 30, forward 0 (B) right 0, forward 30 (C) right 15, forward 15

3. A friend says the robot should drive at the brightest receiver, because that is where the ball is. Use what you learned today to answer.

Answers

QuestionAnswerWhy
1BSquare root of 10 squared plus 10 squared: 14.1. The magnitude of a sum is not the sum of the magnitudes.
2Asin 90 is 1 and cos 90 is 0.
3Open answerThe brightest receiver gives the direction only to the nearest 22.5 degrees; adding all the readings as vectors points between receivers, closer to the ball (51 against 45 here).

If your state or umbrella school asks, this lesson covers Common Core Math HSN-VM.A.1, Common Core Math HSN-VM.B.4a, Common Core Math HSN-VM.B.4b.