Go to the documentation of this file.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
00027
00028
00029
00030
00031 #include "ros/ros.h"
00032 #include <sensor_msgs/LaserScan.h>
00033 #include <geometry_msgs/PolygonStamped.h>
00034 #include <sstream>
00035 #include <boost/iterator/iterator_concepts.hpp>
00036 #include <boost/shared_ptr.hpp>
00037 #include <opencv2/opencv.hpp>
00038
00039 #ifndef V4R_LASER_FILTER
00040 #define V4R_LASER_FILTER
00041
00042 namespace LaserFilter {
00043 class Pose : public cv::Vec3f {
00044 public:
00045 Pose();
00046 Pose(float _x, float _y, float _angle);
00047 void set( float _x, float _y, float _angle);
00048 const cv::Point2f& point() const;
00049 cv::Point2f& point();
00050 const float& x() const;
00051 float& x();
00052 const float& y() const;
00053 float& y() ;
00054 const float& angle() const;
00055 float& angle();
00056 void normalizeAngle();
00057 };
00058 class Beam {
00059 public:
00060 Beam();
00061 void set(float _alpha, float _range);
00062 float alpha;
00063 float range;
00064 };
00065 class Measurment : public cv::Point2f {
00066 public:
00067 Measurment(): cv::Point2f() {};
00068 Measurment(float _x, float _y) : cv::Point2f(_x, _y) {};
00069 void set(float _alpha, float _range);
00070 bool valid;
00071 bool inf;
00072 bool nan;
00073 };
00074 class LineEq : public cv::Vec3f {
00075 public:
00076 LineEq();
00077 LineEq(const cv::Vec3f& l);
00078 LineEq(float _a, float _b, float _c);
00079 void set(const cv::Point2f &p0, const cv::Point2f &p1);
00080 float distance(const cv::Point2f &p) const;
00081 };
00082 class Line : public LineEq {
00083 public:
00084 Line();
00085 Line(const cv::Vec3f& l) ;
00086 Line(const Line& l) ;
00087 Line(const cv::Point2f &_p0, const cv::Point2f &_p1);
00088 void set(const cv::Point2f &_p0, const cv::Point2f &_p1);
00089 void computeEquation();
00090 float length() const;
00091 float angle() const;
00092 float angleDiff(const Line &line) const;
00093 cv::Vec2f vector() const;
00094 cv::Point2f p0, p1;
00095 };
00096 class LineSegment : public Line {
00097 public:
00098 LineSegment();
00099 LineSegment(const cv::Vec3f& l);
00100 LineSegment(const Line& l);
00101 LineSegment(const LineSegment& l);
00102 LineSegment(unsigned int idx0, unsigned int idx1, const std::vector<Measurment> &measurments);
00103 void set(unsigned int _idx0, unsigned int _idx1, const std::vector<Measurment> &measurments);
00104 void updateLineStatistic(const std::vector<Measurment> &measurments);
00105 bool isSupportPoint(int idx);
00106 unsigned int nrSupportPoint();
00107 unsigned int id;
00108 std::pair<unsigned int, unsigned int> idx;
00109 float distances_mean;
00110 float distances_variance;
00111 float distances_error;
00112 void estimator_theilsen(const std::vector<Measurment> &measurments, Line &line);
00113 private:
00114
00115 };
00116
00117 class Corner : public Pose {
00118 public:
00119 Corner();
00120 Corner(const Corner &c);
00121 void set(const LineSegment &_l0, const LineSegment &_l1);
00122 bool isCorner(float threshold_angle, float max_line_diff);
00123 void redefine(const std::vector<Measurment> &measurments);
00124 float updateError(const std::vector<Measurment> &measurments);
00125 float error;
00126 LineSegment l0, l1;
00127 };
00128
00129 void copy(const sensor_msgs::LaserScan& _msg, std::vector<Measurment> &_desMeasurments, std::vector<Beam> &_desBeams);
00130 void intersection(const cv::Vec3f &l1, const cv::Vec3f &l2, cv::Point2f &p);
00131 float dot(const cv::Vec3f &l1, const cv::Point2f &p);
00132 void readScan(const std::string &filename, sensor_msgs::LaserScan &msg );
00133 void writeScan(const std::string &filename, const sensor_msgs::LaserScan &msg );
00134 };
00135 #endif // V4R_LASER_LINE_FILTER_NODE