Obstacle Detector (Initial) Design
Naming conventions in algorithm documentation below do not attempt to precisely model expected naming conventio/cygdrive/c/cygwin64/home/svigi/Proj/BusLogic ns in code. They are meant to be a guide as to what class, attribute and method names may be.
maxDiff = 10 degrees ‘largest angle between features all on the same obstacle.
minFeaturesInObj = 3 This is the smallest number of clumped features to be
Considered an obstacle
featureCount = 1 Minimum assumed feature count
currentFeatureID = 0 // Assume valid data input
lastObstacle = false // Used by iterator to signal that no further obstacles are to be found.
IDFirstObstacle(Features)
If CurrentFeatureID == -1, quit
lastObstacle = false
While (isFalseLastLastObstacle())
IDNextObstacle(Features)
obstacleHelper.Cout()
For (i=0; i>numObstacles; i++)
CoutObstacle()
    Class Features
        Attributes:
        Member functions:
Class
Obstacles
IDFirstObstacle() This might be same as IDNextObstacle, but not sure yet.
// currentFeatureID = 0 Assume initialized and valid data input
// featureCount = 1 Assumed for first ID
leftEdgeID = currentFeatureID
nextFeatureID = currentFeatureID + 1 // Assume valid
While (nextFeatureInRange) {
If nextFeatureInRange
RightEdgeID = CurrentFeatureID
FeatureCount++
currentFeatureID++
If featureCount > minFeaturesInObj, set thisIsAnObj = true
ComputeMidpoint()
// Done with this obstacle. Next, we move on to evaluate for next feature and to
// see if possibly it is left edge of the next obstacle
IDNextObstacle()
// General: Cycle through the features in order to identify and locate the next obstacle.
// currentFeatureID // Available from Features array. Assume valid data.
// featureCount Currently valid in features obstacle
leftEdgeID = currentFeatureID // Candidate left edge
// nextFeatureID = currentFeatureID + 1 // Assume set and valid by nextFeatureInRange()
While (nextFeatureInRange) {
If nextFeatureInRange
RightEdgeID = CurrentFeatureID
FeatureCount++
currentFeatureID++
If featureCount > minFeaturesInObj, set thisIsAnObj = true
// Done with this obstacle. Next, we move on to evaluate for next feature and to
// see if possibly it is left edge of the next obstacle
// Todo: Handle condition where we run out of Features. Then, processing ends.
// Todo: Handle condition where an obstacle spans the perimeter at the boundary.
FirstObstacle()
CurrentObstacle = 0
NextObstacle()
If CurrentObstacle+1 invalid, set lastObstacle = true
Else CurrentObstacle++
LastObstacle()
Return lastObstacle boolean, true if last obstacle has been detected.
nextFeatureInRange()
return “quit” if nextFeatureValid is false
thetaDiff = data[currentFeatureID+1] - data[currentFeatureID]
result = (thetaDiff <= maxDiff)
return result
LastObstacle()
Return true if nextFeature fails
else return false
ComputeMidpoint()
ObstacleMidpoint = feature[currentFeatureID].right edge - left edge
- Todo, compute as average of theta values for all points from left edge to right edge.