XMLSceneImporter.h
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 MemoryX::XMLSceneImporter
17 * @author (kozlov at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
29 
30 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
31 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
32 
33 namespace memoryx
34 {
36  {
40  };
41 
44  {
45  public:
48  {
49  defineRequiredProperty<std::string>("SceneFile", "Name of scene XML file to import")
50  .setCaseInsensitive(true);
51  defineRequiredProperty<std::string>("SnapshotName", "Name of snapshot (=MongoDB collection) to load objects to")
52  .setCaseInsensitive(true);
53  defineOptionalProperty<LengthUnit>("TargetLengthUnit", eMETER, "Length unit to convert into (M, CM or MM)")
54  .setCaseInsensitive(false)
55  .map("M", eMETER)
56  .map("CM", eCENTIMETER)
57  .map("MM", eMILLIMETER);
58  }
59  };
60 
95  virtual public armarx::Component
96  {
97  public:
98  // inherited from Component
99  std::string getDefaultName() const override
100  {
101  return "XMLSceneImporter";
102  }
103  void onInitComponent() override;
104  void onConnectComponent() override;
105 
110  {
111  return armarx::PropertyDefinitionsPtr(new XMLSceneImporterPropertyDefinitions(getConfigIdentifier()));
112  }
113 
114  private:
115  WorkingMemoryInterfacePrx memoryPrx;
116  ObjectInstanceMemorySegmentBasePrx objectInstancesMemoryPrx;
117  LongtermMemoryInterfacePrx longtermMemoryPrx;
118 
119  LengthUnit targetUnit;
120 
125  void importXMLSnapshot(const std::string& fileName);
131  ObjectInstanceBasePtr createObjectInstanceFromXML(rapidxml::xml_node<>* xmlNode);
132 
138  armarx::FramedPositionBasePtr positionFromXML(rapidxml::xml_node<>* xmlNode);
139 
146  float scaleFactorFromPositionXML(rapidxml::xml_node<>* positionNode);
147 
153  armarx::FramedOrientationBasePtr orientationFromXML(rapidxml::xml_node<>* xmlNode);
154  };
155 
156 }
157 
Pose.h
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
memoryx::XMLSceneImporterPropertyDefinitions
Definition: XMLSceneImporter.h:42
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::eCENTIMETER
@ eCENTIMETER
Definition: XMLSceneImporter.h:38
memoryx::eMILLIMETER
@ eMILLIMETER
Definition: XMLSceneImporter.h:39
memoryx::LengthUnit
LengthUnit
Definition: XMLSceneImporter.h:35
memoryx::XMLSceneImporterPropertyDefinitions::XMLSceneImporterPropertyDefinitions
XMLSceneImporterPropertyDefinitions(std::string prefix)
Definition: XMLSceneImporter.h:46
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::XMLSceneImporter
The XMLSceneImporter class reads scene specification files and creates a snapshot with the specified ...
Definition: XMLSceneImporter.h:94
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
memoryx::XMLSceneImporter::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: XMLSceneImporter.h:109
rapidxml::xml_node
Class representing a node of XML document.
Definition: rapidxml.hpp:138
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
memoryx::eMETER
@ eMETER
Definition: XMLSceneImporter.h:37
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
rapidxml.hpp
memoryx::XMLSceneImporter::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: XMLSceneImporter.h:99
ImportExportComponent.h