LaserScannerObstacleDetection.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 Armar6Skills::ArmarXObjects::LaserObstacleDetection
17  * @author Christian R. G. Dreher <c.dreher@kit.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 <string>
29 #include <mutex>
30 
31 // Eigen
32 #include <Eigen/Core>
33 
34 // Ice
35 #include <Ice/Current.h>
36 
37 // ArmarX
40 
41 // Interface
42 #include <RobotComponents/interface/components/ObstacleDetection/LaserScannerObstacleDetectionInterface.h>
43 
44 // ObstacleAvoidance
45 #include <RobotAPI/interface/components/ObstacleAvoidance/DynamicObstacleManagerInterface.h>
46 
47 
48 namespace armarx
49 {
50 
52  virtual public Component,
53  virtual public LaserScannerObstacleDetectionInterface
54  {
55 
56  public:
57 
58  static const std::string default_name;
59 
60  public:
61 
63 
64  std::string getDefaultName() const override;
65  void setEnabled(bool enable, const Ice::Current& = Ice::emptyCurrent) override;
66  void enable(const Ice::Current& = Ice::emptyCurrent) override;
67  void disable(const Ice::Current& = Ice::emptyCurrent) override;
68 
69  // void reportCorrectedPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current& = Ice::Current()) override { /* nop */ };
70  // void reportPoseUncertainty(Ice::Float, Ice::Float, Ice::Float, const Ice::Current& = Ice::Current()) override { /* nop */ };
71  // void reportLaserScanPoints(const Vector2fSeq&, const Ice::Current& = Ice::Current()) override { /* nop */ };
72  // void reportExtractedEdges(const LineSegment2DSeq&, const Ice::Current& = Ice::Current()) override;
73 
74  void reportExtractedLineSegments(const laser_scanner_feature_extraction::LineSegment2DChainSeq& globalLineSegmentChains, const Ice::Current& = Ice::Current()) override;
75 
76  protected:
77 
78  void onInitComponent() override;
79  void onConnectComponent() override;
80  void onDisconnectComponent() override;
81  void onExitComponent() override;
83 
84 
85  private:
86  void eval_obstacles();
87  float get_distance_from_point_to_line_segment(const Eigen::Vector2f& start, const Eigen::Vector2f& end, const Eigen::Vector2f& p) const;
88  float get_angle_between_vectors(const Eigen::Vector2f&, const Eigen::Vector2f&) const;
89 
90  bool m_enabled;
91  int m_only_submit_first_n_results;
92  float m_max_distance_to_put_together;
93  float m_max_yaw_difference;
94 
95  unsigned int m_periodic_task_interval;
96  unsigned int m_accept_lines_after;
97 
98  PeriodicTask<LaserScannerObstacleDetection>::pointer_type m_eval_obstacles;
99  laser_scanner_feature_extraction::LineSegment2DChainSeq m_lines_buffer;
100  IceUtil::Time m_last_accepted_lines;
101 
102  std::mutex m_lines_buffer_mutex;
103  std::mutex m_enabled_mutex;
104 
105  DynamicObstacleManagerInterface::ProxyType m_obstacle_manager;
106  };
107 
108 }
armarx::LaserScannerObstacleDetection::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: LaserScannerObstacleDetection.cpp:314
Eigen
Definition: Elements.h:36
armarx::LaserScannerObstacleDetection::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: LaserScannerObstacleDetection.cpp:50
armarx::LaserScannerObstacleDetection
Definition: LaserScannerObstacleDetection.h:51
armarx::LaserScannerObstacleDetection::default_name
static const std::string default_name
Definition: LaserScannerObstacleDetection.h:58
armarx::LaserScannerObstacleDetection::disable
void disable(const Ice::Current &=Ice::emptyCurrent) override
Definition: LaserScannerObstacleDetection.cpp:306
PeriodicTask.h
armarx::LaserScannerObstacleDetection::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: LaserScannerObstacleDetection.cpp:321
armarx::LaserScannerObstacleDetection::setEnabled
void setEnabled(bool enable, const Ice::Current &=Ice::emptyCurrent) override
Definition: LaserScannerObstacleDetection.cpp:290
IceUtil
Definition: Instance.h:21
armarx::LaserScannerObstacleDetection::LaserScannerObstacleDetection
LaserScannerObstacleDetection() noexcept
Definition: LaserScannerObstacleDetection.cpp:38
armarx::LaserScannerObstacleDetection::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: LaserScannerObstacleDetection.cpp:66
armarx::LaserScannerObstacleDetection::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: LaserScannerObstacleDetection.cpp:73
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:41
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::navigation::components::laser_scanner_feature_extraction::LineSegment2DChainSeq
armarx::laser_scanner_feature_extraction::LineSegment2DChainSeq LineSegment2DChainSeq
Definition: Component.h:56
armarx::LaserScannerObstacleDetection::reportExtractedLineSegments
void reportExtractedLineSegments(const laser_scanner_feature_extraction::LineSegment2DChainSeq &globalLineSegmentChains, const Ice::Current &=Ice::Current()) override
Definition: LaserScannerObstacleDetection.cpp:338
armarx::LaserScannerObstacleDetection::enable
void enable(const Ice::Current &=Ice::emptyCurrent) override
Definition: LaserScannerObstacleDetection.cpp:298
Ice
Definition: DBTypes.cpp:64
std
Definition: Application.h:66
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::LaserScannerObstacleDetection::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: LaserScannerObstacleDetection.cpp:57
armarx::PeriodicTask
Definition: ArmarXManager.h:70
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28