79 <<
"Scene description " <<
QUOTED(filename.string()) <<
" does not exist.";
81 std::ifstream ifs{filename};
82 const nlohmann::json j = nlohmann::json::parse(ifs);
88 const nlohmann::json& jScene = j.at(
"scene");
90 config.
scene.
bounds.
min = toVector2f(jScene.at(
"bounds").at(
"min"));
91 config.
scene.
bounds.
max = toVector2f(jScene.at(
"bounds").at(
"max"));
98 for (
const nlohmann::json& jObstacle : jScene.at(
"obstacles"))
100 const std::string type = jObstacle.value(
"type", std::string{
"box"});
103 throw std::invalid_argument(
"Unsupported obstacle type `" + type +
104 "`. Only `box` is supported.");
107 const Box box{.min = toVector2f(jObstacle.at(
"min")),
108 .max = toVector2f(jObstacle.at(
"max"))};
117 config.
start = toPose(j.at(
"start"));
118 config.
goal = toPose(j.at(
"goal"));
122 const nlohmann::json jCostmap = j.value(
"costmap", nlohmann::json::object());
135 const nlohmann::json jSpfa = j.value(
"spfa", nlohmann::json::object());
139 jSpfa.value(
"obstacle_distance_costs", algo.obstacleDistanceCosts);
140 algo.obstacleCostExponent =
141 jSpfa.value(
"obstacle_cost_exponent", algo.obstacleCostExponent);
142 algo.obstacleMaxDistance =
143 jSpfa.value(
"obstacle_max_distance", algo.obstacleMaxDistance);
144 algo.obstacleDistanceWeight =
145 jSpfa.value(
"obstacle_distance_weight", algo.obstacleDistanceWeight);
148 jSpfa.value(
"enable_position_smoothing",
151 jSpfa.value(
"enable_final_velocity_clamp",
157 const nlohmann::json jGeneral = j.value(
"general", nlohmann::json::object());
177 const nlohmann::json jSim = j.value(
"simulation", nlohmann::json::object());
183 sim.dt = jSim.value(
"dt", sim.dt);
184 sim.maxDuration = jSim.value(
"max_duration", sim.maxDuration);
185 sim.goalDistanceThreshold =
186 jSim.value(
"goal_distance_threshold", sim.goalDistanceThreshold);
188 ctrl.alpha = jSim.value(
"alpha", ctrl.alpha);
189 ctrl.velocityFactor = jSim.value(
"velocity_factor", ctrl.velocityFactor);
190 ctrl.maxSegmentsAhead = jSim.value(
"max_segments_ahead", ctrl.maxSegmentsAhead);
191 ctrl.orientationWeight = jSim.value(
"orientation_weight", ctrl.orientationWeight);
192 ctrl.coupleLinearAndAngularLimits =
193 jSim.value(
"couple_linear_and_angular_limits",
194 ctrl.coupleLinearAndAngularLimits);
195 ctrl.enableAngularFeedforward =
196 jSim.value(
"enable_angular_feedforward", ctrl.enableAngularFeedforward);
198 ctrl.pidPos.Kp = jSim.value(
"pid_pos_kp", ctrl.pidPos.Kp);
199 ctrl.pidPos.Ki = jSim.value(
"pid_pos_ki", ctrl.pidPos.Ki);
200 ctrl.pidPos.Kd = jSim.value(
"pid_pos_kd", ctrl.pidPos.Kd);
201 ctrl.pidOri.Kp = jSim.value(
"pid_ori_kp", ctrl.pidOri.Kp);
202 ctrl.pidOri.Ki = jSim.value(
"pid_ori_ki", ctrl.pidOri.Ki);
203 ctrl.pidOri.Kd = jSim.value(
"pid_ori_kd", ctrl.pidOri.Kd);
213 config.
robot = jSim.value(
"robot", std::string{
"Armar7"});
215 sim.dynamics.maxLinearAcceleration =
216 jSim.value(
"max_linear_acceleration", sim.dynamics.maxLinearAcceleration);
217 sim.dynamics.maxAngularAcceleration =
218 jSim.value(
"max_angular_acceleration", sim.dynamics.maxAngularAcceleration);
222 const nlohmann::json jRamp =
223 jSim.value(
"rate_limit", nlohmann::json::object());
224 auto& ramp = sim.rateLimit;
226 ramp.enabled = jRamp.value(
"enabled", ramp.enabled);
227 ramp.dt = jRamp.value(
"dt", ramp.dt);
228 ramp.maxVelocity = jRamp.value(
"max_velocity", ramp.maxVelocity);
229 ramp.maxAcceleration = jRamp.value(
"max_acceleration", ramp.maxAcceleration);
230 ramp.maxDeceleration = jRamp.value(
"max_deceleration", ramp.maxDeceleration);
231 ramp.maxAngularVelocity =
232 jRamp.value(
"max_angular_velocity", ramp.maxAngularVelocity);
233 ramp.maxAngularAcceleration =
234 jRamp.value(
"max_angular_acceleration", ramp.maxAngularAcceleration);
235 ramp.maxAngularDeceleration =
236 jRamp.value(
"max_angular_deceleration", ramp.maxAngularDeceleration);
237 ramp.directionPreserving =
238 jRamp.value(
"direction_preserving", ramp.directionPreserving);
241 if (jSim.contains(
"model"))
243 const std::string model = jSim.at(
"model");
244 if (model ==
"omni_wheel_torque")
248 else if (model ==
"omni_wheel_velocity")
252 else if (model ==
"mecanum_torque")
256 else if (model ==
"cartesian")
265 throw std::invalid_argument(
266 "Unknown platform model `" + model +
267 "`. Expected `cartesian`, `omni_wheel_velocity`, `omni_wheel_torque` "
268 "or `mecanum_torque`.");
275 const nlohmann::json jParam =
276 j.value(
"reparametrization", nlohmann::json::object());