PoseSegment.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 * @package VisionX::ArmarXObjects::armem_images_server
17 * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18 * @date 2021
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "PoseSegment.h"
24
27
28#include <VisionX/libraries/armem_human/aron/HumanPose.aron.generated.h>
32
34{
35 const std::string PoseSegment::CORE_SEGMENT_NAME =
37
42
43 void
45 {
46 Base::defineProperties(defs, prefix);
47 }
48
49 std::map<std::string, std::vector<armarx::armem::human::HumanPose>>
51 {
52 std::map<std::string, std::vector<armarx::armem::human::HumanPose>> humanPosesMap;
53
54 const auto now = armarx::Clock::Now();
55
56 return segmentPtr->doLocked(
57 [&]
58 {
59 segmentPtr->forEachProviderSegment(
60 [&](const wm::ProviderSegment& provSegment)
61 {
62 humanPosesMap[provSegment.name()] = {};
63
64 provSegment.forEachEntity(
65 [&](const wm::Entity& entity)
66 {
67 if (entity.empty())
68 {
69 return;
70 }
71 entity.getLatestSnapshot().forEachInstance(
72 [&](const wm::EntityInstance& instance)
73 {
74 armarx::human::arondto::HumanPose dto;
75 dto.fromAron(instance.data());
76
77
79 fromAron(dto, bo);
80
81 if ((now - instance.metadata().referencedTime) < maxAge)
82 {
83 humanPosesMap[provSegment.name()].push_back(bo);
84 }
85 });
86 });
87 });
88
89 return humanPosesMap;
90 });
91 }
92
93} // namespace armarx::armem::server::human
static DateTime Now()
Current time on the virtual clock.
Definition Clock.cpp:93
std::string coreSegmentName
Definition MemoryID.h:51
Helps connecting a Memory server to the Ice interface.
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
std::map< std::string, std::vector< armarx::armem::human::HumanPose > > getHumanPoseEntities(const Duration &maxAge) const
static const std::string CORE_SEGMENT_NAME
Definition PoseSegment.h:50
PoseSegment(armem::server::MemoryToIceAdapter &iceMemory)
armem::server::segment::SpecializedCoreSegment Base
Definition PoseSegment.h:39
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
armem::wm::EntityInstance EntityInstance
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
armarx::core::time::Duration Duration
const armem::MemoryID PoseCoreSegmentID
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Time referencedTime
Time this instance refers to.
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.