MemoryToIceAdapter.cpp
Go to the documentation of this file.
1 #include "MemoryToIceAdapter.h"
2 
3 #include <iostream>
4 #include <list>
5 #include <sstream>
6 #include <thread>
7 
12 
20 
21 
24 
26 #include "query_proc/wm/wm.h"
27 
28 namespace armarx::armem::server
29 {
30 
32  server::ltm::Memory* longtermMemory) :
33  workingMemory(workingMemory), longtermMemory(longtermMemory)
34  {
35  }
36 
37  void
38  MemoryToIceAdapter::setMemoryListener(client::MemoryListenerInterfacePrx memoryListener)
39  {
40  this->memoryListenerTopic = memoryListener;
41  }
42 
43  // WRITING
44  data::AddSegmentResult
45  MemoryToIceAdapter::addSegment(const data::AddSegmentInput& input, bool addCoreSegments)
46  {
49 
50  data::AddSegmentResult output;
51 
52  server::wm::CoreSegment* coreSegment = nullptr;
53  try
54  {
55  coreSegment = &workingMemory->getCoreSegment(input.coreSegmentName);
56  }
57  catch (const armem::error::MissingEntry& e)
58  {
59  if (addCoreSegments)
60  {
61  coreSegment = &workingMemory->addCoreSegment(input.coreSegmentName);
62  }
63  else
64  {
65  output.success = false;
66  output.errorMessage = e.what();
67  return output;
68  }
69  }
70  ARMARX_CHECK_NOT_NULL(coreSegment);
71 
72  if (input.providerSegmentName.size() > 0)
73  {
74  coreSegment->doLocked(
75  [&coreSegment, &input]()
76  {
77  try
78  {
79  coreSegment->addProviderSegment(input.providerSegmentName);
80  }
82  {
83  // This is ok.
84  if (input.clearWhenExists)
85  {
86  server::wm::ProviderSegment& provider =
87  coreSegment->getProviderSegment(input.providerSegmentName);
88  provider.clear();
89  }
90  }
91  });
92  }
93 
94  armem::MemoryID segmentID;
95  segmentID.memoryName = workingMemory->name();
96  segmentID.coreSegmentName = input.coreSegmentName;
97  segmentID.providerSegmentName = input.providerSegmentName;
98 
99  output.success = true;
100  output.segmentID = segmentID.str();
101  return output;
102  }
103 
104  data::AddSegmentsResult
105  MemoryToIceAdapter::addSegments(const data::AddSegmentsInput& input, bool addCoreSegments)
106  {
107  ARMARX_TRACE;
109 
110  data::AddSegmentsResult output;
111  for (const auto& i : input)
112  {
113  output.push_back(addSegment(i, addCoreSegments));
114  }
115  return output;
116  }
117 
118  data::CommitResult
119  MemoryToIceAdapter::commit(const data::Commit& commitIce, Time timeArrived)
120  {
121  ARMARX_TRACE;
123  auto handleException = [](const std::string& what)
124  {
125  data::CommitResult result;
126  data::EntityUpdateResult& r = result.results.emplace_back();
127  r.success = false;
128  r.errorMessage = what;
129  return result;
130  };
131 
133  try
134  {
135  ::armarx::armem::fromIce(commitIce, commit, timeArrived);
136  }
137  catch (const aron::error::AronNotValidException& e)
138  {
139  throw;
140  return handleException(e.what());
141  }
142  catch (const Ice::Exception& e)
143  {
144  throw;
145  return handleException(e.what());
146  }
147 
148  armem::CommitResult result = this->commit(commit);
149  data::CommitResult resultIce;
150  toIce(resultIce, result);
151 
152  return resultIce;
153  }
154 
155  data::CommitResult
156  MemoryToIceAdapter::commit(const data::Commit& commitIce)
157  {
158  ARMARX_TRACE;
159  return commit(commitIce, armem::Time::Now());
160  }
161 
164  {
165  ARMARX_TRACE;
166  return this->_commit(commit, false);
167  }
168 
169  data::CommitResult
170  MemoryToIceAdapter::commitLocking(const data::Commit& commitIce, Time timeArrived)
171  {
172  ARMARX_TRACE;
174  auto handleException = [](const std::string& what)
175  {
176  data::CommitResult result;
177  data::EntityUpdateResult& r = result.results.emplace_back();
178  r.success = false;
179  r.errorMessage = what;
180  return result;
181  };
182 
184  try
185  {
186  ::armarx::armem::fromIce(commitIce, commit, timeArrived);
187  }
188  catch (const aron::error::AronNotValidException& e)
189  {
190  throw;
191  return handleException(e.what());
192  }
193  catch (const Ice::Exception& e)
194  {
195  throw;
196  return handleException(e.what());
197  }
198 
199  armem::CommitResult result = this->commitLocking(commit);
200  data::CommitResult resultIce;
201  toIce(resultIce, result);
202 
203  return resultIce;
204  }
205 
206  data::CommitResult
207  MemoryToIceAdapter::commitLocking(const data::Commit& commitIce)
208  {
209  ARMARX_TRACE;
210  return commitLocking(commitIce, armem::Time::Now());
211  }
212 
215  {
216  ARMARX_TRACE;
217  return this->_commit(commit, true);
218  }
219 
221  MemoryToIceAdapter::_commit(const armem::Commit& commit, bool locking)
222  {
223  ARMARX_TRACE;
224  std::vector<data::MemoryID> updatedIDs;
225  const bool publishUpdates = bool(memoryListenerTopic);
226 
227  CommitResult commitResult;
228  for (const EntityUpdate& update : commit.updates)
229  {
230  EntityUpdateResult& result = commitResult.results.emplace_back();
231  try
232  {
233  auto updateResult =
235 
236  result.success = true;
237  result.snapshotID = updateResult.id;
238  result.arrivedTime = update.arrivedTime;
239 
240  for (const auto& snapshot : updateResult.removedSnapshots)
241  {
242  ARMARX_DEBUG << "The id " << snapshot.id() << " was removed from wm";
243  }
244 
245  // Consolidate to ltm(s) if recording mode is CLONE_WM
246  if (longtermMemory->isRecording() &&
249  {
250  // convert removedSnapshots to Memory
252  m.update(update, true, false);
253  //this removes information about segments, because new memory (wm) is used
254 
255  // store memory
256  longtermMemory->store(m);
257  }
258 
259 
260  // Consolidate to ltm(s) if recording mode is CONSOLIDATE_REMOVED
261  if (longtermMemory->isRecording() &&
264  {
265  // convert removedSnapshots to Memory
267  armem::wm::toMemory(m, *workingMemory, updateResult.removedSnapshots);
268  //this removes information about segments, because new memory (wm) is used
269 
270  // store memory
271  longtermMemory->store(m);
272  }
273 
274  if (longtermMemory->isRecording() &&
277  {
278  ARMARX_WARNING << deactivateSpam() << "THIS IS NOT IMPLEMENTED YET!!!";
279  }
280 
281  if (publishUpdates)
282  {
283  data::MemoryID& id = updatedIDs.emplace_back();
284  toIce(id, result.snapshotID);
285  }
286  }
287  catch (const error::ArMemError& e)
288  {
289  result.success = false;
290  result.errorMessage = e.what();
291  }
292  catch (const aron::error::AronException& e)
293  {
294  result.success = false;
295  result.errorMessage = e.what();
296  }
297  catch (const Ice::Exception& e)
298  {
299  result.success = false;
300  result.errorMessage = e.what();
301  }
302  catch (...)
303  {
304  ARMARX_INFO << "Error during LTM consollidation";
305  }
306  }
307 
308  if (publishUpdates)
309  {
310  memoryListenerTopic->memoryUpdated(updatedIDs);
311  }
312 
313  return commitResult;
314  }
315 
316  // READING
317  armem::query::data::Result
318  MemoryToIceAdapter::query(const armem::query::data::Input& input)
319  {
320  ARMARX_TRACE;
323 
324  // Core segment processors will aquire the core segment locks.
327  armem::wm::Memory wmResult = wmServerProcessor.process(input, *workingMemory);
328 
329  armem::query::data::Result result;
330 
331 
332  result.memory = armarx::toIce<data::MemoryPtr>(wmResult);
333 
334  result.success = true;
335  if (result.memory->coreSegments.size() == 0)
336  {
337  ARMARX_DEBUG << "No data in memory found after query.";
338  }
339 
340  return result;
341  }
342 
343  armem::query::data::Result
344  MemoryToIceAdapter::queryLTM(const armem::query::data::Input& input, bool storeIntoWM)
345  {
346  ARMARX_TRACE;
347 
349  armem::wm::Memory ltmResult = ltmProcessor.process(input, *longtermMemory);
350 
351  // convert memory ==> meaning resolving references
352  // upon query, the LTM only returns a structure of the data (memory without data)
353  if (input.withData)
354  {
355  longtermMemory->resolve(ltmResult);
356  }
357 
358  if (longtermMemory->isRecording() || storeIntoWM)
359  {
360  this->commit(toCommit(ltmResult));
361 
362  // mark removed entries of wm in viewer
363  // TODO
364  }
365 
366  armem::query::data::Result result;
367 
368  result.memory = armarx::toIce<data::MemoryPtr>(ltmResult);
369 
370  result.success = true;
371  if (result.memory->coreSegments.size() == 0)
372  {
373  ARMARX_DEBUG << "No data in ltm found after query.";
374  }
375 
376  return result;
377  }
378 
379 
382  {
383  ARMARX_TRACE;
384 
385  return client::QueryResult::fromIce(query(input.toIce()));
386  }
387 
388  armem::structure::data::GetServerStructureResult
390  {
391  ARMARX_TRACE;
394 
395  armem::structure::data::GetServerStructureResult ret;
396  ret.success = true;
397 
398  wm::Memory structure;
399  structure.id() = workingMemory->id();
400 
401  // Get all info from the WM
403  builder.all();
404 
405  auto query_result = this->query(builder.buildQueryInput());
406  if (query_result.success)
407  {
408  structure.append(query_result.memory);
409  }
410 
411  // Get all info from the LTM
413 
414  ret.serverStructure = armarx::toIce<data::MemoryPtr>(structure);
415 
416  return ret;
417  }
418 
420  {
421  ARMARX_TRACE;
422 
423  ARMARX_INFO << "Reloading of all core segments from LTM into WM triggered";
424 
425  int maxAmountOfSnapshots = this->longtermMemory->p.maxAmountOfSnapshotsLoaded;
426  //create WM and load latest references
428  this->longtermMemory->loadLatestNReferences(maxAmountOfSnapshots, m);
429 
430  //construct a commit of the loaded data and commit it to the working memory
431  auto com = armem::toCommit(m);
432  auto res = this->commit(com);
433 
434  //the CommitResult contains some information which might be helpful:
435  return res;
436  }
437 
438  armem::CommitResult MemoryToIceAdapter::reloadCoreSegmentsFromLTM(std::list<std::string>& coreSegmentNames)
439  {
440  ARMARX_TRACE;
441 
442  ARMARX_INFO << "Reloading of specific core segments from LTM into WM triggered";
443 
444  std::ostringstream namesStr;
445  for (auto it = coreSegmentNames.begin(); it != coreSegmentNames.end(); ++it) {
446  if (it != coreSegmentNames.begin()) namesStr << ", "; // Add comma before every element except the first
447  namesStr << *it;
448  }
449 
450  ARMARX_INFO << "Loading core segments=" << namesStr.str();
451 
452 
453  int maxAmountOfSnapshots = this->longtermMemory->p.maxAmountOfSnapshotsLoaded;
454  //create WM and load latest references
456  this->longtermMemory->loadLatestNReferences(maxAmountOfSnapshots, m, coreSegmentNames);
457 
458  //construct a commit of the loaded data and commit it to the working memory
459  auto com = armem::toCommit(m);
460  auto res = this->commit(com);
461 
462  //the CommitResult contains some information which might be helpful:
463  return res;
464  }
465 
468  {
469  ARMARX_INFO << "Reloading of coresegment defined in 'loadedCoreSegments' from LTM into WM on startup triggered";
470 
471  auto coreNames = this->longtermMemory->p.coreSegmentsToLoad;
472 
473  ARMARX_INFO << "Loading core segments=" << coreNames << " defined in property 'loadedCoreSegments'";
474 
475  //convert string to list of names:
476  std::list<std::string> names;
477  std::stringstream ss(coreNames);
478  std::string item;
479 
480  while (std::getline(ss, item, ','))
481  {
482  names.push_back(item);
483  }
484 
486  }
487 
488  // WM LOADING FROM LTM
491  {
492  ARMARX_TRACE;
493 
494  ARMARX_INFO << "Reloading of data from LTM into WM on startup triggered";
495 
496  if (this->longtermMemory->p.importOnStartUp)
497  {
499  }
500  else
501  {
502  ARMARX_INFO << "Not loading initial data from LTM due to importOnStartup being "
503  << this->longtermMemory->p.importOnStartUp;
505  return r;
506  }
507  }
508 
509  // LTM STORING AND RECORDING
510  dto::DirectlyStoreResult
511  MemoryToIceAdapter::directlyStore(const dto::DirectlyStoreInput& directlStoreInput)
512  {
513  ARMARX_TRACE;
515 
516  dto::DirectlyStoreResult output;
517  output.success = true;
518 
519  armem::wm::Memory m = armarx::fromIce<armem::wm::Memory>(directlStoreInput.memory);
521 
522  return output;
523  }
524 
525  dto::StartRecordResult
526  MemoryToIceAdapter::startRecord(const dto::StartRecordInput& startRecordInput)
527  {
528  ARMARX_TRACE;
530  ARMARX_IMPORTANT << "Enabling the recording of memory " << longtermMemory->id().str();
532 
533  dto::StartRecordResult ret;
534  ret.success = true;
535 
536  return ret;
537  }
538 
539  dto::StopRecordResult
541  {
542  ARMARX_TRACE;
545  ARMARX_IMPORTANT << "Disabling the recording of memory " << longtermMemory->id().str();
546 
548  { //if true this means when stopping LTM recording leftover snapshots are transferred to WM using the simulated consolidation
549  ARMARX_INFO << "Starting to save left-over WM data into LTM";
551  ARMARX_INFO << "Stored leftover WM data into LTM";
552  }
553  else
554  {
555  ARMARX_INFO << "Not storing WM data into LTM on stop, because storeOnStop is "
557  }
558 
559  //put calling stopRecording into a seperate thread and detach to make sure GUI does not freeze
560  auto ltm = longtermMemory;
561 
562  std::thread stopRecordingThread(
563  [&ltm]()
564  {
565  ltm->stopRecording();
566  ltm->bufferFinished();
567  ARMARX_INFO << "Storing finished";
568  });
569  stopRecordingThread.detach();
570 
572  << "Stopped all LTM recordings, please wait with stopping the component until "
573  "all files are written";
574 
575  dto::StopRecordResult ret;
576  ret.success = true;
577 
578  return ret;
579  }
580 
581  dto::RecordStatusResult
583  {
584  dto::RecordStatusResult ret;
585  ret.success = true;
586 
587  long savedSnapshots;
588  long totalSnapshots;
589 
590  ARMARX_DEBUG << "Get record status";
591 
593  [&savedSnapshots, &totalSnapshots](const auto& c)
594  {
595  c.forEachProviderSegment(
596  [&savedSnapshots, &totalSnapshots](const auto& p)
597  {
598  p.forEachEntity(
599  [&savedSnapshots, &totalSnapshots](const auto& e)
600  {
601  savedSnapshots += e.getStatistics().recordedSnapshots;
602 
603  e.forEachSnapshot([&totalSnapshots](const auto&)
604  { totalSnapshots++; });
605  });
606  });
607  });
608 
609  ret.status.savedSnapshots = savedSnapshots;
610  ret.status.totalSnapshots = totalSnapshots;
611 
612  return ret;
613  }
614 
615  // PREDICTION
616  prediction::data::PredictionResultSeq
617  MemoryToIceAdapter::predict(prediction::data::PredictionRequestSeq requests)
618  {
620  armarx::fromIce<std::vector<PredictionRequest>>(requests));
621  return armarx::toIce<prediction::data::PredictionResultSeq>(res);
622  }
623 
624  prediction::data::EngineSupportMap
626  {
627  prediction::data::EngineSupportMap result;
629 
630  // Uncomment once LTM also supports prediction engines.
631 
632  /*prediction::data::EngineSupportMap ltmMap;
633  armarx::toIce(ltmMap, longtermMemory->getAllPredictionEngines());
634  for (const auto& [memoryID, engines] : ltmMap)
635  {
636  auto entryIter = result.find(memoryID);
637  if (entryIter == result.end())
638  {
639  result.emplace(memoryID, engines);
640  }
641  else
642  {
643  // Merge LTM-supported engines with WM-supported engines, removing duplicates
644  std::set<prediction::data::PredictionEngine> engineSet;
645  engineSet.insert(entryIter->second.begin(), entryIter->second.end());
646  engineSet.insert(engines.begin(), engines.end());
647  entryIter->second.assign(engineSet.begin(), engineSet.end());
648  }
649  }*/
650 
651  return result;
652  }
653 
654 } // namespace armarx::armem::server
armarx::armem::server::MemoryToIceAdapter::workingMemory
server::wm::Memory * workingMemory
Definition: MemoryToIceAdapter.h:89
armarx::armem::server::ltm::detail::MemoryBase::isRecording
bool isRecording() const
Definition: MemoryBase.h:318
RestPersistence.h
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
memory_conversions.h
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::armem::MemoryID::providerSegmentName
std::string providerSegmentName
Definition: MemoryID.h:52
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
MemoryPersistenceStrategy.h
armarx::armem::client::query::Builder::buildQueryInput
QueryInput buildQueryInput() const
Definition: Builder.cpp:12
armarx::armem::server::ltm::detail::MemoryBase::getRecordingMode
RecordingMode getRecordingMode() const
Definition: MemoryBase.h:90
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:51
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:74
armarx::armem::server::ltm::detail::MemoryBase::Properties::coreSegmentsToLoad
std::string coreSegmentsToLoad
Definition: MemoryBase.h:425
armarx::armem::server::MemoryToIceAdapter::longtermMemory
server::ltm::Memory * longtermMemory
Definition: MemoryToIceAdapter.h:90
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:79
armarx::armem::base::MemoryBase::getCoreSegment
CoreSegmentT & getCoreSegment(const std::string &name)
Definition: MemoryBase.h:132
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::armem::server::MemoryToIceAdapter::startRecord
dto::StartRecordResult startRecord(const dto::StartRecordInput &startRecordInput)
Definition: MemoryToIceAdapter.cpp:526
armarx::armem::server::MemoryToIceAdapter::memoryListenerTopic
client::MemoryListenerInterfacePrx memoryListenerTopic
Definition: MemoryToIceAdapter.h:92
armarx::armem::MemoryID::str
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition: MemoryID.cpp:102
armarx::armem::wm::toMemory
void toMemory(Memory &m, const std::vector< CoreSegment > &e)
Definition: memory_conversions.cpp:6
armarx::armem::toIce
void toIce(data::MemoryID &ice, const MemoryID &id)
Definition: ice_conversions.cpp:20
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::armem::server::ltm::detail::MemoryBase::Properties::importOnStartUp
bool importOnStartUp
Definition: MemoryBase.h:423
armarx::armem::query::boolToDataMode
DataMode boolToDataMode(bool withData)
Definition: DataMode.cpp:6
armarx::armem::base::MemoryBase::name
std::string & name()
Definition: MemoryBase.h:92
armarx::armem::server::ltm::detail::MemoryBase::p
struct armarx::armem::server::ltm::detail::MemoryBase::Properties p
ice_conversions.h
ltm.h
armarx::armem::client::QueryResult
Result of a QueryInput.
Definition: Query.h:50
armarx::armem::server::query_proc::wm_server::MemoryQueryProcessor
Definition: wm.h:186
armarx::armem::MemoryID::coreSegmentName
std::string coreSegmentName
Definition: MemoryID.h:51
armarx::armem::server::MemoryToIceAdapter::predict
prediction::data::PredictionResultSeq predict(prediction::data::PredictionRequestSeq requests)
Definition: MemoryToIceAdapter.cpp:617
armarx::armem::server::MemoryToIceAdapter::getServerStructure
armem::structure::data::GetServerStructureResult getServerStructure()
Definition: MemoryToIceAdapter.cpp:389
armarx::armem::server::ltm::Memory
A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mong...
Definition: Memory.h:20
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:75
armarx::armem::server::MemoryToIceAdapter::reloadFromLTMOnStartup
armem::CommitResult reloadFromLTMOnStartup()
Triggers a reload (.
Definition: MemoryToIceAdapter.cpp:490
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::armem::server::MemoryToIceAdapter::setMemoryListener
void setMemoryListener(client::MemoryListenerInterfacePrx memoryListenerTopic)
Definition: MemoryToIceAdapter.cpp:38
armarx::armem::server::wm::Memory
Definition: memory_definitions.h:122
armarx::armem::server::ltm::detail::MemoryBase::resolve
void resolve(armem::wm::Memory &memory)
convert the references of the input into a wm::Memory
Definition: MemoryBase.h:231
armarx::armem::server::query_proc::base::MemoryQueryProcessorBase::process
ResultMemoryT process(const armem::query::data::Input &input, const MemoryT &memory) const
Definition: MemoryQueryProcessorBase.h:48
armarx::armem::server::MemoryToIceAdapter::reloadPropertyDefinedCoreSegmentsFromLTM
armem::CommitResult reloadPropertyDefinedCoreSegmentsFromLTM()
Definition: MemoryToIceAdapter.cpp:467
armarx::armem::server::ltm::detail::MemoryBase::Properties::storeOnStop
bool storeOnStop
Definition: MemoryBase.h:419
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::base::detail::PredictiveContainer::getAllPredictionEngines
std::map< MemoryID, std::vector< PredictionEngine > > getAllPredictionEngines() const
Definition: Predictive.h:94
armarx::core::eigen::fromIce
void fromIce(Eigen::Vector2f &e, const Ice::FloatSeq &ice)
Definition: ice_conversions.cpp:10
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::armem::server::ltm::detail::MemoryBase::loadLatestNReferences
armem::wm::Memory loadLatestNReferences(int n)
Definition: MemoryBase.h:185
armarx::armem::client::QueryInput
A query for parts of a memory.
Definition: Query.h:23
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:12
error.h
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::server::ltm::detail::MemoryBase::Properties::maxAmountOfSnapshotsLoaded
int maxAmountOfSnapshotsLoaded
Definition: MemoryBase.h:424
wm.h
armarx::aron::error::AronNotValidException
The AronNotValidException class.
Definition: Exception.h:71
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:25
armarx::armem::CommitResult
Result of a Commit.
Definition: Commit.h:110
ice_conversions.h
armarx::armem::base::MemoryBase::addCoreSegment
CoreSegmentT & addCoreSegment(const std::string &name, aron::type::ObjectPtr coreSegmentType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
Add an empty core segment with the given name, type and prediction engines.
Definition: MemoryBase.h:259
armarx::armem::server::ltm::Memory::forEachCoreSegment
bool forEachCoreSegment(std::function< void(CoreSegment &)> func) const final
iterate over all core segments of this ltm
Definition: Memory.cpp:182
armarx::armem::server::MemoryToIceAdapter::getRecordStatus
dto::RecordStatusResult getRecordStatus()
Definition: MemoryToIceAdapter.cpp:582
armarx::armem::server::ltm::detail::mixin::BufferedMemoryMixin::directlyStore
void directlyStore(const armem::wm::Memory &memory, bool simulatedVersion=false)
Definition: BufferedMemoryMixin.h:31
armarx::armem::base::detail::MemoryItem::id
MemoryID & id()
Definition: MemoryItem.h:25
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition: memory_definitions.h:110
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:68
armarx::armem::EntityUpdateResult::snapshotID
MemoryID snapshotID
Definition: Commit.h:78
armarx::armem::server::ltm::detail::MemoryBase::startRecording
void startRecording()
enable/disable
Definition: MemoryBase.h:303
MemoryToIceAdapter.h
armarx::armem::server::MemoryToIceAdapter::getAvailableEngines
prediction::data::EngineSupportMap getAvailableEngines()
Definition: MemoryToIceAdapter.cpp:625
ice_conversions.h
armarx::armem::server::MemoryToIceAdapter::stopRecord
dto::StopRecordResult stopRecord()
Definition: MemoryToIceAdapter.cpp:540
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:27
armarx::armem::MemoryID::memoryName
std::string memoryName
Definition: MemoryID.h:50
armarx::armem::server
Definition: GraspMemory.cpp:34
armarx::armem::server::MemoryToIceAdapter::directlyStore
dto::DirectlyStoreResult directlyStore(const dto::DirectlyStoreInput &directlStoreInput)
Definition: MemoryToIceAdapter.cpp:511
ExpressionException.h
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_LATEST
@ CONSOLIDATE_LATEST
armarx::armem::server::wm::CoreSegment
base::CoreSegmentBase
Definition: memory_definitions.h:75
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::server::MemoryToIceAdapter::addSegment
data::AddSegmentResult addSegment(const data::AddSegmentInput &input, bool addCoreSegments=false)
Definition: MemoryToIceAdapter.cpp:45
Exception.h
armarx::armem::server::ltm::detail::MemoryItem::id
MemoryID id() const
Definition: MemoryItem.cpp:37
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:13
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::armem::server::ltm::detail::MemoryBase::loadAllReferences
armem::wm::Memory loadAllReferences()
return the full ltm as a wm::Memory with only references the ltm may be huge, use with caution
Definition: MemoryBase.h:167
armarx::armem::CommitResult::results
std::vector< EntityUpdateResult > results
Definition: Commit.h:112
armarx::armem::server::MemoryToIceAdapter::addSegments
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input, bool addCoreSegments=false)
Definition: MemoryToIceAdapter.cpp:105
armarx::armem::server::MemoryToIceAdapter::MemoryToIceAdapter
MemoryToIceAdapter(server::wm::Memory *workingMemory=nullptr, server::ltm::Memory *longtermMemory=nullptr)
Construct an MemoryToIceAdapter from an existing Memory.
Definition: MemoryToIceAdapter.cpp:31
armarx::armem::server::MemoryToIceAdapter::reloadCoreSegmentsFromLTM
armem::CommitResult reloadCoreSegmentsFromLTM(std::list< std::string > &coreSegmentname)
Only load specific core segments and their data from the LTM.
Definition: MemoryToIceAdapter.cpp:438
armarx::armem::query::DataMode::NoData
@ NoData
Just get the structure, but no ARON data.
Builder.h
armarx::armem::base::MemoryBase::append
void append(const OtherDerivedT &other)
Merge another memory into this one.
Definition: MemoryBase.h:347
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:81
armarx::armem::client::query::Builder
The query::Builder class provides a fluent-style specification of hierarchical queries.
Definition: Builder.h:21
ice_conversions_templates.h
armarx::armem::server::wm::detail::PredictionContainer::dispatchPredictions
std::vector< PredictionResult > dispatchPredictions(const std::vector< PredictionRequest > &requests)
Definition: Prediction.h:168
armarx::armem::base::MemoryBase::update
std::vector< UpdateResult > update(const Commit &commit, const bool addMissingCoreSegmentDuringUpdate=false, const bool checkMemoryName=true)
Store all updates in commit.
Definition: MemoryBase.h:297
armarx::armem::error::ContainerEntryAlreadyExists
Indicates that a name in a given ID does not match a container's own name.
Definition: ArMemError.h:57
Logging.h
armarx::armem::client::query::Builder::all
void all()
Get all snapshots from all entities in all segments.
Definition: Builder.cpp:54
armarx::armem::server::query_proc::ltm_server::MemoryQueryProcessor
Definition: ltm.h:56
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::armem::server::MemoryToIceAdapter::reloadAllFromLTM
armem::CommitResult reloadAllFromLTM()
Loads all core segments and their data from the LTM.
Definition: MemoryToIceAdapter.cpp:419
armarx::armem::server::wm::CoreSegment::addProviderSegment
ProviderSegment & addProviderSegment(const std::string &name, Args... args)
Definition: memory_definitions.h:91
armarx::armem::server::wm::Memory::updateLocking
std::vector< Base::UpdateResult > updateLocking(const Commit &commit)
Perform the commit, locking the core segments.
Definition: memory_definitions.cpp:50
armarx::armem::client::QueryResult::fromIce
static QueryResult fromIce(const armem::query::data::Result &ice)
Definition: Query.cpp:26
armarx::armem::server::MemoryToIceAdapter::queryLTM
query::data::Result queryLTM(const armem::query::data::Input &input, bool storeIntoWM)
Query the LTMs of the memory server.
Definition: MemoryToIceAdapter.cpp:344
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:76
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_ALL
@ CONSOLIDATE_ALL
armarx::armem::toCommit
Commit toCommit(const ContainerT &container)
Definition: operations.h:23
armarx::armem::server::MemoryToIceAdapter::commitLocking
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:170
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_REMOVED
@ CONSOLIDATE_REMOVED
armarx::armem::server::MemoryToIceAdapter::commit
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:119
ice_conversions.h
armarx::armem::error::MissingEntry
Indicates that a container did not have an entry under a given name.
Definition: ArMemError.h:74
armarx::armem::server::MemoryToIceAdapter::query
query::data::Result query(const armem::query::data::Input &input)
Definition: MemoryToIceAdapter.cpp:318
armarx::armem::server::ltm::detail::MemoryBase::store
void store(const armem::wm::Memory &memory)
append a wm::Memory instance to the ltm
Definition: MemoryBase.h:240
armarx::armem::server::ltm::detail::MemoryItem::name
std::string name() const
Definition: MemoryItem.cpp:43
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:28