Chapter 8. Advanced Programming and Control

In this chapter, we will explore advanced controlling algorithms to use for sensor-based navigation and tracking. We will cover:

  • Proportional distance control with the Ultrasonic Sensor
  • Proportional distance control with the Infrared (IR) Sensor
  • Line following with the Color Sensor
  • Two-level control with the Color Sensor
  • Proportional control with the Color Sensor
  • Proportional integral derivative control
  • Precise turning and course correction with the Gyro Sensor
  • Beacon tracking with the IR sensor
  • Triangulation with two IR beacons

Distance controller

In this section, we will program the robot to gradually come to a stop using a proportional algorithm. In Chapter 4, Sensors and Control, we wrote a program where the robot would stop a set distance from a barrier using feedback from the distance sensors. These programs used a discrete reading where the robot would run at full speed until the sensor feedback triggered the robot to abruptly stop. In a proportional algorithm, the robot will gradually slow down as it approaches the desired stopping point.

Before we begin, we need to attach a distance sensor to our robot. If you have the Home Edition, you will be using the IR sensor, whereas if you have the Educational Edition, you will use the Ultrasonic Sensor. Because these sensors use reflected beams (infrared light or sound), they need to be placed unobstructed by the other parts of the robot. You could either place the sensor high above the robot or well out in front of many parts of the robot.

The design I have shown in the following screenshot allows you to place the sensor in front of the robot. If you are using the Ultrasonic Sensor for FIRST Lego League (a competition that uses a lot of sensor-based navigation) and trying to measure the distance to the border, you will find it is a good idea to place the sensor as low as possible. This is because the perimeter of the playing fields for FIRST LEGO League are made from 3- or 4-inch- high pieces of lumber.

Distance controller
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.29.73