25 #include <unordered_set>
42 def->component(proxies.commonStorage);
43 def->component(proxies.priorKnowledge);
44 def->component(proxies.workingMemory);
45 def->component(proxies.longtermMemory);
47 def->optional(properties.mongoDbName,
"p.MongoDbName",
48 "Name of snapshot Mongo database to load files into");
49 def->optional(properties.dryRun,
"p.dryRun",
50 "If true, don't actually change anything.");
53 def->optional(properties.importObjects,
"p.obj.00_DoImport",
54 "Whether to import objects.");
56 def->optional(properties.objectsRepository,
"p.obj.10_Repository",
57 "Repository such as ArmarXObjects containing the object classes.");
59 def->optional(properties.datasetName,
"p.obj.20_DatasetName",
60 "If set, only the given dataset in ArmarXObjects is imported.\n"
61 "Otherwise (default), all objects are imported.");
62 def->optional(properties.className,
"p.obj.21_ClassName",
63 "If set, only the given dataset in ArmarXObjects is imported.\n"
64 "Otherwise (default), all objects are imported.");
67 def->optional(properties.importScenes,
"p.scenes.00_DoImport",
68 "Whether to import scenes.");
69 def->optional(properties.scenesDirectory,
"p.scenes.10_Directory",
70 "Directory containing the scene files (Scene_*.json).");
71 def->optional(properties.sceneNames,
"p.scenes.20_Scenes",
72 "Scenes to load by name. Comma separated. ({scene_name}.json).");
87 memoryx::PersistentObjectClassSegmentBasePrx objectClassesSegment =
88 proxies.priorKnowledge->getObjectClassesSegment();
92 importer.
dryRun = properties.dryRun;
94 if (properties.dryRun)
99 if (properties.importObjects)
102 std::vector<armarx::ObjectInfo> objectInfos;
103 if (properties.datasetName.size() > 0)
105 if (properties.className.size() > 0)
107 ARMARX_INFO <<
"Finding " << properties.datasetName << properties.className <<
"...";
108 if (
auto info = finder.
findObject(properties.datasetName, properties.className))
110 objectInfos.push_back(info.value());
115 ARMARX_INFO <<
"Finding objects in dataset " << properties.datasetName <<
" ...";
124 ARMARX_INFO <<
"Found " << objectInfos.size() <<
" object classes in " << properties.objectsRepository <<
".";
126 ARMARX_INFO <<
"Importing " << objectInfos.size() <<
" object classes ...";
128 objectInfos, gridFileManager, objectClassesSegment, properties.mongoDbName);
131 if (properties.importScenes)
134 std::unordered_set<std::string> scenes;
135 if (not properties.sceneNames.empty())
137 bool trim =
true, removeEmpty =
true;
138 const auto scenesTmp =
armarx::split(properties.sceneNames,
",", trim, removeEmpty);
140 scenes = std::unordered_set<std::string> (scenesTmp.begin(), scenesTmp.end());
143 if (not scenes.empty())
145 ARMARX_INFO <<
"The following scenes will be loaded (if available): " << std::vector<std::string>(scenes.begin(), scenes.end());
148 ARMARX_INFO <<
"Importing scenes in " << scenesDir;
150 scenesDir, proxies.longtermMemory, proxies.workingMemory, objectClassesSegment, scenes);
167 return "ArmarXObjectsImporter";
170 ArmarXObjectsImporter::Properties::Properties() :
171 objectsRepository(
armarx::ObjectFinder::DefaultObjectsPackageName),
172 scenesDirectory(
armarx::ObjectFinder::DefaultObjectsPackageName +
"/scenes")