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

ArLineFinder.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
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 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARSICKLINEFINDER_H
00028 #define ARSICKLINEFINDER_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArRangeDevice.h"
00032 #include "ariaUtil.h"
00033 #include <vector>
00034 
00035 class ArLineFinderSegment;
00036 
00038 class ArLineFinder
00039 {
00040 public:
00042   ArLineFinder(ArRangeDevice *dev);
00044   virtual ~ArLineFinder();
00045 
00047   std::map<int, ArLineFinderSegment *> *getLines(void);
00049   ArPose getLinesTakenPose(void) { return myPoseTaken; }
00051   void saveLast(void);
00053   void getLinesAndSaveThem(void);
00055   void setVerbose(bool verbose) { myPrinting = verbose; }
00057   bool getVerbose(void) { return myPrinting; }
00059   void setLineCreationParams(int minLineLen = 40, int minLinePoints = 2)
00060     { myMakingMinLen = minLineLen; myMakingMinPoints = minLinePoints; }
00062   void setLineCombiningParams(int angleTol = 30, int linesCloseEnough = 75) 
00063     { myCombiningAngleTol = angleTol; 
00064     myCombiningLinesCloseEnough = linesCloseEnough; }
00066   void setLineFilteringParams(int minPointsInLine = 3, int minLineLength = 75)
00067     { myFilteringMinPointsInLine = minPointsInLine; 
00068     myFilteringMinLineLength = minLineLength; }
00070   void setLineValidParams(int maxDistFromLine = 30, 
00071                           int maxAveDistFromLine = 20)
00072     { myValidMaxDistFromLine = maxDistFromLine; 
00073     myValidMaxAveFromLine = maxAveDistFromLine; }
00074 protected:
00075   // where the readings were taken
00076   ArPose myPoseTaken;
00077   // our points
00078   std::map<int, ArPose> *myPoints;
00079   std::map<int, ArLineFinderSegment *> *myLines;
00080 
00081   // fills up the myPoints variable from sick laser
00082   void fillPointsFromLaser(void);
00083   // fills up the myLines variable from the myPoints
00084   void findLines(void);
00085   // cleans the lines and puts them into myLines 
00086   bool combineLines();
00087   // takes two segments and sees if it can average them
00088   ArLineFinderSegment *averageSegments(ArLineFinderSegment *line1, 
00089                                           ArLineFinderSegment *line2);
00090   // removes lines that don't have enough points added in
00091   void filterLines();
00092 
00093   bool myFlippedFound;
00094   bool myFlipped;
00095   int myValidMaxDistFromLine;
00096   int myValidMaxAveFromLine;
00097   int myMakingMinLen;
00098   int myMakingMinPoints;
00099   int myCombiningAngleTol;
00100   int myCombiningLinesCloseEnough;
00101   int myFilteringMinPointsInLine;
00102   int myFilteringMinLineLength;
00103   bool myPrinting;
00104   ArRangeDevice *myRangeDevice;
00105 };
00106 
00108 class ArLineFinderSegment : public ArLineSegment
00109 {
00110 public:
00111   ArLineFinderSegment() {}
00112   ArLineFinderSegment(double x1, double y1, double x2, double y2, 
00113                       int numPoints, int startPoint, int endPoint)
00114     { newEndPoints(x1, y1, x2, y2, numPoints, startPoint, endPoint); }
00115   virtual ~ArLineFinderSegment() {}
00116   void newEndPoints(double x1, double y1, double x2, double y2, 
00117                     int numPoints, int startPoint, int endPoint)
00118     {
00119       ArLineSegment::newEndPoints(x1, y1, x2, y2);
00120       myLineAngle = ArMath::atan2(y2 - y1, x2 - x1);
00121       myLength = ArMath::distanceBetween(x1, y1, x2, y2);
00122       myNumPoints = numPoints;
00123       myStartPoint = startPoint;
00124       myEndPoint = endPoint;
00125       myAveDistFromLine = 0;
00126     }
00127   double getLineAngle(void) { return myLineAngle; }
00128   double getLength(void) { return myLength; }
00129   int getNumPoints(void) { return myNumPoints; }
00130   int getStartPoint(void) { return myStartPoint; }
00131   int getEndPoint(void) { return myEndPoint; }
00132   void setAveDistFromLine(double aveDistFromLine) 
00133     { myAveDistFromLine = aveDistFromLine; }
00134   double getAveDistFromLine(void) { return myAveDistFromLine; }
00135 protected:
00136   double myLineAngle;
00137   double myLength;
00138   int myNumPoints;
00139   int myStartPoint;
00140   int myEndPoint;
00141   double myAveDistFromLine;
00142 };
00143 
00144 #endif // ARSICKLINEFINDER_H

Generated on Wed Oct 19 12:56:36 2005 for Aria by  doxygen 1.4.0