PersonInstanceSegment.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
24
27
28#include <VisionX/libraries/armem_human/aron/PersonInstance.aron.generated.h>
32
34{
35
38
43
44 void
46 const std::string& prefix)
47 {
48 Base::defineProperties(defs, prefix);
49 }
50
51 std::map<std::string, std::vector<armarx::armem::human::PersonInstance>>
53 {
54 std::map<std::string, std::vector<armarx::armem::human::PersonInstance>> personInstanceMap;
55
56 const auto now = armarx::Clock::Now();
57
58
59 return segmentPtr->doLocked(
60 [&]
61 {
62 segmentPtr->forEachProviderSegment(
63 [&](const wm::ProviderSegment& provSegment)
64 {
65 personInstanceMap[provSegment.name()] = {};
66
67 provSegment.forEachEntity(
68 [&](const wm::Entity& entity)
69 {
70 if (entity.empty())
71 {
72 return;
73 }
74 entity.getLatestSnapshot().forEachInstance(
75 [&](const wm::EntityInstance& instance)
76 {
77 armarx::human::arondto::PersonInstance dto;
78 dto.fromAron(instance.data());
79
80
83
84 if ((now - instance.metadata().referencedTime) < maxAge)
85 {
86 personInstanceMap[provSegment.name()].push_back(bo);
87 }
88 });
89 });
90 });
91
92 return personInstanceMap;
93 });
94 }
95
96} // 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::PersonInstance > > getPersonInstanceEntities(const Duration &maxAge) const
PersonInstanceSegment(armem::server::MemoryToIceAdapter &iceMemory)
armem::server::segment::SpecializedCoreSegment Base
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
void fromAron(const armarx::human::arondto::HumanPose &dto, HumanPose &bo)
armem::wm::EntityInstance EntityInstance
armarx::core::time::Duration Duration
const armem::MemoryID PersonInstanceCoreSegmentID
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.