HandOverGroupStatechartContext.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX
19 * @author Mirko Waechter( mirko.waechter at kit dot edu)
20 * @date 2018
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
25
27#include <mutex>
28
29#include <IceUtil/UUID.h>
30
32
33namespace armarx
34{
35
40
43 {
44 return listener;
45 }
46
47 void
49 {
50 HandOverGroup::HandOverGroupStatechartContext::onInitStatechartContext();
51 auto object =
52 getIceManager()
53 ->registerObject(listener, "OpenPose3dListenerImpl" + IceUtil::generateUUID())
54 .first;
55 getIceManager()->subscribeTopic(object, "OpenPoseEstimation3D");
56 }
57
58 void
60 {
61 HandOverGroup::HandOverGroupStatechartContext::onConnectStatechartContext();
62 }
63
64 void
66 Ice::Long timestamp,
67 const Ice::Current&)
68 {
69 ARMARX_INFO << deactivateSpam(5) << "Got new data of size: " << data.size()
70 << " keys: " << ARMARX_STREAM_PRINTER
71 {
72 if (!data.empty())
73 {
74 //for (auto& pair : data.at(0))
75 //{
76 // out << pair.first << ": " << pair.second.x << ", " << pair.second.y << ", " << pair.second.z << "\n";
77 //}
78 // out << armarx::getMapKeys(data.at(0));
79 }
80 };
81 std::unique_lock lock(mutex);
82 std::vector<armarx::Keypoint3DMap> vec;
83 for (const auto& [name, entity] : data)
84 {
85 if (entity.keypointMap.empty())
86 {
87 ARMARX_IMPORTANT << "Received empty keypoint map for entity: " << name;
88 continue;
89 }
90 vec.push_back(entity.keypointMap);
91 }
92 latestData = vec;
93 this->timestamp = IceUtil::Time::microSeconds(timestamp);
94 }
95
96 std::pair<IceUtil::Time, std::vector<armarx::Keypoint3DMap>>
98 {
99 std::unique_lock lock(mutex);
100 return std::make_pair(timestamp, latestData);
101 }
102} // namespace armarx
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
#define ARMARX_STREAM_PRINTER
use this macro to write output code that is executed when printed and thus not executed if the debug ...
Definition Logging.h:310
const IceInternal::Handle< OpenPose3DListenerImpl > & getPoseData() const
void report3DKeypoints(const armarx::HumanPose3DMap &, Ice::Long, const Ice::Current &) override
std::pair< IceUtil::Time, std::vector< armarx::Keypoint3DMap > > getLatestData()
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
This file offers overloads of toIce() and fromIce() functions for STL container types.