LaserBasedProximity.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 <cstdint>
26#include <optional>
27
28#include <boost/circular_buffer.hpp>
29
30#include <SimoxUtility/color/ColorMap.h>
31
36
37#include "SafetyGuard.h"
38
39namespace armarx::viz
40{
41 struct Layer;
42}
43
45{
46
48 {
49 enum class Mode : std::uint8_t
50 {
54 };
55
57
58 float safetyDistance{500.F};
59 float influenceDistance{2000.F};
60
61 // if enabled, reduce the velocity between safetyDistance and influenceDistance. If false, the robot will move with maximum velocity until it has to stop at safetyDistance.
62 bool reduceVelocity{true};
63
64 // Parameters to reduce the velocity in proximity to an obstacle between minDistance and maxDistance.
65 // It is v = v_max / (1 + lambda * d_s^lambda) with d_s = (1 - (d / maxDistance))^k
66 float k{4.F};
67 float lambda{6.F};
68 };
69
71 {
72 float robotRadius{500.F}; //TODO(utetg): should there be a default, if yes what
73
74 bool enableHumans{true};
76
79
80 // any laser scanner feature that lies **fully** inside any of these regions will be ignored
81 std::vector<Eigen::AlignedBox2f> ignoredRegions;
82
83 float attachedObjectsInflation = 200; // [mm]
84
85 // any laser scanner feature that lies **fully** inside the OOBB of the attached object will be ignored
87
88 // Whether to filter out small laser scanner features close to the robot
89 // These can appear due to measuring errors of the sensors
91 // features with <= this number of points are ignored
93 // [mm]; only filter features where all points are within this distance from the robot
95
96 Algorithms algorithm() const override;
97 aron::data::DictPtr toAron() const override;
99 };
100
101 class LaserBasedProximity : virtual public SafetyGuard
102 {
103 public:
105
107 const core::GeneralConfig& generalConfig,
108 const core::Scene& scene,
109 const Context& ctx);
110 ~LaserBasedProximity() override = default;
111
112 SafetyGuardResult computeSafetyLimits(const Eigen::Vector2f& global_V_movement) override;
113
114 private:
115 struct DistanceAndClosestPoint
116 {
117 float distance;
118 Eigen::Vector2f closestPoint;
119
120 std::size_t clusterSize;
121 };
122
123 std::optional<core::TwistLimits> safetyLimitsHumans(viz::Layer& layer) const;
124 std::optional<core::TwistLimits>
125 safetyLimitsLaserScanners(viz::Layer& layer,
126 const Eigen::Vector2f& global_V_movement) const;
127
128 DistanceAndClosestPoint
129 calculateMinDistance(const util::geometry::polygon_type& convexHull,
130 const core::Pose& robot_T_global,
131 const std::vector<Eigen::Vector3f>& globalPoints) const;
132
133 std::pair<core::TwistLimits, float>
134 evaluateProximityField(const ProximityFieldParams& proximityField, float minDistance) const;
135
136 bool isFeatureIgnored(const std::vector<Eigen::Vector3f>& featurePoints3DGlobal,
137 const std::vector<Eigen::Vector2f>& featurePoints2DGlobal) const;
138
139 struct InternalVelocityLimitResult
140 {
141 core::TwistLimits twistLimits;
142 std::optional<float> minDistance;
143
144 // not necessarily the closest point according to the Euclidean distance, but the point that leads to the calculated safety limits
145 std::optional<Eigen::Vector2f> closestPoint;
146 };
147
148 InternalVelocityLimitResult velocityLimitsDirectionDependent(
149 const Eigen::Vector2f& global_V_movement,
150 const std::vector<DistanceAndClosestPoint>& minDistanceToObstacles,
151 const Eigen::Isometry3f& global_T_robot) const;
152
153 InternalVelocityLimitResult velocityLimitsDirectionIndependent(
154 const std::vector<DistanceAndClosestPoint>& minDistanceToObstacles) const;
155
156
157 protected:
159
160 private:
161 core::GeneralConfig generalConfig;
162
163 simox::ColorMap humanColorMap_;
164 simox::ColorMap laserColorMap_;
165
166 mutable boost::circular_buffer<std::vector<memory::LaserScannerFeatures>>
167 laserScannerFeatureHistory_{5};
168 };
169} // namespace armarx::navigation::safety_guard
SafetyGuardResult computeSafetyLimits(const Eigen::Vector2f &global_V_movement) override
LaserBasedProximity(const Params &params, const core::GeneralConfig &generalConfig, const core::Scene &scene, const Context &ctx)
SafetyGuard(const core::Scene &scene, const Context &ctx)
std::shared_ptr< Dict > DictPtr
Definition Dict.h:42
Eigen::Isometry3f Pose
Definition basic_types.h:31
This file is part of ArmarX.
Definition fwd.h:55
boost::geometry::model::polygon< point_type > polygon_type
Definition geometry.h:36
This file is part of ArmarX.
double distance(const Point &a, const Point &b)
Definition point.hpp:95
static LaserBasedProximityParams FromAron(const aron::data::DictPtr &dict)