BridgeConf.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * National Institute of Advanced Industrial Science and Technology (AIST)
00008  * General Robotix Inc. 
00009  */
00015 #ifndef OPENHRP_BRIDGE_CONF_H_INCLUDED
00016 #define OPENHRP_BRIDGE_CONF_H_INCLUDED
00017 
00018 #if ( defined ( WIN32 ) || defined ( _WIN32 ) || defined(__WIN32__) || defined(__NT__) )
00019 #define SUFFIX_SHARED_EXT   ".dll"
00020 #elif defined(__APPLE__)
00021 #define SUFFIX_SHARED_EXT   ".dylib"
00022 #else
00023 #define SUFFIX_SHARED_EXT   ".so"
00024 #endif
00025 
00026 #include <map>
00027 #include <list>
00028 #include <vector>
00029 #include <string>
00030 #include <boost/program_options.hpp>
00031 #include <rtm/Manager.h>
00032 #include <rtm/RTObject.h>
00033 
00034 enum DataTypeId {
00035     INVALID_DATA_TYPE = 0,
00036     JOINT_VALUE,
00037     JOINT_VELOCITY,
00038     JOINT_ACCELERATION,
00039     JOINT_TORQUE,
00040     EXTERNAL_FORCE,
00041     ABS_TRANSFORM,
00042     ABS_VELOCITY,
00043     ABS_ACCELERATION,
00044     FORCE_SENSOR,
00045     RATE_GYRO_SENSOR,
00046     ACCELERATION_SENSOR,
00047     COLOR_IMAGE,
00048     GRAYSCALE_IMAGE,
00049     DEPTH_IMAGE,
00050     RANGE_SENSOR,
00051     CONSTRAINT_FORCE,
00052     RATE_GYRO_SENSOR2,
00053     ACCELERATION_SENSOR2,
00054     ABS_TRANSFORM2,
00055 };
00056 
00057 struct PortInfo {
00058     std::string portName;
00059     DataTypeId dataTypeId;
00060     std::vector<std::string> dataOwnerName; // link name or sensor name
00061     int dataOwnerId;           // sensor id
00062     double stepTime;
00063 };
00064     
00065 typedef std::map<std::string, PortInfo> PortInfoMap;
00066     
00067 
00068 struct PortConnection {
00069     std::string robotPortName;
00070     std::string controllerInstanceName;
00071     std::string controllerPortName;
00072 };
00073 typedef std::vector<PortConnection> PortConnectionList;
00074     
00075     
00076 struct ModuleInfo {
00077     std::string fileName;
00078     std::string componentName;
00079     std::string initFuncName;
00080     bool isLoaded;
00081     RTC::RtcBase* rtcServant;
00082 };
00083 typedef std::list<ModuleInfo> ModuleInfoList;
00084     
00085 typedef std::map<std::string, double> TimeRateMap;
00086 
00087 class BridgeConf
00088 {
00089     BridgeConf(int argc, char* argv[]);
00090       
00091 public:
00092       
00093     static BridgeConf* initialize(int argc, char* argv[]);
00094     static BridgeConf* instance();
00095       
00096     ~BridgeConf();
00097 
00098     bool isReady() { return isReady_; }
00099       
00100     const char* getOpenHRPNameServerIdentifier();
00101     const char* getControllerName();
00102     const char* getVirtualRobotRtcTypeName();
00103 
00104     void setupModules();
00105 
00106     typedef std::map<std::string, DataTypeId> LabelToDataTypeIdMap;
00107     LabelToDataTypeIdMap labelToDataTypeIdMap;
00108       
00109     PortInfoMap outPortInfos;
00110     PortInfoMap inPortInfos;
00111       
00112     ModuleInfoList moduleInfoList;
00113 
00114     PortConnectionList portConnections;
00115         
00116         TimeRateMap timeRateMap;
00117 
00118 private:
00119       
00120     boost::program_options::variables_map vmap;
00121     boost::program_options::options_description options;
00122     boost::program_options::options_description commandLineOptions;
00123       
00124     bool isReady_;
00125     bool isProcessingConfigFile;
00126       
00127     std::string virtualRobotRtcTypeName;
00128     std::string controllerName;
00129     std::string nameServerIdentifier;
00130 
00131     void initOptionsDescription();
00132     void initLabelToDataTypeMap();
00133 
00134     void parseCommandLineOptions(int argc, char* argv[]);
00135     void parseOptions();
00136     void setPortInfos(const char* optionLabel, PortInfoMap& portInfos);
00137     void addPortConnection(const std::string& value);
00138     
00139     void setPreLoadModuleInfo();
00140     void addModuleInfo(const std::string& value);
00141     void addTimeRateInfo(const std::string& value);
00142     
00143     std::vector<std::string> extractParameters(const std::string& str, const char delimiter=':');
00144     std::string expandEnvironmentVariables(std::string str);
00145 };
00146 
00147 
00148 #endif 


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:15