Table of Contents

Function Definition: initializelinefollower(F = 35, T1 = 40, T2 = 10)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
FintThe speed with which the robot will move forward when it has not detected a black line.0 to 10035
T1intThe speed with which the motor will move forward on turning.0 to 10040
T2intThe speed with which the motor will move backword on turning.0 to 10010

Description

The function initializes the following line parameters for the Quarky robot – F. T1 and T2:

There are 3 important things we will use in a line following robot:

  1. F: The speed with which the robot will move forward when it has not detected a black line.
  2. T1 & T2: When the robot is following the line and if one of the sensors says the left one, detects the black line, then the robot is off track and has to turn left in order to get back on track. And we know how to turn the robot left. The left motor moves backward and the right move forward. But if both are moving at the same speed, then the robot’s motion will become jerky and inefficient. Hence we will have two speeds for turning T1 and T2, where
    1. T1 will be the speed with which the motor will move forward and
    2. T2 will be the speed with which the motor will move backward.

The user will have to set F, T1, and T2 during the programming and calibrate it for effective line following. 

Example

The example demonstrates how to make a delivery robot that follows the line and stops when it reaches checkpoint 1 in the Python Coding Mode.

Code

sprite = Sprite('Tobi')
quarky = Quarky()
cards = RecognitionCards()

cards.video("on", 0)
cards.enablebox()
cards.setthreshold(0.5)

quarky.setirthreshold("IRL", 3000)
quarky.setirthreshold("IRR", 3000)
quarky.initializelinefollower(35, 40, 10)

quarky.drawpattern("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

while True:
  if not (quarky.getirstate(35) and quarky.getirstate(34)):
    quarky.dolinefollowing()

  else:
    quarky.stoprobot()
    cards.analysecamera()

    if cards.isnumberdetected(1):
      quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
      break

    quarky.runrobot("FORWARD", 40)

Output

Read More
The example demonstrates how to make a simplified line following a robot with Quarky in the Python Coding Environment.

Code

sprite = Sprite('Tobi')
quarky = Quarky()

quarky.setirthreshold("IRL", 3000)
quarky.setirthreshold("IRR", 3000)
quarky.initializelinefollower(35, 40, 10)

while True:
  if not (quarky.getirstate(35) and quarky.getirstate(34)):
    quarky.dolinefollowing()

  else:
    quarky.stoprobot()

Output

Read More
All articles loaded
No more articles to load