Family edition
Robot Soccer Lab: Read the Ring, Adding Sensor Readings as Vectors
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
- A computer or Chromebook with a current browser.
- The link: mytekdev.com/try/robotsoccerlab?lesson=read-the-ring-adding-sensor-readings-as-vectors&ref=fam-robotsoccerlab-3. No account, no email and nothing to install.
- A calculator set to degrees.
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.
- 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).
- 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.
- 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.
- 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.
- 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 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
- 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.
- 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.
- 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.
- 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.
- 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:
- What are the magnitude and direction of receiver 4's vector?
- Why does receiver 16 add a little to the forward part and take a little from the right part?
- Why does the sum point at about 51 degrees, between receivers 3 and 4?
- Why is the sum's magnitude less than the readings added up?
- Which thresholds stopped the robot 5 to 20 cm away, and why do the others fail?
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
- Write the sum in Python: import math, then add readings[n] x sin and cos of n x 22.5 for all 16, and print the direction with math.atan2. Compare it with robot.ball_angle().
- Steer at the brightest receiver instead of the sum (brightest x 22.5 as the move angle). Does the robot still stop by all three at 75? Why might a real team still prefer the sum?
- The strength is 100 / (1 + d squared / 0.25), with d the distance between the centers in meters, times how squarely the receiver faces the ball. Find d for a strength of 75 and compare it with your stopping distances.
Bring it into other subjects
- Physics: add forces the same way. Two ropes pull a box at 45 and 67.5 degrees: which way does it move?
- Computer science: write the sum in Python with a for loop over the 16 readings, and print it beside robot.ball_angle().
- Earth science: find how a seismograph network or a phone's GPS combines readings from several directions.
- Careers: look up the sensors on a self-driving car and how it combines them to know what is around it.
For your records
Ready to copy into an hour log, a portfolio or a transcript.
| Lesson | Robot Soccer Lab: Read the Ring, Adding Sensor Readings as Vectors |
|---|---|
| Subjects | Math |
| Time | 45 minutes |
| What we did | Added 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 practiced | Adding 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? ________________________
- Vocabulary. Vector, component, magnitude, resultant, receiver, threshold: write each in your own words.
- The print line. brightest: ________ sum: ________ strength: ________
- Two vectors. Receiver 3, 37.6 at 45 degrees, plus receiver 4, 36.4 at 67.5 degrees. Right: ______ Forward: ______ Magnitude: ______ Direction: ______
- 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: ______
- 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
| Question | Answer | Why |
|---|---|---|
| 1 | B | Square root of 10 squared plus 10 squared: 14.1. The magnitude of a sum is not the sum of the magnitudes. |
| 2 | A | sin 90 is 1 and cos 90 is 0. |
| 3 | Open answer | The 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.