BridgeConf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  * General Robotix Inc.
9  */
15 #ifndef OPENHRP_BRIDGE_CONF_H_INCLUDED
16 #define OPENHRP_BRIDGE_CONF_H_INCLUDED
17 
18 #if ( defined ( WIN32 ) || defined ( _WIN32 ) || defined(__WIN32__) || defined(__NT__) )
19 #define SUFFIX_SHARED_EXT ".dll"
20 #elif defined(__APPLE__)
21 #define SUFFIX_SHARED_EXT ".dylib"
22 #else
23 #define SUFFIX_SHARED_EXT ".so"
24 #endif
25 
26 #include <map>
27 #include <list>
28 #include <vector>
29 #include <string>
30 #include <boost/program_options.hpp>
31 #include <rtm/Manager.h>
32 #include <rtm/RTObject.h>
33 
34 enum DataTypeId {
55 };
56 
57 struct PortInfo {
58  std::string portName;
60  std::vector<std::string> dataOwnerName; // link name or sensor name
61  int dataOwnerId; // sensor id
62  double stepTime;
63 };
64 
65 typedef std::map<std::string, PortInfo> PortInfoMap;
66 
67 
69  std::string robotPortName;
71  std::string controllerPortName;
72 };
73 typedef std::vector<PortConnection> PortConnectionList;
74 
75 
76 struct ModuleInfo {
77  std::string fileName;
78  std::string componentName;
79  std::string initFuncName;
80  bool isLoaded;
82 };
83 typedef std::list<ModuleInfo> ModuleInfoList;
84 
85 typedef std::map<std::string, double> TimeRateMap;
86 
88 {
89  BridgeConf(int argc, char* argv[]);
90 
91 public:
92 
93  static BridgeConf* initialize(int argc, char* argv[]);
94  static BridgeConf* instance();
95 
96  ~BridgeConf();
97 
98  bool isReady() { return isReady_; }
99 
100  const char* getOpenHRPNameServerIdentifier();
101  const char* getControllerName();
102  const char* getVirtualRobotRtcTypeName();
103 
104  void setupModules();
105 
106  typedef std::map<std::string, DataTypeId> LabelToDataTypeIdMap;
107  LabelToDataTypeIdMap labelToDataTypeIdMap;
108 
111 
113 
115 
117 
118 private:
119 
120  boost::program_options::variables_map vmap;
121  boost::program_options::options_description options;
122  boost::program_options::options_description commandLineOptions;
123 
124  bool isReady_;
126 
128  std::string controllerName;
129  std::string nameServerIdentifier;
130 
131  void initOptionsDescription();
132  void initLabelToDataTypeMap();
133 
134  void parseCommandLineOptions(int argc, char* argv[]);
135  void parseOptions();
136  void setPortInfos(const char* optionLabel, PortInfoMap& portInfos);
137  void addPortConnection(const std::string& value);
138 
139  void setPreLoadModuleInfo();
140  void addModuleInfo(const std::string& value);
141  void addTimeRateInfo(const std::string& value);
142 
143  std::vector<std::string> extractParameters(const std::string& str, const char delimiter=':');
144  std::string expandEnvironmentVariables(std::string str);
145 };
146 
147 
148 #endif
std::string nameServerIdentifier
Definition: BridgeConf.h:129
PortInfoMap inPortInfos
Definition: BridgeConf.h:110
boost::program_options::variables_map vmap
Definition: BridgeConf.h:120
std::string controllerName
Definition: BridgeConf.h:128
png_voidp int value
Definition: png.h:2113
TimeRateMap timeRateMap
Definition: BridgeConf.h:116
std::string controllerInstanceName
Definition: BridgeConf.h:70
PortInfoMap outPortInfos
Definition: BridgeConf.h:109
std::string portName
Definition: BridgeConf.h:58
PortConnectionList portConnections
Definition: BridgeConf.h:114
DataTypeId
Definition: BridgeConf.h:34
bool isProcessingConfigFile
Definition: BridgeConf.h:125
LabelToDataTypeIdMap labelToDataTypeIdMap
Definition: BridgeConf.h:107
std::string componentName
Definition: BridgeConf.h:78
std::map< std::string, DataTypeId > LabelToDataTypeIdMap
Definition: BridgeConf.h:106
std::string robotPortName
Definition: BridgeConf.h:69
RTC::RtcBase * rtcServant
Definition: BridgeConf.h:81
DataTypeId dataTypeId
Definition: BridgeConf.h:59
std::string fileName
Definition: BridgeConf.h:77
std::map< std::string, PortInfo > PortInfoMap
Definition: BridgeConf.h:65
boost::program_options::options_description commandLineOptions
Definition: BridgeConf.h:122
bool isLoaded
Definition: BridgeConf.h:80
std::vector< PortConnection > PortConnectionList
Definition: BridgeConf.h:73
std::vector< std::string > dataOwnerName
Definition: BridgeConf.h:60
std::string virtualRobotRtcTypeName
Definition: BridgeConf.h:127
std::map< std::string, double > TimeRateMap
Definition: BridgeConf.h:85
std::string controllerPortName
Definition: BridgeConf.h:71
bool isReady()
Definition: BridgeConf.h:98
std::list< ModuleInfo > ModuleInfoList
Definition: BridgeConf.h:83
bool isReady_
Definition: BridgeConf.h:124
double stepTime
Definition: BridgeConf.h:62
std::string initFuncName
Definition: BridgeConf.h:79
boost::program_options::options_description options
Definition: BridgeConf.h:121
ModuleInfoList moduleInfoList
Definition: BridgeConf.h:112
int dataOwnerId
Definition: BridgeConf.h:61


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:19