34 std::ifstream file(fullFilePath);
37 throw std::runtime_error(
"Could not open config file: " + fullFilePath.string());
41 while (std::getline(file, line))
43 auto commentPos = line.find(
'#');
44 if (commentPos != std::string::npos)
45 line = line.substr(0, commentPos);
50 if (!std::isspace(
static_cast<unsigned char>(
c)))
59 std::istringstream iss(line);
61 if (!std::getline(iss, key,
'='))
65 size_t end = key.find_last_not_of(
" \t\r\n");
66 if (end != std::string::npos)
67 key = key.substr(0, end + 1);
75 if (!std::getline(iss, value))
79 size_t start = value.find_first_not_of(
" \t\r\n");
80 if (start != std::string::npos)
82 size_t end = value.find_last_not_of(
" \t\r\n");
83 value = value.substr(start, end - start + 1);
93 if (key ==
"clearance")
95 else if (key ==
"hillClimbStepSize")
97 else if (key ==
"hillClimbMaxIterations")
99 else if (key ==
"obsMaxDistance")
101 else if (key ==
"segmentObstacleSamples")
103 else if (key ==
"pass1WeightObstacle")
105 else if (key ==
"pass1WeightPoseSmooth")
107 else if (key ==
"pass1WeightSpacing")
109 else if (key ==
"pass1WeightTracking")
111 else if (key ==
"pass1WeightSafeTracking")
113 else if (key ==
"pass2WeightObstacle")
115 else if (key ==
"pass2WeightPoseSmooth")
117 else if (key ==
"pass2WeightSpacing")
119 else if (key ==
"pass2WeightTracking")
121 else if (key ==
"pass2WeightSafeTracking")
123 else if (key ==
"pass3WeightObstacle")
125 else if (key ==
"pass3WeightPoseSmooth")
127 else if (key ==
"pass3WeightSpacing")
129 else if (key ==
"pass3WeightTracking")
131 else if (key ==
"pass3WeightSafeTracking")
133 else if (key ==
"repairWeightObstacle")
135 else if (key ==
"repairWeightPoseSmooth")
137 else if (key ==
"repairWeightSpacing")
139 else if (key ==
"repairWeightTracking")
141 else if (key ==
"repairWeightSafeTracking")
143 else if (key ==
"repairMaxIterations")
145 else if (key ==
"trackingDeadzone")
147 else if (key ==
"trackingMaxDeviation")
149 else if (key ==
"weightTrackingInBounds")
151 else if (key ==
"weightTrackingHard")
153 else if (key ==
"maxIterations")
155 else if (key ==
"numThreads")
157 else if (key ==
"initialTrustRegionRadius")
159 else if (key ==
"maxTrustRegionRadius")
161 else if (key ==
"minTrustRegionRadius")
164 catch (
const std::invalid_argument&)
166 throw std::runtime_error(
"Invalid value for key " + key +
": " + value);