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 <SimoxUtility/color/ColorMap.h>
29
34
35#include "SafetyGuard.h"
36
37namespace armarx::viz
38{
39 struct Layer;
40}
41
43{
44
46 {
47 enum class Mode : std::uint8_t
48 {
52 };
53
55
56 float safetyDistance{500.F};
57 float influenceDistance{2000.F};
58
59 // 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.
60 bool reduceVelocity{true};
61
62 // Parameters to reduce the velocity in proximity to an obstacle between minDistance and maxDistance.
63 // It is v = v_max / (1 + lambda * d_s^lambda) with d_s = (1 - (d / maxDistance))^k
64 float k{4.F};
65 float lambda{6.F};
66 };
67
69 {
70 float robotRadius{500.F}; //TODO(utetg): should there be a default, if yes what
71
72 bool enableHumans{true};
74
77
78 // any laser scanner feature that lies **fully** inside any of these regions will be ignored
79 std::vector<Eigen::AlignedBox2f> ignoredRegions;
80
81 float attachedObjectsInflation = 200; // [mm]
82
83 // any laser scanner feature that lies **fully** inside the OOBB of the attached object will be ignored
85
86 // Whether to filter out small laser scanner features close to the robot
87 // These can appear due to measuring errors of the sensors
89 // features with <= this number of points are ignored
91 // [mm]; only filter features where all points are within this distance from the robot
93
94 Algorithms algorithm() const override;
95 aron::data::DictPtr toAron() const override;
97 };
98
99 class LaserBasedProximity : virtual public SafetyGuard
100 {
101 public:
103
105 const core::GeneralConfig& generalConfig,
106 const core::Scene& scene,
107 const Context& ctx);
108 ~LaserBasedProximity() override = default;
109
110 SafetyGuardResult computeSafetyLimits(const Eigen::Vector2f& global_V_movement) override;
111
112 private:
113 struct DistanceAndClosestPoint
114 {
115 float distance;
116 Eigen::Vector2f closestPoint;
117 };
118
119 std::optional<core::TwistLimits> safetyLimitsHumans(viz::Layer& layer) const;
120 std::optional<core::TwistLimits>
121 safetyLimitsLaserScanners(viz::Layer& layer,
122 const Eigen::Vector2f& global_V_movement) const;
123
124 DistanceAndClosestPoint
125 calculateMinDistance(const util::geometry::polygon_type& convexHull,
126 const core::Pose& robot_T_global,
127 const std::vector<Eigen::Vector3f>& globalPoints) const;
128
129 std::pair<core::TwistLimits, float>
130 evaluateProximityField(const ProximityFieldParams& proximityField, float minDistance) const;
131
132 bool isFeatureIgnored(const std::vector<Eigen::Vector3f>& featurePoints3DGlobal,
133 const std::vector<Eigen::Vector2f>& featurePoints2DGlobal) const;
134
135 struct InternalVelocityLimitResult
136 {
137 core::TwistLimits twistLimits;
138 float minDistance;
139
140 // not necessarily the closest point according to the Euclidean distance, but the point that leads to the calculated safety limits
141 Eigen::Vector2f closestPoint;
142 };
143
144 InternalVelocityLimitResult velocityLimitsDirectionDependent(
145 const Eigen::Vector2f& global_V_movement,
146 const std::vector<DistanceAndClosestPoint>& minDistanceToObstacles,
147 const Eigen::Isometry3f& global_T_robot) const;
148
149 InternalVelocityLimitResult velocityLimitsDirectionIndependent(
150 const std::vector<DistanceAndClosestPoint>& minDistanceToObstacles) const;
151
152
153 protected:
155
156 private:
157 core::GeneralConfig generalConfig;
158
159 simox::ColorMap humanColorMap_;
160 simox::ColorMap laserColorMap_;
161 };
162} // 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)