v4r_laser_filter_utils.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * Copyright (c) 2014 Markus Bader <markus.bader@tuwien.ac.at>
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  * 3. All advertising materials mentioning features or use of this software
00013  *    must display the following acknowledgement:
00014  *    This product includes software developed by the TU-Wien.
00015  * 4. Neither the name of the TU-Wien nor the
00016  *    names of its contributors may be used to endorse or promote products
00017  *    derived from this software without specific prior written permission.
00018  * 
00019  * THIS SOFTWARE IS PROVIDED BY Markus Bader ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL Markus Bader BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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


v4r_laser_filter
Author(s):
autogenerated on Wed Aug 26 2015 16:41:46