00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ARSICKLINEFINDER_H
00027 #define ARSICKLINEFINDER_H
00028
00029 #include "ariaTypedefs.h"
00030 #include "ArRangeDevice.h"
00031 #include "ariaUtil.h"
00032 #include <vector>
00033
00034 class ArLineFinderSegment;
00035
00037 class ArLineFinder
00038 {
00039 public:
00041 AREXPORT ArLineFinder(ArRangeDevice *dev);
00043 AREXPORT virtual ~ArLineFinder();
00044
00046 AREXPORT std::map<int, ArLineFinderSegment *> *getLines(void);
00048 ArPose getLinesTakenPose(void) { return myPoseTaken; }
00050 AREXPORT void saveLast(void);
00052 AREXPORT void getLinesAndSaveThem(void);
00054 void setVerbose(bool verbose) { myPrinting = verbose; }
00056 bool getVerbose(void) { return myPrinting; }
00058 void setLineCreationParams(int minLineLen = 40, int minLinePoints = 2)
00059 { myMakingMinLen = minLineLen; myMakingMinPoints = minLinePoints; }
00061 void setLineCombiningParams(int angleTol = 30, int linesCloseEnough = 75)
00062 { myCombiningAngleTol = angleTol;
00063 myCombiningLinesCloseEnough = linesCloseEnough; }
00065 void setLineFilteringParams(int minPointsInLine = 3, int minLineLength = 75)
00066 { myFilteringMinPointsInLine = minPointsInLine;
00067 myFilteringMinLineLength = minLineLength; }
00069 void setLineValidParams(int maxDistFromLine = 30,
00070 int maxAveDistFromLine = 20)
00071 { myValidMaxDistFromLine = maxDistFromLine;
00072 myValidMaxAveFromLine = maxAveDistFromLine; }
00074 void setMaxDistBetweenPoints(int maxDistBetweenPoints = 0)
00075 { myMaxDistBetweenPoints = maxDistBetweenPoints; }
00076 protected:
00077
00078 ArPose myPoseTaken;
00079
00080 std::map<int, ArPose> *myPoints;
00081 std::map<int, ArLineFinderSegment *> *myLines;
00082
00083
00084 AREXPORT void fillPointsFromLaser(void);
00085
00086 AREXPORT void findLines(void);
00087
00088 AREXPORT bool combineLines();
00089
00090 AREXPORT ArLineFinderSegment *averageSegments(ArLineFinderSegment *line1,
00091 ArLineFinderSegment *line2);
00092
00093 AREXPORT void filterLines();
00094
00095 bool myFlippedFound;
00096 bool myFlipped;
00097 int myValidMaxDistFromLine;
00098 int myValidMaxAveFromLine;
00099 int myMakingMinLen;
00100 int myMakingMinPoints;
00101 int myCombiningAngleTol;
00102 int myCombiningLinesCloseEnough;
00103 int myFilteringMinPointsInLine;
00104 int myFilteringMinLineLength;
00105 int myMaxDistBetweenPoints;
00106 double mySinMultiplier;
00107 bool myPrinting;
00108 ArRangeDevice *myRangeDevice;
00109 };
00110
00112 class ArLineFinderSegment : public ArLineSegment
00113 {
00114 public:
00115 ArLineFinderSegment() {}
00116 ArLineFinderSegment(double x1, double y1, double x2, double y2,
00117 int numPoints, int startPoint, int endPoint)
00118 { newEndPoints(x1, y1, x2, y2, numPoints, startPoint, endPoint); }
00119 virtual ~ArLineFinderSegment() {}
00120 void newEndPoints(double x1, double y1, double x2, double y2,
00121 int numPoints, int startPoint, int endPoint)
00122 {
00123 ArLineSegment::newEndPoints(x1, y1, x2, y2);
00124 myLineAngle = ArMath::atan2(y2 - y1, x2 - x1);
00125 myLength = ArMath::distanceBetween(x1, y1, x2, y2);
00126 myNumPoints = numPoints;
00127 myStartPoint = startPoint;
00128 myEndPoint = endPoint;
00129 myAveDistFromLine = 0;
00130 }
00131 double getLineAngle(void) { return myLineAngle; }
00132 double getLength(void) { return myLength; }
00133 int getNumPoints(void) { return myNumPoints; }
00134 int getStartPoint(void) { return myStartPoint; }
00135 int getEndPoint(void) { return myEndPoint; }
00136 void setAveDistFromLine(double aveDistFromLine)
00137 { myAveDistFromLine = aveDistFromLine; }
00138 double getAveDistFromLine(void) { return myAveDistFromLine; }
00139 protected:
00140 double myLineAngle;
00141 double myLength;
00142 int myNumPoints;
00143 int myStartPoint;
00144 int myEndPoint;
00145 double myAveDistFromLine;
00146 };
00147
00148 #endif // ARSICKLINEFINDER_H