28#include <boost/program_options.hpp>
30#include <SimoxUtility/json/json.hpp>
51 po::options_description desc(
"Allowed options");
55 (
"help,h",
"produce help message")
56 (
"scene", po::value<std::string>()->required(),
"Scene description (JSON).")
57 (
"out", po::value<std::string>()->default_value(
"result.json"),
"Output file (JSON).")
62 po::store(po::parse_command_line(argc, argv, desc), vm);
64 if (vm.count(
"help") != 0u)
66 std::cout << desc <<
"\n";
72 const std::filesystem::path sceneFilename = vm[
"scene"].as<std::string>();
73 const std::filesystem::path outFilename = vm[
"out"].as<std::string>();
75 ARMARX_INFO <<
"Reading scene from `" << sceneFilename.string() <<
"`.";
87 std::optional<global_planning::GlobalPlannerResult> result =
90 if (result.has_value())
92 ARMARX_IMPORTANT <<
"Planning succeeded: " << result->trajectory.points().size()
93 <<
" points, " << result->trajectory.length() <<
" mm.";
102 nlohmann::json reference =
nullptr;
108 double parametrizationSeconds = 0.0;
110 if (result.has_value() and
118 result->trajectory = std::move(reparametrized.
trajectory);
119 reference = std::move(reparametrized.
reference);
120 parametrizationSeconds = reparametrized.
seconds;
126 if (result.has_value())
135 std::optional<simulation::TrajectoryFollowingSimulation::Result> simulated;
136 if (result.has_value() and config.
simulate)
138 ARMARX_INFO <<
"Simulating trajectory following ...";
140 simulated = sim.
run(result->trajectory, config.
start);
145 outFilename, config, costmap, result, planner.
velocityLimit(), simulated, reference,
146 rampCheck, parametrizationSeconds);
151catch (
const std::exception& e)
std::optional< GlobalPlannerResult > plan(const core::Pose &start, const core::Pose &goal)
algorithms::ObstacleAwareVelocityLimit velocityLimit() const
The obstacle-aware velocity limit this planner applies, for the current costmap.
Point-mass simulation of the platform following a global trajectory.
Result run(const core::GlobalTrajectory &trajectory, const core::Pose &start) const
Follow trajectory starting from start, which need not be on the trajectory.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
CommandRampCheck checkAgainstCommandRamp(const core::GlobalTrajectory &trajectory, const simulation::CommandRateLimit &rateLimit, const float boundaryVelocity)
Compare the profile's v * dv/ds against rateLimit.
ReparametrizationResult reparametrize(const core::GlobalTrajectory &trajectory, const Config &config)
Re-assign the velocities along trajectory according to config.parametrization.
std::string toString(const core::TrajectoryParametrization mode)
void writeResult(const std::filesystem::path &filename, const Config &config, const algorithms::Costmap &costmap, const std::optional< global_planning::GlobalPlannerResult > &result, const algorithms::ObstacleAwareVelocityLimit &limit, const std::optional< simulation::TrajectoryFollowingSimulation::Result > &simulated, const nlohmann::json &reference, const CommandRampCheck &rampCheck, const double parametrizationSeconds)
Write scene, costmap and planning result as JSON for the python plotting tool.
Config readConfig(const std::filesystem::path &filename)
Read the scene description. Throws on malformed input.
algorithms::Costmap buildCostmap(const Config &config)
Build a costmap holding, per cell, the distance to the closest obstacle reduced by the robot radius (...
@ None
Leave the planner's velocities alone.
This file is part of ArmarX.
How far a velocity profile asks for more than the device command ramp can deliver.
Everything the application needs, as read from the scene description file.
core::GeneralConfig generalConfig
global_planning::SPFAParams plannerParams
bool simulate
Simulate the low-level controller following the planned trajectory.
core::TrajectoryParametrization parametrization
How the velocities along the planned path are (re-)assigned before simulating.
simulation::TrajectoryFollowingSimulation::Parameters simulationParams
double seconds
Wall-clock time the parametrization took [s].
nlohmann::json reference
The time-parametrized reference, as {duration, waypoints: [...]}.
core::GlobalTrajectory trajectory
CommandRateLimit rateLimit
The device-side command ramp between the controller and the platform.