|
Hormodular 1.0
Locomotion gait discovery by using digital hormones on modular robots
|
00001 //------------------------------------------------------------------------------ 00002 //-- ConfigParser 00003 //------------------------------------------------------------------------------ 00004 //-- 00005 //-- Reads the configuration file and gets the main parameters 00006 //-- 00007 //------------------------------------------------------------------------------ 00008 //-- 00009 //-- This file belongs to the Hormodular project 00010 //-- (https://github.com/David-Estevez/hormodular.git) 00011 //-- 00012 //------------------------------------------------------------------------------ 00013 //-- Author: David Estevez-Fernandez 00014 //-- 00015 //-- Released under the GPL license (more info on LICENSE.txt file) 00016 //------------------------------------------------------------------------------ 00017 00024 #ifndef CONFIGPARSER_H 00025 #define CONFIGPARSER_H 00026 00027 #include <iostream> 00028 #include <string> 00029 #include <cstring> 00030 #include <vector> 00031 #include <algorithm> 00032 #include <tinyxml2.h> 00033 #include "Orientation.hpp" 00034 00035 namespace hormodular { 00036 00037 enum ModuleFunction { ModuleFunction_none = -1, 00038 ModuleFunction_limb = 0, 00039 ModuleFunction_thorax = 1, 00040 ModuleFunction_coxa = 2 }; 00041 00046 class ConfigParser 00047 { 00048 public: 00049 ConfigParser(); 00050 00056 int parse(const std::string& filepath); 00057 00058 std::string getRobotName(); 00059 std::string getSimulationFile(); 00060 std::string getGaitTableFolder(); 00061 std::string getFrequencyTableFile(); 00062 std::string getSerialPort(); 00063 int getNumModules(); 00064 int getJointID(const int& module); 00065 std::vector<int> getJointIDs(); 00066 std::vector< std::vector<int> > getConnectorInfo(int moduleIndex); 00067 std::vector<Orientation> getOrientations(); 00068 00069 //-- Error constants 00070 static const int FILE_NOT_OPENED = -1; 00071 static const int FILE_XML_ERROR = -2; 00072 static const int TAG_NOT_FOUND = -3; 00073 00074 //-- Deprecated functions: 00076 std::vector<ModuleFunction> getFunctionIDs(); 00078 std::vector<int> getDepthIDs(); 00080 std::vector<unsigned long> getShapeIDs(); 00082 std::vector<int> getNumLimbsIDs(); 00084 std::vector<int> getLimbsIDs(); 00085 00086 private: 00087 00089 void clearData(); 00090 00097 bool removeBadCharacters(std::string& string); 00098 00099 std::string robotName; 00100 std::string simulationFile; 00101 std::string gaitTableFolder; 00102 std::string frequencyTableFile; 00103 std::string serialPort; 00104 int numModules; 00105 std::vector<int> jointIDs; 00106 std::vector< std::vector< std::vector<int> > > connector_info_vector; 00107 std::vector<Orientation> orientation_vector; 00108 00109 //-- Deprecated variables 00111 std::vector<ModuleFunction> id_function_vector; 00113 std::vector<int> id_depth_vector; 00115 std::vector<unsigned long> id_shape_vector; 00117 std::vector<int> id_num_limbs_vector; 00119 std::vector<int> id_limbs_vector; 00120 00121 }; 00122 } 00123 00124 00125 #endif // CONFIGPARSER_H
1.7.4