Cookie CodersFTC Team 39092

Autonomous · FTC Blocks // Student lesson

Auto-Learn-LimelightTracking
Blue Nectar: Center & Approach

Code Lab / Auto-Learn-LimelightTracking

Study Auto-Learn-LimelightTracking using the disabled Blue Nectar: Center & Approach excerpt, BlueNectarStudy.blk. It contains REAL motor-power commands but omits the side/rear wall guard and MUST NOT be run on the physical robot. Trace blue-contour filtering, centering, steering, loss handling, and stop reasons on paper. The estimated 3-inch lens gap is not a verified safe clearance.

The area-distance constant was calibrated at a longer distance, not verified close-up. The robot front can protrude beyond the lens. Under-250-ms results can be reread and counted more than once; the source does not prove distinct frames. Its encoder check detects little aggregate movement early in approach, not every individual frozen encoder or every later stall.

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

Mission control

Read, predict, compare, explain.

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

If an old picture still shows a blue ball, what stops a robot from driving toward a position that is no longer true?

  • Limelight pipeline 0
  • Fresh blue contour
  • Continuous steering
  • Lost-target stop

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

If an old picture still shows a blue ball, what stops a robot from driving toward a position that is no longer true?

By the end, you can…

  • Trace valid, pipeline, age, contour-area, and image-height acceptance tests.
  • Compute source range estimates, steering corrections, and the fixed encoder cap.
  • Explain centered-check counters, contour continuity, and immediate zero on loss.
  • Distinguish estimated lens-gap completion from encoder/time stops and physical clearance.

01Recognize real outputs in a disabled study

Actual Blocks for this section
Blocks for Recognize real outputs in a disabled study
Blocks to noticeHover, focus or tap a block to see what it does.
  • Sets which way each drive motor spins for a positive power: front-left, back-left and back-right REVERSE, front-right FORWARD.
  • Makes each drive motor resist turning when its power is 0, so the wheels stop firmly instead of coasting.
  • Lets each motor controller use wheel-encoder feedback to regulate speed. The program also reads the encoder counts later to measure wheel movement.
  • Sets the two power variables to 0. They are only requests until applyPower copies them to the motors.
  • Runs applyPower, which really writes leftPower to both left motors and rightPower to both right motors. This study has no wall guard.

FL, BL, and BR are REVERSE; FR is FORWARD. All four use BRAKE and RUN_USING_ENCODER, and initial left/right requests are zero. applyPower really writes those requests to motors. DISABLED metadata prevents ordinary selection until changed, but it does not turn the source into a simulation. This excerpt omits the actual side/rear wall guard and must not run on the physical robot.

For example: A paper trace may contain leftPower 0.18. If this code were enabled and run, applyPower would send it to both left motors rather than merely display it.

Think first

Is this read-only like WallGuardStudy because both are disabled studies?

Show Answer

No. WallGuardStudy reports requests only; BlueNectarStudy includes real motor-power writes and must not be run on the robot.

02Identify the front blue-color camera

Actual Blocks for this section
Blocks for Identify the front blue-color camera
Blocks to noticeHover, focus or tap a block to see what it does.
  • Asks the front Limelight to report up to 100 times per second. It is only a request and does not guarantee each read is a new image.
  • Selects Limelight pipeline 0, which this program expects to be the blue color pipeline, not an AprilTag pipeline.
  • Starts the front Limelight so it begins processing images and returning results.

The source selects blue color pipeline 0 on the forward-facing Limelight and requests 100 Hz polling. The separate rear Logitech camera is not used. Slot 0 must contain the expected blue-contour settings, unlike the AprilTag lessons' slot 0. A polling rate does not guarantee that every later read is a distinct image.

For example: AprilTag pipeline 0 and blue color pipeline 0 are different camera configurations, even though both are numbered 0.

Think first

Can a rear Logitech image satisfy readBlue's Limelight ColorResults tests?

Show Answer

No. This source reads the configured Limelight's result object and color contours.

03Preview detection without starting the motion phases

Actual Blocks for this section
Blocks for Preview detection without starting the motion phases
Blocks to noticeHover, focus or tap a block to see what it does.
  • Repeats the blocks inside during INIT, before START, so the camera preview updates without any motion phase starting.
  • Runs readBlue, which checks the latest Limelight result and, if it passes the tests, picks a blue contour and sets seen, tx and rangeInches.
  • Adds the blue ball's angle, estimated lens-to-center range and contour area to telemetry, or a not-detected message when nothing is seen.
  • Subtracts the assumed 1.4-inch ball radius to estimate the lens-to-ball-surface gap. It is an estimate, not robot-front clearance.
  • Pauses the loop for 50 milliseconds so the preview does not refresh as fast as the controller can run.
  • Pauses the program until the driver presses START, so the centering and approach phases cannot begin early.

INIT reads blue contours and reports angle, lens-to-center estimate, contour area, and estimated lens-to-surface gap = range - 1.4. Setup has already requested zero, and the motion phases begin only after waitForStart. A missing contour displays not detected. This preview and all subsequent motion logic are for source study only, not authorization to run the disabled excerpt.

For example: An estimated center range 7.1 inches gives a surface gap estimate 5.7 inches, using half of the assumed 2.8-inch ball diameter.

Think first

Does a 5.7-inch estimated lens gap prove a 5.7-inch robot-front clearance?

Show Answer

No. The robot front can extend beyond the lens, and the estimate is not close-range tape-verified.

04Gate centering with visible and centered checks

Actual Blocks for this section
Blocks for Gate centering with visible and centered checks
Blocks to noticeHover, focus or tap a block to see what it does.
  • Limits the centering loop to 6 seconds since the timer was reset, so it cannot run forever.
  • Keeps centering until five centered checks are counted. These are loop checks, not guaranteed distinct camera frames.
  • True when a blue contour was accepted and is less than 25 degrees off center. Otherwise both powers go to 0 and both counters reset.
  • True after five accepted visible checks. The first four only warm up with zero power before any turning or centered counting starts.
  • True when the ball angle is within 2 degrees of center. The program then requests zero power and adds one to centeredFrames.
  • Pauses 25 milliseconds each loop to pace the checks. Processing adds time, so this is not an exact loop rate.

Centering lasts at most 6 seconds. Only seen targets with |tx| strictly below 25 degrees advance visibleFrames; the first four accepted checks keep powers zero. Starting with check 5, |tx| <= 2 increments centeredFrames at zero; otherwise centeredFrames resets and positive tx requests left +0.12/right -0.12, with signs reversed for negative tx. Loss or |tx| >=25 sets both powers zero and resets both counters. Five centered checks are needed, but no image identity is checked, so these counters are not guaranteed distinct fresh frames.

For example: For a continually seen 0-degree target, checks 1-4 are visibility warmup; checks 5-9 increment centeredFrames to 5. At exactly 25 degrees this centering gate fails.

Think first

What happens if tx leaves the 2-degree band after centeredFrames reaches 3?

Show Answer

The found-but-off-center branch resets centeredFrames to 0 and selects a +/-0.12 turn; loss also resets visibleFrames.

05Keep an estimated lens target separate from clearance

Actual Blocks for this section
Blocks for Keep an estimated lens target separate from clearance
Blocks to noticeHover, focus or tap a block to see what it does.
  • Allows the approach only if the program is running, five centered checks were counted, a ball is seen, and its estimated range is above 4.4 inches.
  • Turns on continuity checking so later readings that jump too far in angle or size are rejected.
  • Saves each wheel's current encoder position as a starting point so later code can measure how far each wheel has turned.
  • Sets a fixed encoder-tick cap from the first range estimate, using 115 ticks per inch. It is a software limit, not a verified travel distance.
  • Limits the approach loop to 16 seconds after the timer reset. Reaching the limit stops the loop without proving the ball was reached.

Approach enters only with sufficient centering, a seen contour, and estimated range above 4.4 inches. A 2.8-inch ball has radius 1.4, so 4.4 lens-to-center suggests a 3-inch lens-to-surface gap. The constant was calibrated at a longer distance; this close-up gap is not verified, and the robot front may project beyond the lens. The source fixes an encoder cap from the initial estimated range at 115 ticks/inch, remembers all four starting positions, enables contour continuity checks, and starts a 16-second maximum approach timer.

For example: Starting range 14.2 inches makes targetTicks = (14.2 - 4.4)*115 = 1127. That is a software cap from an estimate, not permission to travel toward a ball.

Think first

Does an initially centered target already at 4.4 inches enter the approach?

Show Answer

No. Entry requires range > 4.4; the else report says no target, not centered, or already inside the estimated gap.

06Read again and measure the largest wheel change

Actual Blocks for this section
Blocks for Read again and measure the largest wheel change
Blocks to noticeHover, focus or tap a block to see what it does.
  • Reads the camera again every loop, updating seen, tx, range and area. A repeated recent result can still pass, so it is not proof of a new frame.
  • Finds how many ticks one wheel has moved since its baseline, as a positive number regardless of direction.
  • Keeps the largest of the four wheel changes as encoderTicks. It is not an average, so one stuck wheel can hide behind the others.
  • Pauses 25 milliseconds before the next loop. With processing time, this is not an exact loop rate.

Every approach loop calls readBlue and computes encoderTicks as the maximum absolute change among the four wheels, not their mean or sum. It later sleeps 25 ms, but processing adds time, so this is not an exact 40 Hz control guarantee. A repeated latest result may still pass the age test; refreshing the call does not prove a new frame. Displayed tx/range can retain old numbers after seen becomes false, so flags and commands matter.

For example: Changes 100, 105, 80, 0 ticks yield encoderTicks 105. A single frozen encoder is not exposed by this aggregate alone.

Think first

Would rereading the same 100-ms-old valid result necessarily fail readBlue?

Show Answer

No. It is still under 250 ms and there is no frame-deduplication check.

07Add and subtract a clipped correction

Actual Blocks for this section
Blocks for Add and subtract a clipped correction
Blocks to noticeHover, focus or tap a block to see what it does.
  • True when a ball is seen, within 25 degrees of center, and still estimated farther than 4.4 inches, so the driving branch is allowed.
  • True when the largest wheel change reaches the fixed tick cap. The program then requests zero power and records an encoder safety-limit stop.
  • Multiplies tx by 0.02, then limits the result to between -0.18 and +0.18 so the steering correction cannot grow too large.
  • Sets the left power request to 0.18 plus the correction, so a positive tx makes the left side stronger.
  • Sets the right power request to 0.18 minus the correction, so a positive tx makes the right side weaker and steers the robot.

A seen target at |tx| <=25 and range >4.4 permits the approach decision. Reaching the fixed encoder cap selects zero and a safety-limit reason before another forward write. Otherwise correction = clip(0.02*tx,-0.18,+0.18); left adds it to 0.18 and right subtracts it. Commands range from 0 to 0.36, and the correction saturates at |tx| >=9 degrees. This forward differential steering does not strafe and is recalculated each loop.

For example: tx +5 gives correction +0.10, left 0.28, right 0.08. tx -12 clips to -0.18, giving left 0 and right 0.36.

Think first

Is tx exactly +25 degrees allowed by the approach steering gate?

Show Answer

Yes, if seen and range >4.4. The approach uses <=25, unlike centering's strict <25; correction is clipped to +0.18.

08Zero first, then distinguish goal, edge, and loss

Actual Blocks for this section
Blocks for Zero first, then distinguish goal, edge, and loss
Blocks to noticeHover, focus or tap a block to see what it does.
  • Sets both power requests to 0 right away whenever the steering gate fails, before deciding whether the cause was goal, edge or loss.
  • Writes the zero power requests to all four motors immediately.
  • True when the ball is seen and estimated 4.4 inches or less away. The program records an estimated-gap COMPLETE reason and sets done.
  • Handles a seen ball more than 25 degrees off center: the program sets abort with a camera-edge STOPPED reason.
  • Stores the time the ball was first unseen, or -1 when it is not lost. It starts the loss timer while the motors stay at 0.
  • True when the ball has been unseen for at least 0.35 seconds. The program then sets abort with a target-lost reason; power is already 0.

Whenever the steering gate fails, both commands are zeroed immediately. If seen and estimated range <=4.4, the source sets done and an estimated-gap completion reason. Otherwise a seen target outside the angle gate aborts at the camera edge. An unseen target starts a loss timer and aborts after at least 0.35 seconds; it stays at zero throughout the wait. The close-range branch is tested before the edge branch, so a seen close estimate can report completion even if |tx| exceeds 25. That is another reason not to treat this study as validated safe behavior.

For example: At loss start, motors are zero, not allowed to coast forward under power for 0.35 seconds. Recovery into the valid guiding branch clears lossStartedAt to -1.

Think first

Does the loss timeout authorize driving blind for the grace interval?

Show Answer

No. Power is zero immediately; 0.35 seconds governs abandoning the approach, not when stopping begins.

09Separate safety-limit stops from estimated arrival

Actual Blocks for this section
Blocks for Separate safety-limit stops from estimated arrival
Blocks to noticeHover, focus or tap a block to see what it does.
  • True when at least 1 second has passed and the largest wheel change is under 5 ticks, meaning almost no movement was reported.
  • Runs the movement check only while the ball is seen and the approach has not already finished or aborted.
  • Shows the largest wheel travel in inches by dividing ticks by 115, an assumed ticks-per-inch value. It is an estimate, not floor-measured distance.
  • After the loop ends for any reason, sets both powers to 0, applies them, and reports the stop reason on telemetry and in the log.

The early movement check aborts only when seen, not already done/aborted, time >=1 second, and the maximum absolute wheel change is <5 ticks. That detects very little reported movement across all wheels, not every single stuck encoder; it does not continuously detect a later stall once cumulative travel exceeds 5. Encoder-cap termination sets done but labels the result STOPPED, not gap success. The 16-second timer also stops without proving arrival. Final cleanup writes zero and stops the Limelight.

For example: At 1.2 seconds changes 4,3,0,2 have max 4 and trigger this check. Changes 100,100,100,0 have max 100 and do not expose the frozen fourth encoder through this test.

Think first

If encoderTicks reaches targetTicks while camera range is still 6 inches, is the estimated 3-inch lens gap achieved?

Show Answer

No. The source records an encoder safety-limit stop before the camera gap, even though it uses done to terminate the loop.

10Reset seen and require a recent result

Actual Blocks for this section
Blocks for Reset seen and require a recent result
Blocks to noticeHover, focus or tap a block to see what it does.
  • Clears seen at the start of each read so an old detection cannot be reused when this read finds nothing valid.
  • Asks the Limelight for its newest result. It may be the same result as before, so it does not prove a new frame.
  • True when the camera returned a result at all. The validity, age and contour checks come after this.
  • Reads whether the Limelight marks the result as valid. The program compares its text form with the word true.
  • True when the result is less than 250 milliseconds old. Exactly 250 fails, and a recent result is not proof of a new frame.
  • Checks that the result came from pipeline 0, the blue color pipeline, and not another pipeline slot.
  • Checks that the result contains at least one blue color contour to choose from.

readBlue resets seen false and fetches the latest result. A non-null result may report age, global Ta, and contour count. Detection proceeds only with validity true (the source compares its text form with 'true'), age strictly under 250 ms, pipeline index 0, and a nonempty ColorResults list. Global whole-image Ta is displayed but not used for distance. Unlike the AprilTag samples, this has an explicit age gate; it still does not deduplicate frame identity.

For example: A valid pipeline-0 frame at 249 ms with qualifying contours can pass; the same conditions at exactly 250 ms cannot.

Think first

Can a valid 20-ms-old result from pipeline 1 guide this program?

Show Answer

No. PipelineIndex must equal 0 as well as passing age and validity.

11Select the largest eligible ball-height contour

Actual Blocks for this section
Blocks for Select the largest eligible ball-height contour
Blocks to noticeHover, focus or tap a block to see what it does.
  • Resets the best contour area to 0 before looking at candidates, so any eligible contour can be chosen first.
  • Repeats for every blue contour in the result, checking whether it should replace the best candidate so far.
  • True for a contour larger than the best so far but no more than 0.75 in area, which skips huge blue regions.
  • True when the contour sits between pixel rows 215 and 260, the band where a ball-height contour is expected, which helps skip other blue patches.
  • Accepts the choice only if the best area is at least 0.001, ignoring tiny specks. Then seen becomes true and the range is calculated.
  • Estimates the lens-to-ball-center range in inches from the chosen contour area. It is calibrated at a longer distance, not verified up close.

The source chooses the largest contour with area no more than 0.75 and Y pixels inclusively between 215 and 260. Only after scanning candidates does area >=0.001 set seen true. Equal-area candidates do not replace the earlier choice. tx comes from that contour's TargetXDegrees, not global tx. The distance model treats this contour area as the source's area fraction, using 2.84/sqrt(area); area units and the longer-distance scale need review. It is not a tape-verified close-range measurement and cannot distinguish every blue floor patch by color alone.

For example: Eligible area 0.04 gives 2.84/0.20 = 14.2 inches. A larger contour at Y 300 is rejected; one at Y 215 is within the band.

Think first

Should whole-image Ta replace the chosen contour's area in this range equation?

Show Answer

No. The source deliberately uses the selected contour's area; global Ta can combine unrelated blue regions.

12Reject continuity jumps without claiming identity

Actual Blocks for this section
Blocks for Reject continuity jumps without claiming identity
Blocks to noticeHover, focus or tap a block to see what it does.
  • Applies the same-target check only when tracking is on, which the approach turns on when it starts.
  • True when the ball's angle jumped more than 12 degrees from the last accepted reading, a sudden change that fails the check.
  • True when the contour area is under 0.4 or over 2.5 times the last accepted area, a sudden size change that fails the check.
  • Marks the reading as rejected, so the calling loop requests zero power. The program does not try a smaller candidate instead.
  • Saves the current angle and area as the new reference only when the reading was accepted, so rejected readings do not move the comparison point.

During approach, tracking rejects an angle jump greater than 12 degrees or an area outside [0.4,2.5] times the last accepted area. Boundary equality passes. Rejected candidates leave seen false and do not update the remembered accepted values, causing immediate zero in the caller. Selection chooses the largest eligible contour BEFORE this continuity test; it does not try another candidate if that largest one fails. These heuristics discourage target switching but do not prove the same physical ball.

For example: With lastArea 0.10, areas 0.04 and 0.25 pass the ratio boundary; 0.039 or 0.251 fail. An exact 12-degree jump passes, but 12.1 fails.

Think first

If the largest eligible contour fails continuity, does readBlue automatically fall back to a smaller matching contour?

Show Answer

No. It marks seen false after the chosen candidate fails; there is no fallback search.

13Locate the unguarded physical output stage

Actual Blocks for this section
Blocks for Locate the unguarded physical output stage
Blocks to noticeHover, focus or tap a block to see what it does.
  • Sends the left power request to the front-left motor. This is a real motor write, not telemetry.
  • Sends the same left power request to the back-left motor, so both left wheels get the same command.
  • Sends the right power request to the front-right motor. Unequal left and right requests steer the robot while it moves forward.
  • Sends the same right power request to the back-right motor. This function has no wall-sensor check in this study.

applyPower writes leftPower to both left motors and rightPower to both right motors. Their difference steers the chassis while moving forward; this stage contains no distance-sensor checks. Source notes say the complete guarded robot program checks walls before these writes, but that guard is omitted here and is not installed by this migration. Keep BlueNectarStudy disabled and never run it on the physical robot.

For example: left 0.28 and right 0.08 become FL/FR/BL/BR 0.28/0.08/0.28/0.08 in a paper trace. These are real output Blocks, not telemetry.

Think first

Could running WallGuardStudy separately make these four writes guarded?

Show Answer

No. It cannot intercept this OpMode, and the disabled blue excerpt must not be run on the robot.

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.

eligible result = valid AND age < 250 ms AND pipeline = 0 AND contour count > 0
The source checks recent result eligibility, not distinct-image identity; all conditions must pass.
range estimate (in) = 2.84 / sqrt(chosen contour area)
Uses the source's contour-area scale, not global Ta. Quadrupling area halves the estimated range under this unverified close-up model.
estimated lens gap = range - 1.4 in; target center range = 3 + 1.4 = 4.4 in
The assumed 2.8-inch ball radius is 1.4 inches. This is lens-to-surface geometry, not robot-front clearance or a verified stop distance.
c = clip(0.02*tx,-0.18,+0.18); left = 0.18+c; right = 0.18-c
Positive tx adds on the left and subtracts on the right. Magnitudes saturate at 9 degrees; recalculate every eligible loop.
cap = (initial range - 4.4)*115 ticks; observed ticks = max(|four wheel changes|)
The cap is fixed at approach entry. Reaching it is a safety-limit stop, not proof of the estimated lens-gap goal.
continuity: |tx-lastTx| <= 12 AND 0.4*lastArea <= area <= 2.5*lastArea
Applies after choosing the largest eligible contour during tracking; it is a heuristic, not unique object identity.

1. Filter a result and its contours

On paper use valid pipeline 0 results aged 249 and 250 ms. Candidate areas/Y pixels are 0.04/230, 0.16/300, 0.03/215, and 0.80/240. Which contour wins when the result passes? Calculate range and estimated lens gap. Explain why repeated accepted reads do not prove distinct frames.

2. Calculate steering and continuity

Compute correction and left/right powers for tx +5, -5, +12, and +25 degrees during eligible approach. With lastTx 0 and lastArea 0.10, test candidate angle/area pairs 12/0.04, 12.1/0.10, 0/0.25, and 0/0.251. Does the source try another contour after a failed continuity test?

3. Classify four stops

Start at estimated 14.2 inches and calculate targetTicks. Trace missing target at time 2.0 and still missing at 2.35; max encoder changes 4 ticks at 1.2 seconds; max reaches the cap with range still 6; and seen range reaches 4.4 before the cap. Name each reason and distinguish the source's done flag from verified success.

4. Explain the clearance problem

Draw a lens behind the robot's front edge and a 2.8-inch ball. Show why range 4.4 suggests a 3-inch lens gap but not a 3-inch robot gap. Write the evidence needed to validate close-up distance separately from the single longer-distance calibration; do not propose a physical run of this excerpt.

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 / 9 correct · 0 / 9 answered

0
0
Question 1Which statement correctly describes BlueNectarStudy?

Question 2A valid pipeline-0 result has eligible contours and age exactly 250 ms. Does it set seen true?

Question 3Contours are area/Y 0.04/230, 0.16/300, and 0.03/215. Which supplies the range if the result is eligible?

Question 4The chosen area is 0.04. What range and lens-surface gap does the model estimate?

Question 5During eligible approach tx is -12 degrees. What left/right requests follow clipping?

Question 6The target becomes unseen. What happens during the first 0.35 seconds of loss?

Question 7Starting range is 14.2 inches. The maximum wheel change reaches 1127 ticks while range still reads 6 inches. What outcome is reported?

Question 8tracking is true, lastTx = 0 and lastArea = 0.10. Does tx = 12 and area = 0.04 pass the continuity test?

Question 9Wheel changes at 1.2 seconds are 100,100,100,0 ticks. Does the source's <5-tick movement check detect the frozen fourth encoder?

Reset clears every choice, explanation, and score.

Adult supervision · setup · safety

Supervisor notes

For supervisors: 90-minute teaching plan & robot setup

Before the robot is used

Safety: DO NOT RUN BlueNectarStudy on the physical robot, including as a wheels-raised trial. Keep it disabled and do not deploy it. It contains actual motor commands, omits the side/rear wall guard, and cannot be guarded by WallGuardStudy in another OpMode. The 3-inch lens gap is an estimate from a longer-distance calibration, unverified close-up; the front can protrude beyond the lens. Use source inspection, paper traces, and independently supplied stationary evidence only.

Required hardware & dependencies

  • Four mecanum drive motors named front_left_drive, front_right_drive, back_left_drive, and back_right_drive; verify each configured name against its physical cable and wheel.
  • FTC Robot Controller, Driver Station, secure battery, and a notebook. Motor direction settings are specific to the source and mounting, not universal wiring instructions.
  • Source reference only: forward Limelight 3A named limelight with blue color pipeline 0. The rear Logitech camera is not an input to this excerpt.
  • Source reference only: four wheel encoders, assumed 115 ticks/inch, and a 2.8-inch blue ball. These constants are not validated by this lesson.
  • For learning: printed Blocks, notebook, calculator, and prerecorded or stationary measurement evidence that does not require executing this excerpt.

Source remains BlueNectarStudy.blk, DISABLED study-only. Native dependencies are Limelight 3A named limelight, a blue color pipeline 0, and four drive motors with encoder properties. No helper ZIP is provided. Review screenshots/Blocks and paper traces only; do not enable, deploy, or run this excerpt on the physical robot. The omitted wall guard and unverified close-range calibration cannot be supplied by another OpMode.

Robot setup checklist

  1. Open the disabled BlueNectarStudy.blk for inspection only. Verify the DISABLED flag, real applyPower writes, and absence of distance-sensor checks; do not change enablement.
  2. Review native Limelight result and ColorResults Blocks, pipeline 0 contents, contour-area units, Y-pixel band, and the documented single longer-distance calibration. No helper ZIP or deployed guarded program is supplied by this page.
  3. Mark lens position, assumed radius, robot-front offset, encoder scale, and unverified close-range behavior on a diagram. Do not infer a safe route from a 4.4-inch center estimate.
  4. Prepare synthetic paper results for age, angle, contour, continuity, loss, encoder-cap, and timeout cases. Treat counter values as loop checks unless distinct image evidence is separately provided.

90-minute teaching sequence

  1. 0-15 min

    Establish the no-run constraint and identify real outputs plus omitted guards.

    Look for: Students distinguish this study from read-only WallGuardStudy.

  2. 15-35 min

    Filter result eligibility and contour candidates, then calculate range and gap.

    Look for: Strict age boundary, inclusive height band, selected contour not global Ta, estimate not clearance.

  3. 35-55 min

    Trace visibility warmup, centered checks, steering saturation, and continuity.

    Look for: First possible fifth centered count at check 9, no frame deduplication, exact lock boundaries.

  4. 55-75 min

    Classify immediate loss zero, grace timeout, edge, encoder cap, movement check, and range branch.

    Look for: done is not a universal success flag; max ticks is not an individual-encoder health check.

  5. 75-90 min

    Quiz, clearance diagram, and exit ticket.

    Look for: No physical run proposed; close-up accuracy and robot-front clearance remain unverified.

Observation notebook

Paper notebook: frame eligibility, chosen contour, commands, and outcome
Result / contourseen / tracking matchEstimated range / gapLeft / right requestReason / caveat
Valid pipeline 0, age 249 ms, area 0.04, Y230true if continuity passes14.2 / 12.8 inAt tx +5: 0.28 / 0.08Model estimate, not measured clearance
Same conditions, age 250 msfalseStored numbers may remain0 / 0Immediate zero; loss timer may start
Cap 1127 ticks reached, range 6true6 / 4.6 in0 / 0STOPPED: encoder safety limit
Accepted contour, range <=4.4trueEstimated gap <=3 in0 / 0Estimated completion only; no close-up proof

Record source reason text separately from done/abort flags. Note repeated-result risk, lens/front offsets, and missing wall checks. These rows are paper traces, not physical trial instructions.

Troubleshooting · stop before investigating

No contour is accepted despite blue pixels.
On paper check validity, age <250, pipeline 0, nonempty contours, Y 215-260, area <=0.75, and chosen area >=0.001. Global Ta is not the range input.
Centering checks accumulate faster than processed images.
The source has no frame identity test; repeated under-250-ms results can increment counters. Do not call them verified distinct frames.
A larger blue patch causes seen to become false.
Selection picks the largest eligible contour before continuity rejection. Check >12-degree jump and 0.4-2.5 area ratio; there is no smaller-candidate fallback.
done is true but the reason says STOPPED.
The encoder cap uses done to terminate. Distinguish this reason from the seen-and-range<=4.4 estimated completion branch.
One encoder stays zero without the movement check failing.
MAX of four changes can exceed 5 even with a frozen wheel. This is not a per-wheel health or continuous stall detector.
The estimated lens gap seems safe for the robot front.
Reject that inference. The front may protrude beyond the lens, calibration is not close-up validated, and the excerpt must not be run.

Exit ticket & assessment

  1. State the no-run rule and contrast the two disabled study programs.
  2. Calculate clipped steering for tx -12 degrees.
  3. Explain why encoder-cap done is not success and why 4.4 inches is not verified robot clearance.

Assessment: Require correct result/contour gates, steering saturation, continuity boundaries, immediate zero-on-loss, and stop classification. A pass also requires the explicit physical no-run constraint, missing guard, repeated-frame limitation, aggregate-encoder limitation, and unverified lens/front clearance distinction.

Extension challenge: Analyze an independently collected stationary dataset to compare estimated range with tape range at several distances, especially close-up, and quantify lens/front offsets. Do not run, modify, or deploy this excerpt to collect it.

Teacher key · discuss after students predict

Contour and range practice

Age 249 passes, 250 fails. Area 0.04/Y230 wins; 0.16/Y300 and 0.80 exceed height/area limits, and 0.03/Y215 is smaller. Range = 14.2 inches and gap estimate = 12.8 inches.

Steering practice

tx +5 gives c +0.10 and 0.28/0.08; -5 gives -0.10 and 0.08/0.28; +12 and +25 clip to +0.18 and 0.36/0. Source centering rejects exactly 25, while approach steering accepts it.

Continuity practice

12/0.04 and 0/0.25 pass boundaries; 12.1/0.10 and 0/0.251 fail. A failed selected candidate sets seen false with no fallback or last-value update.

Stop practice

Cap is 1127 ticks. Loss commands zero at 2.0 and aborts when elapsed >=0.35; maximum 4 ticks at 1.2 seconds can trigger movement failure if seen and not done/abort. Cap at range 6 is a STOPPED reason. A seen range<=4.4 reports only estimated lens-gap completion.

Center and clearance limits

First four accepted center checks are visibility warmup, so five centered increments can finish at check 9; repeated frames are not excluded. Radius is 1.4 inches, but a robot front beyond the lens reduces real clearance. One longer-distance calibration does not verify this close-up stop.