The avoid behaviour tries to ensure the robot stays away from objects and steers the robots out of the way. It takes its input from both the sonar and IR range finders.
The sonar sensors are good for distances between 27cm to >200cm, and have a very reliable response and accurate resolution.
As the IR range finders have a reliable range from 10cm to 100cm.
The avoid behaviour bases its decisions on two parameters:
The purpose of the SonarTracingLimit is so the avoid behaviour, although whilst not changing the direction of the robot, can slow the robots speed down. This means that it has more time to accurately detect and obstacle.
Once the distance between the robot and an object has fallen below the SonarObjectNear threshold it will arc the robot away from that object until there is enough room to clear the object.
In the case of the front sonar detecting and object, instead of just turning in a predefined way it will calculate the average free space to both left and right of the front sonar. Which ever is greater it will then turn in that direction.
Whilst the IRRF data is always sent onto the HCS for mapping processing they are only using by the avoid behaviour when the value of a specific IRRF sensor is: