Well, I haven’t yet used them, but I’ve some ideas in mind:
On my biped’s car, I’ll be placing 3 equally-spaced sensors on the nose of the bot.
They’ll be pointing left-forewards, forwards, and right-forewards, respectively.
I’ll use the left and right sensors to navigate evenly between obstacles.
I’ll start off with some simple code like:
[code]If DrivingFlag = 1 and TimeToCheckSonarFlag = 1
{
LeftSensor = GetADCleft();
RightSensor = GetADCright();
If (LeftSensor - RightSensor) > UpperThreshold
TurnLeft();
ElseIf (LeftSensor - RightSensor) > UpperThreshold
TurnRight();
Else
KeepDriving();
TimeToCheckSonarFlag = 0;
}
(The driving flag will be set by the background PWM motor control and the check sonar flag will be set by the overall timer interupt.
I’ve found that a single overall timer interupt set at a low period of time works very well to set necessary flags.
If large times between flag triggers are needed, as they would be here, then I have the flag trigger after multiple timer iterations.)
[/code]
That code won’t always work, especially when navigating down a hallway and coming across an open door on the left or right.
I’ll have to tweak thing when I get to that point, but putting in something simple like this should do well enough:
If BothSensorsAreAtLeast5InchesFromTheWall then
DontBotherCorrecting();
The foreward sensor will be used for less ordinary things as well as to aid in ordinary obstancle avoidance.
I might also use it to aid in chasing down target objects, but that’ll be later on.
I’ll also be eventually using a CMUcam2 and 3 laser pointers to measure distances of traced objects.
When the rover is at rest (driving flag is 0) I’ll have the sensors much more actively polled so that I can detect moving objects crossing the rover’s path.
Since the two sensors side sensors will be at nice 45 degree angles, I’ll have a pretty easy job of calculating the approximate speed and trajectory of the moving object.
For instance, if a ball rolls diagonally in front of the rover from the right side to the left (from the perspective of the rover), the right sensor will be the first to read a largely-changed value.
At that point, a timer will start.
When the next sensor (the middle) detects a large change, it’ll record the time, and restart the timer.
And so on for the last sensor.
The rest is all just basic trig and goeometry to figure out the speed based on the times, angle of the sensors, and sensor readings during the change.
So, to sum it all up, the rover-mounted sensors will be employed mostly for avoidance when moving and the pan/tilt-mounted sensors will be used for chasing.