Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArLineFinder.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   // where the readings were taken
00078   ArPose myPoseTaken;
00079   // our points
00080   std::map<int, ArPose> *myPoints;
00081   std::map<int, ArLineFinderSegment *> *myLines;
00082 
00083   // fills up the myPoints variable from sick laser
00084   AREXPORT void fillPointsFromLaser(void);
00085   // fills up the myLines variable from the myPoints
00086   AREXPORT void findLines(void);
00087   // cleans the lines and puts them into myLines 
00088   AREXPORT bool combineLines();
00089   // takes two segments and sees if it can average them
00090   AREXPORT ArLineFinderSegment *averageSegments(ArLineFinderSegment *line1, 
00091                       ArLineFinderSegment *line2);
00092   // removes lines that don't have enough points added in
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

Generated on Tue Feb 20 10:51:40 2007 for Aria by  doxygen 1.4.0