@@ -145,10 +145,10 @@ CoverageSystem::CoverageSystem(
145145 InitSetup ();
146146}
147147
148- std::pair<MapType, MapType> const & CoverageSystem::GetCommunicationMap (
148+ std::pair<MapType, MapType> CoverageSystem::GetRobotCommunicationMaps (
149149 size_t const id, size_t map_size) {
150- communication_maps_[id] = std::make_pair (MapType::Zero (map_size, map_size),
151- MapType::Zero (map_size, map_size));
150+ std::pair<MapType, MapType> communication_maps = std::make_pair (
151+ MapType::Zero (map_size, map_size), MapType::Zero (map_size, map_size));
152152 PointVector robot_neighbors_pos = GetRelativePositonsNeighbors (id);
153153 double center = map_size / 2 . - params_.pResolution / 2 .;
154154 Point2 center_point (center, center);
@@ -157,24 +157,23 @@ std::pair<MapType, MapType> const &CoverageSystem::GetCommunicationMap(
157157 relative_pos * map_size /
158158 (params_.pCommunicationRange * params_.pResolution * 2 .) +
159159 center_point;
160- int scaled_indices_x = scaled_indices_val[0 ];
161- int scaled_indices_y = scaled_indices_val[1 ];
160+ int scaled_indices_x = std::round ( scaled_indices_val[0 ]) ;
161+ int scaled_indices_y = std::round ( scaled_indices_val[1 ]) ;
162162 Point2 normalized_relative_pos = relative_pos / params_.pCommunicationRange ;
163163
164- communication_maps_[id] .first (scaled_indices_x, scaled_indices_y) +=
164+ communication_maps .first (scaled_indices_x, scaled_indices_y) +=
165165 normalized_relative_pos[0 ];
166- communication_maps_[id] .second (scaled_indices_x, scaled_indices_y) +=
166+ communication_maps .second (scaled_indices_x, scaled_indices_y) +=
167167 normalized_relative_pos[1 ];
168168 }
169- return communication_maps_[id] ;
169+ return communication_maps ;
170170}
171171
172172void CoverageSystem::InitSetup () {
173173 num_robots_ = robots_.size ();
174174 robot_positions_history_.resize (num_robots_);
175175
176176 voronoi_cells_.resize (num_robots_);
177- communication_maps_.resize (num_robots_);
178177
179178 robot_global_positions_.resize (num_robots_);
180179 for (size_t iRobot = 0 ; iRobot < num_robots_; ++iRobot) {
@@ -588,7 +587,7 @@ void CoverageSystem::PlotRobotCommunicationMaps(std::string const &dir_name,
588587 int const &robot_id,
589588 int const &step,
590589 size_t const &map_size) {
591- auto robot_communication_maps = GetCommunicationMap (robot_id, map_size);
590+ auto robot_communication_maps = GetRobotCommunicationMaps (robot_id, map_size);
592591 Plotter plotter_x (dir_name, map_size * params_.pResolution ,
593592 params_.pResolution );
594593 plotter_x.SetPlotName (
0 commit comments