Cookie CodersFTC Team 39092

Safety · FTC Blocks // Student lesson

Tele-Learn-SafetyStops
2m Sensors & Safety Stop

Code Lab / Tele-Learn-SafetyStops

Use Tele-Learn-SafetyStops to trace the 2m Sensors & Safety Stop decisions in WallGuardStudy.blk. This DISABLED study reports modified command requests but never sends motor power. It cannot protect Start or any other OpMode. Learn exactly which directions are reduced at 24 inches and blocked at 12 inches, including the unprotected front.

A reported BLOCKED message is a decision in this read-only study, not evidence that a drivetrain has been stopped. The source's mention of a guarded Start should not be read as a claim about the actual basic Start.blk, which has no sensor guard. Sensor-to-wall distance is not bumper clearance, and invalid readings have no explicit health-validation branch.

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

Mission control

Read, predict, compare, explain.

12source-linked steps
7scored quiz checks
Start with a question

If a right wall is close, should a program remove every movement request or only the requests that could move toward that wall?

  • Three 2m sensors
  • 24-inch slowdown
  • 12-inch stop
  • Safe escape directions

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 a right wall is close, should a program remove every movement request or only the requests that could move toward that wall?

By the end, you can…

  • Match signed strafe and reverse commands to their right, left, and rear sensors.
  • Predict strict 12-inch and 24-inch boundary decisions without sign errors.
  • Explain why escape translation can remain available while turning is blocked.
  • Distinguish read-only reports, actual motor outputs, sensor distance, and physical clearance.

01Study decisions without commanding motors

Actual Blocks for this section
Blocks for Study decisions without commanding motors
Blocks to noticeHover, focus or tap a block to see what it does.
  • Pauses the program until the driver presses START on the Driver Station. This study then reports decisions and never sends motor power.
  • Repeats the blocks inside it again and again until the driver presses STOP, so the study keeps re-reading sensors and joysticks.
  • Sends numbers and text to the Driver Station screen. This study reports its decisions this way and has no motor power blocks.

WallGuardStudy is disabled by default and contains sensor/input decisions and reports, not motor setPower blocks. It does not run alongside another OpMode as a protection service. The comment describes a study copy, but the actual basic Start sample is unguarded: do not infer that opening Start installs these decisions.

For example: A report of strafe 0 means this study reduced its variable. It cannot zero a motor controlled by some other program.

Think first

Can leaving this study imported protect a later Start drive session?

Show Answer

No. Importing or reporting a guard decision does not install it in another OpMode's motor-output path.

02Refresh distances before this loop's commands

Actual Blocks for this section
Blocks for Refresh distances before this loop's commands
Blocks to noticeHover, focus or tap a block to see what it does.
  • Runs the custom readWalls function, which reads the three distance sensors and recalculates wall status and scales before the joystick requests are limited.
  • Reads the current left and right stick values on gamepad1 and stores them as the forward, strafe, and turn requests for this loop.
  • The if blocks that limit strafe and reverse requests when a wall is close, using the sensor on the side being moved toward. They change reported values only.
  • Sends the lines added this loop, including the modified forward, strafe, and turn requests, to the Driver Station screen. It does not drive motors.

After START, every active loop calls readWalls, then reads current joysticks, modifies direction requests, and sends telemetry. Sensor sampling precedes command limiting, so the decision uses this loop's sensor readings rather than an intentionally retained old value. It has no explicit sensor-age, plausibility, or hardware-health check.

For example: A paper sequence right distance 30, then 24, then 12 inches should recalculate the guard each time rather than retain CLEAR from the first row.

Think first

Which occurs first: checking the right-strafe branch or reading the right distance?

Show Answer

Reading right distance through readWalls comes first.

03Use direction signs to choose the guard

Actual Blocks for this section
Blocks for Use direction signs to choose the guard
Blocks to noticeHover, focus or tap a block to see what it does.
  • Flips the left-stick up/down reading because FTC reports pushing forward as a negative number, so forward becomes positive.
  • Uses the left stick's side-to-side reading as strafe: positive means right and negative means left.
  • Uses the right stick's side-to-side reading as the turn request. It is later multiplied by turnScale.
  • Tests the sign of a request. Strafe above 0 picks the right guard, strafe below 0 the left guard, and forward below 0 the rear guard.

Positive forward is ahead and negative forward is backward. Positive strafe is right; negative is left. The right sensor is relevant only to positive strafe, the left only to negative strafe, and the rear only to negative forward. The turn input is later multiplied by a shared turnScale. This is not the four-wheel mecanum mixing stage.

For example: LeftStickY +0.70 becomes forward -0.70 and enters the rear branch; LeftStickX -0.60 enters the left branch.

Think first

Which distance controls a negative strafe request?

Show Answer

leftInches, not rightInches.

04Cap positive strafe toward the right wall

Actual Blocks for this section
Blocks for Cap positive strafe toward the right wall
Blocks to noticeHover, focus or tap a block to see what it does.
  • Runs the right-wall guard only when strafe is positive, meaning the driver is asking to move toward the right wall.
  • Multiplies strafe by rightScale, which is 1 when the right sensor reads above 12 inches and 0 at 12 or less, so a close wall zeroes the request.
  • Limits strafe to 0 up to 1 when the right reading is above 24 inches, or 0 up to 0.25 at 24 or less. Smaller requests stay unchanged.

Only a positive rightward strafe enters this branch. Above 24 inches the upper limit is 1. At 24 or below the upper limit is 0.25. rightScale is 1 only above 12 inches; at 12 or below multiplication first makes the request zero. A cap preserves smaller requests rather than multiplying every request by 0.25.

For example: At right distance 20 inches, +0.80 becomes +0.25 but +0.10 stays +0.10. At 12 inches both become 0.

Think first

At exactly 24 inches, does +0.80 remain unchanged?

Show Answer

No. The >24 test is false, so it is capped at +0.25.

05Keep the leftward cap negative

Actual Blocks for this section
Blocks for Keep the leftward cap negative
Blocks to noticeHover, focus or tap a block to see what it does.
  • Runs the left-wall guard only when strafe is negative, meaning the driver is asking to move toward the left wall.
  • Multiplies strafe by leftScale, which is 1 when the left sensor reads above 12 inches and 0 at 12 or less, so a close wall zeroes the request.
  • Limits negative strafe to -1 up to 0 when the left reading is above 24 inches, or -0.25 up to 0 at 24 or less. The bounds stay negative.

A leftward request is negative, so its permitted near-wall interval is [-0.25,0], not [0,0.25]. Above 24 inches the lower bound is -1. At 12 or below leftScale makes leftward strafe zero. A close left wall does not directly remove positive rightward escape.

For example: At left distance 18 inches, -0.80 becomes -0.25 and -0.10 stays -0.10. Using +0.25 as the lower bound would destroy the intended sign.

Think first

With left distance 12 inches and a +0.50 rightward request, does the left branch block it?

Show Answer

No. The left branch runs only for strafe < 0; the right branch evaluates rightward motion using the right sensor.

06Limit reversing, not forward escape

Actual Blocks for this section
Blocks for Limit reversing, not forward escape
Blocks to noticeHover, focus or tap a block to see what it does.
  • Runs the rear-wall guard only when forward is negative, meaning the driver is asking to reverse toward the rear wall.
  • Multiplies forward by rearScale, which is 1 when the rear sensor reads above 12 inches and 0 at 12 or less, so a close wall zeroes reverse.
  • Limits reverse to -1 up to 0 when the rear reading is above 24 inches, or -0.25 up to 0 at 24 or less. Forward motion is not limited here.

Negative forward means reversing toward the rear sensor's wall. Between above 12 and at most 24 inches, that request is bounded to [-0.25,0]. At 12 or below rearScale is zero. Positive forward is not changed by the rear branch, even when the rear is blocked.

For example: At rear distance 24 inches, reverse -0.60 becomes -0.25; forward +0.60 remains +0.60.

Think first

At exactly 12 inches behind the sensor, what happens to reverse -0.20?

Show Answer

It becomes 0 because rearScale is 0 at the boundary.

07Do not mistake direction filtering for full protection

Actual Blocks for this section
Blocks for Do not mistake direction filtering for full protection
Blocks to noticeHover, focus or tap a block to see what it does.
  • Adds the forward request, after the rear guard, to the screen. It is only a reported value; nothing sends it to a motor.
  • Adds the strafe request, after the left and right guards, to the screen. It is only a reported value; nothing sends it to a motor.
  • Adds the turn request, after it is multiplied by turnScale, to the screen. It is only a reported value; nothing sends it to a motor.
  • Sends the three reported requests to the Driver Station screen. There is no front sensor, so a forward request is not checked for obstacles.

The final telemetry reports modified direction requests without writing them to motors. A blocked right wall still allows leftward translation if the left side is clear; a rear wall still allows forward. There is no front sensor, so forward escape can head toward an unseen front obstacle. Turning is handled separately and can be blocked even when escape translation remains.

For example: Right 10 inches, left/rear 40: a -0.50 left request remains -0.50, but any requested turn becomes zero.

Think first

Does the ability to request forward mean the front path has been checked?

Show Answer

No. There is no front distance sensor in this study.

08Read three named sensors in inches

Actual Blocks for this section
Blocks for Read three named sensors in inches
Blocks to noticeHover, focus or tap a block to see what it does.
  • Reads the right REV 2m distance sensor in inches and stores it as rightInches. The range is from the sensor face, not the robot's bumper.
  • Reads the left REV 2m distance sensor in inches and stores it as leftInches. The range is from the sensor face, not the robot's bumper.
  • Reads the rear REV 2m distance sensor in inches and stores it as rearInches. The range is from the sensor face, not the robot's bumper.

readWalls reads the three REV 2m sensors using the names right_distance, left_distance, and rear_distance and requests INCH units. The instructional wiring map assigns right I2C 0, left I2C 1, and rear I2C 2; verify the actual configuration and hub connections rather than guessing. Range is measured from each sensor's face along its view, not from the outer robot bumper.

For example: A sensor recessed 3 inches behind the right edge can report 12 inches while the edge is only about 9 inches from a perpendicular wall.

Think first

Can a millimeter reading be compared directly with the source's number 12?

Show Answer

No. The source threshold means 12 inches; use the INCH getter or convert units consistently.

09Treat exactly 12 as blocked

Actual Blocks for this section
Blocks for Treat exactly 12 as blocked
Blocks to noticeHover, focus or tap a block to see what it does.
  • True when at least one of the three sensors reads 12 inches or less, so one close wall is enough. This sets wallStop for the report.
  • Gives each direction a scale of 1 when its distance is above 12 inches and 0 at exactly 12 or less. The direction guards multiply by it.

Each scale is 1 only if its distance is strictly greater than 12 inches; exactly 12 is false and produces 0. wallStop is NOT(all three >12), so a single boundary/close reading selects the blocked status. Each translation branch uses its own scale, not wallStop as a global translation kill switch.

For example: Right 12, left 30, rear 30 give scales 0,1,1 and wallStop true. Rightward strafe is removed, but leftward escape can remain.

Think first

At 12.1 inches, what is that direction's scale?

Show Answer

1. It is above the hard-stop boundary, though a toward-wall request is still capped by the 24-inch rule.

10Block rotation when any side is blocked

Actual Blocks for this section
Blocks for Block rotation when any side is blocked
Blocks to noticeHover, focus or tap a block to see what it does.
  • Nests two constrain blocks so the three scales combine into their smallest value: 1 only if all are 1, and 0 if any is 0. The result is turnScale.
  • Multiplies the turn request by turnScale, so turning passes unchanged when all sides are above 12 inches and becomes 0 if any side is blocked.

For these 0-or-1 direction scales, nested constrain operations produce their minimum. turnScale is 1 only if all three are 1; if any is 0, it is 0. The main loop multiplies turn by that scale. This addresses turning into a nearby wall, but does not validate the robot's full swept volume or any unseen front obstacle.

For example: Scales 1,0,1 yield turnScale 0, so a -0.70 turn request becomes 0 even with the rear and right clear.

Think first

If all sensors are 18 inches away, is turn multiplied by 0.25?

Show Answer

No. All scales are 1 above 12, so turning remains unchanged; the 24-inch slowdown applies only to toward-wall translation.

11Separate near-wall status from translation caps

Actual Blocks for this section
Blocks for Separate near-wall status from translation caps
Blocks to noticeHover, focus or tap a block to see what it does.
  • True unless all three sensors read above 24 inches, so one reading of 24 inches or less counts as near a wall.
  • Stores that true/false result in nearWall, which only picks the SLOW report when no hard block exists. It does not slow anything itself.
  • Each direction's constrain uses its own sensor's 24-inch test, so a close right wall caps rightward strafe only, not leftward strafe or turning.

nearWall is true unless all three readings are strictly above 24 inches. It supplies the SLOW report when no hard block exists. The actual caps were applied in the matching direction branches using each sensor's own >24 test. A near right wall does not reduce leftward strafe, and the 24-inch status does not slow turning.

For example: Right 20, left 40, rear 40 set nearWall true. A -0.80 left strafe and +0.60 turn stay unchanged in the reported commands.

Think first

Is SLOW status a statement that every requested axis has been reduced?

Show Answer

No. It describes a nearby wall; only matching toward-wall translations are capped.

12Give BLOCKED priority without overstating the result

Actual Blocks for this section
Blocks for Give BLOCKED priority without overstating the result
Blocks to noticeHover, focus or tap a block to see what it does.
  • Adds the right, left, and rear distance readings in inches to the Driver Station screen so students can compare them with the status.
  • Checked first: when any sensor reads 12 inches or less, the report says BLOCKED. This wins over the SLOW message.
  • Checked only when wallStop is false: if any sensor reads 24 inches or less, the report says SLOW.
  • The three status messages the report can show: blocked toward a wall and rotation at 12 inches, slow at 24, or clear. They are reports, not proof of safe clearance.

readWalls adds distance rows and chooses BLOCKED first, then SLOW, then CLEAR. The main loop later adds modified requests and calls telemetry update. A reading <=12 also qualifies as nearWall, but the first branch wins. These are read-only reports, not a tested stop distance or motor protection. Sensor mounting offset, material response, invalid readings, and inertia need separate review.

For example: Right 10, left 20, rear 40 report BLOCKED rather than SLOW, even if a leftward escape request is allowed.

Think first

Does CLEAR certify that no obstacle exists anywhere around the robot?

Show Answer

No. It only reflects these three threshold comparisons; the front, sensor blind spots, and validity are not certified.

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.

directionScale = distance > 12 in ? 1 : 0
The boundary is strict: exactly 12 blocks movement toward that sensor's wall.
positive strafe = constrain(strafe*rightScale, 0, rightInches > 24 ? 1 : 0.25)
At or below 24 inches cap the magnitude at 0.25; do not multiply every small request by 0.25.
negative strafe/reverse = constrain(request*matchingScale, distance > 24 ? -1 : -0.25, 0)
Negative motion toward left/rear walls must retain negative bounds.
turnScale = min(rightScale, leftScale, rearScale); turn = turn*turnScale
The nested source constrains produce this minimum for 0/1 scales. A 12-inch block anywhere removes rotation; 24 inches alone does not.

1. Boundary notebook

On paper trace a +0.80 right request and a +0.10 right request at distances 30, 24, 12.1, and 12 inches. Record rightScale, upper bound, final strafe, turnScale (other sensors 40), and report. Explain cap versus multiplication.

2. Signed escape decisions

Set right/left/rear to 10/40/18 inches. Trace strafe +0.70, strafe -0.70, forward -0.60, forward +0.60, and turn +0.50 independently. Which requests remain, which shrink, and why does BLOCKED not mean all translations are zero?

3. Scope and clearance

Draw three sensors and an absent front sensor. With a right sensor recessed 3 inches from the edge, estimate edge clearance at a 12-inch reading. Explain why WallGuardStudy cannot protect an independently selected Start OpMode and why these reported variables are not wheel powers.

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

0
0
Question 1rightInches = 12 and strafe = +0.80. What reported strafe results?

Question 2rightInches = 20 and strafe = +0.10. What reported strafe results?

Question 3leftInches = 24 and strafe = -0.80. What is the correct limited request?

Question 4Right, left, and rear are all 18 inches away. What happens to a turn request +0.60?

Question 5Right is 10 inches, left and rear 40. Which independent reported request remains allowed?

Question 6What does WallGuardStudy actually do for another selected OpMode?

Question 7Right is 10, left 20, rear 40 inches. Which status branch wins?

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: Keep WallGuardStudy disabled and study-only. It reads sensors and reports command requests; it neither commands motors nor guards another OpMode. No motor outputs should be added for this lesson. For any separately approved read-only sensor observation, secure the robot with wheels clear and a supervisor at STOP, and isolate power before touching hardware. There is no front sensor, no explicit sensor-health validation, and no guarantee of bumper clearance or stopping distance.

Required hardware & dependencies

  • Three REV 2m distance sensors configured right_distance, left_distance, rear_distance; the teaching map is right I2C 0, left I2C 1, rear I2C 2. Verify actual hub/port configuration.
  • FTC Robot Controller, Driver Station, and paired gamepad for any separately authorized read-only observation; drive motors are not an output dependency of this study.
  • Paper threshold table, ruler or tape, and representative stationary targets for sensor-face versus robot-edge measurements. Keep hardware disconnected or secured unless separately authorized.

Source remains WallGuardStudy.blk and is disabled study-only. It uses native distance-sensor Blocks for right_distance, left_distance, and rear_distance; no helper ZIP is provided. Use paper traces or separately reviewed read-only sensor observations. Do not enable this as a safety service for another OpMode, and do not wire its reported commands to motors as part of this lesson.

Robot setup checklist

  1. Inspect the disabled WallGuardStudy.blk in the native Blocks editor. Confirm there are no dcMotor power writes and no intended concurrent protection service.
  2. Use paper inputs first. For a separately reviewed sensor-only observation, check exact sensor names, INCH units, physical orientations, the instructional I2C map, and sensor-to-edge offsets.
  3. Review what happens with blind spots and invalid/out-of-range values rather than assuming every numeric reading is a valid clearance. Do not connect reported forward/strafe/turn variables to a drivetrain.

60-minute teaching sequence

  1. 0-10 min

    Establish study-only scope and draw sensor directions.

    Look for: No motors commanded, no protection for Start, no front sensing.

  2. 10-25 min

    Trace signed branches at 30, 24, 12.1, and 12 inches.

    Look for: Strict boundaries and negative left/rear caps.

  3. 25-40 min

    Work mixed proximity and escape cases, including turning.

    Look for: Direction-specific translation versus any-close rotation block.

  4. 40-60 min

    Interpret status priority, sensor-face offsets, and quiz results.

    Look for: Reported BLOCKED is not measured drivetrain stopping.

Observation notebook

Notebook: read-only thresholds and requested-direction decisions
Right / left / rear (in)Input requestScale / boundReported requestStatus / limitation
24 / 40 / 40strafe +0.801 / upper 0.25+0.25SLOW; not a wheel command
20 / 40 / 40strafe +0.101 / upper 0.25+0.10Cap does not amplify or shrink a small request
12 / 40 / 40strafe -0.50; turn +0.50left 1; turn 0-0.50; 0BLOCKED; escape translation remains

Label every output as a reported variable, not motor power or measured motion. Keep sensor-face and robot-edge clearances in separate columns if measuring.

Troubleshooting · stop before investigating

No motors move when commands are reported.
That is intentional: this disabled study has no motor output stage. Do not fix it by adding motor power.
A -0.80 request becomes a positive value in a student's table.
Review constrain bounds: left and rear near-wall intervals are [-0.25,0], not [0,0.25].
A small +0.10 request is calculated as +0.025.
Distinguish the 1/0 stop scale from the 0.25 cap. At 20 inches the scale is 1, and constrain preserves 0.10.
SLOW appears while turn remains unchanged.
That matches the source: above 12 all turn scales are 1, even if a reading is at or below 24.
CLEAR conflicts with a front obstacle or unexpected range.
The front is unmeasured and there is no explicit reading-validity gate. Treat the report as limited evidence, not a safety certificate.

Exit ticket & assessment

  1. Predict a left request of -0.80 at exactly 24 inches.
  2. Explain why a 12-inch right block also removes rotation but can allow left escape.
  3. Explain why this study cannot stop another OpMode.

Assessment: Require correct signed caps, strict thresholds, turnScale, and report precedence. A student must explicitly distinguish read-only requests from motor outputs and name the absent front sensor and cross-OpMode limitation.

Extension challenge: On paper propose sensor validity checks and a sensor-face-to-edge clearance model for a future reviewed system. Do not convert this study into an active drive guard.

Teacher key · discuss after students predict

Boundary table

For right distances 30/24/12.1/12: +0.80 becomes 0.80/0.25/0.25/0; +0.10 becomes 0.10/0.10/0.10/0. rightScale is 1/1/1/0; turnScale is the same with other sensors 40. Status CLEAR/SLOW/SLOW/BLOCKED.

Escape practice

At 10/40/18: right +0.70 becomes 0, left -0.70 stays -0.70, reverse -0.60 becomes -0.25, forward +0.60 stays +0.60, and turn +0.50 becomes 0. BLOCKED wins.

Clearance and scope

A 12-inch reading with a 3-inch recessed sensor suggests about 9 inches of perpendicular edge clearance. No motor writes or cross-OpMode hook exist, so reported variables do not stop Start.