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
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef COSTMAP_TO_LINES_RANSAC_H_
00040 #define COSTMAP_TO_LINES_RANSAC_H_
00041
00042 #include <costmap_converter/costmap_converter_interface.h>
00043 #include <costmap_converter/costmap_to_polygons.h>
00044 #include <costmap_converter/misc.h>
00045 #include <boost/random.hpp>
00046
00047 #include <costmap_converter/CostmapToLinesDBSRANSACConfig.h>
00048
00049 namespace costmap_converter
00050 {
00051
00071 class CostmapToLinesDBSRANSAC : public CostmapToPolygonsDBSMCCH
00072 {
00073 public:
00074
00078 CostmapToLinesDBSRANSAC();
00079
00083 virtual ~CostmapToLinesDBSRANSAC();
00084
00089 virtual void initialize(ros::NodeHandle nh);
00090
00094 virtual void compute();
00095
00096
00107 template <typename Point, typename LinePoint>
00108 static bool isInlier(const Point& point, const LinePoint& line_start, const LinePoint& line_end, double min_distance);
00109
00110 protected:
00111
00112 double ransac_inlier_distance_;
00113 int ransac_min_inliers_;
00114 int ransac_no_iterations_;
00115 int ransac_remainig_outliers_;
00116 bool ransac_convert_outlier_pts_;
00117 bool ransac_filter_remaining_outlier_pts_;
00118
00119
00120 boost::random::mt19937 rnd_generator_;
00121
00122
00134 bool lineRansac(const std::vector<KeyPoint>& data, double inlier_distance, int no_iterations, int min_inliers,
00135 std::pair<KeyPoint, KeyPoint>& best_model, std::vector<KeyPoint>* inliers = NULL,
00136 std::vector<KeyPoint>* outliers = NULL);
00137
00147 bool linearRegression(const std::vector<KeyPoint>& data, double& slope, double& intercept,
00148 double* mean_x_out = NULL, double* mean_y_out = NULL);
00149
00150
00151
00152
00153
00154
00155 private:
00156
00164 void reconfigureCB(CostmapToLinesDBSRANSACConfig& config, uint32_t level);
00165
00166 dynamic_reconfigure::Server<CostmapToLinesDBSRANSACConfig>* dynamic_recfg_;
00167
00168 };
00169
00170
00171
00172 template <typename Point, typename LinePoint>
00173 bool CostmapToLinesDBSRANSAC::isInlier(const Point& point, const LinePoint& line_start, const LinePoint& line_end, double min_distance)
00174 {
00175 bool is_inbetween = false;
00176 double distance = computeDistanceToLineSegment(point, line_start, line_end, &is_inbetween);
00177 if (!is_inbetween)
00178 return false;
00179 if (distance <= min_distance)
00180 return true;
00181 return false;
00182 }
00183
00184
00185 }
00186
00187 #endif