Human.cpp
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
* @author Fabian Reister ( fabian dot reister at kit dot edu )
17
* @date 2022
18
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19
* GNU General Public License
20
*/
21
22
#include "
Human.h
"
23
24
#include <optional>
25
#include <string>
26
27
#include <
ArmarXCore/core/exceptions/local/ExpressionException.h
>
28
#include <
ArmarXCore/core/logging/Logging.h
>
29
30
#include <
VisionX/libraries/human/pose/model/k4a_bt_body_32.h
>
31
32
namespace
armarx::view_selection::targets
33
{
34
35
Human::Human
(
const
armem::human::HumanPose
& human,
36
const
Eigen::Vector3f& robotPosition,
37
const
Params
& params) :
38
human_(human), robotPosition_(robotPosition), params_(params)
39
{
40
}
41
42
std::optional<gaze_targets::GazeTarget>
43
Human::asGazeTarget
()
const
44
{
45
ARMARX_CHECK
(human_.
humanTrackingId
.has_value())
46
<<
"A tracking id is required. Otherwise, the name will be ambiguous"
;
47
48
// at the moment, we assume the azure kinect model
49
const
auto
headKey =
armarx::human::pose::model::k4a_bt_body_32::JointNames
.to_name(
50
armarx::human::pose::model::k4a_bt_body_32::Joints::Head
);
51
52
if
(not(human_.
keypoints
.count(headKey) > 0))
53
{
54
ARMARX_VERBOSE
<<
"head keypoint `"
<< headKey <<
"` not available"
;
55
return
std::nullopt;
56
}
57
58
const
auto
globalPosition = human_.
keypoints
.at(headKey).positionGlobal;
59
if
(not globalPosition.has_value())
60
{
61
ARMARX_VERBOSE
<<
"global position not available"
;
62
return
std::nullopt;
63
}
64
65
gaze_targets::GazeTarget
target
;
66
67
{
68
target
.name =
"human_"
+ human_.
humanTrackingId
.value();
69
target
.position =
armarx::FramedPosition
(globalPosition->toEigen(),
GlobalFrame
,
""
);
70
71
target
.priority =
gaze_targets::TargetPriority
(
gaze_targets::AttentionType::TaskDriven
,
72
priority(globalPosition->toEigen()));
73
target
.duration =
armarx::Duration::Seconds
(1);
74
target
.creationTimestamp =
armarx::Clock::Now
();
75
}
76
77
return
target
;
78
}
79
80
double
81
Human::priority(
const
Eigen::Vector3f& globalHeadPosition)
const
82
{
83
const
double
distance
= (globalHeadPosition - robotPosition_).
norm
();
84
return
1 - (
distance
- params_.
distanceMin
) / (params_.
distanceMax
- params_.
distanceMin
);
85
}
86
87
88
}
// namespace armarx::view_selection::targets
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition:
Logging.h:187
armarx::view_selection::targets::Human::Human
Human(const armem::human::HumanPose &human, const Eigen::Vector3f &robotPosition, const Params ¶ms)
Definition:
Human.cpp:35
armarx::view_selection::targets::Human::Params::distanceMax
double distanceMax
Definition:
Human.h:46
armarx::GlobalFrame
const std::string GlobalFrame
Definition:
FramedPose.h:65
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition:
point_cloud_graph.h:668
armarx::view_selection::gaze_targets::GazeTarget
Business Object (BO) class of GazeTarget.
Definition:
GazeTarget.h:39
armarx::view_selection::targets
This file is part of ArmarX.
Definition:
Human.cpp:32
k4a_bt_body_32.h
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition:
ExpressionException.h:82
armarx::human::pose::model::k4a_bt_body_32::Joints::Head
@ Head
armarx::view_selection::gaze_targets::AttentionType::TaskDriven
@ TaskDriven
Task-Driven attention has highest priority.
armarx::view_selection::targets::Human::Params::distanceMin
double distanceMin
Definition:
Human.h:45
armarx::core::time::Duration::Seconds
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
Definition:
Duration.cpp:72
armarx::human::pose::model::k4a_bt_body_32::JointNames
const simox::meta::EnumNames< Joints > JointNames
Names of the joints as defined in the body model.
Definition:
k4a_bt_body_32.h:77
Human.h
armarx::armem::human::HumanPose
Definition:
types.h:30
armarx::armem::human::HumanPose::humanTrackingId
std::optional< std::string > humanTrackingId
Definition:
types.h:36
ExpressionException.h
armarx::view_selection::targets::Human::asGazeTarget
std::optional< gaze_targets::GazeTarget > asGazeTarget() const
Definition:
Human.cpp:43
armarx::core::time::Clock::Now
static DateTime Now()
Current time on the virtual clock.
Definition:
Clock.cpp:93
distance
double distance(const Point &a, const Point &b)
Definition:
point.hpp:95
armarx::armem::human::HumanPose::keypoints
KeyPointMap keypoints
Definition:
types.h:35
Logging.h
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition:
FramedPose.h:38
armarx::view_selection::gaze_targets::TargetPriority
The Priority of a GazeTarget.
Definition:
TargetPriority.h:39
armarx::view_selection::targets::Human::Params
Definition:
Human.h:43
norm
double norm(const Point &a)
Definition:
point.hpp:102
armarx
view_selection
targets
Human.cpp
Generated by
1.8.17