Component.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 Navigation::ArmarXObjects::NavigationMemory
17  * @author Fabian Reister ( fabian dot reister 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 "Component.h"
24 
25 #include <filesystem>
26 #include <fstream>
27 #include <iostream>
28 #include <iterator>
29 
37 
48 
50 #include <armarx/navigation/algorithms/aron/Costmap.aron.generated.h>
52 #include <armarx/navigation/core/aron/Graph.aron.generated.h>
53 #include <armarx/navigation/core/aron/Location.aron.generated.h>
54 #include <armarx/navigation/core/aron/Trajectory.aron.generated.h>
55 #include <armarx/navigation/core/aron/Twist.aron.generated.h>
57 #include <armarx/navigation/human/aron/Human.aron.generated.h>
59 #include <armarx/navigation/memory/aron/LaserScannerFeatures.aron.generated.h>
61 #include <armarx/navigation/rooms/aron/Room.aron.generated.h>
63 
64 #include "Visu.h"
65 
67 {
68 
70 
73  {
76 
77  // Publish to a topic (passing the TopicListenerPrx).
78  // def->topic(myTopicListener);
79 
80  // Subscribe to a topic (passing the topic name).
81  // def->topic<PlatformUnitListener>("MyTopic");
82 
83  // Use (and depend on) another component (passing the ComponentInterfacePrx).
84  // def->component(myComponentProxy)
85 
86 
87  def->optional(properties.snapshotToLoad,
88  "p.snapshotToLoad",
89  "Snapshot to load at start up \n"
90  "(e.g. 'R003' to load 'PriorKnowledgeData/navigation-graphs/R003').");
91 
92  def->optional(properties.packageToLoad,
93  "p.packageToLoad",
94  "Package to load snapshot at start up \n"
95  "(e.g. 'PriorKnowledgeData').");
96 
97  def->optional(properties.locationGraph.visuLocations,
98  "p.locationGraph.visuLocation",
99  "Enable visualization of locations.");
100 
101  def->optional(
102  properties.locationGraph.visuRelativeLocations,
103  "p.locationGraph.visuRelativeLocation",
104  "Enable visualization of relative locations (currently supported: robots, objects).");
105 
106  def->optional(properties.locationGraph.visuGraphEdges,
107  "p.locationGraph.visuGraphEdges",
108  "Enable visualization of navigation graph edges.");
109 
110  def->optional(
111  properties.visuCostmaps, "p.visuCostmaps", "Enable visualization of costmaps.");
112  def->optional(properties.zOffsetCostmap,
113  "p.zOffsetCostmap",
114  "Adjust the height of the visualized costmap.");
115 
116  def->optional(properties.visuHumans, "p.visuHumans", "Enable visualization of humans.");
117 
118  def->optional(properties.visuTransparent,
119  "p.visuTransparent",
120  "Enable visualization of humans a bit transparent.");
121 
122  def->optional(properties.visuHumanMaxAgeMs,
123  "p.visuHumanMaxAgeMs",
124  "The maximum age of humans to be drawn in ms.");
125 
126  def->optional(properties.visuRooms, "p.visuRooms", "Enable visualization of rooms.");
127 
128  def->optional(properties.visuFrequency,
129  "p.visuFrequency",
130  "Visualization frequeny of locations and graph edges [Hz].");
131 
132  return def;
133  }
134 
136  {
137  workingMemory().setName("Navigation");
138  }
139 
140  void
142  {
143  // Topics and properties defined above are automagically registered.
144 
145  // Keep debug observer data until calling `sendDebugObserverBatch()`.
146  // (Requies the armarx::DebugObserverComponentPluginUser.)
147  // setDebugObserverBatchModeEnabled(true);
148 
151 
153  algorithms::arondto::Costmap::ToAronType());
154 
155  workingMemory().addCoreSegment("Results_GlobalPlanner",
156  navigation::core::arondto::GlobalTrajectory::ToAronType());
157  workingMemory().addCoreSegment("Results_LocalPlanner",
158  navigation::core::arondto::LocalTrajectory::ToAronType());
159  // workingMemory().addCoreSegment("Results_TrajectoryController",
160  // navigation::core::arondto::Twist::ToAronType());
161  // workingMemory().addCoreSegment("Results_SafetyController",
162  // navigation::core::arondto::Twist::ToAronType());
163 
164  workingMemory().addCoreSegment("Events"); //, armem::example::ExampleData::ToAronType());
166  "Exceptions"); //, armem::example::ExampleData::ToAronType());
167 
168 
170  navigation::location::arondto::Location::ToAronType());
172  navigation::core::arondto::Graph::ToAronType());
173 
175  navigation::human::arondto::Human::ToAronType());
176 
177  workingMemory()
179  navigation::memory::arondto::LaserScannerFeatures::ToAronType())
180  .setMaxHistorySize(properties.laserScannerFeaturesMaxHistorySize);
181 
182  // workingMemory().addCoreSegment(memory::constants::HumanGroupCoreSegmentName,
183  // navigation::human::arondto::Human::ToAronType());
185  navigation::rooms::arondto::Room::ToAronType());
186 
187  loadSnapshot();
188  }
189 
190  void
192  {
193  // connect readers if enabled
194  if (properties.locationGraph.visuRelativeLocations)
195  {
197  }
198 
199  // Setup the remote GUI.
200  {
203  }
204 
205  tasks.visuTask = new SimpleRunningTask<>([this]() { this->visuRun(); }, "Visualization");
206  tasks.visuTask->start();
207  }
208 
209  void
211  {
212  }
213 
214  void
216  {
217  }
218 
219  std::string
221  {
222  return GetDefaultName();
223  }
224 
225  std::string
227  {
228  return "navigation_memory";
229  }
230 
231  void
233  {
234  using namespace armarx::RemoteGui::Client;
235 
236  // Setup the widgets.
237  tab.locationGraph.setup(*this);
238 
239  // Setup the layout.
240  VBoxLayout root = {tab.locationGraph.group, VSpacer()};
241  RemoteGui_createTab(getName(), root, &tab);
242  }
243 
244  void
246  {
247  tab.locationGraph.update(*this);
248  }
249 
250  void
252  {
253  using namespace armarx::RemoteGui::Client;
254  GridLayout grid;
255  int row = 0;
256  {
257  reloadSnapshot = Button();
258  reloadSnapshot.setLabel("Reload from Snapshot '" + owner.properties.snapshotToLoad +
259  "'");
260 
261  visuLocations.setValue(owner.properties.locationGraph.visuLocations);
262  visuGraphEdges.setValue(owner.properties.locationGraph.visuLocations);
263 
264  grid.add(reloadSnapshot, {row, 0}, {1, 2});
265  ++row;
266 
267  grid.add(Label("Visualize Locations"), {row, 0}).add(visuLocations, {row, 1});
268  ++row;
269 
270  grid.add(Label("Visualize Graph Edges"), {row, 0}).add(visuGraphEdges, {row, 1});
271  ++row;
272  }
273 
274  group = GroupBox({grid});
275  group.setLabel("Locations");
276  }
277 
278  void
280  {
281  if (reloadSnapshot.wasClicked())
282  {
283  owner.loadSnapshot();
284  }
285  if (visuLocations.hasValueChanged() or visuGraphEdges.hasValueChanged())
286  {
287  std::scoped_lock lock(owner.propertiesMutex);
288  owner.properties.locationGraph.visuLocations = visuLocations.getValue();
289  owner.properties.locationGraph.visuGraphEdges = visuGraphEdges.getValue();
290  }
291  }
292 
293  void
294  Component::visuRun()
295  {
296  memory::Visu visu{arviz,
302 
304  Properties p;
305  {
306  std::scoped_lock lock(propertiesMutex);
307  pp = properties.locationGraph;
308  p = properties;
309  }
310 
311  Metronome metronome(Frequency::HertzDouble(p.visuFrequency));
312  while (tasks.visuTask and not tasks.visuTask->isStopped())
313  {
314  ARMARX_TRACE;
315 
316  {
317  std::scoped_lock lock(propertiesMutex);
318  pp = properties.locationGraph;
319  }
320 
321  std::vector<viz::Layer> layers;
322 
323  // Locations
324  // TODO: @fabian.peller this is ugly!
325  if (properties.locationGraph.visuRelativeLocations)
326  {
327  visu.drawLocations(objClient, layers, pp.visuLocations);
328  }
329  else
330  {
331  visu.drawLocations(layers, pp.visuLocations);
332  }
333 
334  // Graph Edges
335  if (properties.locationGraph.visuRelativeLocations)
336  {
337  visu.drawGraphs(objClient, layers, pp.visuGraphEdges);
338  }
339  else
340  {
341  visu.drawGraphs(layers, pp.visuGraphEdges);
342  }
343 
344  // Costmaps
345  visu.drawCostmaps(layers, p.visuCostmaps, p.zOffsetCostmap);
346 
347  // Humans
348  visu.drawHumans(layers,
349  p.visuHumans,
350  p.visuTransparent,
351  Duration::MilliSeconds(p.visuHumanMaxAgeMs));
352  // Rooms
353  visu.drawRooms(layers, p.visuRooms);
354 
355  arviz.commit(layers);
356 
357  metronome.waitForNextTick();
358  }
359  }
360 
361  void
362  Component::loadSnapshot()
363  {
364  if (properties.snapshotToLoad.empty())
365  {
367  << "Not loading any predefined locations or graphs as the params was empty ...";
368  return;
369  }
370 
371  ARMARX_INFO << "Loading snapshots from snapshot '" << properties.snapshotToLoad
372  << "' in package '" << properties.packageToLoad << "' ...";
373 
375  properties.packageToLoad,
377 
378  if (auto graph = f.find(properties.snapshotToLoad); graph.has_value())
379  {
380  const std::string graphId = graph->getID();
381  ARMARX_DEBUG << "Found graph " << graphId << " with path: " << graph->getFullPath();
382 
383  // Sometimes, we use the date before the snapshotname.
384  // In this case a symlink to the real data should be used (e.g. R003 and 2022-03-01_R003)
385 
386  // This loads the location. All locations are stored in a single locations.json file
387  // The file contains json with the framed poses (frame, agent, 4x4 matrix)
388  {
389  std::filesystem::path locationsFilePath = graph->getFullPath() / "locations.json";
390  if (not std::filesystem::is_regular_file(locationsFilePath))
391  {
392  ARMARX_WARNING << "Found no locations file for graph '" << graphId << "'.";
393  }
394  else
395  {
396 
397  ARMARX_DEBUG << "Found the locations file";
399  armem::MemoryID providerID = workingMemory().id();
400  providerID.coreSegmentName = "Location";
401  providerID.providerSegmentName = graphId;
402 
403  const auto now = armem::Time::Now();
404  ARMARX_DEBUG << "Loading " << locationsFilePath;
405 
406  std::ifstream ifs(locationsFilePath);
407  const std::string content((std::istreambuf_iterator<char>(ifs)),
408  (std::istreambuf_iterator<char>()));
409 
410  // parse location as json. All files in Location folder must be valid json objects!
411  nlohmann::json js = nlohmann::json::parse(content);
412 
413  auto locations =
415 
416  for (const auto& location : locations)
417  {
418  // we assert that only framedLocations are allowed. Everything else will be rejected!
419  if (location->type !=
421  {
423  << "Navigation memory received location '" + location->id.name +
424  "' which is not of type "
425  "'armarx::priorknowledge::util::LocationType:"
426  ":FRAMED_LOCATION' (e.g. you specified a "
427  "FRAMED_BOXED_LOCATION?). Only FramedLocations (i.e. "
428  "poses in 3D space) are navigatable. Ignoring this location "
429  "but please check the location.json file.";
430  continue;
431  }
432 
433  auto& framedLocation =
434  dynamic_cast<armarx::priorknowledge::util::FramedLocation&>(*location);
435 
436  navigation::location::arondto::Location loc;
437 
438  // set members of loc
439  loc.framedPose.header.frame = framedLocation.frame;
440  loc.framedPose.header.agent = framedLocation.agent;
441  loc.framedPose.pose = framedLocation.pose;
442  toAron(loc.names, framedLocation.names);
443 
444  // send commit to memory
445  auto& up = c.add();
446  up.confidence = 1.0;
447  up.referencedTime = now;
448  up.sentTime = now;
449  up.arrivedTime = now;
450  up.entityID = providerID.withEntityName(framedLocation.id.name);
451  up.instancesData = {loc.toAron()};
452  }
453 
454  ARMARX_DEBUG << "Sending locations to memory";
456  }
457  }
458 
459  {
460  // Next we load the graphs. The graph folder may contain several graphs, represented by different json files.
461  // Each of those graphs contains a list of files representing the vertices. The filename is the vertice id (ideally starting at 0).
462  // The file contains a json with the corresponding location name (as path) and the adjacent vertives (representing the directed outgoing edges).
463  std::filesystem::path graphFilesPath = graph->getFullPath() / "Graph";
464 
465  if (not std::filesystem::is_directory(graphFilesPath))
466  {
467  ARMARX_INFO << "Found no `Graph/` folder for graph '" << graphId << "'.";
468  ARMARX_INFO << "Creating empty graph.";
469 
471  armem::MemoryID providerID = workingMemory().id();
473  providerID.providerSegmentName = graphId;
474 
475  const auto now = armem::Time::Now();
476 
478 
479  auto& up = c.add();
480  up.confidence = 1.0;
481  up.referencedTime = now;
482  up.arrivedTime = now;
483  up.sentTime = now;
484  up.entityID = providerID.withEntityName(properties.snapshotToLoad);
485  up.instancesData = {g.toAron()};
486 
487  ARMARX_DEBUG << "Sending empty graph `" << properties.snapshotToLoad
488  << "` to memory.";
489  iceAdapter().commit(c);
490  }
491  else
492  {
493  ARMARX_DEBUG << "Loading graphs from " << graphFilesPath;
494 
496  armem::MemoryID providerID = workingMemory().id();
498  providerID.providerSegmentName = graphId;
499 
500  const auto now = armem::Time::Now();
501 
502  for (const auto& graphFile : std::filesystem::directory_iterator(
503  graphFilesPath)) // iterate over the different graphs (json files)
504  {
505  if (std::filesystem::is_regular_file(graphFile.path()) and
506  simox::alg::ends_with(graphFile.path().filename(),
507  ".json")) // assure that its a json file
508  {
509  const std::string graphName = graphFile.path().stem();
510 
511 
512  ARMARX_DEBUG << "Loading graph `" << graphName << " `from file `"
513  << graphFile.path() << "`.";
514 
516 
517  std::ifstream ifs(graphFile.path());
518  const std::string content((std::istreambuf_iterator<char>(ifs)),
519  (std::istreambuf_iterator<char>()));
520 
521  // TODO: Perhaps move to PriorKnowledge similar to locations
522  const nlohmann::json j = nlohmann::json::parse(content);
523 
524  const auto& jEdges = j.at("edges");
525  const auto& jVertices = j.at("vertices");
526 
527  for (const auto& jVertex : jVertices)
528  {
529  const armarx::armem::MemoryID vertexLocationMemoryId(
530  jVertex.at("locationID"));
531 
532  armarx::navigation::core::arondto::Vertex v;
533  v.vertexID = jVertex.at("vertexID");
534  toAron(v.locationID, vertexLocationMemoryId);
535  toAron(v.locationID.timestamp, armem::Time::Invalid());
536  v.locationID.instanceIndex = 0;
537 
538  g.vertices.push_back(v);
539  }
540 
541  for (const auto& jEdge : jEdges)
542  {
543  std::pair<std::int64_t, std::int64_t> edgeSourceTargetPair;
544  jEdge.get_to(edgeSourceTargetPair);
545 
546  armarx::navigation::core::arondto::Edge e;
547  e.sourceVertexID = edgeSourceTargetPair.first;
548  e.targetVertexID = edgeSourceTargetPair.second;
549  g.edges.push_back(e);
550  }
551 
552  auto& up = c.add();
553  up.confidence = 1.0;
554  up.referencedTime = now;
555  up.arrivedTime = now;
556  up.sentTime = now;
557  up.entityID = providerID.withEntityName(graphName);
558  up.instancesData = {g.toAron()};
559  }
560  }
561 
562  ARMARX_DEBUG << "Sending graphs to memory";
563  iceAdapter().commit(c);
564  }
565  }
566 
567  {
568  // Next we load the rooms.
569  std::filesystem::path roomsFilePath = graph->getFullPath() / "rooms.json";
570  if (not std::filesystem::is_regular_file(roomsFilePath))
571  {
572  ARMARX_INFO << "Found no rooms file for graph '" << graphId << "'.";
573  }
574  else
575  {
576  ARMARX_DEBUG << "Found the rooms file";
577 
579  armem::MemoryID providerID = workingMemory().id();
581  providerID.providerSegmentName = graphId;
582 
583  const auto now = armem::Time::Now();
584  ARMARX_VERBOSE << "Loading " << roomsFilePath;
585 
586  std::ifstream ifs(roomsFilePath);
587  const std::string content((std::istreambuf_iterator<char>(ifs)),
588  (std::istreambuf_iterator<char>()));
589 
590  // parse room. TODO: Move into PriorKnowledge similar to locations
591  const nlohmann::json js = nlohmann::json::parse(content);
592 
593  const auto rooms = js.at("rooms").get<std::map<std::string, nlohmann::json>>();
594  ARMARX_INFO << "Found " << rooms.size() << " rooms.";
595  for (const auto& [roomId, j] : rooms)
596  {
597  auto roomMemoryId = providerID;
598  roomMemoryId.entityName = roomId;
599 
600  const std::string roomMemoryIdStr = roomMemoryId.str();
601 
602  if (j.find("polygon") == j.end())
603  {
604  ARMARX_WARNING << "The element '" << roomMemoryIdStr
605  << "' has no 'polygon' member. Skipping "
606  "this entity.";
607  continue;
608  }
609 
610  if (j.find("height") == j.end())
611  {
612  ARMARX_WARNING << "The element '" << roomMemoryIdStr
613  << "' has no 'height' member. "
614  "Skipping this entity.";
615  continue;
616  }
617 
618  navigation::rooms::arondto::Room room;
619  j.at("polygon").get_to(room.polygon);
620  j.at("height").get_to(room.height);
621  room.name = roomId;
622 
623  // set the polygon to z=0
624  for (auto& point : room.polygon)
625  {
626  point.z() = 0;
627  }
628 
629  // send commit to memory
630  auto& up = c.add();
631  up.confidence = 1.0;
632  up.referencedTime = now;
633  up.sentTime = now;
634  up.arrivedTime = now;
635  up.entityID = armarx::armem::MemoryID(roomMemoryIdStr);
636  up.instancesData = {room.toAron()};
637  }
638 
639  ARMARX_DEBUG << "Sending rooms to memory";
640  iceAdapter().commit(c);
641  }
642  }
643  ARMARX_INFO << "Loaded NavigationMemory '" << properties.snapshotToLoad
644  << "' --> graph: '" << graphId << "'";
645  }
646  else
647  {
648  ARMARX_WARNING << "Could not load NavigationMemory '" << properties.snapshotToLoad
649  << "'. Continue with empty memory.";
650  }
651  }
652 
653  bool
654  store(const std::map<armem::MemoryID, core::Graph>& graphs,
655  const std::filesystem::path& baseDirectory)
656  {
657  ARMARX_INFO << "Creating export directory `" << baseDirectory << "`.";
658  std::filesystem::create_directories(baseDirectory);
659 
660  for (const auto& [memoryId, graph] : graphs)
661  {
662  const std::filesystem::path nestedSubDir =
663  std::filesystem::path(memoryId.providerSegmentName) / memoryId.coreSegmentName;
664  const std::filesystem::path dir = baseDirectory / nestedSubDir;
665 
666  std::filesystem::create_directories(dir);
667 
668  nlohmann::json j;
669 
670  // source -> target
671  std::vector<std::pair<std::size_t, std::size_t>> outgoingEdges;
672  std::transform(graph.m_edges.begin(),
673  graph.m_edges.end(),
674  std::back_inserter(outgoingEdges),
675  [](const auto& edge)
676  { return std::make_pair(edge.m_source, edge.m_target); });
677 
678  j["edges"] = outgoingEdges;
679  j["vertices"] = {};
680 
681  for (const auto& vertex : graph.m_vertices)
682  {
683 
684  armarx::armem::MemoryID locationId;
685  fromAron(vertex.m_property.aron.locationID, locationId);
686 
687  nlohmann::json jVertex;
688  jVertex["locationID"] = locationId.getEntityID().str();
689  jVertex["vertexID"] = vertex.m_property.aron.vertexID;
690 
691  j["vertices"].push_back(jVertex);
692  }
693 
694  // save to disk
695  const std::filesystem::path filename = dir / (memoryId.entityName + ".json");
696  ARMARX_VERBOSE << "Saving file `" << filename << "`.";
697  std::ofstream ofs(filename);
698  ofs << std::setw(4) << j;
699  }
700 
701  return true;
702  }
703 
704  bool
705  store(const std::map<armem::MemoryID, location::arondto::Location>& locations,
706  const std::filesystem::path& baseDirectory)
707  {
708  ARMARX_INFO << "Creating export directory `" << baseDirectory << "`.";
709  std::filesystem::create_directories(baseDirectory);
710 
711  // key: provider id
712  std::map<std::string, nlohmann::json> js;
713 
714  for (const auto& [memoryId, location] : locations)
715  {
716  auto& j = js[memoryId.providerSegmentName];
717 
718  if (j.count("locations") == 0)
719  {
720  j["locations"] = {};
721  }
722 
723  nlohmann::json jLoc;
724  nlohmann::json framedPose;
725 
726  framedPose["agent"] = location.framedPose.header.agent;
727  framedPose["frame"] = location.framedPose.header.frame;
728 
729  // utilize ice conversion of eigen
730  std::vector<std::vector<float>> poseAsVec;
731  armarx::core::eigen::toIce(location.framedPose.pose, poseAsVec);
732  framedPose["pose"] = poseAsVec;
733 
734  jLoc["framedPose"] = framedPose;
735 
736  auto entityId = memoryId.getEntityID();
737  j["locations"][entityId.providerSegmentName + "/" + entityId.entityName] = jLoc;
738  }
739 
740  // save to disk
741  for (const auto& [providerId, j] : js)
742  {
743  const std::filesystem::path subDir = std::filesystem::path(providerId);
744  const std::filesystem::path dir = baseDirectory / subDir;
745 
746  if (not std::filesystem::exists(dir))
747  {
748  std::filesystem::create_directories(dir);
749  }
750 
751  const std::filesystem::path filename = dir / "locations.json";
752  ARMARX_VERBOSE << "Saving file `" << filename << "`.";
753  std::ofstream ofs(filename);
754  ofs << std::setw(4) << j;
755  }
756 
757 
758  return true;
759  }
760 
761  bool
762  Component::storeLocationGraph(const armarx::data::PackagePath& packagePath,
763  const Ice::Current& current)
764  {
765  armem::server::wm::CoreSegment& locationCoreSegment =
767  armem::server::wm::CoreSegment& graphCoreSegment =
769 
770  // obtain locations and graphs
771 
772  const std::map<armem::MemoryID, location::arondto::Location> locations =
773  [&locationCoreSegment]()
774  {
775  std::map<armem::MemoryID, location::arondto::Location> locations;
776  locationCoreSegment.doLocked(
777  [&]()
778  {
779  locationCoreSegment.forEachEntity(
780  [&](const armarx::armem::server::wm::Entity& entity) -> bool
781  {
782  if (const armarx::armem::server::wm::EntityInstance* instance =
783  entity.findLatestInstance())
784  {
785  locations[entity.id()].fromAron(instance->data());
786  }
787 
788  return true;
789  });
790 
791  return true;
792  });
793 
794  return locations;
795  }();
796 
797  const auto graphs = [&graphCoreSegment]()
798  {
799  std::map<armem::MemoryID, core::Graph> graphs;
800  graphCoreSegment.doLocked(
801  [&]()
802  {
803  graphCoreSegment.forEachEntity(
804  [&](const armarx::armem::server::wm::Entity& entity) -> bool
805  {
806  core::Graph& graph = graphs[entity.id()];
807  if (const armarx::armem::server::wm::EntityInstance* instance =
808  entity.findLatestInstance())
809  {
811  aron.fromAron(instance->data());
812  fromAron(aron, graph);
813  }
814 
815  return true;
816  });
817  });
818 
819  return graphs;
820  }();
821 
822 
823  // store on disk
824 
825  const std::filesystem::path baseDirectory = armarx::PackagePath(packagePath).toSystemPath();
826 
827  store(locations, baseDirectory);
828  store(graphs, baseDirectory);
829 
830  return true;
831  }
832 
833 
834 } // namespace armarx::navigation::components::navigation_memory
Visu.h
armarx::SimpleRunningTask
Usage:
Definition: TaskUtil.h:70
armarx::viz::Client::commit
CommitResult commit(StagedCommit const &commit)
Definition: Client.cpp:80
armarx::navigation::graph::coreSegmentID
const armem::MemoryID coreSegmentID
Definition: constants.h:30
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::navigation::components::navigation_memory::Component::Properties::LocationGraph
Definition: Component.h:109
armarx::navigation::components::navigation_memory::Component::storeLocationGraph
bool storeLocationGraph(const armarx::data::PackagePath &packagePath, const Ice::Current &current) override
Definition: Component.cpp:762
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::navigation::memory::constants::CostmapCoreSegmentName
const std::string CostmapCoreSegmentName
Definition: constants.h:34
armarx::armem::MemoryID::providerSegmentName
std::string providerSegmentName
Definition: MemoryID.h:52
query.h
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition: memory_definitions.h:32
armarx::priorknowledge::util::FramedLocation::frame
std::string frame
Definition: Location.h:50
armarx::RemoteGui::Client::VBoxLayout
Definition: Widgets.h:167
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::navigation::components::navigation_memory::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:72
armarx::navigation::rooms::coreSegmentID
const armem::MemoryID coreSegmentID
Definition: constants.h:10
MemoryID.h
armarx::armem::base::MemoryBase::getCoreSegment
CoreSegmentT & getCoreSegment(const std::string &name)
Definition: MemoryBase.h:132
armarx::navigation::components::navigation_memory::Component::RemoteGui_update
void RemoteGui_update() override
Definition: Component.cpp:245
armarx::RemoteGui::Client::GridLayout::add
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
Definition: Widgets.cpp:412
constants.h
ice_conversions.h
armarx::armem::MemoryID::str
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition: MemoryID.cpp:102
armarx::navigation::components::navigation_memory::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:215
armarx::navigation::components::navigation_memory::Component
Definition: Component.h:54
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::navigation::components::navigation_memory::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:210
aron_conversions.h
armarx::armem::server::wm::Entity
Definition: memory_definitions.h:30
armarx::armem::server::plugins::ReadWritePluginUser::workingMemory
server::wm::Memory & workingMemory()
Definition: ReadWritePluginUser.cpp:106
armarx::armem::MemoryID::coreSegmentName
std::string coreSegmentName
Definition: MemoryID.h:51
armarx::RemoteGui::Client::VSpacer
Definition: Widgets.h:204
armarx::armem::base::detail::ForEachEntityMixin::forEachEntity
bool forEachEntity(FunctionT &&func)
Definition: iteration_mixins.h:258
armarx::navigation::components::navigation_memory::ARMARX_REGISTER_COMPONENT_EXECUTABLE
ARMARX_REGISTER_COMPONENT_EXECUTABLE(Component, Component::GetDefaultName())
constants.h
Costmap.h
armarx::navigation::components::navigation_memory::store
bool store(const std::map< armem::MemoryID, core::Graph > &graphs, const std::filesystem::path &baseDirectory)
Definition: Component.cpp:654
armarx::navigation::components::navigation_memory::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:141
memory_definitions.h
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
LocationLoader.h
armarx::navigation::memory::Visu
Definition: Visu.h:45
armarx::RemoteGui::Client::GridLayout
Definition: Widgets.h:186
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::navigation::components::navigation_memory::Component::Component
Component()
Definition: Component.cpp:135
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::PackagePath::toSystemPath
static std::filesystem::path toSystemPath(const data::PackagePath &pp)
Definition: PackagePath.cpp:54
Memory.h
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::navigation::core::Graph
Definition: Graph.h:88
armarx::core::time::Frequency::HertzDouble
static Frequency HertzDouble(double hertz)
Definition: Frequency.cpp:34
armarx::navigation::components::navigation_memory
Definition: Component.cpp:66
armarx::RemoteGui::Client::GroupBox
Definition: Widgets.h:193
armarx::navigation::components::navigation_memory::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:220
filename
std::string filename
Definition: VisualizationRobot.cpp:84
armarx::navigation::memory::constants::GraphCoreSegmentName
const std::string GraphCoreSegmentName
Definition: constants.h:32
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
Metronome.h
armarx::armem::server::plugins::ReadWritePluginUser::iceAdapter
MemoryToIceAdapter & iceAdapter()
Definition: ReadWritePluginUser.cpp:112
armarx::Graph
boost::subgraph< CloudGraph > Graph
Definition: Common.h:54
armarx::armem::base::EntityBase::findLatestInstance
auto * findLatestInstance(int instanceIndex=0)
Definition: EntityBase.h:355
operations.h
armarx::core::eigen::toIce
void toIce(const Eigen::Vector2f &e, Ice::FloatSeq &ice)
Definition: ice_conversions.cpp:17
armarx::armem::base::detail::MemoryItem::id
MemoryID & id()
Definition: MemoryItem.h:27
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition: memory_definitions.h:112
armarx::armem::MemoryID::entityName
std::string entityName
Definition: MemoryID.h:53
armarx::navigation::memory::constants::HumanCoreSegmentName
const std::string HumanCoreSegmentName
Definition: constants.h:35
aron_conversions.h
forward_declarations.h
armarx::RemoteGui::Client::GroupBox::setLabel
void setLabel(std::string const &text)
Definition: Widgets.cpp:395
Component.h
aron_conversions.h
armarx::LightweightRemoteGuiComponentPluginUser::RemoteGui_startRunningTask
void RemoteGui_startRunningTask()
Definition: LightweightRemoteGuiComponentPlugin.cpp:110
CycleUtil.h
armarx::armem::server::wm::CoreSegment
base::CoreSegmentBase
Definition: memory_definitions.h:86
armarx::priorknowledge::util::FramedLocation
Definition: Location.h:48
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
Decoupled.h
armarx::navigation::components::navigation_memory::Component::RemoteGuiTab::LocationGraph::update
void update(Component &owner)
Definition: Component.cpp:279
armarx::armem::MemoryID::getEntityID
MemoryID getEntityID() const
Definition: MemoryID.cpp:305
Graph.h
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::armem::MemoryID::withEntityName
MemoryID withEntityName(const std::string &name) const
Definition: MemoryID.cpp:420
armarx::navigation::components::navigation_memory::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:191
armarx::priorknowledge::util::LocationLoader::LoadLocations
static std::vector< LocationPtr > LoadLocations(const std::string &dataset, const nlohmann::json &)
Definition: LocationLoader.cpp:143
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ArVizComponentPluginUser::arviz
armarx::viz::Client arviz
Definition: ArVizComponentPlugin.h:43
armarx::navigation::components::navigation_memory::Component::GetDefaultName
static std::string GetDefaultName()
Definition: Component.cpp:226
armarx::LightweightRemoteGuiComponentPluginUser::RemoteGui_createTab
void RemoteGui_createTab(std::string const &name, RemoteGui::Client::Widget const &rootWidget, RemoteGui::Client::Tab *tab)
Definition: LightweightRemoteGuiComponentPlugin.cpp:95
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::core::time::Metronome
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
Definition: Metronome.h:35
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:315
NavigationGraphFinder.h
armarx::ends_with
bool ends_with(const std::string &haystack, const std::string &needle)
Definition: StringHelpers.cpp:50
armarx::priorknowledge::navigation_graphs::NavigationGraphFinder::DEFAULT_DIR_TO_IDS
static const constexpr auto DEFAULT_DIR_TO_IDS
Definition: NavigationGraphFinder.h:12
armarx::fromAron
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
armarx::navigation::memory::constants::ParameterizationCoreSegmentName
const std::string ParameterizationCoreSegmentName
Definition: constants.h:30
constants.h
armarx::navigation::location::coreSegmentID
const armem::MemoryID coreSegmentID
Definition: constants.h:30
armarx::ManagedIceObject::getName
std::string getName() const
Retrieve name of object.
Definition: ManagedIceObject.cpp:107
armarx::RemoteGui::Client::Button
Definition: Widgets.h:120
armarx::toAron
void toAron(arondto::PackagePath &dto, const PackageFileLocation &bo)
armarx::ObjectPoseClientPluginUser::getClient
objpose::ObjectPoseClient getClient() const
Definition: ObjectPoseClientPlugin.cpp:64
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::priorknowledge::navigation_graphs::NavigationGraphFinder
Definition: NavigationGraphFinder.h:7
armarx::RemoteGui::Client
Definition: EigenWidgets.cpp:8
ArmarXDataPath.h
armarx::PackagePath
Definition: PackagePath.h:55
armarx::priorknowledge::util::LocationType::FRAMED_LOCATION
@ FRAMED_LOCATION
armarx::navigation::components::navigation_memory::Component::createRemoteGuiTab
void createRemoteGuiTab()
Definition: Component.cpp:232
armarx::navigation::components::navigation_memory::Component::Properties::LocationGraph::visuGraphEdges
bool visuGraphEdges
Definition: Component.h:112
armarx::navigation::memory::constants::LaserScannerFeaturesCoreSegment
const std::string LaserScannerFeaturesCoreSegment
Definition: constants.h:36
armarx::core::time::DateTime::Invalid
static DateTime Invalid()
Definition: DateTime.cpp:60
armarx::armem::base::MemoryBase::setName
void setName(const std::string &name)
Definition: MemoryBase.h:246
armarx::armem::server::MemoryToIceAdapter::commitLocking
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:163
armarx::armem::server::MemoryToIceAdapter::commit
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:112
armarx::core::time::Duration::MilliSeconds
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition: Duration.cpp:55
armarx::navigation::components::navigation_memory::Component::RemoteGuiTab::LocationGraph::setup
void setup(Component &owner)
Definition: Component.cpp:251
constants.h
armarx::navigation::components::navigation_memory::Component::Properties::LocationGraph::visuLocations
bool visuLocations
Definition: Component.h:111
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29