IR Rangefinders Algorithm

One of the robot’s navigation logic is implemented using the digital inputs from 8 identical on-board Infrared Sensors. Each of these sensors returns a digital voltage signal.

Real Distance Linearization

The voltage signal input of the sensors are converted to real distance using linearization because the voltage and distance are in a non-linear relationship. After plotting the data of voltage VS distance, the following calculation is done for distance approximation.

  • 0 – 0.8V: distance = ((1.1 – voltage)*100000) / 875
  • 0.8 – 1.55V: distance = ((2.25 – voltage)*100000) / 4545
  • 1.55 and above: distance = (4 – voltage)*10000 / 1531

Front Sensor

Depending on the range of the front sensor input, the robot is controlled in 5 forwarding speed and 1 reversing speed

  • 0 – 15: reverse the motor because it is too close to an object (wall)
  • 16 – 70: set the motor to move forward in turtle speed mode
  • 71 – 90: set the motor to move forward in slow speed mode>
  • 91 – 100: set the motor to move forward in normal speed mode>
  • 100 – 120: set the motor to move forward in fast speed mode
  • 120 and above: set the motor to move forward in extreme speed mode

6 Blind Spot Sensors

These 6 IR sensors are for front left and right blind spot checking. The center angle for the robot to move straight is 84, while the left most turning angle is 72 and the right most turning angle is 96. The turning angle varies depending on the difference of the IR sensors on each side.

  • Difference > 8: steering is set to 80 (left)
  • Difference < -8: steering is set to 88 (right)
  • Otherwise: steering is set to 84 (go straight)

The above cases set the initial steering angle for the robot using the first pair of the blind spot sensors that are placed near the front of the robot. The following cases adds relative angles depending on the difference of the second pair of IR sensors pointing diagonally 45 degree from the sides.

  • Difference > 15: minus 4 to the initial steering angle if the angle range is still within 72 to 96 (turn left more)
  • Difference > 30: minus 8 to the initial steering angle if the angle range is still within 72 to 96 (turn left even more)
  • Difference < -15: plus 4 to the initial steering angle if the angle range is still within 72 to 96 (turn right more)
  • Difference < -30: plus 8 to the initial steering angle if the angle range is still within 72 to 96 (turn right even more)

Finally the pair of 90 degree side sensors are checked.

  • Difference > 20: minus 1 to the initial steering angle if the angle range is still within 72 to 96 (turn left more)
  • Difference < -20: plus 1 to the initial steering angle if the angle range is still within 72 to 96 (turn right more)

These side pair is also used for speed control at the intersection. If both sensors detect a distance greater the width of the race course, then it will set the forward speed to low. Doing so will reduce error that might occur in navigating at the intersection.

Rear IR sensor

One IR sensor is places at the rear of the robot for obstacle avoidance when a reverse operation is being done.
While the distance returned by the rear sensor is larger then 50, the motor is set to reverse direction.

Reverse Operation

Due to the limitation of the mechanical design where a 4-wheel drive system is used, there are times where the robot needs to perform a reverse operation to turn around (e.g., when it’s really close to a wall or it realizes it’s going the wrong direction). The pair of blind spot checking IR sensors at the front are used as inputs for the reverse operation. The main reason is because out of the 6 blind spot sensors, this pair is the most sensitive to what is in the closest front left and right. The logic is as follow:

  • left distance > right distance: reverse left
  • left distance < right distance: reverse right
This entry was posted in Software Design and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *