Segment.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 "Segment.h"
24 
27 
28 #include <VisionX/libraries/armem_human/aron/FaceRecognition.aron.generated.h>
30 
31 
33 {
34 
35  const std::string Segment::CORE_SEGMENT_NAME =
37 
38 
40  Base(iceMemory,
41  CORE_SEGMENT_NAME,
42  armarx::human::arondto::FaceRecognition::ToAronType(),
43  64)
44  {
45  }
46 
47 
48  void
50  {
51  Base::defineProperties(defs, prefix);
52  defs->optional(properties.loadDummyEntries,
53  prefix + "loadDummyEntries",
54  "Initialise FaceRecognition segment with some dummy entries.");
55  }
56 
57 
58  void
60  {
61  Base::init();
62 
64  loadDummyEntries();
65  }
66  }
67 
68  void
69  Segment::loadDummyEntries()
70  {
71  armem::Commit commit;
72  const armem::Time now = armem::Time::Now();
73  using armarx::human::arondto::FaceRecognition;
74 
76  rainer.memoryName = "Human";
77  rainer.coreSegmentName = "Profile";
78  rainer.providerSegmentName = "jubot_long_term_memory_data";
79  rainer.entityName = "rainer-kartmann";
80  {
81  FaceRecognition fr;
82  fr.profileID = rainer;
83  armem::EntityUpdate& update = commit.add();
84  update.entityID =
86  .id()
87  .withProviderSegmentName("Dummy")
88  .withEntityName("rainer");
89  update.referencedTime = update.sentTime = update.arrivedTime = now;
90  update.instancesData = {fr.toAron()};
91  }
92  {
93  FaceRecognition fr;
94  armem::EntityUpdate& update = commit.add();
95  update.entityID =
97  .id()
98  .withProviderSegmentName("Dummy")
99  .withEntityName("unknown");
100  update.referencedTime = update.sentTime = update.arrivedTime = now;
101  update.instancesData = {fr.toAron()};
102  }
103 
104  iceMemory.commit(commit);
105  }
106 
107 } // namespace armarx::armem::server::human::facerecog
armarx::human::FaceRecognitionCoreSegmentID
const armem::MemoryID FaceRecognitionCoreSegmentID
Definition: memory_ids.cpp:31
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition: MemoryToIceAdapter.h:19
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::FaceRecognition
Brief description of class FaceRecognition.
Definition: FaceRecognition.h:68
armarx::armem::server::human::facerecog::Segment::CORE_SEGMENT_NAME
static const std::string CORE_SEGMENT_NAME
Definition: Segment.h:37
armarx::armem::server::human::facerecog::Segment::init
void init() override
Definition: Segment.cpp:59
memory_ids.h
armarx::armem::MemoryID::coreSegmentName
std::string coreSegmentName
Definition: MemoryID.h:51
armarx::armem::server::human::facerecog
Definition: Segment.cpp:32
armarx::armem::server::human::facerecog::Segment::Properties::loadDummyEntries
bool loadDummyEntries
Definition: Segment.h:54
armarx::armem::MemoryID::withProviderSegmentName
MemoryID withProviderSegmentName(const std::string &name) const
Definition: MemoryID.cpp:412
armarx::armem::server::segment::SpecializedCoreSegment::getCoreSegment
wm::CoreSegment & getCoreSegment()
Definition: SpecializedCoreSegment.cpp:93
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >
armarx::armem::server::segment::SpecializedCoreSegment::init
virtual void init() override
Definition: SpecializedCoreSegment.cpp:49
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:27
armarx::armem::base::detail::MemoryItem::id
MemoryID & id()
Definition: MemoryItem.h:27
armarx::armem::server::human::facerecog::Segment::properties
Properties properties
Definition: Segment.h:56
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
MemoryToIceAdapter.h
armarx::armem::MemoryID::memoryName
std::string memoryName
Definition: MemoryID.h:50
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::server::human::facerecog::Segment::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
Definition: Segment.cpp:49
armarx::armem::MemoryID::withEntityName
MemoryID withEntityName(const std::string &name) const
Definition: MemoryID.cpp:420
armarx::armem::Commit::add
EntityUpdate & add()
Definition: Commit.cpp:81
armarx::armem::server::segment::detail::SegmentBase< server::wm::CoreSegment >::iceMemory
MemoryToIceAdapter & iceMemory
Definition: SpecializedSegment.h:60
PropertyDefinitionContainer.h
Segment.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::server::human::facerecog::Segment::Segment
Segment(armem::server::MemoryToIceAdapter &iceMemory)
Definition: Segment.cpp:39
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
armarx::armem::server::MemoryToIceAdapter::commit
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:112
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29