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 
39  Base(iceMemory, CORE_SEGMENT_NAME, armarx::human::arondto::HumanPose::ToAronType(), 256)
40  {
41  }
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  {
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 
78  armarx::armem::human::HumanPose bo;
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
armarx::armem::base::detail::MemoryContainerBase::empty
bool empty() const
Definition: MemoryContainerBase.h:41
armarx::armem::server::human::PoseSegment::getHumanPoseEntities
std::map< std::string, std::vector< armarx::armem::human::HumanPose > > getHumanPoseEntities(const Duration &maxAge) const
Definition: PoseSegment.cpp:50
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:50
armarx::armem::base::ProviderSegmentBase::name
std::string & name()
Definition: ProviderSegmentBase.h:95
memory_ids.h
armarx::armem::server::wm::Entity
Definition: memory_definitions.h:27
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:38
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::segmentPtr
server::wm::CoreSegment * segmentPtr
Definition: SpecializedSegment.h:53
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:52
armarx::armem::server::human::PoseSegment::defineProperties
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: PoseSegment.cpp:44
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition: memory_definitions.h:110
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:16
armarx::core::time::Clock::Now
static DateTime Now()
Current time on the virtual clock.
Definition: Clock.cpp:93
armarx::human::PoseCoreSegmentID
const armem::MemoryID PoseCoreSegmentID
Definition: memory_ids.cpp:38
armarx::armem::server::segment::SpecializedCoreSegment::defineProperties
virtual void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: SpecializedCoreSegment.cpp:31
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27