costmap_to_lines_ransac.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2016,
00006  *  TU Dortmund - Institute of Control Theory and Systems Engineering.
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the institute nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * Author: Christoph Rösmann
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 //     void adjustLineLength(const std::vector<KeyPoint>& data, const KeyPoint& linept1, const KeyPoint& linept2, 
00153 //                           KeyPoint& line_start, KeyPoint& line_end);
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 } //end namespace teb_local_planner
00186 
00187 #endif /* COSTMAP_TO_LINES_RANSAC_H_ */


costmap_converter
Author(s): Christoph Rösmann , Franz Albers , Otniel Rinaldo
autogenerated on Wed Sep 20 2017 03:00:37