Infrared sensors for reliable FTC line following
Infrared sensors for line following in FTC turn a visually simple track into a measurable control problem. A reflectance array samples infrared light reflected from the field, and software converts the contrast into line position and motor commands. This approach suits offseason challenges and custom autonomous exercises where a robot follows a black tape line, a white line, or a marked route with turns and branches.
Reliable performance depends on more than choosing a sensor. The array needs correct height and wiring, calibration for the actual surface, control suited to a differential-drive chassis, and realistic testing. Australian teams should account for varied venue lighting, travel between cities, summer school holidays, and delays when importing replacement parts.
Match the sensor to the task
An eight- or sixteen-channel IR reflectance array is usually the most direct option for FTC line following. Each channel reports how much infrared light returns from the field, allowing the program to estimate where the line sits beneath the robot. A pair of IR distance sensors can detect a line or obstacle, but it provides much less positional information than an array.
| Sensing option | Signal used | Best fit | Main limitation |
|---|---|---|---|
| IR reflectance array | Reflected IR brightness | Continuous line position | Requires light and contrast calibration |
| Single IR distance sensor | Distance to a surface | Obstacle or edge checks | Cannot locate a line across the robot |
| 2D optical distance sensor | Distance and reflected-light geometry | Mapping and obstacle sensing | One spatial sample per reading |
| Camera | Pixels and colour | Markings and intersections | Lighting, processing, and latency |
For a continuous route, the reflectance array offers the best balance of speed and simplicity. A 2D optical distance sensor is useful when a task also needs obstacle ranging or custom mapping. A camera can handle colour-dependent markings and complex intersections, although it introduces greater lighting, processing, and latency requirements.
Check the current FIRST rules before selecting hardware, especially for a custom or multi-channel array. Power it through a compatible sensor interface and confirm that its readings can be read reliably by the Control Hub or Expansion Hub. Also check connector pinouts and cable strain relief; a neat prototype can still fail when the robot bumps into another robot at an event.
Mount and calibrate for consistent readings
Mount the array squarely across the chassis and parallel to the floor. Follow its specified clearance, often only a few millimetres, then lock the bracket so vibration cannot change the gap. Keep it away from direct sunlight, robot LEDs, sharp shadows, hot motors, and motor-current cables. An adjustable mount helps during setup, but a fixed position is better after testing.
Calibrate on the surface the robot will actually follow. Record several readings over the light field and over the dark line, then determine each channel’s usable range. For a dark line, subtract the raw reading from the light-field reference and treat only positive differences as line signal. For a light line on a dark field, reverse that relationship. Avoid starting automatic calibration while the robot is already over the line, because it may mistake the line for the background.
A consistent routine helps a developing team avoid guesswork. This account of growing an FTC team shows why moving from rookie to veteran is not just about adding mechanisms: written checklists, shared calibration data, and versioned code make knowledge repeatable. Keep a reference configuration for each field type, and log suspicious channels instead of silently discarding them.
Convert reflectance into a line error
Turn calibrated channel readings into an “active” value representing likely line coverage. For a dark line, a simple calculation is active[i] = max(0, lightReference[i] - raw[i]). For a light line, use max(0, raw[i] - darkReference[i]). The program can then calculate a weighted line position as error = sum(weight[i] * active[i]) / sum(active[i]), assigning negative weights to channels on the left and positive weights to channels on the right.
This calculation makes the control signal understandable. If only a centre channel sees the line, the error stays close to zero. A line under a left channel produces a negative error, while one under a right channel produces a positive error. Normalise or limit the result before using it because the denominator can become very small when no channel detects strong contrast. That may be the signal to enter a recovery routine rather than steer violently.
Use the sum of active readings as a confidence measure as well as position. A narrow line usually activates one or two channels; a wide intersection may activate several; an endpoint may activate none. These patterns can distinguish ordinary following from branches, crossings, and a lost line. Apply a short median or moving-average filter to reduce spikes, but keep the delay low enough for the robot to respond during sharp turns.
Close the control loop cleanly
A line error still needs to become a physical correction. FTC teams commonly use proportional, integral, and derivative control: output = Kp * error + Ki * integralError + Kd * derivativeError. On a differential-drive chassis, subtract or add the steering component to the left and right motor power. A positive steering command might make one side faster than the other, depending on motor orientation and the sign chosen for the error.
Tune one term at a time and begin with proportional control. Increase the gain until the robot tracks a straight section without excessive oscillation, then add derivative control to reduce overshoot. Integral control can remove a steady bias, but too much causes wind-up and slow recovery after a turn. Compensate for the drivetrain’s dead zone if the robot only turns when one motor receives noticeably more power. On a skid-steer chassis, unequal loading and friction can also make identical commands produce different paths.
Run the follower as a state machine inside the autonomous routine. Useful states include acquiring the line, following it, handling a branch, recovering from loss, and finishing. Give every state a timeout so the robot cannot remain in a recovery loop indefinitely. Telemetry for raw channels, filtered error, confidence, and motor output makes tuning much faster than watching the robot alone.
Test under Australian event conditions
Home testing often uses one carpet, one lighting setup, and the same battery charger. Events change that baseline. Strong daylight near windows in Perth or Brisbane can overpower an IR array, while a hall in Melbourne or Adelaide may have different lamps and shadows. Test on both light and dark field materials, at different battery voltages, and with the robot carrying its final mechanisms. Australian slang has a useful place in the workshop too: when a prototype fails, “give it a go” is fine, but record what changed before trying again.
Plan around the southern-hemisphere calendar as well. The long summer break, generally from late December through January, can interrupt testing just as a school year begins. Allow time for the robot to return to the bench, recalibrate, and recheck drivetrain fasteners. If an event is in another state, rehearse the transport case, charging routine, and setup process before travelling; a sensor that worked at home may need recalibration after a long drive.
A scrimmage exposes problems that solo testing misses, including unreliable line acquisition, route ambiguity, and motor differences between robots. This guide to running a robotics scrimmage offers useful event habits for FIRST programs even though it focuses on LEGO League. In an FTC session, give teams the same route and scoring conditions, require a quick inspection before each run, and schedule time for sensor recalibration. Teams buying from overseas suppliers should also allow for GST, Australian dollar exchange rates, and shipping lead times when ordering a spare array or interface.
Build a reliable team routine
Treat line following as a shared engineering system, not one student’s private project. A mentor can establish calibration and review procedures; students can own the sensing software, drivetrain tuning, or test documentation. Sponsorship helps with sensors, batteries, field materials, and travel, so search grant opportunities and check each organisation’s eligibility, timing, and reporting requirements before promising a project budget. A well-supported team can buy spare parts, but sound processes still matter more than expensive hardware.
Keep the work visible. A short test log should state the field surface, lighting conditions, sensor configuration, error settings, battery level, and observed failure. After each event, separate calibration data from control settings so a change in one does not create confusion in the other. This approach also makes mentoring easier: a new student can reproduce a known-good result before attempting a new feature.
Use this checklist each week:
- Calibrate on the actual field material and save a named configuration.
- Log raw readings, filtered error, confidence, and motor commands for every test.
- Change one control parameter at a time and record the result.
- Pack spare sensors, cables, and a compatible interface before an event.
For the next build cycle, select a short route, assign sensor calibration, control software, and testing roles, then schedule a practice scrimmage with the deadline in the team calendar. Give teams a clear route, consistent judging, and time to fix their robots, and publish the results so every crew can see how iteration improved reliability.
Maryland FIRST Robotics