DynamicObstacleManager.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  * @package armar6_skills::ArmarXObjects::DynamicObstacleManager
17  * @author Fabian PK ( fabian dot peller-konrad at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 
27 // STD/STL
28 #include <array>
29 #include <string>
30 #include <tuple>
31 #include <vector>
32 #include <shared_mutex>
33 
34 // Eigen
35 #include <Eigen/Geometry>
36 
37 // Ice
38 #include <Ice/Current.h>
39 
40 // ArmarX
41 #include <ArmarXCore/interface/observers/ObserverInterface.h>
44 
45 // Managed Objects
47 
48 // ObstacleAvoidance
49 #include <RobotAPI/interface/components/ObstacleAvoidance/DynamicObstacleManagerInterface.h>
50 #include <RobotAPI/interface/components/ObstacleAvoidance/ObstacleDetectionInterface.h>
51 
52 // ArViz
54 
55 namespace armarx
56 {
57 
59  virtual public Component,
60  virtual public DynamicObstacleManagerInterface,
61  virtual public ArVizComponentPluginUser
62  {
63  public:
64 
65  DynamicObstacleManager() noexcept;
66 
67  std::string getDefaultName() const override;
68 
69  void add_decayable_obstacle(const Eigen::Vector2f&, float, float, float, const Ice::Current& = Ice::Current()) override;
70  void add_decayable_line_segment(const Eigen::Vector2f&, const Eigen::Vector2f&, const Ice::Current& = Ice::Current()) override;
71  void add_decayable_line_segments(const dynamicobstaclemanager::LineSegments& lines, const Ice::Current& = Ice::Current()) override;
72  void remove_all_decayable_obstacles(const Ice::Current& = Ice::Current()) override;
73  void directly_update_obstacle(const std::string& name, const Eigen::Vector2f&, float, float, float, const Ice::Current& = Ice::Current()) override;
74  void remove_obstacle(const std::string& name, const Ice::Current& = Ice::Current()) override;
75  void wait_unitl_obstacles_are_ready(const Ice::Current& = Ice::Current()) override;
76  float distanceToObstacle(const Eigen::Vector2f& agentPosition, float safetyRadius, const Eigen::Vector2f& goal, const Ice::Current& = Ice::Current()) override;
77 
78  protected:
79  void onInitComponent() override;
80  void onConnectComponent() override;
81  void onDisconnectComponent() override;
82  void onExitComponent() override;
84 
85  private:
86  void update_decayable_obstacles();
87 
88  void visualize_obstacle(viz::Layer& l, const ManagedObstaclePtr& o, const armarx::DrawColor& color, double z_pos, bool);
89 
90  public:
91  static const std::string default_name;
92 
93  private:
94  const std::string m_obstacle_manager_layer_name = "DynamicObstacleManagerObstacles";
95 
96  unsigned long m_obstacle_index;
97 
98  std::vector<ManagedObstaclePtr> m_managed_obstacles;
99  std::shared_mutex m_managed_obstacles_mutex;
100 
102  unsigned int m_decay_after_ms;
103  unsigned int m_periodic_task_interval;
104  unsigned int m_decay_factor;
105  unsigned int m_access_bonus;
106  unsigned int m_min_value_for_accepting;
107 
108  float m_min_coverage_of_obstacles;
109  float m_min_coverage_of_line_samples_in_obstacle;
110  unsigned int m_min_size_of_obstacles;
111  unsigned int m_min_length_of_lines;
112  unsigned int m_max_size_of_obstacles;
113  unsigned int m_max_length_of_lines;
114  unsigned int m_thickness_of_lines;
115  unsigned int m_security_margin_for_obstacles;
116  unsigned int m_security_margin_for_lines;
117 
118  bool m_remove_enabled;
119  bool m_only_visualize;
120  bool m_allow_spwan_inside;
121 
122  ObstacleDetectionInterface::ProxyType m_obstacle_detection;
123 
124  };
125 }
ArVizComponentPlugin.h
armarx::DynamicObstacleManager::add_decayable_line_segment
void add_decayable_line_segment(const Eigen::Vector2f &, const Eigen::Vector2f &, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:121
PeriodicTask.h
ManagedObstacle.h
armarx::DynamicObstacleManager::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: DynamicObstacleManager.cpp:95
armarx::DynamicObstacleManager::distanceToObstacle
float distanceToObstacle(const Eigen::Vector2f &agentPosition, float safetyRadius, const Eigen::Vector2f &goal, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:258
armarx::DynamicObstacleManager::directly_update_obstacle
void directly_update_obstacle(const std::string &name, const Eigen::Vector2f &, float, float, float, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:304
armarx::DynamicObstacleManager::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: DynamicObstacleManager.cpp:89
armarx::DynamicObstacleManager::add_decayable_line_segments
void add_decayable_line_segments(const dynamicobstaclemanager::LineSegments &lines, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:209
armarx::DynamicObstacleManager::remove_obstacle
void remove_obstacle(const std::string &name, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:230
armarx::DynamicObstacleManager::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DynamicObstacleManager.cpp:479
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
armarx::DynamicObstacleManager::add_decayable_obstacle
void add_decayable_obstacle(const Eigen::Vector2f &, float, float, float, const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:115
armarx::DynamicObstacleManager::remove_all_decayable_obstacles
void remove_all_decayable_obstacles(const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:218
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:41
armarx::DynamicObstacleManager
Definition: DynamicObstacleManager.h:58
armarx::DynamicObstacleManager::wait_unitl_obstacles_are_ready
void wait_unitl_obstacles_are_ready(const Ice::Current &=Ice::Current()) override
Definition: DynamicObstacleManager.cpp:249
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
TripleBuffer.h
armarx::DynamicObstacleManager::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: DynamicObstacleManager.cpp:105
armarx::DynamicObstacleManager::default_name
static const std::string default_name
Definition: DynamicObstacleManager.h:91
armarx::DynamicObstacleManager::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: DynamicObstacleManager.cpp:110
armarx::DynamicObstacleManager::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: DynamicObstacleManager.cpp:83
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::DynamicObstacleManager::DynamicObstacleManager
DynamicObstacleManager() noexcept
Definition: DynamicObstacleManager.cpp:61
armarx::viz::Layer
Definition: Layer.h:12
armarx::ManagedObstaclePtr
std::shared_ptr< ManagedObstacle > ManagedObstaclePtr
Definition: ManagedObstacle.h:46
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28