64 size_t num_robots_ = 0;
69 std::vector<double> voronoi_mass_;
71 bool is_converged_ =
false;
78 : params_{params}, num_robots_{num_robots}, env_{env} {
80 actions_.resize(num_robots_);
81 goals_ = robot_global_positions_;
82 voronoi_mass_.resize(num_robots_, 0);
83 voronoi_ =
Voronoi(robot_global_positions_, env_.GetSystemExploredIDFMap(),
91 auto GetGoals() {
return goals_; }
93 auto &GetVoronoi() {
return voronoi_; }
96 voronoi_ = Voronoi(robot_global_positions_, env_.GetSystemExploredIDFMap(),
99 auto voronoi_cells = voronoi_.GetVoronoiCells();
100 for (
size_t iRobot = 0; iRobot < num_robots_; ++iRobot) {
101 goals_[iRobot] = voronoi_cells[iRobot].centroid();
102 voronoi_mass_[iRobot] = voronoi_cells[iRobot].mass();
106 bool IsConverged()
const {
return is_converged_; }
109 is_converged_ =
true;
112 auto voronoi_cells = voronoi_.GetVoronoiCells();
113 for (
size_t iRobot = 0; iRobot < num_robots_; ++iRobot) {
114 actions_[iRobot] =
Point2(0, 0);
115 Point2 diff = goals_[iRobot] - robot_global_positions_[iRobot];
116 double dist = diff.norm();
128 speed = std::min(params_.pMaxRobotSpeed, speed);
130 direction.normalize();
131 actions_[iRobot] = speed * direction;
132 is_converged_ =
false;