01READ-ONLY WALL GUARD STUDY
This is a small copy of the sensor and safety decisions in Start. It does not drive the robot or protect another program. To see the actual motor commands, open the full Start sample next.
Explore the real right, left, and rear REV 2m sensor Blocks from Start: 24-inch toward-wall speed limit and 12-inch directional stop. This read-only study sample reports guarded joystick commands but cannot drive or protect the robot by itself.
Before running: Ask your mentor first. Keep Driver Station STOP ready.
Read these steps before exploring the full program. The numbered blue comments in the diagram link back to the matching step.
This is a small copy of the sensor and safety decisions in Start. It does not drive the robot or protect another program. To see the actual motor commands, open the full Start sample next.
The loop repeats while START is active. First read each sensor again. Then read the joysticks and apply the guard before showing the result. This study program never sends power to a motor.
Forward is positive; backing up is negative. Strafe means sliding sideways: right is positive and left is negative. Turning uses the other joystick. We only reduce a command when it points toward the wall that sensor sees.
When the joystick asks for a positive (rightward) strafe, use the RIGHT sensor. At 24 inches or closer, cap it at 0.25. At 12 inches or closer, rightScale is 0, so the rightward command becomes 0.
A leftward strafe is a NEGATIVE number. Near the left wall the cap is -0.25, not +0.25. At 12 inches or closer, leftScale is 0, so leftward movement stops while rightward escape is still possible.
Backing up is negative forward power. If the REAR sensor sees a wall within 24 inches, limit the backward command to -0.25. At 12 inches or closer, rearScale makes backing up 0.
The right sensor only changes right strafe, the left sensor only changes left strafe, and the rear sensor only changes reversing. The robot can still move away. There is no sensor at the front.
Right is named right_distance on I2C 0. Left is left_distance on I2C 1. Rear is rear_distance on I2C 2. Each reading is requested in INCHES. These sensors cannot see a wall in front.
The test says greater than 12. At exactly 12 inches it is false. Each direction gets a 1 if clear or 0 if blocked. Multiplying by 0 removes movement TOWARD that wall, not every movement.
The smallest of the three direction scales becomes turnScale. If any sensor is at or below 12 inches, that scale is 0 and turning is blocked. Above 12, rotation is still allowed.
The guard limits only a command headed TOWARD the matching wall to at most 0.25 of full power. A smaller command stays small. Turning is not slowed just because a wall is 24 inches away.
Show right, left, and rear inches plus a CLEAR, SLOW, or BLOCKED message. The BLOCKED message wins when a wall is within 12 inches. A sensor measures from itself, not the bumper; always test with the wheels raised and a person ready to press STOP.
Zoom in to follow the connections. Click a blue comment or focus its label and press Enter to revisit that lesson step.
Ask your mentor before importing or running these Blocks. A download does not set up or start the robot.
Study-only: This importable excerpt reports guarded commands but never powers a motor. It cannot protect another OpMode by itself. See the complete Start driving program for where the guard is applied to the wheels. Test with wheels raised and STOP ready.