39 #ifndef COSTMAP_TO_LINES_RANSAC_H_ 40 #define COSTMAP_TO_LINES_RANSAC_H_ 45 #include <boost/random.hpp> 47 #include <costmap_converter/CostmapToLinesDBSRANSACConfig.h> 107 template <
typename Po
int,
typename LinePo
int>
108 static bool isInlier(
const Point& point,
const LinePoint& line_start,
const LinePoint& line_end,
double min_distance);
134 bool lineRansac(
const std::vector<KeyPoint>& data,
double inlier_distance,
int no_iterations,
int min_inliers,
135 std::pair<KeyPoint, KeyPoint>& best_model, std::vector<KeyPoint>* inliers = NULL,
136 std::vector<KeyPoint>* outliers = NULL);
147 bool linearRegression(
const std::vector<KeyPoint>& data,
double& slope,
double& intercept,
148 double* mean_x_out = NULL,
double* mean_y_out = NULL);
164 void reconfigureCB(CostmapToLinesDBSRANSACConfig& config, uint32_t level);
172 template <
typename Po
int,
typename LinePo
int>
175 bool is_inbetween =
false;
179 if (distance <= min_distance)
double computeDistanceToLineSegment(const Point &point, const LinePoint &line_start, const LinePoint &line_end, bool *is_inbetween=NULL)
Calculate the distance between a point and a straight line segment.
double ransac_inlier_distance_
Maximum distance to the line segment for inliers.
virtual void initialize(ros::NodeHandle nh)
Initialize the plugin.
bool ransac_convert_outlier_pts_
If true, convert remaining outliers to single points.
int ransac_min_inliers_
Minimum numer of inliers required to form a line.
boost::random::mt19937 rnd_generator_
Random number generator for ransac with default seed.
int ransac_no_iterations_
Number of ransac iterations.
int ransac_remainig_outliers_
Repeat ransac until the number of outliers is as specified here.
This class converts the costmap_2d into a set of lines (and points)
double distance(double x0, double y0, double x1, double y1)
dynamic_reconfigure::Server< CostmapToLinesDBSRANSACConfig > * dynamic_recfg_
Dynamic reconfigure server to allow config modifications at runtime.
virtual ~CostmapToLinesDBSRANSAC()
Destructor.
virtual void compute()
This method performs the actual work (conversion of the costmap to polygons)
bool lineRansac(const std::vector< KeyPoint > &data, double inlier_distance, int no_iterations, int min_inliers, std::pair< KeyPoint, KeyPoint > &best_model, std::vector< KeyPoint > *inliers=NULL, std::vector< KeyPoint > *outliers=NULL)
Find a straight line segment in a point cloud with RANSAC (without linear regression).
CostmapToLinesDBSRANSAC()
Constructor.
This class converts the costmap_2d into a set of convex polygons (and points)
void reconfigureCB(CostmapToLinesDBSRANSACConfig &config, uint32_t level)
Callback for the dynamic_reconfigure node.
bool linearRegression(const std::vector< KeyPoint > &data, double &slope, double &intercept, double *mean_x_out=NULL, double *mean_y_out=NULL)
Perform a simple linear regression in order to fit a straight line 'y = slope*x + intercept'...
static bool isInlier(const Point &point, const LinePoint &line_start, const LinePoint &line_end, double min_distance)
Check if the candidate point is an inlier.
bool ransac_filter_remaining_outlier_pts_
If true, filter the interior of remaining outliers and keep only keypoints of their convex hull...