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 
29 #include <VisionX/libraries/armem_human/aron/HumanPose.aron.generated.h>
32 
33 
35 {
36  const std::string PoseSegment::CORE_SEGMENT_NAME =
38 
40  Base(iceMemory, CORE_SEGMENT_NAME, armarx::human::arondto::HumanPose::ToAronType(), 256)
41  {
42  }
43 
44  void
46  {
47  Base::defineProperties(defs, prefix);
48  }
49 
50  std::map<std::string, std::vector<armarx::armem::human::HumanPose>>
52  {
53  std::map<std::string, std::vector<armarx::armem::human::HumanPose>> humanPosesMap;
54 
55  const auto now = armarx::Clock::Now();
56 
57  return segmentPtr->doLocked(
58  [&]
59  {
61  [&](const wm::ProviderSegment& provSegment)
62  {
63  humanPosesMap[provSegment.name()] = {};
64 
65  provSegment.forEachEntity(
66  [&](const wm::Entity& entity)
67  {
68  if (entity.empty())
69  {
70  return;
71  }
72  entity.getLatestSnapshot().forEachInstance(
73  [&](const wm::EntityInstance& instance)
74  {
75  armarx::human::arondto::HumanPose dto;
76  dto.fromAron(instance.data());
77 
78 
79  armarx::armem::human::HumanPose bo;
80  fromAron(dto, bo);
81 
82  if ((now - instance.metadata().referencedTime) < maxAge)
83  {
84  humanPosesMap[provSegment.name()].push_back(bo);
85  }
86  });
87  });
88  });
89 
90  return humanPosesMap;
91  });
92  }
93 
94 } // namespace armarx::armem::server::human
armarx::armem::base::detail::MemoryContainerBase::empty
bool empty() const
Definition: MemoryContainerBase.h:44
armarx::armem::server::human::PoseSegment::getHumanPoseEntities
std::map< std::string, std::vector< armarx::armem::human::HumanPose > > getHumanPoseEntities(const Duration &maxAge) const
Definition: PoseSegment.cpp:51
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition: memory_definitions.h:32
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition: MemoryToIceAdapter.h:19
armarx::armem::base::detail::GetLatestSnapshotMixin::getLatestSnapshot
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
Definition: lookup_mixins.h:199
armarx::armem::server::human::PoseSegment::CORE_SEGMENT_NAME
static const std::string CORE_SEGMENT_NAME
Definition: PoseSegment.h:51
armarx::armem::base::ProviderSegmentBase::name
std::string & name()
Definition: ProviderSegmentBase.h:95
memory_ids.h
armarx::armem::server::wm::Entity
Definition: memory_definitions.h:30
armarx::armem::MemoryID::coreSegmentName
std::string coreSegmentName
Definition: MemoryID.h:51
Clock.h
armarx::armem::server::human::PoseSegment::PoseSegment
PoseSegment(armem::server::MemoryToIceAdapter &iceMemory)
Definition: PoseSegment.cpp:39
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::segmentPtr
server::wm::CoreSegment * segmentPtr
Definition: SpecializedSegment.h:54
types.h
PoseSegment.h
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >
armarx::armem::base::CoreSegmentBase::forEachProviderSegment
bool forEachProviderSegment(ProviderSegmentFunctionT &&func)
Definition: CoreSegmentBase.h:217
armarx::armem::server::wm::ProviderSegment
Definition: memory_definitions.h:60
armarx::armem::server::human::PoseSegment::defineProperties
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: PoseSegment.cpp:45
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition: memory_definitions.h:120
armarx::armem::server::human
Definition: aron_conversions.cpp:11
PropertyDefinitionContainer.h
aron_conversions.h
armarx::armem::base::ProviderSegmentBase::forEachEntity
bool forEachEntity(EntityFunctionT &&func)
Definition: ProviderSegmentBase.h:189
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::core::time::Clock::Now
static DateTime Now()
Current time on the virtual clock.
Definition: Clock.cpp:97
armarx::human::PoseCoreSegmentID
const armem::MemoryID PoseCoreSegmentID
Definition: memory_ids.cpp:40
armarx::armem::server::segment::SpecializedCoreSegment::defineProperties
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: SpecializedCoreSegment.cpp:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28