Cookie CodersFTC Team 39092

Maps & Sensors · FTC Blocks // Student lesson

Core-Learn-FieldGeometry
Field Geometry Maps & Distance Hits

Code Lab / Core-Learn-FieldGeometry

Use Core-Learn-FieldGeometry on Tuesday November 3, 2026 to build a small map of fixed field geometry with native FTC Blocks lists. Put (0,0) at field center, then combine a distance return with the robot's capture-time pose to estimate a possible robot or obstacle's reflecting surface. Paper-first, disabled, and non-driving.

A range return estimates a reflecting surface, not a robot center or identity. Matching fixed geometry only filters a candidate layer; it must never suppress raw proximity collision protection. Invalid, stale, and ambiguous samples remain UNKNOWN.

Before running: Ask your supervisor first. Keep Driver Station STOP ready.

Mission control

Read, predict, compare, explain.

9source-linked steps
8scored quiz checks
Start with a question

Your distance sensor sees something. How can the robot remember where the walls are without deciding every unfamiliar reflection is another robot?

  • List-backed maps
  • Centered coordinates
  • Sensor mounting
  • Unknown evidence

Read · predict · explain

Build the idea, one block at a time

Read these steps before exploring the full program. The numbered blue comments in the diagram link back to the matching step.

Start with a question

Your distance sensor sees something. How can the robot remember where the walls are without deciding every unfamiliar reflection is another robot?

By the end, you can…

  • Explain name-to-record lookup as a map abstraction, and distinguish a linear list search from a hash table.
  • Use inches, a centered origin, positive axes, heading, and sensor mounting consistently.
  • Rotate the sensor offset and project a time-aligned range into a field surface position.
  • Keep unknown evidence unknown and separate candidate filtering from raw collision protection.

01Start at the center, not a corner

Actual Blocks for this section
Blocks for Start at the center, not a corner
Blocks to noticeHover, focus or tap a block to see what it does.
  • Waits for START in the disabled study; no motor commands are present.
  • Builds the fictional named geometry records using native Lists.
  • Resets evidence, checks gates, and only then projects and associates a paper sample.

Draw a fictional 144-by-144-inch practice field. Center is (0,0); +X is east/right on the drawing and +Y north/up. Heading 0 degrees faces +X; +90 faces +Y, counterclockwise. The run procedure waits, uses paper inputs, classifies once, and reports. It never drives. These are teaching coordinates, not an assertion about a current field or odometry device's native frame.

For example: West edge is X=-72, east edge X=+72. A robot at (12,-24) is right of center and below it. A lower-left-origin position (84,48) becomes (12,-24) by subtracting 72 from both coordinates.

Think first

Where is the center, and which direction does heading +90 face?

Show Answer

Center is (0,0); heading +90 faces +Y/up. A field-frame adapter must establish these conventions before supplying pose.

02Store names with geometry in native lists

Actual Blocks for this section
Blocks for Store names with geometry in native lists
Blocks to noticeHover, focus or tap a block to see what it does.
  • Native Lists stores the geometry collection and each five-item record. It is not a HashMap block.
  • One-based columns: name, xMin, xMax, yMin, yMax. Native roundDecimal keeps paper bounds as doubles, rounded to three decimals, for safe SDK Java list casts.
  • Two inches expands every fictional rectangle for coarse endpoint association, not a safety clearance.

Each record is [name,xMin,xMax,yMin,yMax], with native one-based positions 1..5. Unique names are keys. Four wall records sit at +/-72 and the fictional center fixture spans X and Y from -12 to +12. The tolerance is 2 inches. Native roundDecimal rounds paper numbers to three decimal places and establishes double values for SDK Java generation: this avoids integer heading division, truncated hits, and Integer-to-Double list casts. Names plus records model a map; this implementation searches a list in O(n), not a hash table's typical average O(1) keyed lookup. Geometry scanning still costs O(n), even if a separate hash map accelerates name lookup.

For example: ['east wall',72,72,-72,72] describes the east boundary; ['center fixture',-12,12,-12,12] describes a practice rectangle. All dimensions are fictional, not measured season geometry.

Think first

Does a list of named records become a hash table just because we call names keys?

Show Answer

No. Map describes key-to-value behavior; a hash table is one implementation. These Blocks use Lists and a linear scan, with no invented HashMap block.

03Look up a key and preserve missing or duplicate results

Actual Blocks for this section
Blocks for Look up a key and preserve missing or duplicate results
Blocks to noticeHover, focus or tap a block to see what it does.
  • Visits every record: linear search is O(n), unlike average hash-table key lookup.
  • Position 1 is the text key; positions 2 through 5 contain inch bounds.
  • Missing or duplicate keys retain UNKNOWN instead of choosing a default or last match.

Search for wantedKey='center fixture'. Compare position 1 of every record, count matches, and retain the record only for exactly one matching key. Missing or duplicate names return UNKNOWN. A reviewed map must have unique keys, five correctly typed fields per record, ordered bounds, and the agreed units/frame. The fixed authored practice map has these properties; geometryValid is a paper assumption, not a runtime schema validator.

For example: The center fixture lookup returns its five-item record. 'scoring basket' is absent and returns UNKNOWN, never an invented (0,0) default.

Think first

What if two records share 'center fixture'?

Show Answer

lookupCount=2, so lookupResult is UNKNOWN. Do not silently pick whichever duplicate appeared last.

04Pair range with capture-time pose and mounting

Actual Blocks for this section
Blocks for Pair range with capture-time pose and mounting
Blocks to noticeHover, focus or tap a block to see what it does.
  • Paper capture-time robot center in inches, using the centered field frame.
  • Paper sensor offset: six inches forward and two inches left in robot coordinates.
  • Classroom assumptions only. These booleans are not real hardware-health or timestamp checks.

Paper inputs use inches throughout. Robot center is (12,-24), heading 0 degrees. The sensor is mounted 6 inches forward and 2 inches left of center, with yaw 0 relative to robot forward. Range is 30 inches along that beam. Sample age is 0 ms and pose skew 0 ms. The flags assert a valid pose, range, mount, and map for this exercise; they do not read actual health or synchronization.

For example: At heading 0 the sensor face is (18,-22), not the robot center. A 30-inch range starts at that face. Using a later current pose while the robot moves would shift the estimated hit incorrectly.

Think first

Can we reuse yesterday's field pose or a pose read much later than the range?

Show Answer

No. Use a valid capture-time pose, or a justified synchronized/interpolated pose. Without it, the field hit is UNKNOWN. A later current pose is acceptable only if the stationary/time-alignment assumption is justified.

05Reject invalid, stale, or untrusted samples

Actual Blocks for this section
Blocks for Reject invalid, stale, or untrusted samples
Blocks to noticeHover, focus or tap a block to see what it does.
  • Erases previous coordinates and labels before considering a new sample.
  • Inclusive numeric bounds reject out-of-range values, NaN, and infinities.
  • All validity, age, skew, pose, mount, and range conditions must pass; otherwise evidence stays UNKNOWN.

Reset hit and labels before every classification. Require all four validity flags, range 1..60 inches, age 0..100 ms, pose skew 0..20 ms, robot X/Y within +/-72, heading/yaw within +/-180, and mounting translations within +/-18. Positive bounded comparisons also reject NaN and infinities. These are classroom acceptance bounds, not REV accuracy/range guarantees. Real flags must come from reviewed health, frame, mounting, and map validation.

For example: A 150-ms-old sample, NaN range, negative age, false poseValid, or range 0 leaves hit and classification UNKNOWN. It is not a CLEAR reading.

Think first

After a valid hit, what should the next stale sample display?

Show Answer

UNKNOWN, not the previous hit. The reset prevents stale coordinates from looking current. Raw range is still reported separately.

06Estimate a reflecting surface in the centered frame

Actual Blocks for this section
Blocks for Estimate a reflecting surface in the centered frame
Blocks to noticeHover, focus or tap a block to see what it does.
  • FTC native trig Blocks take degrees. The Java generator performs the radians conversion.
  • Rotates forward/left translation by robot heading to locate the sensor face.
  • Adds range from the sensor face along heading plus mounting yaw, estimating a reflecting surface.

Rotate the forward/left mount vector by heading h to find the sensor face. Add range r along beam angle h+yaw. Native FTC math_trig sin/cos Blocks accept degrees; generated Java converts to radians internally. This assumes a planar point ray and time-aligned pose, with measured mounting translation/yaw. Finite beam width, material response, and localization error limit the estimate.

For example: Default: sensor=(18,-22), hit=(48,-22). Rotate the whole case: pose=(-24,12), h=90, same mount and range gives sensor=(-26,18), hit=(-26,48). This is a surface point, never the other robot's center.

Think first

At pose (0,0), h=0, mount=(6,2), yaw=90 and range=30, where is the hit?

Show Answer

(6,32): yaw rotates the beam, not the mounting position. Adding yaw to the mount rotation would be a different, incorrect transform.

07Separate fixed-consistent hits from possible obstacles

Actual Blocks for this section
Blocks for Separate fixed-consistent hits from possible obstacles
Blocks to noticeHover, focus or tap a block to see what it does.
  • Visits the authored practice rectangles; this does not implement beam occlusion or identity recognition.
  • The endpoint must be inside all four expanded coordinate bounds, including equality.
  • One match is fixed-consistent, none is a possible obstacle, and multiple is UNKNOWN.

Accept hits only inside the practice field plus its 2-inch tolerance (+/-74). Count rectangles whose expanded bounds contain the endpoint. Exactly one gives CONSISTENT WITH FIXED; zero gives POSSIBLE ROBOT OR OBSTACLE; multiple gives UNKNOWN. An endpoint within a rectangle is a coarse association, not proof of the reflecting face. It does not test the first intersection, occlusion, beam footprint, object height, or identity. A robot near a wall can still be hidden by this association, so never suppress raw safety sensing.

For example: Pose=(30,0), h=0, mount=(6,2), range=36 gives (72,2), consistent with east wall. Default (48,-22) has no match: possible robot OR scoring element OR another obstacle. Corner (72,72) matches two walls and stays UNKNOWN.

Think first

Does 'no geometry match' confirm another robot, and does 'east wall' mean safe to drive?

Show Answer

Neither. No match is only an unexplained obstacle candidate. A wall match is still raw proximity to a physical object; collision protection remains active.

08Keep raw proximity and require identity evidence

Actual Blocks for this section
Blocks for Keep raw proximity and require identity evidence
Blocks to noticeHover, focus or tap a block to see what it does.
  • Raw distance is always shown, including known geometry matches; never remove it from collision protection.
  • Reports a surface estimate and candidate label, not a robot center or confirmed identity.
  • Sends accumulated telemetry. This study has no motor-output path or independent protection service.

Always report raw inches, even for a wall match or invalid field estimate. This disabled study has no motors and cannot guard a separate OpMode. Real collision protection belongs in a separately reviewed motor-output path and must not depend on this candidate label. Confirm robot identity using independent robot-recognizing vision plus repeated time-aligned observations and uncertainty checks. Motion alone is insufficient: scoring elements can move too.

For example: A 6-inch reflection matching the center fixture must still reach the raw collision guard. A POSSIBLE ROBOT OR OBSTACLE report is not permission to chase it.

Think first

Should filtering a known wall remove its distance from the emergency proximity input?

Show Answer

No. Candidate-layer filtering must never disable raw collision protection. Unknown pose/map evidence likewise must never become an all-clear signal.

09Recognize the real distance Block and the missing adapter

Actual Blocks for this section
Blocks for Recognize the real distance Block and the missing adapter
Blocks to noticeHover, focus or tap a block to see what it does.
  • Real SDK distance getter requesting inches from fictional placeholder example_distance; reference procedure is uncalled.
  • A numeric read alone is not validated range evidence; a reviewed adapter must establish validity.
  • The distance getter supplies no centered field pose or synchronization; no localization helper is claimed.

The uncalled readDistanceExample procedure contains the real FTC SDK 12 distanceSensor.getDistance Block with INCH units. example_distance is fictional placeholder hardware, not proof of Cookie Coders configuration. It explicitly invalidates range and pose after reading: the getter alone does not provide health, capture timestamps, or centered field pose. No localization helper is shipped or claimed. A reviewed adapter would replace paperSample with synchronized sensor and pose inputs, measured mounting, and honest validity flags.

For example: An actual 762-mm return converts to 30 inches, but the native INCH request already performs unit selection. Neither value tells you the robot's field location. Historical OtterBots wiring is not current hardware evidence.

Think first

Can enabling this import magically supply centered robot localization?

Show Answer

No. Keep it disabled. Hardware mapping, localization/frame conversion, timing, and validation are explicit remaining integration work, not hidden features of the distance Block.

Try it without a robot

Make the math make sense

Use a notebook or talk through your answer with a partner. You do not need a robot to predict what these blocks will do.

centeredX = cornerX - 72; centeredY = cornerY - 72
Only for this fictional 144-inch square with a lower-left corner frame and the same positive axes.
sensorX = robotX + forward*cos(h) - left*sin(h)
Inches; robot heading h in degrees, counterclockwise from +X.
sensorY = robotY + forward*sin(h) + left*cos(h)
Rotate mounting translation by robot heading only, not sensor yaw.
hit = sensor + range*[cos(h+yaw), sin(h+yaw)]
Capture-time surface estimate; range starts at sensor face, not robot center. Native trig takes degrees.
xMin-2 <= hitX <= xMax+2 AND yMin-2 <= hitY <= yMax+2
Fictional 2-inch endpoint association; one match fixed-consistent, none possible obstacle, multiple unknown. Never a raw safety filter.

1. Key-to-record paper map

Write the five records from the Blocks, label one-based columns, and trace center fixture, missing key, and duplicate key lookup. Explain map versus hash table and why scanning geometry still visits all records.

2. Centered-frame surface traces

Trace the default, +90-degree rotated, yaw=90, and east-wall examples. Include robot center, sensor face, beam heading, surface hit, match count, and raw range. Explain why none identifies a robot center.

3. Adversarial evidence

Trace age=150 ms, poseValid=false, range=NaN, corner hit (72,72), and a scoring element at (48,-22). Draw an obstacle near a wall to show false fixed association. Name independent identity evidence and explain why raw proximity never disappears.

Full-program context

Explore the full Blocks program

One source program, in one column. Calls connect any named helper routines; they are not separate programs. Click a numbered blue comment to return to its explanation.

Full commented Blocks program
100%

Ask your supervisor before importing or running these Blocks. Viewing the program does not control the robot.

Section in context

Full Blocks program

The highlighted Blocks belong to this section. You can select another blue comment.

Check your understanding

Your turn

Choose an answer, then check your thinking. You can change an answer and try again.

Your answers stay on this page and reset when you reload. No cookies, account, or saved answers.

0 / 8 correct · 0 / 8 answered

0
0
Question 1In the practice centered frame, where is the west edge?

Question 2What do these named native list records implement?

Question 3Pose (12,-24), h=0, mount (forward 6,left 2), yaw=0, range=30. Surface hit?

Question 4Pose (-24,12), h=90, same mount, yaw=0, range=30. Surface hit?

Question 5The previous hit was valid; the next sample is 150 ms old. What field estimate remains?

Question 6A hit at (72,72) matches east and north wall bounds. Classification?

Question 7An in-field hit has no fixed geometry match. What can we claim?

Question 8A close raw return matches a known wall. What reaches collision protection?

Reset clears every choice, explanation, and score.

Adult supervision · setup · safety

Supervisor notes

For supervisors: 60-minute teaching plan & robot setup

Before the robot is used

Safety: Paper and website only. Keep the .blk disabled and do not add motor outputs, call the sensor reference, or enable it as part of this lesson. It cannot protect another OpMode. No physical controls or live deployment are requested. Any later hardware integration needs separate review, verified mapping, synchronized pose/range, measured mounting, sensor health and uncertainty, and an independent raw collision guard.

Required hardware & dependencies

  • Paper field drawing, ruler, calculator, and website; no robot required.
  • Fictional example_distance reference only; no current Cookie Coders sensor, localization, or port configuration is proven.

Newly authored FieldGeometryBlocks.blk uses FTC SDK 12 native Lists, loops, comparisons, degree sin/cos, telemetry, and a native distance getter. This is not a controller-exported or hardware-tested program. No HashMap block or custom Java helper is claimed. The uncalled getter uses fictional example_distance; selecting even a disabled import may need that placeholder resolved. Generated Java does not inherit the .blk disabled metadata: do not install or enable a Java export. Use the website and paper traces only. Robot deployment is not part of this lesson.

Robot setup checklist

  1. Open the registered Code Lab lesson, source-linked Blocks, prediction reveals, full-program explorer, and quiz. Check the downloaded source remains disabled.
  2. Draw center (0,0), +X right, +Y up, headings 0/+90, and the fictional +/-72 edges and +/-12 fixture. Label all positions/ranges in inches and timestamps in milliseconds.
  3. Explain one-based record columns, unique keys, trusted map assumptions, capture-time pose, and sensor mount (forward 6,left 2,yaw 0). Never borrow an old team's configuration as evidence.

60-minute teaching sequence

  1. 0-10 min

    Draw the centered field and distinguish a surface point from identity.

    Look for: Signed axes and heading convention; fictional dimensions.

  2. 10-25 min

    Build named records and paper-trace key lookup.

    Look for: Map abstraction versus hash table; missing/duplicate stays unknown.

  3. 25-40 min

    Work default, rotated, yaw, and wall surface projections.

    Look for: Mount translation rotation precedes range; degrees and capture-time pose.

  4. 40-50 min

    Trace stale, corner, and near-wall obstacle cases.

    Look for: Unknown evidence, imperfect association, raw safety preserved.

  5. 50-60 min

    Quiz, reset, and exit ticket.

    Look for: Possible obstacle is not robot identity or center.

Observation notebook

Paper trace: centered surface estimates and candidate evidence
Pose X,Y / hRange / mount yawSensor faceSurface hitClassification / raw input
12,-24 / 0 deg30 in / 0 deg18,-2248,-22Possible robot or obstacle / 30 in retained
-24,12 / 90 deg30 in / 0 deg-26,18-26,48Possible robot or obstacle / 30 in retained
30,0 / 0 deg36 in / 0 deg36,272,2East wall consistent / 36 in retained
0,0 / 0 deg30 in / 90 deg6,26,32Possible robot or obstacle / 30 in retained
Valid pose; age 150 ms30 inNot usedUNKNOWNUNKNOWN / raw 30 in retained

Default forward/left mounting is 6/2 inches. Coordinates are surface points, not robot centers. Paper flags and tolerances are not hardware validation or measured accuracy.

Troubleshooting · stop before investigating

Hit is off by six inches or has the wrong Y sign.
Start range at the rotated sensor face; positive left adds +Y at heading 0.
Yaw changes the mounting position.
Rotate mounting by h only. Rotate the beam by h+yaw.
A stale or ambiguous hit looks clear.
Reset labels and coordinates each sample, verify all gates, and retain UNKNOWN when more than one geometry record matches.
The Blocks editor asks for example_distance.
It is a fictional uncalled reference, not verified hardware. Stay with the website/paper lesson; do not guess a port or enable the import.

Exit ticket & assessment

  1. Compute default surface hit and a +90-degree rotated hit.
  2. Explain map versus hash table and missing/duplicate keys.
  3. Name what is needed to confirm robot identity, and why known walls still reach raw collision protection.

Assessment: Look for correct centered-frame mounting math, honest list-map terminology, unknown-preserving decisions, and clear separation of surface association, semantic identity, and collision safety.

Extension challenge: On paper, draw a finite-width beam and an obstacle in front of a wall. Explain why a 2D endpoint rectangle match is insufficient and what first-intersection, uncertainty, repeated-observation, and vision evidence would add. Do not implement motion.

Teacher key · discuss after students predict

Default and rotated traces

Default sensor (18,-22), hit (48,-22). Rotated sensor (-26,18), hit (-26,48). Neither identifies a robot or its center.

Wall and corner traces

(72,2) matches east only; (72,72) matches east and north and remains UNKNOWN. Inclusive tolerance includes boundary equality.

Unknown and raw safety

Failed gates erase the old hit. Geometry association never removes raw range; a separate reviewed guard is needed to affect actual motor outputs.