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