TrajectoryFollowingController.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 * @author Christian R. G. Dreher ( c dot dreher at kit dot edu )
18 * @date 2021
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <memory>
26
29
35
37{
38 // using arondto::TrajectoryFollowingControllerParams;
39
41 {
42
45
46 float velocityFactor = 1.F;
47
48 float alpha = 0;
49
50 float orientationWeight = 3.0f / M_PIf32;
51
53
54 /// Lookahead as a distance [mm]. 0 keeps the pure `maxSegmentsAhead` behaviour.
55 float lookaheadDistance = 0.F;
56
57 /// Fraction of `limits.angular` the angular feed-forward may use. 1 lets it saturate.
59
60 /// Floor on the capped linear feed-forward, as a fraction of the requested velocity.
62
64
66
67 /// Rate at which the RT thread walks the commanded twist towards this controller's
68 /// output. Not a limit on the motion -- the joint controller's ramp stays authoritative,
69 /// since the same control mode is shared with the platform unit and the gamepad -- but
70 /// the bridge between the 100 Hz non-RT task and the 1 kHz RT thread. Defaults are
71 /// ARMAR-7's device command ramp, so this never asks for more than the ramp would grant.
72 float maxLinearAcceleration = 250.F; // [mm/s^2]
73 float maxAngularAcceleration = 0.4F; // [rad/s^2]
74
75 Algorithms algorithm() const override;
76 aron::data::DictPtr toAron() const override;
77
79 };
80
82 {
83 public:
85
87 ~TrajectoryFollowingController() override = default;
88
90 const core::Pose& global_T_robot) override;
91
92
93 void updateParams(const Params& params);
94
95 void resetProgress();
96
97 protected:
99
101
102 private:
103 Params params;
104
105
110
111 struct TrajectoryId
112 {
113 std::size_t numPoints = 0;
114 Eigen::Vector3f firstTranslation = Eigen::Vector3f::Zero();
115 Eigen::Vector3f lastTranslation = Eigen::Vector3f::Zero();
116
117 bool operator==(const TrajectoryId& other) const
118 {
119 return numPoints == other.numPoints &&
120 firstTranslation == other.firstTranslation &&
121 lastTranslation == other.lastTranslation;
122 }
123 bool operator!=(const TrajectoryId& other) const
124 {
125 return !(*this == other);
126 }
127 };
128
129 std::optional<TrajectoryId> lastTrajectoryId_;
130 std::size_t lastProjectionIndex_ = 0;
131
132 /**
133 * @brief Per-trajectory latches for the `[nav-guard]` warnings.
134 *
135 * `control()` runs at 100 Hz, so a guard that fires every cycle would flood the log. The
136 * latches make the first firing on a given trajectory unconditional and leave the
137 * sustained case to `deactivateSpam`, which is what makes a robot log readable while
138 * still never hiding the onset.
139 */
140 struct GuardState
141 {
142 bool zeroLengthSegment = false;
143
144 bool nonFiniteTwist = false;
145
146 bool noUsableProjection = false;
147
148 bool angularFeedforwardSaturated = false;
149
150 /// Consecutive cycles the angular feed-forward has been pinned at the limit.
151 std::size_t angularSaturatedCycles = 0;
152 };
153
154 GuardState guards_;
155 };
156
157 using TrajectoryFollowingControllerPtr = std::shared_ptr<TrajectoryFollowingController>;
158
159} // namespace armarx::navigation::traj_ctrl::global
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
Eigen::Isometry3f Pose
Definition basic_types.h:31
std::shared_ptr< TrajectoryFollowingController > TrajectoryFollowingControllerPtr
bool operator==(const RemoteHandle< PrxTA > &fst, const RemoteHandle< PrxTB > &snd)
bool operator!=(const RemoteHandle< PrxTA > &fst, const RemoteHandle< PrxTB > &snd)
This file is part of ArmarX.
float maxLinearAcceleration
Rate at which the RT thread walks the commanded twist towards this controller's output.
float minFeedforwardVelocityFraction
Floor on the capped linear feed-forward, as a fraction of the requested velocity.
float angularFeedforwardFraction
Fraction of limits.angular the angular feed-forward may use. 1 lets it saturate.
static TrajectoryFollowingControllerParams FromAron(const aron::data::DictPtr &dict)
float lookaheadDistance
Lookahead as a distance [mm]. 0 keeps the pure maxSegmentsAhead behaviour.