OrientationOptimizer.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 2021
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <optional>
25
27
29{
30
32 {
33 Any = 10,
36 };
37
39 {
40 int iterations{5};
41 float movementDirWeightStart{0.0F}; // inclusive
42 float movementDirWeightEnd{0.5F}; // inclusive
43
44 float smoothnessWeight{0.4F};
46
47 float priorStartWeight{1.F};
48 float priorEndWeight{1.F};
49
51
53
54 /**
55 * @brief Most the heading may turn per millimetre travelled [rad/mm].
56 *
57 * The rotation a profile needs is fixed by its start and goal; how much *path* it is
58 * spread over is this optimizer's choice, and that choice decides whether the result can
59 * be executed at all -- the yaw rate asked of the base is `yaw'(s) * v`.
60 *
61 * Nothing in the cost function is expressed per unit distance. The movement-direction
62 * prior pulls every interior heading onto the path tangent and only the smoothness term
63 * resists, so the profile holds the tangent as long as it can and then swings the whole
64 * rotation across a narrow band -- the same band whether the path is one metre or six.
65 * On ARMAR-7 that put a 116 deg rotation into 300 mm of a 3212 mm path and asked for
66 * 3.9 rad/s against a 0.8 rad/s limit.
67 *
68 * The default is what a base holding 0.8 rad/s can turn while still making the 150 mm/s
69 * the profile is floored at. Deliberately not an aron parameter: it is a property of the
70 * drive, and every shipped config would have to grow a member to add it.
71 */
72 double maxTurnRate{0.8 / 150.0}; // [rad/mm]
73
74 /**
75 * @brief How short a segment has to be, relative to the path's own spacing, before the
76 * turn-rate check stops asking it anything.
77 *
78 * A segment far shorter than its neighbours carries no reliable direction: the heading
79 * across it is `atan2` of numerical noise, and `dyaw/ds` on it is that noise divided by
80 * nothing. It is a *position* defect, and `spfa::smoothing::GeometryLimits` already owns
81 * it -- `findGeometryViolations` reports any segment under `minSegmentLength` (1 mm).
82 *
83 * The floor here is deliberately **relative** where that one is absolute, and an absolute
84 * gate would be worse than useless: on a path whose spacing is legitimately around a
85 * millimetre it excludes *every* segment, so the turn rate comes back as zero, the
86 * smoothing loop never runs and `orientation-unturnable` can no longer fire at all. The
87 * guard would go quiet exactly where it is needed. `TrajectoryFollowingController` hit
88 * the same wall from the other side and lowered its own gate to 1e-3 mm for it. Only the
89 * ratio to the path's own scale separates a defect from a small path, so do not unify
90 * the three floors in this repo -- they answer different questions.
91 *
92 * A tenth, rather than something larger: the smoothing upstream can legitimately leave a
93 * 40 mm segment among 200 mm ones, and excluding that would under-report a real turn
94 * rate. The splice artefacts this exists for are three to four orders of magnitude below
95 * their neighbours, so the margin is ample either way.
96 */
98 };
99
101 {
102 public:
104
105 OrientationOptimizer(const core::GlobalTrajectory& trajectory, const Params& params);
106
108 {
109 std::optional<core::GlobalTrajectory> trajectory;
110
111 /* //COMMENT IN FOR TEST CASE PLOTTING
112 std::vector<double> initial;
113 std::vector<double> prior; */
114
115 operator bool() const noexcept
116 {
117 return trajectory.has_value();
118 }
119 };
120
121 OptimizationResult optimize();
122
123 protected:
124 private:
126
127 const Params params;
128 };
129} // namespace armarx::navigation::global_planning::optimization
130
131// FIXME remove
133{
135}
OrientationOptimizer(const core::GlobalTrajectory &trajectory, const Params &params)
This file is part of ArmarX.
Definition fwd.h:30
double maxTurnRate
Most the heading may turn per millimetre travelled [rad/mm].
double degenerateSegmentFraction
How short a segment has to be, relative to the path's own spacing, before the turn-rate check stops a...