HumanObstacleDetection.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::HumanAvoidance
17 * @author Christian R. G. Dreher <c.dreher@kit.edu>
18 * @author Fabian Peller
19 * @date 2019
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24
25#pragma once
26
27
28// STD/STL
29#include <array>
30#include <string>
31#include <tuple>
32#include <vector>
33
34// Eigen
35#include <Eigen/Core>
36
37// Ice
38#include <Ice/Current.h>
39
40// ArmarX
44
45// Interface
46#include <RobotComponents/interface/components/ObstacleDetection/HumanObstacleDetectionInterface.h>
47
48// ObstacleAvoidance
49#include <RobotAPI/interface/components/ObstacleAvoidance/DynamicObstacleManagerInterface.h>
50
51namespace armarx
52{
53
55 virtual public armarx::Component,
56 virtual public armarx::HumanObstacleDetectionInterface
57 {
58
59 private:
60 struct OpenPoseResult
61 {
62 bool valid = false;
63 unsigned int index;
64 float distance;
65 float confidence;
66 Eigen::Vector3f mean_position;
67 armarx::Keypoint3DMap keypoints;
68 IceUtil::Time timestamp;
69 };
70
71 struct HumanApproximation
72 {
73 bool valid = false;
74 std::map<std::string, std::pair<IceUtil::Time, Eigen::Vector2f>> transformed_keypoints;
75 double posX;
76 double posY;
77 double yaw;
78 double axisLengthX;
79 double axisLengthY;
80 IceUtil::Time timestamp;
81 };
82
83 public:
84 HumanObstacleDetection() noexcept;
85
86 std::string getDefaultName() const override;
87
88 void setEnabled(bool enable, const Ice::Current& = Ice::emptyCurrent) override;
89 void enable(const Ice::Current& = Ice::emptyCurrent) override;
90 void disable(const Ice::Current& = Ice::emptyCurrent) override;
91 void report3DKeypoints(const armarx::HumanPose3DMap& kpml,
92 long timestamp,
93 const Ice::Current& = Ice::emptyCurrent) override;
94
96
97 protected:
98 void onInitComponent() override;
99
100 void onConnectComponent() override;
101
102 void onDisconnectComponent() override;
103
104 void onExitComponent() override;
105
107
108 private:
109 OpenPoseResult find_closest_human(const std::vector<armarx::Keypoint3DMap>& kpml,
110 const IceUtil::Time& time);
111
112 HumanApproximation approximate_human(const OpenPoseResult& human);
113
114 public:
115 static const std::string default_name;
116
117 private:
118 bool m_enabled;
119 int m_onlyUseFirstNResults;
120
121 unsigned int m_warn_distance;
122
123 float m_human_confidence_filter_value;
124 float m_min_velocity_treshold;
125 IceUtil::Time m_keypoint_after;
126
127 unsigned int m_pose_buffer_fillctr = 0;
128 unsigned int m_pose_buffer_index = 0;
130
132
133 HumanApproximation last_human_approximation;
134
135
136 DynamicObstacleManagerInterface::ProxyType m_obstacle_manager;
137
138 std::mutex m_human_mutex;
139 std::mutex m_enabled_mutex;
140 };
141
142} // namespace armarx
std::string timestamp()
uint8_t index
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
void onInitComponent() override
Pure virtual hook for the subclass.
static const std::string default_name
void onDisconnectComponent() override
Hook for subclass.
void onConnectComponent() override
Pure virtual hook for the subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void enable(const Ice::Current &=Ice::emptyCurrent) override
void setEnabled(bool enable, const Ice::Current &=Ice::emptyCurrent) override
void onExitComponent() override
Hook for subclass.
void disable(const Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
void report3DKeypoints(const armarx::HumanPose3DMap &kpml, long timestamp, const Ice::Current &=Ice::emptyCurrent) override
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
Same as the TripleBuffer, but partial writes of the data structure are ok. The write operation may be...
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
double distance(const Point &a, const Point &b)
Definition point.hpp:95