Planning the program Pro Preview

The main difference between this field and the easier one is the addition of crossroads. Crossroads introduce a new level of difficulty that can be overcome by programming the robot to remember the paths it has taken, although there are simpler and more elegant solutions.

For this challenge, it is assumed that the field layout is unknown before the competition, making it impossible to hardcode a specific sequence of turns.

content picture

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #2303
  • 29 Oct 2024

Previously, we planned three functions for the robot (line following, turning, and skipping missing segments). However, we now face situations with two simultaneous turns, where only one is correct. A closer inspection reveals two details that will help us plan our solution:

  1. After a wrong turn, the correct path is always 180° in the opposite direction.
  2. There are crossroads with two incorrect paths, which the robot must be able to account for.

With this in mind, we make the following changes to the previous program:

  1. The robot does not turn immediately after detecting a turn; instead, it remembers the turn’s direction while continuing forward. This ensures that the robot always moves forward when facing a crossroads.
  2. After detecting a turn, it resets the relative position of one motor to help determine if it has passed a crossroads or if it needs to turn immediately due to no path forward.
  3. After each turn or successful segment skip, the robot clears any previously detected turns from memory.
  4. If skipping a missing segment fails to find a line and no turns are detected, the robot assumes it took a wrong turn, makes a 180° turn, and goes in the opposite direction. Since the wrong turn always ends near the crossroads, this approach ensures recovery.
  5. If skipping a missing segment fails to find a line and turns are detected, the robot returns to the crossroads, where the motor position was reset, and makes a turn.
  6. All turns have two sets of commands: one for immediate turns and one that returns to the crossroads before turning.

These changes add complexity, so let's review how this program behaves in different scenarios. First, let’s start with a simple turn:

  1. The robot detects a turn but attempts to continue forward.
  2. When it finds no path forward, it initiates a turn.
  3. The turn command detects a low motor position and executes the immediate turn sequence.
  4. The robot resets its memory of turns and resumes following the line.

Next, let’s see what the robot does when it encounters a "T" section and makes the wrong turn:

  1. The robot detects turns in both directions but continues forward.
  2. When it finds no path forward, it initiates a turn.
  3. The turn command detects a low motor position and executes the immediate turn sequence.
  4. The robot resets its memory of turns and resumes following the line.
  5. Upon reaching the end of the path, it attempts to skip a missing segment.
  6. After the skip, it finds no line and no turns since they were reset, so it makes a 180° turn and resumes following the line.

Finally, let’s see what the robot does when it encounters a crossroads with two incorrect paths:

  1. The robot detects turns in both directions but continues forward.
  2. Upon reaching the end of the path, it attempts to skip a missing segment.
  3. After the skip, it finds no line but detects previously identified turns, prompting it to turn.
  4. The turn command detects a high motor position and executes the correction turn sequence.
  5. The robot resets its memory of turns and resumes following the line.
  6. Upon reaching the end of the second path, it again attempts to skip a missing segment.
  7. After the skip, it finds no line and no turns since they were reset, so it makes a 180° turn and resumes following the line.

In each scenario, the robot initially takes the wrong path but ultimately finds the correct one. This program’s simplicity—relying on a few rules rather than memory-based path tracking—demonstrates how basic logic can address complex challenges.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Line Following
  • 15
  • 0:00
  • 42
Image for Taking it up a notch
  • 1
  • 0
  • 4
  • 3d_rotation 2