Skip to content

Commit 287edc0

Browse files
Saurav AgarwalSaurav Agarwal
authored andcommitted
cpp and py compat
1 parent 3cf6fe6 commit 287edc0

18 files changed

+106
-82
lines changed

cppsrc/core/include/CoverageControl/algorithms/abstract_controller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class AbstractController {
5454

5555
/*!
5656
* Pure virtual function to compute the actions for the robots
57-
* \return True if the actions are computed successfully, false otherwise
57+
* \return 0 if the actions are computed successfully, 1 otherwise
5858
**/
59-
virtual bool ComputeActions() = 0;
59+
virtual int ComputeActions() = 0;
6060
};
6161

6262
} /* namespace CoverageControl */

cppsrc/core/include/CoverageControl/algorithms/centralized_cvt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class CentralizedCVT : public AbstractController {
105105

106106
bool IsConverged() const { return is_converged_; }
107107

108-
bool ComputeActions() {
108+
int ComputeActions() {
109109
is_converged_ = true;
110110
robot_global_positions_ = env_.GetRobotPositions();
111111
ComputeGoals();
@@ -131,7 +131,7 @@ class CentralizedCVT : public AbstractController {
131131
actions_[iRobot] = speed * direction;
132132
is_converged_ = false;
133133
}
134-
return true;
134+
return 0;
135135
}
136136
};
137137

cppsrc/core/include/CoverageControl/algorithms/clairvoyant_cvt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ClairvoyantCVT : public AbstractController {
8080
actions_.resize(num_robots_);
8181
goals_ = robot_global_positions_;
8282
voronoi_mass_.resize(num_robots_, 0);
83-
voronoi_ = Voronoi(robot_global_positions_, env_.GetWorldIDF(),
83+
voronoi_ = Voronoi(robot_global_positions_, env_.GetWorldMap(),
8484
Point2(params_.pWorldMapSize, params_.pWorldMapSize),
8585
params_.pResolution);
8686
ComputeGoals();
@@ -101,7 +101,7 @@ class ClairvoyantCVT : public AbstractController {
101101
}
102102
}
103103

104-
bool ComputeActions() {
104+
int ComputeActions() {
105105
is_converged_ = true;
106106
robot_global_positions_ = env_.GetRobotPositions();
107107
ComputeGoals();
@@ -127,7 +127,7 @@ class ClairvoyantCVT : public AbstractController {
127127
actions_[iRobot] = speed * direction;
128128
is_converged_ = false;
129129
}
130-
return true;
130+
return 0;
131131
}
132132

133133
bool IsConverged() const { return is_converged_; }

cppsrc/core/include/CoverageControl/algorithms/decentralized_cvt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class DecentralizedCVT : public AbstractController {
147147
}
148148
}
149149

150-
bool ComputeActions() {
150+
int ComputeActions() {
151151
is_converged_ = true;
152152
robot_global_positions_ = env_.GetRobotPositions();
153153
ComputeGoals();
@@ -173,8 +173,8 @@ class DecentralizedCVT : public AbstractController {
173173
direction.normalize();
174174
actions_[iRobot] = speed * direction;
175175
is_converged_ = false;
176-
return true;
177176
}
177+
return 0;
178178
}
179179

180180
bool IsConverged() const { return is_converged_; }

cppsrc/core/include/CoverageControl/algorithms/near_optimal_cvt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ class NearOptimalCVT : public AbstractController {
9696
void ComputeGoals() {
9797
goals_ = NearOptimalCVTAlgorithm(
9898
params_.pLloydNumTries, params_.pLloydMaxIterations, num_robots_,
99-
env_.GetWorldIDF(), params_.pWorldMapSize, params_.pResolution,
99+
env_.GetWorldMap(), params_.pWorldMapSize, params_.pResolution,
100100
robot_global_positions_, voronoi_);
101101
}
102102

103-
bool ComputeActions() {
103+
int ComputeActions() {
104104
is_converged_ = true;
105105
robot_global_positions_ = env_.GetRobotPositions();
106106
for (size_t iRobot = 0; iRobot < num_robots_; ++iRobot) {
@@ -117,7 +117,7 @@ class NearOptimalCVT : public AbstractController {
117117
actions_[iRobot] = speed * direction;
118118
is_converged_ = false;
119119
}
120-
return true;
120+
return 0;
121121
}
122122

123123
bool IsConverged() { return is_converged_; }

cppsrc/core/include/CoverageControl/algorithms/oracle_bang_explore_exploit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class OracleBangExploreExploit : public AbstractController {
338338
/* } */
339339
}
340340

341-
bool ComputeActions() {
341+
int ComputeActions() {
342342
if (first_step_ == true) {
343343
first_step_ = false;
344344
robot_global_positions_ = env_.GetRobotPositions();
@@ -368,7 +368,7 @@ class OracleBangExploreExploit : public AbstractController {
368368
is_converged_ = false;
369369
}
370370
}
371-
return true;
371+
return 0;
372372
}
373373

374374
bool IsConverged() { return is_converged_; }

cppsrc/core/include/CoverageControl/algorithms/oracle_explore_exploit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class OracleExploreExploit : public AbstractController {
159159
}
160160
}
161161

162-
bool ComputeActions() {
162+
int ComputeActions() {
163163
if (start_exploit_ == false) {
164164
if (recompute_goal_counter_ >= recompute_goal_steps_ or
165165
is_converged_ == true) {
@@ -170,7 +170,7 @@ class OracleExploreExploit : public AbstractController {
170170
}
171171
is_converged_ = not env_.StepRobotsToGoals(goals_, actions_);
172172
UpdateOracleMap();
173-
return true;
173+
return 0;
174174
}
175175

176176
bool IsConverged() { return is_converged_; }

cppsrc/core/include/CoverageControl/algorithms/simul_explore_exploit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class OracleSimulExploreExploit {
334334
* std::endl; */
335335
}
336336

337-
bool ComputeActions() {
337+
int ComputeActions() {
338338
robot_global_positions_ = env_.GetRobotPositions();
339339
goals_ = robot_global_positions_;
340340
if (first_step_ == true) {
@@ -378,7 +378,7 @@ class OracleSimulExploreExploit {
378378
}
379379
is_converged_ = false;
380380
}
381-
return true;
381+
return 0;
382382
}
383383

384384
bool IsConverged() { return is_converged_; }

cppsrc/core/include/CoverageControl/bivariate_normal_distribution.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ class BivariateNormalDistribution {
162162
return scale_ * std::erfc(transformed_point.x() * kOneBySqrt2) *
163163
std::erfc(transformed_point.y() * kOneBySqrt2) / 4.;
164164
}
165+
166+
float IntegrateQuarterPlaneF(Point2 const &point) const {
167+
auto transformed_point = TransformPoint(point);
168+
float x = static_cast<float>(transformed_point.x());
169+
float y = static_cast<float>(transformed_point.y());
170+
float scale = static_cast<float>(scale_);
171+
return scale * std::erfc(x * kOneBySqrt2f) * std::erfc(y * kOneBySqrt2f) /
172+
4.f;
173+
}
165174
};
166175

167176
} /* namespace CoverageControl */

cppsrc/core/include/CoverageControl/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ double const kEps = 1e-10; /*!< Epsilon for double comparison */
5050
double const kLargeEps = 1e-4; /*!< Large epsilon for double comparison */
5151
double const kSqrt2 = std::sqrt(2); /*!< Square root of 2 */
5252
double const kOneBySqrt2 = 1. / std::sqrt(2); /*!< 1 by square root of 2 */
53+
float const kOneBySqrt2f = 1.f / std::sqrt(2.f); /*!< 1 by square root of 2 */
5354
double const kInfD =
5455
std::numeric_limits<double>::infinity(); /*!< Infinity for double */
5556
constexpr auto kMaxPrecision{std::numeric_limits<long double>::digits10 +

0 commit comments

Comments
 (0)