Skip to Main Content

Robots @ SIT

Get hold of one of the available Robots at SIT Library and start your robotics journey today!

Description

Required Knowledge:

Conditional statements, Logical operators, Line Tracking

Application:

Line tracking robots are currently used to deliver mails in some office buildings, move items through factory assembly lines, find and collect products in warehouses and deliver medications in hospitals. These are only a few examples of the many usages of such robots in today's world.

 

Line Tracking Module

Make a function/module that tracks a line using the following line tracking algorithm. Now, anytime you need to track a line, you will be able to reuse this function/module!

  • If the left line sensor is over white and the right is over black, turn right.
  • If the right line sensor is over white and the left is over black, turn left.
  • If both line sensors are over the same color, move forward in a straight line.

Snap: Make a block that only includes the if-else statements and turns that you use to track the line. It should not contain a loop. To test your block, write a program that uses your block in a loop.

 

Snap!:

1. Create a block named FinchLineTrack. 

2. Within the block editor, add an if-else block, and another if-else block within the first else block.

3. Use the following algorithm for the line tracking block:

  • If the left line sensor is over white and the right is over black, turn right.
  • If the right line sensor is over white and the left is over black, turn left.
  • If both line sensors are over the same color, move forward in a straight line.
  • You will need knowledge for logical operators and comparison blocks to accomplish this.

4. Place the FinchLineTrack block into a forever loop block to loop infinitely, or place it in a repeat until block that stops when a button is pressed.

 

 

Python:

1. Use 'def linetrack():' to define the line tracking function.

2. Within the function, use an if-elif-else statement to move the Finch depending on what the line tracking sensors detect.

3. Use the code below to test out your function!

 

Use black electrical tape to create a path on a large sheet of white paper. The path should be about 2.5 cm wide. Avoid sharp turns; it is easier for the Finch to follow gradual curves.

 

Sample Codes