4
* Parser for <config.xml> file which contains the configuration for the Robot3D
5
* robot simulator. In the WITH_MOTES modus it can be used for simulating a WSN.
7
* Created on: Nov 25, 2008
13
#include <xercesc/dom/DOM.hpp>
14
#include <xercesc/dom/DOMDocument.hpp>
15
#include <xercesc/dom/DOMDocumentType.hpp>
16
#include <xercesc/dom/DOMElement.hpp>
17
#include <xercesc/dom/DOMImplementation.hpp>
18
#include <xercesc/dom/DOMImplementationLS.hpp>
19
#include <xercesc/dom/DOMNodeIterator.hpp>
20
#include <xercesc/dom/DOMNodeList.hpp>
21
#include <xercesc/dom/DOMText.hpp>
23
#include <xercesc/parsers/XercesDOMParser.hpp>
24
#include <xercesc/util/XMLUni.hpp>
26
#include <osg/Geometry>
29
#include <dtUtil/matrixutil.h>
30
#include <srCore/organismTree.h>
55
osg::Vec3f orientation;
57
osg::Vec2f resolution;
62
//make class for that to make sure releasing all the stuff:
71
std::vector<float> jointAngles;
72
std::vector<SensorInitData> sensors;
75
struct ControllerInitData
82
#ifdef WITH_CONFIG_PARAMS
83
std::map<std::string, std::string> paramMap;
92
ControllerInitData controller;
95
struct OrganismInitData
100
std::vector<Terminal> terminals;
105
* A struct that stores name and path of plugins that can be loaded by Robot3D.
107
struct PluginInitData
113
//! Class for reading and parsing the scene file
114
class ROBOT_EXPORT GetConfig
117
// static GetConfig* Instance() {
119
// m_pInstance = new GetConfig();
120
// return m_pInstance;
124
void readConfigFile(std::string) throw(std::runtime_error);
126
std::vector<RobotInitData> getRobots() const {return robots;};
127
std::vector<ControllerInitData> getControllers() const {return controllers;};
128
std::vector<PluginInitData> getPlugins() const {return plugins;};
130
char* getMap() const {return map;};
132
bool getWithShadows() const {return withShadows;};
133
bool getWithDetailedModels() const {return withDetailedModels;};
134
bool getConnectorsAsJoints() const {return connectorsAsJoints;};
135
bool getRobotsWithWheels() const {return withWheels;};
136
int getCollisionGeometryDetails() const {return collisionGeometryDetails;};
138
// char *getOptionA() { return m_OptionA; };
139
// char *getOptionB() { return m_OptionB; };
143
// static GetConfig* m_pInstance;
145
void structureParser(char* structure);
146
void processOrganismString(); // throw(std::runtime_error);
147
void computePosQuat(std::string type, std::string lastType, int robot, int si, int lastSide, int rot, osg::Vec3f &pos, osg::Quat &quat);
148
std::vector<osg::Matrix> getSideMatrix(float d);
150
xercesc::XercesDOMParser *m_ConfigFileParser;
151
bool withShadows, withDetailedModels, connectorsAsJoints, withWheels;
152
int collisionGeometryDetails;
155
OrganismInitData organism;
156
std::vector<RobotInitData> robots;
157
std::vector<ControllerInitData> controllers;
158
std::vector<PluginInitData> plugins;
160
// Internal class use only. Hold Xerces data in UTF-16 SMLCh type.
163
XMLCh* ATTR_activateShadows;
164
XMLCh* ATTR_loadDetailedModels;
165
XMLCh* ATTR_connectorsAsJoints;
166
XMLCh* ATTR_withWheels;
167
XMLCh* ATTR_collisionDetails;
169
XMLCh* ATTR_enableAudio;
173
XMLCh* ATTR_moteName;
174
XMLCh* ATTR_moteType;
178
XMLCh* ATTR_org_structure;
185
XMLCh* ATTR_org_quat_x;
186
XMLCh* ATTR_org_quat_y;
187
XMLCh* ATTR_org_quat_z;
188
XMLCh* ATTR_org_quat_w;
195
XMLCh* ATTR_robotName;
196
XMLCh* ATTR_robotType;
203
XMLCh* ATTR_connected;
208
XMLCh* ATTR_sensorName;
209
XMLCh* ATTR_sensorType;
210
XMLCh* ATTR_position_x;
211
XMLCh* ATTR_position_y;
212
XMLCh* ATTR_position_z;
213
XMLCh* ATTR_orientation_x;
214
XMLCh* ATTR_orientation_y;
215
XMLCh* ATTR_orientation_z;
216
XMLCh* ATTR_apertureAngle;
217
XMLCh* ATTR_resolution_x;
218
XMLCh* ATTR_resolution_y;
219
XMLCh* ATTR_bodyPart;
221
XMLCh* TAG_controller;
222
XMLCh* ATTR_controllerName;
223
XMLCh* ATTR_controllerType;
224
XMLCh* ATTR_robotToControl;
225
XMLCh* ATTR_controllerParameter;
228
XMLCh* ATTR_pluginName;
229
XMLCh* ATTR_pluginPath;
235
#endif /* XMLPARSER_H_ */