RobotReader.cpp
Go to the documentation of this file.
1 #include "RobotReader.h"
2 
3 #include <chrono>
4 #include <mutex>
5 #include <optional>
6 #include <thread>
7 
13 
21 #include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h>
25 #include <RobotAPI/libraries/armem_robot_state/aron/Exteroception.aron.generated.h>
26 #include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h>
28 
29 
30 namespace fs = ::std::filesystem;
31 
33 {
35  properties(r.properties),
36  propertyPrefix(r.propertyPrefix),
37  memoryReader(r.memoryReader),
38  transformReader(r.transformReader)
39  {
40  }
41 
42  void
44  {
45  transformReader.registerPropertyDefinitions(def);
46  }
47 
48  void
50  {
51  transformReader.connect(memoryNameSystem);
52 
53  // Wait for the memory to become available and add it as dependency.
54  ARMARX_INFO << "RobotReader: Waiting for memory '" << constants::memoryName << "' ...";
55  try
56  {
57  memoryReader = memoryNameSystem.useReader(constants::memoryName);
58  ARMARX_INFO << "RobotReader: Connected to memory '" << constants::memoryName << "'";
59  }
61  {
62  ARMARX_ERROR << e.what();
63  return;
64  }
65  }
66 
67  std::optional<robot::Robot>
68  RobotReader::get(const std::string& name, const armem::Time& timestamp) const
69  {
70  const auto description = queryDescription(name, timestamp);
71 
72  if (not description)
73  {
74  ARMARX_ERROR << "Unknown object " << name;
75  return std::nullopt;
76  }
77 
78  return get(*description, timestamp);
79  }
80 
82  RobotReader::get(const robot::RobotDescription& description, const armem::Time& timestamp) const
83  {
84  robot::Robot robot{.description = description,
85  .instance = "", // TODO(fabian.reister):
86  .config = {}, // will be populated by synchronize
87  .timestamp = timestamp};
88 
89  ARMARX_CHECK(synchronize(robot, timestamp));
90 
91  return robot;
92  }
93 
94  void
96  {
97  syncTimeout = duration;
98  }
99 
100  void
102  {
104  sleepAfterFailure = duration;
105  }
106 
107  bool
108  RobotReader::synchronize(robot::Robot& obj, const armem::Time& timestamp) const
109  {
110  const auto tsStartFunctionInvokation = armem::Time::Now();
111 
112  while (true)
113  {
114  auto state = queryState(obj.description, timestamp);
115 
116  if (not state) /* c++20 [[unlikely]] */
117  {
118  ARMARX_VERBOSE << "Could not synchronize object " << obj.description.name;
119 
120  // if the syncTime is non-positive there will be no retry
121  const auto elapsedTime = armem::Time::Now() - tsStartFunctionInvokation;
122  if (elapsedTime > syncTimeout)
123  {
124  ARMARX_VERBOSE << "Could not synchronize object " << obj.description.name;
125  return false;
126  }
127 
128  ARMARX_INFO << "Retrying to query robot state after failure";
130  }
131 
132  obj.config = std::move(*state);
133  return true;
134  }
135  }
136 
137  std::optional<robot::RobotDescription>
138  RobotReader::queryDescription(const std::string& name, const armem::Time& timestamp) const
139  {
140 
141  const auto sanitizedTimestamp = timestamp.isValid() ? timestamp : Clock::Now();
142 
143  // Query all entities from provider.
145 
146  // clang-format off
147  qb
149  .providerSegments().withName(name)
150  .entities().all()
151  .snapshots().beforeOrAtTime(sanitizedTimestamp);
152  // clang-format on
153 
154  ARMARX_DEBUG << "Lookup query in reader";
155 
156  if (not memoryReader)
157  {
158  ARMARX_WARNING << "Memory reader is null. Did you forget to call "
159  "RobotReader::connect() in onConnectComponent()?";
160  return std::nullopt;
161  }
162 
163  try
164  {
165  std::scoped_lock l(memoryReaderMutex);
166  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
167 
168  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
169 
170  if (not qResult.success) /* c++20 [[unlikely]] */
171  {
172  return std::nullopt;
173  }
174 
175  return getRobotDescription(qResult.memory, name);
176  }
177  catch (...)
178  {
179  ARMARX_VERBOSE << "Query description failure" << GetHandledExceptionString();
180  }
181 
182  return std::nullopt;
183  }
184 
185  std::optional<robot::RobotState>
187  const armem::Time& timestamp) const
188  {
189  const auto proprioception = queryProprioception(description, timestamp);
190 
191  if (not proprioception.has_value())
192  {
193  ARMARX_VERBOSE << "Failed to query proprioception for robot '" << description.name
194  << "'.";
195  return std::nullopt;
196  }
197  const auto jointMap = proprioception->joints.position;
198 
199  const auto globalPose = queryGlobalPose(description, timestamp);
200  if (not globalPose)
201  {
202  ARMARX_VERBOSE << "Failed to query global pose for robot " << description.name;
203  return std::nullopt;
204  }
205 
206  return robot::RobotState{.timestamp = timestamp,
207  .globalPose = *globalPose,
208  .jointMap = jointMap,
209  .proprioception = proprioception};
210  }
211 
212  std::optional<::armarx::armem::robot_state::Transform>
214  const armem::Time& timestamp) const
215  {
216 
220  .agent = description.name,
221  .timestamp = timestamp}};
222 
223  // try
224  {
225  const auto result = transformReader.lookupTransform(query);
226  if (not result)
227  {
228  return std::nullopt;
229  }
230  return result.transform;
231  }
232  // catch (...)
233  // {
234  // ARMARX_VERBOSE << GetHandledExceptionString();
235  // return std::nullopt;
236  // }
237  }
238 
239  std::optional<armarx::armem::arondto::Proprioception>
241  const armem::Time& timestamp) const // Why timestamp?!?!
242  {
243  // TODO(fabian.reister): how to deal with multiple providers?
244 
245  // Query all entities from provider.
247 
248  ARMARX_DEBUG << "Querying robot description for robot: " << description;
249 
250  // clang-format off
251  qb
253  .providerSegments().withName(description.name) // agent
254  .entities().all() // TODO
255  .snapshots().beforeOrAtTime(timestamp);
256  // clang-format on
257 
258  try
259  {
260  std::scoped_lock l(memoryReaderMutex);
261  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
262 
263  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
264 
265  if (not qResult.success) /* c++20 [[unlikely]] */
266  {
267  ARMARX_VERBOSE << qResult.errorMessage;
268  return std::nullopt;
269  }
270 
271  return getRobotProprioception(qResult.memory, description.name);
272  }
273  catch (...)
274  {
275  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query joint state. Reason: "
277  return std::nullopt;
278  }
279  }
280 
283  const armem::Time& begin,
284  const armem::Time& end) const
285  {
287 
288  ARMARX_DEBUG << "Querying robot joint states for robot: `" << description
289  << "` on time interval [" << begin << "," << end << "]";
290 
291  // clang-format off
292  qb
294  .providerSegments().withName(description.name) // agent
295  .entities().all() // TODO
296  .snapshots().timeRange(begin, end);
297  // clang-format on
298 
299  try
300  {
301  std::scoped_lock l(memoryReaderMutex);
302  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
303 
304  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
305 
306  if (not qResult.success) /* c++20 [[unlikely]] */
307  {
308  ARMARX_VERBOSE << qResult.errorMessage;
309  return {};
310  }
311 
312  return getRobotJointStates(qResult.memory, description.name);
313  }
314  catch (...)
315  {
316  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query joint states. Reason: "
318  return {};
319  }
320  }
321 
322  std::optional<robot::PlatformState>
324  const armem::Time& timestamp) const
325  {
326  // TODO(fabian.reister): how to deal with multiple providers?
327 
328  // Query all entities from provider.
330 
331  ARMARX_DEBUG << "Querying robot description for robot: " << description;
332 
333  // clang-format off
334  qb
336  .providerSegments().withName(description.name) // agent
337  .entities().all() // TODO
338  .snapshots().beforeOrAtTime(timestamp);
339  // clang-format on
340 
341  try
342  {
343  std::scoped_lock l(memoryReaderMutex);
344  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
345 
346  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
347 
348  if (not qResult.success) /* c++20 [[unlikely]] */
349  {
350  ARMARX_VERBOSE << qResult.errorMessage;
351  return std::nullopt;
352  }
353 
354  return getRobotPlatformState(qResult.memory, description.name);
355  }
356  catch (...)
357  {
358  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query platform state. Reason: "
360  return std::nullopt;
361  }
362  }
363 
364  std::optional<robot::RobotState::Pose>
366  const armem::Time& timestamp) const
367  {
368  try
369  {
370  const auto result = transformReader.getGlobalPose(
371  description.name, constants::robotRootNodeName, timestamp);
372  if (not result)
373  {
374  return std::nullopt;
375  }
376 
377  return result.transform.transform;
378  }
379  catch (...)
380  {
381  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query global pose. Reason: "
383  return std::nullopt;
384  }
385  }
386 
387  std::optional<robot::RobotState>
388  RobotReader::getRobotState(const armarx::armem::wm::Memory& memory,
389  const std::string& name) const
390  {
391  // clang-format off
392  const armem::wm::ProviderSegment& providerSegment = memory
393  .getCoreSegment(constants::proprioceptionCoreSegment)
394  .getProviderSegment(name);
395 
396  // TODO entitiesToRobotState()
397 
398  if (providerSegment.empty())
399  {
400  ARMARX_VERBOSE << "No entity found";
401  return std::nullopt;
402  }
403 
404  // clang-format on
405 
406  const armem::wm::EntityInstance* instance = nullptr;
407  providerSegment.forEachInstance(
408  [&instance](const wm::EntityInstance& i)
409  {
410  instance = &i;
411  return false; // break
412  });
413 
414  if (instance == nullptr)
415  {
416  ARMARX_VERBOSE << "No entity snapshots found";
417  return std::nullopt;
418  }
419 
420  // Here, we access the RobotUnit streaming data stored in the proprioception segment.
421  return robot::convertRobotState(*instance);
422  }
423 
424  // FIXME remove this, use armem/util/util.h
425  template <typename AronClass>
426  std::optional<AronClass>
428  {
429  static_assert(std::is_base_of<armarx::aron::codegenerator::cpp::AronGeneratedClass,
430  AronClass>::value);
431 
432  try
433  {
434  return AronClass::FromAron(item.data());
435  }
437  {
438  return std::nullopt;
439  }
440  }
441 
442  std::optional<armarx::armem::arondto::Proprioception>
443  RobotReader::getRobotProprioception(const armarx::armem::wm::Memory& memory,
444  const std::string& name) const
445  {
446  // clang-format off
447  const armem::wm::CoreSegment& coreSegment = memory
448  .getCoreSegment(constants::proprioceptionCoreSegment);
449  // clang-format on
450 
451  std::optional<armarx::armem::arondto::Proprioception> proprioception;
452 
453  coreSegment.forEachEntity(
454  [&proprioception](const wm::Entity& entity)
455  {
456  if (not entity.getLatestSnapshot().hasInstance(0))
457  {
458  return;
459  }
460 
461  const auto& entityInstance = entity.getLatestSnapshot().getInstance(0);
462 
463  proprioception = tryCast<::armarx::armem::arondto::Proprioception>(entityInstance);
464  });
465 
466  return proprioception;
467  }
468 
470  RobotReader::getRobotJointStates(const armarx::armem::wm::Memory& memory,
471  const std::string& name) const
472  {
473 
474  RobotReader::JointTrajectory jointTrajectory;
475 
476  // clang-format off
477  const armem::wm::CoreSegment& coreSegment = memory
479  // clang-format on
480 
481  coreSegment.forEachEntity(
482  [&jointTrajectory](const wm::Entity& entity)
483  {
484  entity.forEachSnapshot(
485  [&](const auto& snapshot)
486  {
487  if (not snapshot.hasInstance(0))
488  {
489  return;
490  }
491 
492  const auto& entityInstance = snapshot.getInstance(0);
493 
494  const auto proprioception =
495  tryCast<::armarx::armem::arondto::Proprioception>(entityInstance);
496  ARMARX_CHECK(proprioception.has_value());
497 
498  const armarx::armem::prop::arondto::Joints& joints = proprioception->joints;
499 
500  jointTrajectory.emplace(entityInstance.id().timestamp, joints.position);
501  });
502  });
503 
504  ARMARX_INFO << "Joint trajectory with " << jointTrajectory.size() << " elements";
505 
506  return jointTrajectory;
507  }
508 
509  // force torque for left and right
510  std::optional<std::map<RobotReader::Hand, robot::ForceTorque>>
512  const armem::Time& timestamp) const
513  {
514 
515  // Query all entities from provider.
517 
518  ARMARX_DEBUG << "Querying force torques description for robot: " << description;
519 
520  // clang-format off
521  qb
523  .providerSegments().withName(description.name) // agent
524  .entities().all() // TODO
525  .snapshots().beforeOrAtTime(timestamp);
526  // clang-format on
527 
528  try
529  {
530  std::scoped_lock l(memoryReaderMutex);
531  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
532 
533  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
534 
535  if (not qResult.success) /* c++20 [[unlikely]] */
536  {
537  ARMARX_VERBOSE << qResult.errorMessage;
538  return std::nullopt;
539  }
540 
541  return getForceTorque(qResult.memory, description.name);
542  }
543  catch (...)
544  {
545  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query force torque. Reason: "
547  return std::nullopt;
548  }
549  }
550 
551  // force torque for left and right
552  std::optional<std::map<RobotReader::Hand, std::map<armem::Time, robot::ForceTorque>>>
554  const armem::Time& start,
555  const armem::Time& end) const
556  {
557 
558  // Query all entities from provider.
560 
561  ARMARX_DEBUG << "Querying force torques description for robot: " << description;
562 
563  // clang-format off
564  qb
566  .providerSegments().withName(description.name) // agent
567  .entities().all() // TODO
568  .snapshots().timeRange(start, end);
569  // clang-format on
570 
571  try
572  {
573  std::scoped_lock l(memoryReaderMutex);
574  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
575 
576  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
577 
578  if (not qResult.success) /* c++20 [[unlikely]] */
579  {
580  ARMARX_VERBOSE << qResult.errorMessage;
581  return std::nullopt;
582  }
583 
584  return getForceTorques(qResult.memory, description.name);
585  }
586  catch (...)
587  {
588  ARMARX_VERBOSE << deactivateSpam(1) << "Failed to query force torques. Reason: "
590  return std::nullopt;
591  }
592  }
593 
594  std::optional<std::map<RobotReader::Hand, robot::ToFArray>>
596  const armem::Time& timestamp) const
597  {
598  // Query all entities from provider.
600 
601  ARMARX_DEBUG << "Querying ToF data for robot: " << description;
602 
603  // clang-format off
604  qb
606  .providerSegments().withName(description.name) // agent
607  .entities().all() // TODO
608  .snapshots().beforeOrAtTime(timestamp);
609  // clang-format on
610 
611  try
612  {
613  std::scoped_lock l(memoryReaderMutex);
614  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
615 
616  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
617 
618  if (not qResult.success) /* c++20 [[unlikely]] */
619  {
620  ARMARX_VERBOSE << qResult.errorMessage;
621  return std::nullopt;
622  }
623 
624  return getToF(qResult.memory, description.name);
625  }
626  catch (...)
627  {
629  << "Failed to query ToF. Reason: " << GetHandledExceptionString();
630  return std::nullopt;
631  }
632  }
633 
634  std::optional<robot::PlatformState>
635  RobotReader::getRobotPlatformState(const armarx::armem::wm::Memory& memory,
636  const std::string& name) const
637  {
638  std::optional<robot::PlatformState> platformState;
639 
640  // clang-format off
641  const armem::wm::CoreSegment& coreSegment = memory
642  .getCoreSegment(constants::proprioceptionCoreSegment);
643  // clang-format on
644 
645  coreSegment.forEachEntity(
646  [&platformState](const wm::Entity& entity)
647  {
648  if (not entity.getLatestSnapshot().hasInstance(0))
649  {
650  return;
651  }
652 
653  const auto& entityInstance = entity.getLatestSnapshot().getInstance(0);
654 
655  const auto proprioception =
656  tryCast<::armarx::armem::arondto::Proprioception>(entityInstance);
657  ARMARX_CHECK(proprioception.has_value());
658 
659  platformState = robot::PlatformState(); // initialize optional
660  fromAron(proprioception->platform, platformState.value());
661  });
662 
663  return platformState;
664  }
665 
666  inline RobotReader::Hand
667  fromHandName(const std::string& name)
668  {
669  if (name == "Left")
670  {
672  }
673 
674  if (name == "Right")
675  {
677  }
678 
679  throw LocalException("Unknown hand name `" + name + "`!");
680  }
681 
682  std::map<RobotReader::Hand, robot::ForceTorque>
683  RobotReader::getForceTorque(const armarx::armem::wm::Memory& memory,
684  const std::string& name) const
685  {
686  std::map<RobotReader::Hand, robot::ForceTorque> forceTorques;
687 
688  // clang-format off
689  const armem::wm::CoreSegment& coreSegment = memory
690  .getCoreSegment(constants::proprioceptionCoreSegment);
691  // clang-format on
692 
693  coreSegment.forEachEntity(
694  [&forceTorques](const wm::Entity& entity)
695  {
696  if (not entity.getLatestSnapshot().hasInstance(0))
697  {
698  return;
699  }
700 
701  const auto& entityInstance = entity.getLatestSnapshot().getInstance(0);
702 
703  const auto proprioception =
704  tryCast<::armarx::armem::arondto::Proprioception>(entityInstance);
705  ARMARX_CHECK(proprioception.has_value());
706 
707  for (const auto& [handName, dtoFt] : proprioception->forceTorque)
708  {
709  robot::ForceTorque forceTorque;
710  fromAron(dtoFt, forceTorque);
711 
712  const auto hand = fromHandName(handName);
713  forceTorques.emplace(hand, forceTorque);
714  }
715  });
716 
717  return forceTorques;
718  }
719 
720  std::map<RobotReader::Hand, std::map<armem::Time, robot::ForceTorque>>
721  RobotReader::getForceTorques(const armarx::armem::wm::Memory& memory,
722  const std::string& name) const
723  {
724  std::map<RobotReader::Hand, std::map<armem::Time, robot::ForceTorque>> forceTorques;
725 
726  // clang-format off
727  const armem::wm::CoreSegment& coreSegment = memory
729  // clang-format on
730 
731  coreSegment.forEachInstance(
732  [&forceTorques](const wm::EntityInstance& entityInstance)
733  {
734  const auto proprioception =
735  tryCast<::armarx::armem::arondto::Proprioception>(entityInstance);
736  ARMARX_CHECK(proprioception.has_value());
737 
738 
739  for (const auto& [handName, dtoFt] : proprioception->forceTorque)
740  {
741  robot::ForceTorque forceTorque;
742  fromAron(dtoFt, forceTorque);
743 
744  const auto hand = fromHandName(handName);
745  forceTorques[hand].emplace(entityInstance.id().timestamp, forceTorque);
746  }
747  });
748 
749  return forceTorques;
750  }
751 
752  std::map<RobotReader::Hand, robot::ToFArray>
753  RobotReader::getToF(const armarx::armem::wm::Memory& memory, const std::string& name) const
754  {
755  std::map<RobotReader::Hand, robot::ToFArray> tofs;
756 
757  // clang-format off
758  const armem::wm::CoreSegment& coreSegment = memory
760  // clang-format on
761 
762  coreSegment.forEachEntity(
763  [&tofs](const wm::Entity& entity)
764  {
765  ARMARX_DEBUG << "Processing ToF element";
766 
767  if (not entity.getLatestSnapshot().hasInstance(0))
768  {
769  return;
770  }
771  const auto& entityInstance = entity.getLatestSnapshot().getInstance(0);
772 
773  const auto exteroception =
774  tryCast<::armarx::armem::arondto::Exteroception>(entityInstance);
775  ARMARX_CHECK(exteroception.has_value());
776 
777 
778  for (const auto& [handName, dtoFt] : exteroception->tof)
779  {
780  ARMARX_DEBUG << "Processing ToF element for hand `" << handName << "`";
781 
782  robot::ToFArray tof;
783  fromAron(dtoFt, tof);
784 
785  const auto hand = fromHandName(handName);
786  tofs.emplace(hand, tof);
787  }
788  });
789 
790  return tofs;
791  }
792 
793  std::optional<robot::RobotDescription>
794  RobotReader::getRobotDescription(const armarx::armem::wm::Memory& memory,
795  const std::string& name) const
796  {
797  // clang-format off
798  const armem::wm::ProviderSegment& providerSegment = memory
800  .getProviderSegment(name);
801  // clang-format on
802 
803  const armem::wm::EntityInstance* instance = nullptr;
804  providerSegment.forEachInstance([&instance](const wm::EntityInstance& i)
805  { instance = &i; });
806  if (instance == nullptr)
807  {
808  ARMARX_VERBOSE << "No entity snapshots found in provider segment `" << name << "`";
809  return std::nullopt;
810  }
811 
812  return robot::convertRobotDescription(*instance);
813  }
814 
815  std::vector<robot::RobotDescription>
816  RobotReader::getRobotDescriptions(const armarx::armem::wm::Memory& memory) const
817  {
818  const armem::wm::CoreSegment& coreSegment =
820 
821  std::vector<robot::RobotDescription> descriptions;
822 
823  coreSegment.forEachInstance(
824  [&descriptions](const wm::EntityInstance& instance)
825  {
826  if (const std::optional<robot::RobotDescription> desc =
828  {
829  descriptions.push_back(desc.value());
830  }
831  });
832 
833  return descriptions;
834  }
835 
836  std::vector<robot::RobotDescription>
838  {
839  const auto sanitizedTimestamp = timestamp.isValid() ? timestamp : Clock::Now();
840 
841  // Query all entities from provider.
843 
844  // clang-format off
845  qb
847  .providerSegments().all()
848  .entities().all()
849  .snapshots().beforeOrAtTime(sanitizedTimestamp);
850  // clang-format on
851 
852  ARMARX_DEBUG << "Lookup query in reader";
853 
854  if (not memoryReader)
855  {
856  ARMARX_WARNING << "Memory reader is null. Did you forget to call "
857  "RobotReader::connect() in onConnectComponent()?";
858  return {};
859  }
860 
861  try
862  {
863  std::scoped_lock l(memoryReaderMutex);
864  const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
865 
866  ARMARX_DEBUG << "Lookup result in reader: " << qResult;
867 
868  if (not qResult.success) /* c++20 [[unlikely]] */
869  {
870  return {};
871  }
872 
873  return getRobotDescriptions(qResult.memory);
874  }
875  catch (...)
876  {
877  ARMARX_VERBOSE << "Query description failure" << GetHandledExceptionString();
878  }
879 
880  return {};
881  }
882 } // namespace armarx::armem::robot_state
armarx::armem::robot_state::RobotReader::queryForceTorque
std::optional< std::map< Hand, robot::ForceTorque > > queryForceTorque(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:511
armarx::armem::client::query::EntitySelector::all
EntitySelector & all() override
Definition: selectors.cpp:96
armarx::aron::error::AronException
A base class for aron exceptions.
Definition: Exception.h:42
armarx::armem::base::detail::MemoryContainerBase::empty
bool empty() const
Definition: MemoryContainerBase.h:44
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::armem::robot_state::RobotReader::queryProprioception
std::optional< armarx::armem::arondto::Proprioception > queryProprioception(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:240
armarx::core::time::DateTime::isValid
bool isValid() const
Definition: DateTime.cpp:135
ARMARX_CHECK_NONNEGATIVE
#define ARMARX_CHECK_NONNEGATIVE(number)
Check whether number is nonnegative (>= 0). If it is not, throw an ExpressionException with the expre...
Definition: ExpressionException.h:152
armarx::armem::server::wm::EntityInstance
armem::wm::EntityInstance EntityInstance
Definition: forward_declarations.h:64
armarx::armem::client::query::ProviderSegmentSelector::entities
EntitySelector & entities()
Start specifying entities.
Definition: selectors.cpp:123
armarx::armem::client::query::SnapshotSelector::timeRange
SnapshotSelector & timeRange(Time min, Time max)
Definition: selectors.cpp:42
armarx::armem::robot_state::RobotReader::queryGlobalPose
std::optional< robot::RobotState::Pose > queryGlobalPose(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:365
armarx::human::pose::model::k4a_bt_body_32::Joints
Joints
Joints with index as defined in the body model.
Definition: k4a_bt_body_32.h:39
armarx::armem::robot_state::RobotReader::synchronize
bool synchronize(robot::Robot &obj, const armem::Time &timestamp) const override
Definition: RobotReader.cpp:108
LocalException.h
armarx::armem::wm::ProviderSegment
Client-side working memory provider segment.
Definition: memory_definitions.h:105
armarx::armem::robot_state::RobotReader::setSyncTimeout
void setSyncTimeout(const armem::Duration &duration)
Definition: RobotReader.cpp:95
armarx::armem::client::robot_state::localization::TransformReader::lookupTransform
TransformResult lookupTransform(const TransformQuery &query) const override
Definition: TransformReader.cpp:137
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition: memory_definitions.h:32
armarx::armem::robot::Robot
Definition: types.h:68
armarx::armem::client::query::Builder::buildQueryInput
QueryInput buildQueryInput() const
Definition: Builder.cpp:11
armarx::armem::base::detail::GetLatestSnapshotMixin::getLatestSnapshot
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
Definition: lookup_mixins.h:199
armarx::core::time::Clock::WaitFor
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
Definition: Clock.cpp:104
armarx::armem::client::robot_state::localization::TransformReader::registerPropertyDefinitions
void registerPropertyDefinitions(::armarx::PropertyDefinitionsPtr &def) override
Definition: TransformReader.cpp:71
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::armem::client::query::EntitySelector::snapshots
SnapshotSelector & snapshots()
Start specifying entity snapshots.
Definition: selectors.cpp:86
armarx::armem::base::MemoryBase::getCoreSegment
CoreSegmentT & getCoreSegment(const std::string &name)
Definition: MemoryBase.h:132
armarx::armem::robot_state::RobotReader::registerPropertyDefinitions
virtual void registerPropertyDefinitions(::armarx::PropertyDefinitionsPtr &def)
Definition: RobotReader.cpp:43
armarx::armem::robot_state::RobotReader::Hand
Hand
Definition: RobotReader.h:91
armarx::armem::common::robot_state::localization::TransformQuery
Definition: types.h:75
armarx::armem::robot_state::RobotReader::Hand::Right
@ Right
armarx::armem::common::robot_state::localization::TransformResult::transform
::armarx::armem::robot_state::Transform transform
Definition: types.h:36
armarx::armem::robot_state::constants::memoryName
const std::string memoryName
Definition: constants.h:26
armarx::armem::robot_state::RobotReader::queryDescription
std::optional< robot::RobotDescription > queryDescription(const std::string &name, const armem::Time &timestamp) const
Definition: RobotReader.cpp:138
constants.h
armarx::armem::robot_state::constants::proprioceptionCoreSegment
const std::string proprioceptionCoreSegment
Definition: constants.h:30
armarx::armem::robot_state
Definition: RobotStatePredictionClient.cpp:42
types.h
armarx::armem::robot_state::RobotReader::connect
virtual void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: RobotReader.cpp:49
armarx::armem::robot_state::tryCast
std::optional< AronClass > tryCast(const wm::EntityInstance &item)
Definition: RobotReader.cpp:427
armarx::armem::robot::convertRobotState
std::optional< RobotState > convertRobotState(const armem::wm::EntityInstance &instance)
Definition: robot_conversions.cpp:46
armarx::armem::client::QueryResult
Result of a QueryInput.
Definition: Query.h:50
armarx::armem::robot_state::constants::robotRootNodeName
const std::string robotRootNodeName
Definition: constants.h:36
armarx::armem::robot_state::RobotReader::queryOdometryPose
std::optional<::armarx::armem::robot_state::Transform > queryOdometryPose(const robot::RobotDescription &description, const armem::Time &timestamp) const
retrieve the robot's pose in the odometry frame.
Definition: RobotReader.cpp:213
armarx::armem::server::wm::Entity
Definition: memory_definitions.h:30
armarx::memory
Brief description of class memory.
Definition: memory.h:39
armarx::armem::base::detail::ForEachEntityMixin::forEachEntity
bool forEachEntity(FunctionT &&func)
Definition: iteration_mixins.h:258
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
Clock.h
armarx::armem::robot::RobotState
Definition: types.h:54
armarx::armem::robot::RobotDescription
Definition: types.h:17
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:72
armarx::GetHandledExceptionString
std::string GetHandledExceptionString()
Definition: Exception.cpp:147
armarx::armem::robot_state::TransformHeader::parentFrame
std::string parentFrame
Definition: types.h:33
armarx::armem::robot_state::RobotReader::JointTrajectory
std::map< armem::Time, robot::RobotState::JointMap > JointTrajectory
Definition: RobotReader.h:74
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::armem::robot_state::RobotReader::Hand::Left
@ Left
armarx::armem::common::robot_state::localization::TransformQuery::header
::armarx::armem::robot_state::TransformHeader header
Definition: types.h:77
FramedPose.h
armarx::armem::client::query::Builder::coreSegments
CoreSegmentSelector & coreSegments()
Start specifying core segments.
Definition: Builder.cpp:38
armarx::armem::robot::Robot::description
RobotDescription description
Definition: types.h:70
armarx::armem::robot_state::RobotReader::setSleepAfterSyncFailure
void setSleepAfterSyncFailure(const armem::Duration &duration)
Definition: RobotReader.cpp:101
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::robot_state::RobotReader::get
std::optional< robot::Robot > get(const std::string &name, const armem::Time &timestamp) const override
Definition: RobotReader.cpp:68
armarx::armem::wm::CoreSegment
Client-side working memory core segment.
Definition: memory_definitions.h:119
armarx::armem::client::robot_state::localization::TransformReader::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem) override
Definition: TransformReader.cpp:85
armarx::armem::client::query::CoreSegmentSelector::withName
CoreSegmentSelector & withName(const std::string &name) override
Definition: selectors.cpp:177
error.h
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::client::MemoryNameSystem::useReader
Reader useReader(const MemoryID &memoryID)
Use a memory server and get a reader for it.
Definition: MemoryNameSystem.cpp:184
armarx::armem::robot_state::RobotReader::queryPlatformState
std::optional< robot::PlatformState > queryPlatformState(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:323
armarx::aron::cpp::AronGeneratedClass
Definition: AronGeneratedClass.h:46
aron_conversions.h
armarx::OdometryFrame
const std::string OdometryFrame
Definition: FramedPose.h:63
RobotReader.h
armarx::armem::robot_state::constants::descriptionCoreSegment
const std::string descriptionCoreSegment
Definition: constants.h:28
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::robot_state::RobotReader
The RobotReader class.
Definition: RobotReader.h:43
aron_conversions.h
memory_definitions.h
for
for(;yybottom<=yytop;yybottom++)
Definition: Grammar.cpp:790
ExpressionException.h
armarx::armem::robot_state::RobotReader::queryToF
std::optional< std::map< Hand, robot::ToFArray > > queryToF(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:595
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::fromAron
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
Definition: aron_conversions.cpp:8
armarx::armem::robot::RobotDescription::name
std::string name
Definition: types.h:21
armarx::armem::robot::convertRobotDescription
std::optional< RobotDescription > convertRobotDescription(const armem::wm::EntityInstance &instance)
Definition: robot_conversions.cpp:21
armarx::armem::client::query::ProviderSegmentSelector::withName
ProviderSegmentSelector & withName(const std::string &name) override
Definition: selectors.cpp:140
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::armem::client::query::SnapshotSelector::beforeOrAtTime
SnapshotSelector & beforeOrAtTime(Time timestamp)
Definition: selectors.cpp:68
armarx::armem::robot_state::RobotReader::queryJointStates
JointTrajectory queryJointStates(const robot::RobotDescription &description, const armem::Time &begin, const armem::Time &end) const
Definition: RobotReader.cpp:282
IceUtil::Handle< class PropertyDefinitionContainer >
types.h
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::armem::base::detail::ForEachEntityInstanceMixin::forEachInstance
bool forEachInstance(InstanceFunctionT &&func)
Definition: iteration_mixins.h:146
Time.h
armarx::armem::robot_state::RobotReader::queryDescriptions
std::vector< robot::RobotDescription > queryDescriptions(const armem::Time &timestamp) const
Definition: RobotReader.cpp:837
Builder.h
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::armem::error::CouldNotResolveMemoryServer
Indicates that a query to the Memory Name System failed.
Definition: mns.h:26
armarx::core::time::Clock::Now
static DateTime Now()
Current time on the virtual clock.
Definition: Clock.cpp:97
armarx::armem::robot_state::RobotReader::queryState
std::optional< robot::RobotState > queryState(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:186
armarx::armem::client::query::Builder
The query::Builder class provides a fluent-style specification of hierarchical queries.
Definition: Builder.h:22
armarx::armem::client::query::CoreSegmentSelector::providerSegments
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
Definition: selectors.cpp:160
armarx::core::time::Duration::toMicroSeconds
std::int64_t toMicroSeconds() const
Returns the amount of microseconds.
Definition: Duration.cpp:41
armarx::armem::robot_state::Transform::transform
Eigen::Affine3f transform
Definition: types.h:45
Logging.h
robot_conversions.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::armem::base::EntityInstanceBase::data
const DataT & data() const
Definition: EntityInstanceBase.h:129
armarx::armem::client::query::ProviderSegmentSelector::all
ProviderSegmentSelector & all() override
Definition: selectors.cpp:133
armarx::armem::robot_state::constants::exteroceptionCoreSegment
const std::string exteroceptionCoreSegment
Definition: constants.h:31
armarx::armem::robot_state::RobotReader::RobotReader
RobotReader()=default
armarx::armem::robot_state::RobotReader::sleepAfterFailure
armem::Duration sleepAfterFailure
Definition: RobotReader.h:126
armarx::armem::robot::Robot::config
RobotState config
Definition: types.h:73
armarx::armem::robot::RobotState::timestamp
DateTime timestamp
Definition: types.h:59
armarx::armem::robot::PlatformState
Definition: types.h:32
armarx::armem::robot_state::RobotReader::queryForceTorques
std::optional< std::map< RobotReader::Hand, std::map< armem::Time, robot::ForceTorque > > > queryForceTorques(const robot::RobotDescription &description, const armem::Time &start, const armem::Time &end) const
Definition: RobotReader.cpp:553
armarx::armem::robot_state::RobotReader::syncTimeout
armem::Duration syncTimeout
Definition: RobotReader.h:125
armarx::armem::client::Reader::query
QueryResult query(const QueryInput &input) const
Perform a query.
Definition: Reader.cpp:33
armarx::armem::robot_state::fromHandName
RobotReader::Hand fromHandName(const std::string &name)
Definition: RobotReader.cpp:667
armarx::armem::client::robot_state::localization::TransformReader::getGlobalPose
TransformResult getGlobalPose(const std::string &agentName, const std::string &robotRootFrame, const armem::Time &timestamp) const override
Definition: TransformReader.cpp:102
PackagePath.h