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 <optional>
26 
27 #include <SimoxUtility/color/Color.h>
28 #include <SimoxUtility/color/ColorMap.h>
29 
33 
34 #include "SafetyGuard.h"
35 
36 namespace armarx::viz
37 {
38  struct Layer;
39 }
40 
42 {
43 
45  {
46  bool reduceVelocity{true};
47 
48  float minDistance{500.F};
49  float maxDistance{2000.F};
50 
51  // Parameters to reduce the velocity in proximity to an obstacle between minDistance and maxDistance.
52  // It is v = v_max / (1 + lambda * d_s^lambda) with d_s = (1 - (d / maxDistance))^k
53  float k{4.F};
54  float lambda{6.F};
55  };
56 
58  {
59  float robotRadius{500.F}; //TODO(utetg): should there be a default, if yes what
60 
61  bool enableHumans{true};
62  bool enableLaserScanners{true};
63 
65  .linear = 500.F,
66  .angular = 0.5F,
67  };
68 
71 
72  Algorithms algorithm() const override;
73  aron::data::DictPtr toAron() const override;
75  };
76 
77  class LaserBasedProximity : virtual public SafetyGuard
78  {
79  public:
81 
82  LaserBasedProximity(const Params& params, const core::Scene& scene, const Context& ctx);
83  ~LaserBasedProximity() override = default;
84 
86 
87  private:
88  std::optional<core::TwistLimits> safetyLimitsHumans(viz::Layer& layer) const;
89  std::optional<core::TwistLimits> safetyLimitsLaserScanners(viz::Layer& layer) const;
90 
91  std::pair<float, Eigen::Vector2f>
92  calculateMinDistance(const util::geometry::polygon_type& convexHull,
93  const core::Pose& robot_T_global,
94  const std::vector<Eigen::Vector3f>& globalPoints) const;
95 
96  std::pair<core::TwistLimits, float>
97  evaluateProximityField(const ProximityFieldParams& proximityField, float minDistance) const;
98 
99  protected:
100  const Params params;
101 
102  private:
103  simox::ColorMap humanColorMap_;
104  simox::ColorMap laserColorMap_;
105  };
106 } // namespace armarx::navigation::safety_guard
armarx::navigation::safety_guard::LaserBasedProximityParams::enableLaserScanners
bool enableLaserScanners
Definition: LaserBasedProximity.h:62
armarx::navigation::safety_guard::ProximityFieldParams::reduceVelocity
bool reduceVelocity
Definition: LaserBasedProximity.h:46
armarx::navigation::safety_guard::LaserBasedProximityParams
Definition: LaserBasedProximity.h:57
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
basic_types.h
armarx::navigation::safety_guard
This file is part of ArmarX.
Definition: fwd.h:54
armarx::navigation::safety_guard::ProximityFieldParams::maxDistance
float maxDistance
Definition: LaserBasedProximity.h:49
Convex::convexHull
ConvexHull< Point >::type convexHull(const std::vector< Point > &points)
Definition: convexHull.hpp:501
armarx::navigation::core::TwistLimits::linear
float linear
Definition: types.h:82
armarx::navigation::safety_guard::LaserBasedProximityParams::humanProximityField
ProximityFieldParams humanProximityField
Definition: LaserBasedProximity.h:69
armarx::navigation::safety_guard::LaserBasedProximityParams::maxVelocity
core::TwistLimits maxVelocity
Definition: LaserBasedProximity.h:64
geometry.h
armarx::navigation::safety_guard::SafetyGuard::Context
Definition: SafetyGuard.h:76
armarx::navigation::safety_guard::LaserBasedProximityParams::laserScannerProximityField
ProximityFieldParams laserScannerProximityField
Definition: LaserBasedProximity.h:70
armarx::navigation::safety_guard::LaserBasedProximityParams::FromAron
static LaserBasedProximityParams FromAron(const aron::data::DictPtr &dict)
Definition: LaserBasedProximity.cpp:110
armarx::navigation::safety_guard::Algorithms
Algorithms
Definition: core.h:30
armarx::navigation::safety_guard::SafetyGuardResult
Definition: SafetyGuard.h:47
armarx::navigation::safety_guard::ProximityFieldParams::lambda
float lambda
Definition: LaserBasedProximity.h:54
armarx::navigation::core::TwistLimits
Definition: types.h:80
armarx::navigation::safety_guard::LaserBasedProximity::params
const Params params
Definition: LaserBasedProximity.h:100
armarx::navigation::safety_guard::LaserBasedProximity::LaserBasedProximity
LaserBasedProximity(const Params &params, const core::Scene &scene, const Context &ctx)
Definition: LaserBasedProximity.cpp:121
armarx::navigation::core::Scene
Definition: types.h:60
armarx::navigation::util::geometry::polygon_type
boost::geometry::model::polygon< point_type > polygon_type
Definition: geometry.h:36
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::navigation::safety_guard::ProximityFieldParams
Definition: LaserBasedProximity.h:44
armarx::navigation::safety_guard::LaserBasedProximityParams::robotRadius
float robotRadius
Definition: LaserBasedProximity.h:59
armarx::navigation::safety_guard::ProximityFieldParams::k
float k
Definition: LaserBasedProximity.h:53
armarx::navigation::safety_guard::SafetyGuardParams
Definition: SafetyGuard.h:65
armarx::navigation::safety_guard::LaserBasedProximityParams::algorithm
Algorithms algorithm() const override
Definition: LaserBasedProximity.cpp:94
armarx::navigation::safety_guard::LaserBasedProximity::~LaserBasedProximity
~LaserBasedProximity() override=default
armarx::navigation::safety_guard::LaserBasedProximityParams::enableHumans
bool enableHumans
Definition: LaserBasedProximity.h:61
armarx::navigation::safety_guard::LaserBasedProximity::computeSafetyLimits
SafetyGuardResult computeSafetyLimits() override
Definition: LaserBasedProximity.cpp:132
armarx::navigation::safety_guard::SafetyGuard
Definition: SafetyGuard.h:73
armarx::navigation::safety_guard::ProximityFieldParams::minDistance
float minDistance
Definition: LaserBasedProximity.h:48
armarx::navigation::safety_guard::LaserBasedProximityParams::toAron
aron::data::DictPtr toAron() const override
Definition: LaserBasedProximity.cpp:100
armarx::viz::Layer
Definition: Layer.h:12
types.h
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:418
armarx::navigation::safety_guard::LaserBasedProximity
Definition: LaserBasedProximity.h:77
SafetyGuard.h
armarx::navigation::safety_guard::SafetyGuard::scene
const core::Scene & scene
Definition: SafetyGuard.h:87