Skip to content

Commit 0d05a95

Browse files
Saurav AgarwalSaurav Agarwal
authored andcommitted
Add const GetObjectiveValue
1 parent d1585e4 commit 0d05a95

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

cppsrc/core/include/CoverageControl/coverage_system.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ class CoverageSystem {
438438
return weighted_exploration_ratio;
439439
}
440440

441-
PointVector GetRelativePositonsNeighbors(size_t const robot_id);
441+
PointVector GetRelativePositonsNeighbors (size_t const robot_id) const;
442+
442443
std::vector<int> GetNeighborIDs(size_t const robot_id) const {
443444
return neighbor_ids_[robot_id];
444445
}
@@ -513,6 +514,13 @@ class CoverageSystem {
513514
return communication_maps;
514515
}
515516

517+
auto GetObjectiveValueConst() const {
518+
auto voronoi = Voronoi(robot_global_positions_, GetWorldMap(),
519+
Point2(params_.pWorldMapSize, params_.pWorldMapSize),
520+
params_.pResolution);
521+
return voronoi.GetSumIDFSiteDistSqr();
522+
}
523+
516524
auto GetObjectiveValue() {
517525
ComputeVoronoiCells();
518526
return voronoi_.GetSumIDFSiteDistSqr();

cppsrc/core/src/coverage_system.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ void CoverageSystem::PlotRobotCommunicationMaps(std::string const &dir_name,
679679
plotter_y.PlotMap(robot_communication_maps.second);
680680
}
681681

682-
PointVector CoverageSystem::GetRelativePositonsNeighbors(
683-
size_t const robot_id) {
682+
PointVector CoverageSystem::GetRelativePositonsNeighbors (
683+
size_t const robot_id) const {
684684
return relative_positions_neighbors_[robot_id];
685685
}
686686

cppsrc/python_bindings/core_binds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ void pyCoverageControl_core_coverage_system(py::module &m) {
350350
.def("GetSystemMap", &CoverageSystem::GetSystemMap,
351351
py::return_value_policy::reference_internal)
352352
.def("GetObjectiveValue", &CoverageSystem::GetObjectiveValue)
353+
.def("GetObjectiveValueConst", &CoverageSystem::GetObjectiveValueConst)
353354
.def("GetNormalizationFactor", &CoverageSystem::GetNormalizationFactor)
354355
.def("PlotSystemMap", py::overload_cast<std::string const &>(
355356
&CoverageSystem::PlotSystemMap, py::const_))

0 commit comments

Comments
 (0)