reparametrization.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2026
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <cstddef>
25#include <string>
26#include <utility>
27#include <vector>
28
29#include <SimoxUtility/json/json.hpp>
30
33
34#include "Scene.h"
35
37{
38
39 /**
40 * @brief How far a velocity profile asks for more than the device command ramp can deliver.
41 *
42 * A `GlobalTrajectory` stores a speed per position, so the tangential acceleration it
43 * implies is `v * dv/ds`. Nothing in the planning stack compares that against the ramp in
44 * `Velocity.cpp`, which is the actual bottleneck: TOPPRA is bounded by motor torque and
45 * happily plans an 873 mm/s^2 stop that the configured 400 mm/s^2 ramp cannot execute, and
46 * the base sails past the goal.
47 */
49 {
50 /// Waypoints demanding more than the ramp can deliver.
51 std::size_t violations{0};
52
53 /// Largest demanded tangential acceleration [mm/s^2], and where along the path it is.
54 float worstDemand{0.F};
55 float worstArcLength{0.F};
56
57 /// The bound that was exceeded there [mm/s^2].
58 float worstLimit{0.F};
59
60 /// Arc-length spans in which the demand exceeds the ramp, for the plot.
61 std::vector<std::pair<float, float>> spans;
62
63 /// Distance the ramp needs to stop from the profile's final velocity [mm].
64 ///
65 /// A flat profile passes the `v * dv/ds` test everywhere and still overshoots, because
66 /// it simply ends at speed: nothing in a `GlobalTrajectory` says the robot has to be
67 /// able to stop. This is the number that predicts the overshoot.
69
70 /// Whether the profile ends above `boundaryVelocity`, i.e. faster than by design.
72 };
73
74 /// Compare the profile's `v * dv/ds` against `rateLimit`. Logs a warning if it exceeds it.
75 ///
76 /// `boundaryVelocity` is the speed the stack deliberately ends at, so a terminal stopping
77 /// distance implied by it is by design and not worth warning about.
79 const simulation::CommandRateLimit& rateLimit,
80 float boundaryVelocity);
81
82 /// Parse the `--parametrization` choice. Throws on an unknown name.
84
86
88 {
90
91 /**
92 * @brief The time-parametrized reference, as `{duration, waypoints: [...]}`.
93 *
94 * A GlobalTrajectory only stores a speed per *position*, so the time information TOPPRA
95 * computed is lost as soon as the result is converted. Reading it back out of the
96 * parametrization lets the plots put the promised profile next to the executed one.
97 * Null unless mode is `toppra`.
98 */
99 nlohmann::json reference;
100
101 /// Wall-clock time the parametrization took [s]. The planner's own stage timings do not
102 /// cover it, and for TOPPRA it dwarfs them.
103 double seconds{0.0};
104 };
105
106 /**
107 * @brief Re-assign the velocities along `trajectory` according to `config.parametrization`.
108 *
109 * A thin wrapper over `fac::TrajectoryParametrizationFactory` -- the modes themselves live
110 * in the algorithms library and are the same objects the `Navigator` runs, so what this
111 * application measures is what the robot would do. All that is added here is assembling
112 * `Toppra::DriveParams` from the scene's simulation config and reading back the time
113 * parametrization for the plots.
114 *
115 * @throws std::runtime_error if the parametrization is unavailable or fails.
116 */
117 ReparametrizationResult reparametrize(const core::GlobalTrajectory& trajectory,
118 const Config& config);
119
120} // namespace armarx::navigation::analysis
This file is part of ArmarX.
Definition io.cpp:36
CommandRampCheck checkAgainstCommandRamp(const core::GlobalTrajectory &trajectory, const simulation::CommandRateLimit &rateLimit, const float boundaryVelocity)
Compare the profile's v * dv/ds against rateLimit.
core::TrajectoryParametrization parametrizationModeFromString(const std::string &name)
Parse the --parametrization choice. Throws on an unknown name.
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)
TrajectoryParametrization
How the velocities along a planned path are assigned.
How far a velocity profile asks for more than the device command ramp can deliver.
bool terminalVelocityExceedsBoundary
Whether the profile ends above boundaryVelocity, i.e. faster than by design.
float worstDemand
Largest demanded tangential acceleration [mm/s^2], and where along the path it is.
float worstLimit
The bound that was exceeded there [mm/s^2].
std::vector< std::pair< float, float > > spans
Arc-length spans in which the demand exceeds the ramp, for the plot.
std::size_t violations
Waypoints demanding more than the ramp can deliver.
float terminalStoppingDistance
Distance the ramp needs to stop from the profile's final velocity [mm].
double seconds
Wall-clock time the parametrization took [s].
nlohmann::json reference
The time-parametrized reference, as {duration, waypoints: [...]}.
The per-axis command ramp the platform device applies below the navigation stack.