18 std::ifstream file(fullFilePath);
21 throw std::runtime_error(
"Could not open config file: " + fullFilePath.string());
25 while (std::getline(file, line))
28 auto commentPos = line.find(
'#');
29 if (commentPos != std::string::npos)
30 line = line.substr(0, commentPos);
36 if (!std::isspace(
static_cast<unsigned char>(
c)))
45 std::istringstream iss(line);
47 if (!std::getline(iss, key,
'='))
52 size_t end = key.find_last_not_of(
" \t\r\n");
53 if (end != std::string::npos)
54 key = key.substr(0, end + 1);
62 if (!std::getline(iss, value))
67 size_t start = value.find_first_not_of(
" \t\r\n");
68 if (start != std::string::npos)
70 size_t end = value.find_last_not_of(
" \t\r\n");
71 value = value.substr(start, end - start + 1);
82 if (key ==
"clearance")
84 else if (key ==
"hillClimbStepSize")
86 else if (key ==
"hillClimbMaxIterations")
89 else if (key ==
"weightObstacle")
90 params.
w_obs = std::stof(value);
91 else if (key ==
"obsMaxDistance")
93 else if (key ==
"obsBarrierEpsMm")
95 else if (key ==
"useObstacle")
96 params.
use_obs = (value ==
"true");
97 else if (key ==
"useFuzzyOrientation")
99 else if (key ==
"fuzzyOrientationWindowBins")
101 else if (key ==
"fuzzyOrientationAlpha")
103 else if (key ==
"weightThetaTrack")
105 else if (key ==
"useObstacleFreeze")
107 else if (key ==
"obstacleFreezeThreshold")
110 else if (key ==
"weightBoundary")
112 else if (key ==
"weightPoseSmooth")
114 else if (key ==
"weightOrientationSmooth")
116 else if (key ==
"weightPoseJerk")
118 else if (key ==
"useJerk")
119 params.
use_jerk = (value ==
"true");
120 else if (key ==
"weightRobotSmooth")
122 else if (key ==
"useRobotSmooth")
125 else if (key ==
"weightSpacing")
127 else if (key ==
"useSoftSpacing")
129 else if (key ==
"spacingRelativeDeviationThreshold")
131 else if (key ==
"weightSpacingLinear")
133 else if (key ==
"weightSpacingQuadratic")
136 else if (key ==
"startVelocity")
138 else if (key ==
"weightAccelDecelLimit")
140 else if (key ==
"maxAccelPerSegment")
142 else if (key ==
"maxDecelPerSegment")
144 else if (key ==
"weightNominalVelocity")
146 else if (key ==
"weightVelocityProximity")
148 else if (key ==
"slowDownDistance")
150 else if (key ==
"minVelocityNearObstacle")
153 else if (key ==
"weightTracking")
154 params.
w_track = std::stof(value);
155 else if (key ==
"useTracking")
157 else if (key ==
"useTrackingClearanceAdaptive")
159 else if (key ==
"trackingFadeStartClearance")
161 else if (key ==
"trackingFadeEndClearance")
164 else if (key ==
"useRobotPoseProximity")
166 else if (key ==
"robotPoseProximityThresholdMm")
168 else if (key ==
"weightRobotPoseProximity")
170 else if (key ==
"robotPoseProximityEpsMm")
173 else if (key ==
"maxIterations")
175 else if (key ==
"numThreads")
177 else if (key ==
"initialTrustRegionRadius")
179 else if (key ==
"maxTrustRegionRadius")
181 else if (key ==
"minTrustRegionRadius")
184 else if (key ==
"alwaysReturnSmoothed")
187 catch (
const std::invalid_argument& e)
189 throw std::runtime_error(
"Invalid value for key " + key +
": " + value);