89 <<
"Scene description " <<
QUOTED(filename.string()) <<
" does not exist.";
91 std::ifstream ifs{filename};
92 const nlohmann::json j = nlohmann::json::parse(ifs);
98 const nlohmann::json& jScene = j.at(
"scene");
100 config.
scene.
bounds.
min = toVector2f(jScene.at(
"bounds").at(
"min"));
101 config.
scene.
bounds.
max = toVector2f(jScene.at(
"bounds").at(
"max"));
108 for (
const nlohmann::json& jObstacle : jScene.at(
"obstacles"))
110 const std::string type = jObstacle.value(
"type", std::string{
"box"});
113 throw std::invalid_argument(
"Unsupported obstacle type `" + type +
114 "`. Only `box` is supported.");
117 const Box box{.min = toVector2f(jObstacle.at(
"min")),
118 .max = toVector2f(jObstacle.at(
"max")),
119 .yaw = jObstacle.value(
"yaw", 0.F)};
128 config.
start = toPose(j.at(
"start"));
129 config.
goal = toPose(j.at(
"goal"));
133 const nlohmann::json jCostmap = j.value(
"costmap", nlohmann::json::object());
146 const nlohmann::json jSpfa = j.value(
"spfa", nlohmann::json::object());
150 jSpfa.value(
"obstacle_distance_costs", algo.obstacleDistanceCosts);
151 algo.obstacleCostExponent =
152 jSpfa.value(
"obstacle_cost_exponent", algo.obstacleCostExponent);
153 algo.obstacleMaxDistance =
154 jSpfa.value(
"obstacle_max_distance", algo.obstacleMaxDistance);
155 algo.obstacleDistanceWeight =
156 jSpfa.value(
"obstacle_distance_weight", algo.obstacleDistanceWeight);
159 jSpfa.value(
"enable_position_smoothing",
162 jSpfa.value(
"enable_final_velocity_clamp",
168 const nlohmann::json jGeneral = j.value(
"general", nlohmann::json::object());
188 const nlohmann::json jSim = j.value(
"simulation", nlohmann::json::object());
194 sim.dt = jSim.value(
"dt", sim.dt);
195 sim.maxDuration = jSim.value(
"max_duration", sim.maxDuration);
196 sim.goalDistanceThreshold =
197 jSim.value(
"goal_distance_threshold", sim.goalDistanceThreshold);
199 ctrl.alpha = jSim.value(
"alpha", ctrl.alpha);
200 ctrl.velocityFactor = jSim.value(
"velocity_factor", ctrl.velocityFactor);
201 ctrl.maxSegmentsAhead = jSim.value(
"max_segments_ahead", ctrl.maxSegmentsAhead);
202 ctrl.orientationWeight = jSim.value(
"orientation_weight", ctrl.orientationWeight);
203 ctrl.coupleLinearAndAngularLimits =
204 jSim.value(
"couple_linear_and_angular_limits",
205 ctrl.coupleLinearAndAngularLimits);
206 ctrl.enableAngularFeedforward =
207 jSim.value(
"enable_angular_feedforward", ctrl.enableAngularFeedforward);
209 ctrl.pidPos.Kp = jSim.value(
"pid_pos_kp", ctrl.pidPos.Kp);
210 ctrl.pidPos.Ki = jSim.value(
"pid_pos_ki", ctrl.pidPos.Ki);
211 ctrl.pidPos.Kd = jSim.value(
"pid_pos_kd", ctrl.pidPos.Kd);
212 ctrl.pidOri.Kp = jSim.value(
"pid_ori_kp", ctrl.pidOri.Kp);
213 ctrl.pidOri.Ki = jSim.value(
"pid_ori_ki", ctrl.pidOri.Ki);
214 ctrl.pidOri.Kd = jSim.value(
"pid_ori_kd", ctrl.pidOri.Kd);
224 config.
robot = jSim.value(
"robot", std::string{
"Armar7"});
226 sim.dynamics.maxLinearAcceleration =
227 jSim.value(
"max_linear_acceleration", sim.dynamics.maxLinearAcceleration);
228 sim.dynamics.maxAngularAcceleration =
229 jSim.value(
"max_angular_acceleration", sim.dynamics.maxAngularAcceleration);
233 const nlohmann::json jRamp =
234 jSim.value(
"rate_limit", nlohmann::json::object());
235 auto& ramp = sim.rateLimit;
237 ramp.enabled = jRamp.value(
"enabled", ramp.enabled);
238 ramp.dt = jRamp.value(
"dt", ramp.dt);
239 ramp.maxVelocity = jRamp.value(
"max_velocity", ramp.maxVelocity);
240 ramp.maxAcceleration = jRamp.value(
"max_acceleration", ramp.maxAcceleration);
241 ramp.maxDeceleration = jRamp.value(
"max_deceleration", ramp.maxDeceleration);
242 ramp.maxAngularVelocity =
243 jRamp.value(
"max_angular_velocity", ramp.maxAngularVelocity);
244 ramp.maxAngularAcceleration =
245 jRamp.value(
"max_angular_acceleration", ramp.maxAngularAcceleration);
246 ramp.maxAngularDeceleration =
247 jRamp.value(
"max_angular_deceleration", ramp.maxAngularDeceleration);
248 ramp.directionPreserving =
249 jRamp.value(
"direction_preserving", ramp.directionPreserving);
252 if (jSim.contains(
"model"))
254 const std::string model = jSim.at(
"model");
255 if (model ==
"omni_wheel_torque")
259 else if (model ==
"omni_wheel_velocity")
263 else if (model ==
"mecanum_torque")
267 else if (model ==
"cartesian")
276 throw std::invalid_argument(
277 "Unknown platform model `" + model +
278 "`. Expected `cartesian`, `omni_wheel_velocity`, `omni_wheel_torque` "
279 "or `mecanum_torque`.");
286 const nlohmann::json jParam =
287 j.value(
"reparametrization", nlohmann::json::object());