| aMo_HugIter | Index |
Definition:
Parameters:
| range | - | Measurement from a ranging device. |
| setpt | - | The distance to maintain from a wall. |
| side | - | The wall to hug. The convention is +1 for a right wall-hug and -1 for a left wall-hug. The defined value AMO_RWHUG may be used for a right wall-hug and the defined value AMO_LWHUG may be used for a left wall-hug. |
Return Value:
Description:
This routine takes a range value (from a device such as an IR ranger or sonar) compares it to a "set point" and steers the robot left or right in order to maintain that distance from the wall. The routine must be called repeatedly in order to keep the robot on course. This may be done in a loop. Additional processing may be done in the loop to control other functions of the robot.
The min and max speeds for the steering must be defined in a copy of an aMo_Def.tea file. The performance will depend on the design of the robot. Typically, a wall-hugging range finder will work best when pointing forward at an angle of about 45 degrees.
The source code for this routine is a good starting point for creating customized tracking routines.
Example:
#include <aMyRobot.tea>
#include <aMo.tea>
void main()
{
int r;
aMo_Init();
while (1)
{
r=(range measurement);
aMo_HugIter(r,120,AMO_RWHUG);
}
}
This would make a robot follow a wall to its right. The set point of 120 corresponds to a 14-16 inch measurement from a Sharp GP2D02. The "aMyRobot.tea" file is a copy of the "aMo_Def.tea" file which contains specific servo parameters for the robot.
Related: