29#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_VORONOI_H_
30#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_VORONOI_H_
60 double sum_idf_site_dist_sqr_ = 0;
61 double sum_idf_goal_dist_sqr_ = 0;
62 double sum_idf_site_dist_ = 0;
63 double sum_idf_goal_dist_ = 0;
67 double mass()
const {
return mass_; }
74 return std::vector<double>{
75 centroid_.x(), centroid_.y(), mass_,
76 sum_idf_site_dist_sqr_, sum_idf_goal_dist_sqr_, sum_idf_site_dist_,
84 sum_idf_site_dist_ = 0;
85 sum_idf_site_dist_sqr_ = 0;
86 sum_idf_goal_dist_ = 0;
87 sum_idf_goal_dist_sqr_ = 0;
92 centroid_ += pt * map_val;
93 sum_idf_site_dist_ += (pt -
site).norm() * map_val;
94 sum_idf_site_dist_sqr_ += (pt -
site).squaredNorm() * map_val;
98 sum_idf_goal_dist_sqr_ += (pt - centroid_).squaredNorm() * map_val;
99 sum_idf_goal_dist_ += (pt - centroid_).norm() * map_val;
119 std::shared_ptr<const MapType> map_ =
nullptr;
121 double resolution_ = 0;
128 bool compute_single_ =
false;
133 std::vector<VoronoiCell> voronoi_cells_;
136 void MassCentroidFunctional(
VoronoiCell &vcell,
double const &map_val,
144 double const &resolution,
bool const compute_single =
false,
145 int const robot_id = 0)
148 resolution_{resolution},
149 compute_single_{compute_single},
150 robot_id_{robot_id} {
153 map_ = std::make_shared<const MapType>(map);
154 num_sites_ = sites_.size();
168 if (compute_single_ ==
false) {
169 voronoi_cells_.resize(num_sites_);
171 origin_shift_ = -sites[0];
180 num_sites_ = sites_.size();
190 for (
auto const &cell : voronoi_cells_) {
191 obj = obj + cell.sum_idf_site_dist_sqr();
197 for (
auto const &cell : voronoi_cells_) {
198 obj = obj + cell.sum_idf_goal_dist_sqr();
Class for computing Voronoi cells.
Voronoi(PointVector const &sites, MapType const &map, Point2 map_size, double const &resolution, bool const compute_single=false, int const robot_id=0)
auto GetVoronoiCells() const
double GetSumIDFSiteDistSqr()
void ComputeVoronoiCells()
void UpdateSites(PointVector const &sites)
double GetSumIDFGoalDistSqr()
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MapType
std::vector< Point2 > PointVector
Namespace for the CoverageControl library.
void ComputeFinalCentroid()
double sum_idf_goal_dist_sqr() const
double sum_idf_goal_dist() const
void MassCentroidFunctional(double const &map_val, Point2 pt)
std::vector< double > GetFeatureVector() const
double sum_idf_site_dist() const
void GoalObjFunctional(double const &map_val, Point2 pt)
double sum_idf_site_dist_sqr() const
Contains typedefs for the library.