00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00033 #ifndef _COIMBRA_CLUSTERING_H_ 00034 #define _COIMBRA_CLUSTERING_H_ 00035 00036 #include <vector> 00037 #include "geometry_msgs/Point.h" 00038 #include "sensor_msgs/LaserScan.h" 00039 00040 using namespace std; 00041 00042 class Point; 00043 typedef boost::shared_ptr<Point> PointPtr; 00044 00045 00054 class Cluster 00055 { 00056 public: 00057 int id; 00059 PointPtr centroid; 00061 PointPtr central_point; 00063 vector<double> ranges; 00065 vector<PointPtr> support_points; 00066 }; 00067 00068 00069 //Shared pointer to the Cluster class 00070 typedef boost::shared_ptr<Cluster> ClusterPtr; 00071 00072 /* Clustering functions */ 00073 00082 int simpleClustering(vector<PointPtr>& points, double threshold, vector<ClusterPtr>& clusters); 00083 00092 int dietmayerClustering( vector<PointPtr>& points, double C0 ,vector<ClusterPtr>& clusters_Dietmayer); 00093 00102 int premebidaClustering( vector<PointPtr>& points, double threshold_prem , vector<ClusterPtr>& clusters_Premebida); 00103 00112 int abdClustering( vector<PointPtr>& points , double lambda ,vector<ClusterPtr>& clusters_ABD); 00113 00122 int nnClustering( vector<PointPtr>& points, double threshold , vector<ClusterPtr>& clusters_nn); 00123 00133 int santosClustering( vector<PointPtr>& points, double C0, double beta, vector<ClusterPtr>& clusters_Santos); 00134 00145 vector<double> rangeFeatures( double range1, double range2, PointPtr range1cart, PointPtr range2cart); 00146 00154 double cosineDistance(vector<double>& vect1, vector<double>& vect2); 00155 00162 double deg2rad(double angle); 00163 00164 00171 PointPtr calculateClusterCentroid( vector<PointPtr> support_points ); 00172 00179 PointPtr calculateClusterMedian(vector<PointPtr> support_points); 00180 00181 #endif