Home | Team Info | Documents | News | Progress | Releases | Robots | Concepts | Site Map


Object Avoidance Algorithm

Assumptions

  • A chair has been found and gripped (Successful completion of Chair Gripping Module).
  • We know the final destination’s x, y coordinates (where we want release the chair).
  • The X and Y coordinates of the robot’s current point are different than the X and Y point the robot is currently located.

 

Algorithm Description

The rafsObjAvoid module starts once the chair has been gripped. This module implements obstacle avoidance using the robot’s laser. The laser fields are set up using the getClosestBox function which defines the corners of a box (field) to check for objects. A field is set up on each side of the robot, and if any object enters that field (or conversely if the robot travels in a direction where it is about to collide with an object), the robot adjusts its heading to avoid the object and once clear of obstacles resets its heading to the nearest path to place the chair. The module finishes when the chair is placed in its proper (predefined) location (empty desk).

The robot will use inverse trigonometric (arc tangent) functions to determine a heading from where it is currently located to its goal position. Consider the following examples:

Assume the robot is at point (1, 1) and the goal point to place a chair is (26, 26). First find the difference between the start and end points. Delta X = 26-1 = 25, Delta Y = 26-1 = 25. Now the arc tangent function is at a (Delta Y/Delta X). The value returned is in radians, to get the value back into degrees it must be multiplied by 180/3.1416. The heading is then .7854 * (180/3.1416) = 45 degrees.

This works well for first quadrant headings. However when the Delta X value is less than zero (second and third quadrant values) 180 must be added to the answer to get a correct value relative to zero. As for the fourth quadrant (when Delta X is positive but Delta Y is less than zero) 360 could be added to get a corrected answer, however the robots software is “good enough” to accept a value like -45 degrees or 315 degrees.

A few notes of caution:

First: If the Delta X value is zero, the program would crash. If Delta Y is zero, the robot’s heading will be either 90 degrees or 270 degrees. If Delta X is zero and Delta Y is positive, the heading is 90 degrees. If Delta X is zero and Delta Y is negative, the heading is 270.

Second: The algorithm provides for the case of Delta Y being zero. If Delta X is positive and Delta Y is zero, the heading will be 0 degrees. If Delta X is negative and Delta Y is zero, the heading is 180 degrees.

Lastly: This algorithm uses variables of type float for all calculations. It has been found that if type int is used Delta values can become overly truncated and “odd” values of 180, 0, 90, and 270 appear for no particular reason.

Other notes about the module:

Two functions are implemented in this module, but are not used. These two functions are farRight and farLeft which are both Boolean functions like nearRight and nearLeft, but testing revealed them to be redundant and were not used in the final algorithm. Later revisions to this module may use these functions.