ObstacleAwareVelocityLimit.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 <vector>
25
26#include <Eigen/Core>
27
30
32{
33
34 /**
35 * @brief The maximum permissible linear velocity as a function of the distance to the
36 * closest obstacle.
37 *
38 * The limit decays from `maxVelocity` in free space to `maxVelocity / (1 + weight)` at zero
39 * clearance:
40 *
41 * \f[
42 * v_{max}(d) = \frac{v_{max}}{1 + w \left(1 - \frac{\min(d, d_{max})}{d_{max}}\right)^{e}}
43 * \f]
44 *
45 * This used to live as a private member function of `global_planning::SPFAImpl`, duplicated
46 * once more in its final velocity clamp. It is a standalone concept, so it lives here and can
47 * be used to *verify* a trajectory produced by any planner: for a path that respects the
48 * limit, `at(position) >= velocity` holds at every trajectory point.
49 *
50 * @note The referenced costmap must outlive this object.
51 */
53 {
54 public:
56 {
57 /// Permissible velocity far away from any obstacle [mm/s].
58 float maxVelocity{200.F};
59
60 /// Distances are clipped to this value; beyond it the limit is `maxVelocity` [mm].
61 float obstacleMaxDistance{500.F};
62
63 /// Strength of the reduction. At zero clearance the limit is `maxVelocity / (1 + w)`.
65
66 /// Exponent of the proximity term. Larger values keep full speed closer to obstacles.
68 };
69
70 ObstacleAwareVelocityLimit(const Costmap& costmap, const Parameters& params);
71
72 /// The limit for a given distance to the closest obstacle [mm].
73 float atDistance(float obstacleDistance) const;
74
75 /**
76 * @brief The limit at a position in the costmap's global frame.
77 *
78 * Cells without costmap information (masked out) are treated as zero clearance, i.e. the
79 * most restrictive limit. Not knowing how far away the obstacles are is not a reason to
80 * drive fast.
81 */
82 float at(const Eigen::Vector2f& position) const;
83
84 std::vector<float> at(const core::Positions& positions) const;
85
86 const Parameters& params() const noexcept;
87
88 private:
89 const Costmap& costmap_;
90
91 const Parameters params_;
92 };
93
94} // namespace armarx::navigation::algorithms
ObstacleAwareVelocityLimit(const Costmap &costmap, const Parameters &params)
float at(const Eigen::Vector2f &position) const
The limit at a position in the costmap's global frame.
float atDistance(float obstacleDistance) const
The limit for a given distance to the closest obstacle [mm].
This file is part of ArmarX.
std::vector< Position > Positions
Definition basic_types.h:37
float obstacleMaxDistance
Distances are clipped to this value; beyond it the limit is maxVelocity [mm].
float obstacleCostExponent
Exponent of the proximity term. Larger values keep full speed closer to obstacles.
float maxVelocity
Permissible velocity far away from any obstacle [mm/s].
float obstacleDistanceWeight
Strength of the reduction. At zero clearance the limit is maxVelocity / (1 + w).