70 dynamic_recfg_ =
new dynamic_reconfigure::Server<CostmapToPolygonsDBSConcaveHullConfig>(nh);
78 std::vector< std::vector<KeyPoint> > clusters;
86 for (
int i = 1; i <clusters.size(); ++i)
88 polygons->push_back( geometry_msgs::Polygon() );
93 if (!clusters.empty())
95 for (
int i=0; i < clusters.front().size(); ++i)
97 polygons->push_back( geometry_msgs::Polygon() );
112 std::vector<geometry_msgs::Point32>& concave_list = polygon.points;
114 for (
int i = 0; i < (int)concave_list.size() - 1; ++i)
118 const geometry_msgs::Point32& vertex1 = concave_list[i];
119 const geometry_msgs::Point32& vertex2 = concave_list[i+1];
126 double line_length =
norm2d(vertex1, vertex2);
128 double dst1 =
norm2d(cluster[nearest_idx], vertex1);
129 double dst2 =
norm2d(cluster[nearest_idx], vertex2);
130 double dd = std::min(dst1, dst2);
134 if (line_length / dd > depth)
141 geometry_msgs::Point32 new_point;
142 cluster[nearest_idx].toPointMsg(new_point);
143 concave_list.insert(concave_list.begin() + i + 1, new_point);
156 std::vector<geometry_msgs::Point32>& concave_list = polygon.points;
159 double mean_length = 0;
160 for (
int i = 0; i < (int)concave_list.size() - 1; ++i)
162 mean_length +=
norm2d(concave_list[i],concave_list[i+1]);
164 mean_length /= double(concave_list.size());
166 for (
int i = 0; i < (int)concave_list.size() - 1; ++i)
170 const geometry_msgs::Point32& vertex1 = concave_list[i];
171 const geometry_msgs::Point32& vertex2 = concave_list[i+1];
173 double line_length =
norm2d(vertex1, vertex2);
183 double dst1 =
norm2d(cluster[nearest_idx], vertex1);
184 double dst2 =
norm2d(cluster[nearest_idx], vertex2);
185 double dd = std::min(dst1, dst2);
189 if (line_length / dd > depth)
196 geometry_msgs::Point32 new_point;
197 cluster[nearest_idx].toPointMsg(new_point);
198 concave_list.insert(concave_list.begin() + i + 1, new_point);
bool intersects(std::vector< geometry_msgs::Point > &polygon, float testx, float testy)
double min_keypoint_separation_
Clear keypoints of the convex polygon that are close to each other [distance in meters] (0: keep all)...
double norm2d(const Point1 &pt1, const Point2 &pt2)
Calculate the distance between two 2d points.
virtual void initialize(ros::NodeHandle nh)
Initialize the plugin.
void concaveHullClusterCut(std::vector< KeyPoint > &cluster, double depth, geometry_msgs::Polygon &polygon)
static void convertPointToPolygon(const Point &point, geometry_msgs::Polygon &polygon)
Convert a generi point type to a geometry_msgs::Polygon.
void dbScan(std::vector< std::vector< KeyPoint > > &clusters)
DBSCAN algorithm for clustering.
virtual ~CostmapToPolygonsDBSConcaveHull()
Destructor.
int max_pts_
Parameter for DB_Scan: maximum number of points that define a cluster (to avoid large L- and U-shapes...
PLUGINLIB_EXPORT_CLASS(BAGReader, nodelet::Nodelet)
This class converts the costmap_2d into a set of non-convex polygons (and points) ...
double concave_hull_depth_
bool checkLineIntersection(const Point1 &line1_start, const Point2 &line1_end, const Point3 &line2_start, const Point4 &line2_end)
virtual void compute()
This method performs the actual work (conversion of the costmap to polygons)
void reconfigureCB(CostmapToPolygonsDBSConcaveHullConfig &config, uint32_t level)
Callback for the dynamic_reconfigure node.
dynamic_reconfigure::Server< CostmapToPolygonsDBSConcaveHullConfig > * dynamic_recfg_
Dynamic reconfigure server to allow config modifications at runtime.
int min_pts_
Parameter for DB_Scan: minimum number of points that define a cluster.
boost::mutex parameter_mutex_
Mutex that keeps track about the ownership of the shared polygon instance.
std::size_t findNearestInnerPoint(PointLine line_start, PointLine line_end, const std::vector< PointCluster > &cluster, const std::vector< PointHull > &hull, bool *found)
double max_distance_
Parameter for DB_Scan, maximum distance to neighbors [m].
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
This abstract class defines the interface for plugins that convert the costmap into polygon types...
void concaveHull(std::vector< KeyPoint > &cluster, double depth, geometry_msgs::Polygon &polygon)
Compute the concave hull for a single cluster.
This class converts the costmap_2d into a set of convex polygons (and points)
void convexHull2(std::vector< KeyPoint > &cluster, geometry_msgs::Polygon &polygon)
Compute the convex hull for a single cluster.
void updatePolygonContainer(PolygonContainerPtr polygons)
Thread-safe update of the internal polygon container (that is shared using getPolygons() from outside...
Parameters parameter_buffered_