32#include "CoverageControl/extern/tomlplusplus/toml.hpp"
36void Parameters::ParseParameters() {
37 std::cout << std::boolalpha;
38 std::cout <<
"Using config file: " <<
config_file_ << std::endl;
40 std::cerr <<
"Could not find config file " <<
config_file_ << std::endl;
41 throw std::runtime_error(
"Could not open config file");
44 toml::table toml_config;
47 }
catch (
const std::exception& e) {
48 std::cerr <<
"Error parsing config file: " << e.what() << std::endl;
49 std::cerr <<
"Please check the config file format" << std::endl;
51 throw std::runtime_error(
"Error parsing config file");
54 if (toml_config[
"NumRobots"].value<int>()) {
55 if (toml_config[
"NumRobots"].value<int>().value() < 1) {
56 std::cerr <<
"NumRobots must be greater than 0" << std::endl;
57 throw std::runtime_error(
"NumRobots must be greater than 0");
59 pNumRobots = toml_config[
"NumRobots"].value<
int>().value();
61 std::cout <<
"NumRobots (default): " <<
pNumRobots << std::endl;
64 auto toml_IO = toml_config[
"IO"];
65 if (toml_IO[
"PlotScale"].value<double>()) {
66 pPlotScale = toml_IO[
"PlotScale"].value<
double>().value();
68 std::cout <<
"PlotScale (default): " <<
pPlotScale << std::endl;
71 auto toml_EnvironmentMaps = toml_config[
"Environment"][
"Maps"];
73 if (toml_EnvironmentMaps) {
74 auto toml_Resolution = toml_EnvironmentMaps[
"Resolution"].value<
double>();
75 auto toml_WorldMapSize = toml_EnvironmentMaps[
"WorldMapSize"].value<
int>();
76 auto toml_RobotMapSize = toml_EnvironmentMaps[
"RobotMapSize"].value<
int>();
77 auto toml_LocalMapSize = toml_EnvironmentMaps[
"LocalMapSize"].value<
int>();
79 if (toml_Resolution) {
83 if (toml_WorldMapSize) {
86 if (toml_RobotMapSize) {
89 if (toml_LocalMapSize) {
93 auto toml_EnvironmentMapsUpdateSettings =
94 toml_EnvironmentMaps[
"UpdateSettings"];
96 if (toml_EnvironmentMapsUpdateSettings) {
97 auto toml_UpdateRobotMap =
98 toml_EnvironmentMapsUpdateSettings[
"UpdateRobotMap"].value<
bool>();
99 auto toml_UpdateSensorView =
100 toml_EnvironmentMapsUpdateSettings[
"UpdateSensorView"].value<
bool>();
101 auto toml_UpdateExplorationMap =
102 toml_EnvironmentMapsUpdateSettings[
"UpdateExplorationMap"]
104 auto toml_UpdateSystemMap =
105 toml_EnvironmentMapsUpdateSettings[
"UpdateSystemMap"].value<
bool>();
107 if (toml_UpdateRobotMap) {
110 if (toml_UpdateSensorView) {
113 if (toml_UpdateExplorationMap) {
116 if (toml_UpdateSystemMap) {
122 auto toml_EnvironmentIDF = toml_config[
"Environment"][
"IDF"];
124 if (toml_EnvironmentIDF) {
125 if (toml_EnvironmentIDF[
"NumGaussianFeatures"].value<int>()) {
130 auto toml_TruncationBND =
131 toml_EnvironmentIDF[
"TruncationBND"].value<
double>();
132 auto toml_Norm = toml_EnvironmentIDF[
"Norm"].value<
double>();
133 auto toml_MinSigma = toml_EnvironmentIDF[
"MinSigma"].value<
double>();
134 auto toml_MaxSigma = toml_EnvironmentIDF[
"MaxSigma"].value<
double>();
135 auto toml_MinPeak = toml_EnvironmentIDF[
"MinPeak"].value<
double>();
136 auto toml_MaxPeak = toml_EnvironmentIDF[
"MaxPeak"].value<
double>();
137 auto toml_UnknownImportance =
138 toml_EnvironmentIDF[
"UnknownImportance"].value<
double>();
139 auto toml_RobotMapUseUnknownImportance =
140 toml_EnvironmentIDF[
"RobotMapUseUnknownImportance"].value<
bool>();
142 if (toml_TruncationBND) {
146 pNorm = toml_Norm.value();
161 if (toml_EnvironmentIDF[
"NumPolygons"].value<int>()) {
162 pNumPolygons = toml_EnvironmentIDF[
"NumPolygons"].value<
int>().value();
164 std::cout <<
"NumPolygons (default): " <<
pNumPolygons << std::endl;
167 if (toml_EnvironmentIDF[
"MaxVertices"].value<int>()) {
168 pMaxVertices = toml_EnvironmentIDF[
"MaxVertices"].value<
int>().value();
170 std::cout <<
"MaxVertices (default): " <<
pMaxVertices << std::endl;
173 if (toml_EnvironmentIDF[
"PolygonRadius"].value<double>()) {
174 pPolygonRadius = toml_EnvironmentIDF[
"PolygonRadius"].value<
double>().value();
176 std::cout <<
"PolygonRadius (default): " <<
pPolygonRadius << std::endl;
179 if (toml_UnknownImportance) {
182 if (toml_RobotMapUseUnknownImportance) {
187 auto toml_RobotModel = toml_config[
"RobotModel"];
189 if (toml_RobotModel) {
190 auto toml_SensorSize = toml_RobotModel[
"SensorSize"].value<
int>();
191 auto toml_CommunicationRange =
192 toml_RobotModel[
"CommunicationRange"].value<
double>();
193 auto toml_MaxRobotSpeed = toml_RobotModel[
"MaxRobotSpeed"].value<
double>();
194 auto toml_RobotInitDist = toml_RobotModel[
"RobotInitDist"].value<
double>();
195 auto toml_RobotPosHistorySize =
196 toml_RobotModel[
"RobotPosHistorySize"].value<
int>();
197 auto toml_TimeStep = toml_RobotModel[
"TimeStep"].value<
double>();
199 if (toml_SensorSize) {
202 if (toml_CommunicationRange) {
205 if (toml_MaxRobotSpeed) {
208 if (toml_RobotInitDist) {
211 if (toml_RobotPosHistorySize) {
219 if (toml_RobotModel[
"AddNoise"]) {
220 auto toml_AddNoisePositions =
221 toml_RobotModel[
"AddNoise"][
"AddNoisePositions"].value<
bool>();
222 auto toml_PositionsNoiseSigma =
223 toml_RobotModel[
"AddNoise"][
"PositionsNoiseSigma"].value<
double>();
224 if (toml_AddNoisePositions) {
227 if (toml_PositionsNoiseSigma) {
232 auto toml_Algorithm = toml_config[
"Algorithm"];
234 if (toml_Algorithm) {
235 auto toml_EpisodeSteps = toml_Algorithm[
"EpisodeSteps"].value<
int>();
236 if (toml_EpisodeSteps) {
239 if (toml_Algorithm[
"CheckOscillations"].value<bool>()) {
241 toml_Algorithm[
"CheckOscillations"].value<
bool>().value();
244 auto toml_LloydMaxIterations =
245 toml_Algorithm[
"Global-CVT"][
"LloydMaxIterations"].value<
int>();
246 auto toml_LloydNumTries =
247 toml_Algorithm[
"Global-CVT"][
"LloydNumTries"].value<
int>();
248 if (toml_LloydMaxIterations) {
251 if (toml_LloydNumTries) {
255 auto toml_NumFrontiers =
256 toml_Algorithm[
"Exploration"][
"NumFrontiers"].value<
int>();
257 if (toml_NumFrontiers) {
264 std::cout <<
"NumRobots: " <<
pNumRobots << std::endl;
265 std::cout <<
"NumPolygons: " <<
pNumPolygons << std::endl;
266 std::cout <<
"MaxVertices: " <<
pMaxVertices << std::endl;
269 std::cout <<
"PlotScale: " <<
pPlotScale << std::endl;
271 std::cout <<
"Resolution: " <<
pResolution << std::endl;
283 std::cout <<
"Norm: " <<
pNorm << std::endl;
284 std::cout <<
"MinSigma: " <<
pMinSigma << std::endl;
285 std::cout <<
"MaxSigma: " <<
pMaxSigma << std::endl;
286 std::cout <<
"MinPeak: " <<
pMinPeak << std::endl;
287 std::cout <<
"MaxPeak: " <<
pMaxPeak << std::endl;
289 std::cout <<
"pNumPolygons: " <<
pNumPolygons << std::endl;
290 std::cout <<
"pMaxVertices: " <<
pMaxVertices << std::endl;
297 std::cout <<
"SensorSize: " <<
pSensorSize << std::endl;
302 std::cout <<
"TimeStep: " <<
pTimeStep << std::endl;
int pRobotMapSize
Robot map saves what the robot has seen.
double pTimeStep
Each time step corresponds to pTimeStep seconds.
int pNumPolygons
Number of polygonal features.
int pNumRobots
Number of robots.
int pNumGaussianFeatures
Bivariate Normal Distribution truncated after pTruncationBND * sigma.
double pUnknownImportance
void PrintParameters() const
double pPositionsNoiseSigma
int pMaxVertices
Maximum number of vertices in a polygon.
int pRobotPosHistorySize
Number of previous positions to store.
bool pUpdateExplorationMap
double pCommunicationRange
Radius of communication (in meters)
bool pRobotMapUseUnknownImportance
Namespace for the CoverageControl library.