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 <shared_mutex>
30#include <string>
31#include <tuple>
32#include <vector>
33
34// Eigen
35#include <Eigen/Geometry>
36
37// Ice
38#include <Ice/Current.h>
39
40// ArmarX
42#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
55namespace armarx
56{
57
59 virtual public Component,
60 virtual public DynamicObstacleManagerInterface,
61 virtual public ArVizComponentPluginUser
62 {
63 public:
64 DynamicObstacleManager() noexcept;
65
66 std::string getDefaultName() const override;
67
68 void add_decayable_obstacle(const Eigen::Vector2f&,
69 float,
70 float,
71 float,
72 const Ice::Current& = Ice::Current()) override;
73 void add_decayable_line_segment(const Eigen::Vector2f&,
74 const Eigen::Vector2f&,
75 const Ice::Current& = Ice::Current()) override;
76 void add_decayable_line_segments(const dynamicobstaclemanager::LineSegments& lines,
77 const Ice::Current& = Ice::Current()) override;
78 void remove_all_decayable_obstacles(const Ice::Current& = Ice::Current()) override;
79 void directly_update_obstacle(const std::string& name,
80 const Eigen::Vector2f&,
81 float,
82 float,
83 float,
84 const Ice::Current& = Ice::Current()) override;
85 void remove_obstacle(const std::string& name,
86 const Ice::Current& = Ice::Current()) override;
87 void wait_unitl_obstacles_are_ready(const Ice::Current& = Ice::Current()) override;
88 float distanceToObstacle(const Eigen::Vector2f& agentPosition,
89 float safetyRadius,
90 const Eigen::Vector2f& goal,
91 const Ice::Current& = Ice::Current()) override;
92
93 protected:
94 void onInitComponent() override;
95 void onConnectComponent() override;
96 void onDisconnectComponent() override;
97 void onExitComponent() override;
99
100 private:
101 void update_decayable_obstacles();
102
103 void visualize_obstacle(viz::Layer& l,
104 const ManagedObstaclePtr& o,
105 const armarx::DrawColor& color,
106 double z_pos,
107 bool);
108
109 public:
110 static const std::string default_name;
111
112 private:
113 const std::string m_obstacle_manager_layer_name = "DynamicObstacleManagerObstacles";
114
115 unsigned long m_obstacle_index;
116
117 std::vector<ManagedObstaclePtr> m_managed_obstacles;
118 std::shared_mutex m_managed_obstacles_mutex;
119
121 unsigned int m_decay_after_ms;
122 unsigned int m_periodic_task_interval;
123 unsigned int m_decay_factor;
124 unsigned int m_access_bonus;
125 unsigned int m_min_value_for_accepting;
126
127 float m_min_coverage_of_obstacles;
128 float m_min_coverage_of_line_samples_in_obstacle;
129 unsigned int m_min_size_of_obstacles;
130 unsigned int m_min_length_of_lines;
131 unsigned int m_max_size_of_obstacles;
132 unsigned int m_max_length_of_lines;
133 unsigned int m_thickness_of_lines;
134 unsigned int m_security_margin_for_obstacles;
135 unsigned int m_security_margin_for_lines;
136
137 bool m_remove_enabled;
138 bool m_only_visualize;
139 bool m_allow_spwan_inside;
140
141 ObstacleDetectionInterface::ProxyType m_obstacle_detection;
142 };
143} // namespace armarx
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
void remove_all_decayable_obstacles(const Ice::Current &=Ice::Current()) override
void onInitComponent() override
Pure virtual hook for the subclass.
static const std::string default_name
void add_decayable_line_segment(const Eigen::Vector2f &, const Eigen::Vector2f &, const Ice::Current &=Ice::Current()) override
void remove_obstacle(const std::string &name, const Ice::Current &=Ice::Current()) override
void add_decayable_obstacle(const Eigen::Vector2f &, float, float, float, const Ice::Current &=Ice::Current()) override
float distanceToObstacle(const Eigen::Vector2f &agentPosition, float safetyRadius, const Eigen::Vector2f &goal, const Ice::Current &=Ice::Current()) override
void onDisconnectComponent() override
Hook for subclass.
void wait_unitl_obstacles_are_ready(const Ice::Current &=Ice::Current()) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void add_decayable_line_segments(const dynamicobstaclemanager::LineSegments &lines, const Ice::Current &=Ice::Current()) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void directly_update_obstacle(const std::string &name, const Eigen::Vector2f &, float, float, float, const Ice::Current &=Ice::Current()) override
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
Retrieve default name of component.
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::shared_ptr< ManagedObstacle > ManagedObstaclePtr