00001 /** 00002 * 00003 * This file contains a class that estimates the distance to the border. 00004 * 00005 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a> 00006 */ 00007 00008 #include "DistanceToBorderEstimator.h" 00009 00010 DistanceToBorderEstimator::DistanceToBorderEstimator(const SelfLocatorInterfaces& interfaces) : 00011 SelfLocatorInterfaces(interfaces) 00012 { 00013 numberOfLinesPerceptsWithoutBorderPoints = 100; 00014 lastDistanceToBorder = 1000; 00015 } 00016 00017 void DistanceToBorderEstimator::execute() 00018 { 00019 int currentDistanceToBorder = 0; 00020 for(int i = 0; i < linesPercept.numberOfPoints[LinesPercept::border]; i++) 00021 { 00022 currentDistanceToBorder += linesPercept.points[LinesPercept::border][i].abs(); 00023 } 00024 if(linesPercept.numberOfPoints[LinesPercept::border] > 0) 00025 { 00026 currentDistanceToBorder /= linesPercept.numberOfPoints[LinesPercept::border]; 00027 numberOfLinesPerceptsWithoutBorderPoints = 0; 00028 } 00029 else 00030 { 00031 numberOfLinesPerceptsWithoutBorderPoints++; 00032 if(numberOfLinesPerceptsWithoutBorderPoints > 30) currentDistanceToBorder = 1000; 00033 else currentDistanceToBorder = lastDistanceToBorder; 00034 } 00035 distanceToBorderBuffer.add(currentDistanceToBorder); 00036 00037 robotPose.distanceToBorder = distanceToBorderBuffer.getSum() / distanceToBorderBuffer.getNumberOfEntries(); 00038 robotPose.angleToBorder = 0.777; 00039 } 00040 00041 00042 /* 00043 * Change log : 00044 * 00045 * $Log: DistanceToBorderEstimator.cpp,v $ 00046 * Revision 1.1.1.1 2004/05/22 17:20:41 cvsadm 00047 * created new repository GT2004_WM 00048 * 00049 * Revision 1.1 2004/03/27 16:17:24 juengel 00050 * Added DistanceToBorderEstimator. 00051 * 00052 */