ManagedObstacle.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 <memory>
30 #include <shared_mutex>
31 #include <string>
32 #include <tuple>
33 #include <vector>
34 
35 // Eigen
36 #include <Eigen/Geometry>
37 
38 // ArmarX
39 #include <RobotAPI/interface/components/ObstacleAvoidance/ObstacleDetectionInterface.h>
40 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
41 
42 namespace armarx
43 {
44 
46  typedef std::shared_ptr<ManagedObstacle> ManagedObstaclePtr;
47 
49  {
50  public:
51  static bool
53  {
54  return (ManagedObstacle::calculateObstacleArea(i->m_obstacle) >
56  }
57 
58  void update_position(const unsigned int);
59 
60  static double calculateObstacleArea(const obstacledetection::Obstacle& o);
61 
62  static bool point_ellipsis_coverage(const Eigen::Vector2f e_origin,
63  const float e_rx,
64  const float e_ry,
65  const float e_yaw,
66  const Eigen::Vector2f point);
67 
68  static float ellipsis_ellipsis_coverage(const Eigen::Vector2f e1_origin,
69  const float e1_rx,
70  const float e1_ry,
71  const float e1_yaw,
72  const Eigen::Vector2f e2_origin,
73  const float e2_rx,
74  const float e2_ry,
75  const float e2_yaw);
76 
77  static float line_segment_ellipsis_coverage(const Eigen::Vector2f e_origin,
78  const float e_rx,
79  const float e_ry,
80  const float e_yaw,
81  const Eigen::Vector2f line_seg_start,
82  const Eigen::Vector2f line_seg_end);
83 
84 
85  obstacledetection::Obstacle m_obstacle;
88  bool m_updated;
89  float m_value;
90  std::shared_mutex m_mutex;
91 
92  unsigned int position_buffer_fillctr = 0;
93  unsigned int position_buffer_index = 0;
94  std::array<std::tuple<double, double, double, double, double>, 6>
95  position_buffer; //x, y, yaw, axisX, axisY
96  std::vector<Eigen::Vector2f> line_matches; // points of line segments
97 
98 
99  unsigned long m_input_index = 0;
100 
101  protected:
102  private:
103  float normalizeYaw(float yaw) const;
104  float getAngleBetweenVectors(const Eigen::Vector2f&, const Eigen::Vector2f&) const;
105  float getXAxisAngle(const Eigen::Vector2f&) const;
106  };
107 } // namespace armarx
armarx::ManagedObstacle::m_input_index
unsigned long m_input_index
Definition: ManagedObstacle.h:99
armarx::ManagedObstacle::ComparatorDESCPrt
static bool ComparatorDESCPrt(ManagedObstaclePtr &i, ManagedObstaclePtr &j)
Definition: ManagedObstacle.h:52
armarx::ManagedObstacle::position_buffer
std::array< std::tuple< double, double, double, double, double >, 6 > position_buffer
Definition: ManagedObstacle.h:95
armarx::ManagedObstacle::ellipsis_ellipsis_coverage
static float ellipsis_ellipsis_coverage(const Eigen::Vector2f e1_origin, const float e1_rx, const float e1_ry, const float e1_yaw, const Eigen::Vector2f e2_origin, const float e2_rx, const float e2_ry, const float e2_yaw)
Definition: ManagedObstacle.cpp:80
armarx::ManagedObstacle::line_matches
std::vector< Eigen::Vector2f > line_matches
Definition: ManagedObstacle.h:96
armarx::ManagedObstacle::m_last_matched
IceUtil::Time m_last_matched
Definition: ManagedObstacle.h:86
armarx::ManagedObstacle::m_obstacle
obstacledetection::Obstacle m_obstacle
Definition: ManagedObstacle.h:85
armarx::ManagedObstacle::m_published
bool m_published
Definition: ManagedObstacle.h:87
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::ManagedObstacle::m_value
float m_value
Definition: ManagedObstacle.h:89
armarx::ManagedObstacle::calculateObstacleArea
static double calculateObstacleArea(const obstacledetection::Obstacle &o)
Definition: ManagedObstacle.cpp:54
armarx::ManagedObstacle::position_buffer_fillctr
unsigned int position_buffer_fillctr
Definition: ManagedObstacle.h:92
armarx::ManagedObstacle::line_segment_ellipsis_coverage
static float line_segment_ellipsis_coverage(const Eigen::Vector2f e_origin, const float e_rx, const float e_ry, const float e_yaw, const Eigen::Vector2f line_seg_start, const Eigen::Vector2f line_seg_end)
Definition: ManagedObstacle.cpp:112
armarx::ManagedObstacle::point_ellipsis_coverage
static bool point_ellipsis_coverage(const Eigen::Vector2f e_origin, const float e_rx, const float e_ry, const float e_yaw, const Eigen::Vector2f point)
Definition: ManagedObstacle.cpp:60
armarx::ManagedObstacle::m_updated
bool m_updated
Definition: ManagedObstacle.h:88
armarx::ManagedObstacle::position_buffer_index
unsigned int position_buffer_index
Definition: ManagedObstacle.h:93
armarx::ManagedObstacle
Definition: ManagedObstacle.h:48
armarx::ManagedObstaclePtr
std::shared_ptr< ManagedObstacle > ManagedObstaclePtr
Definition: ManagedObstacle.h:45
armarx::ManagedObstacle::update_position
void update_position(const unsigned int)
Definition: ManagedObstacle.cpp:174
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ManagedObstacle::m_mutex
std::shared_mutex m_mutex
Definition: ManagedObstacle.h:90