rtt_rosparam_service.cpp
Go to the documentation of this file.
1 #include <rtt/RTT.hpp>
2 #include <rtt/Property.hpp>
6 
7 #include <boost/lexical_cast.hpp>
8 #include <boost/utility/enable_if.hpp>
9 #include <boost/type_traits/is_convertible.hpp>
10 
11 #include <XmlRpcException.h>
12 
13 #include <Eigen/Dense>
14 
15 #include <ros/ros.h>
16 
18 #include <rtt_rosparam/rosparam.h>
19 
20 #ifndef ADD_ROSPARAM_OPERATION
21 #define ADD_ROSPARAM_OPERATION(return_type_str, return_type, func) \
22  this->addOperation("get"#return_type_str, &ROSParamService::get##func< return_type , RELATIVE >, this).doc("Get a " #return_type " from rosparam"); \
23  this->addOperation("set"#return_type_str, &ROSParamService::set##func< return_type , RELATIVE >, this).doc("Set a " #return_type " in rosparam"); \
24  this->addOperation("get"#return_type_str"Relative", &ROSParamService::get##func< return_type , RELATIVE >, this).doc("Get a " #return_type " from rosparam using the relative resolution policy : `relative/param`"); \
25  this->addOperation("set"#return_type_str"Relative", &ROSParamService::set##func< return_type , RELATIVE >, this).doc("Set a " #return_type " in rosparam using the relative resolution policy : `relative/param`"); \
26  this->addOperation("get"#return_type_str"Absolute", &ROSParamService::get##func< return_type , ABSOLUTE >, this).doc("Get a " #return_type " from rosparam using the absolute resolution policy : `/global/param`"); \
27  this->addOperation("set"#return_type_str"Absolute", &ROSParamService::set##func< return_type , ABSOLUTE >, this).doc("Set a " #return_type " in rosparam using the absolute resolution policy : `/global/param`"); \
28  this->addOperation("get"#return_type_str"Private", &ROSParamService::get##func< return_type , PRIVATE >, this).doc("Get a " #return_type " from rosparam using the private resolution policy : `~private/param`"); \
29  this->addOperation("set"#return_type_str"Private", &ROSParamService::set##func< return_type , PRIVATE >, this).doc("Set a " #return_type " in rosparam using the private resolution policy : `~private/param`"); \
30  this->addOperation("get"#return_type_str"ComponentPrivate", &ROSParamService::get##func< return_type , COMPONENT_PRIVATE >, this).doc("Get a " #return_type " from rosparam using the following resolution policy : `~component_name/param`"); \
31  this->addOperation("set"#return_type_str"ComponentPrivate", &ROSParamService::set##func< return_type , COMPONENT_PRIVATE >, this).doc("Set a " #return_type " in rosparam using the following resolution policy : `~component_name/param`"); \
32  this->addOperation("get"#return_type_str"ComponentRelative", &ROSParamService::get##func< return_type , COMPONENT_RELATIVE >, this).doc("Get a " #return_type " from rosparam using the following resolution policy : `component_name/param`"); \
33  this->addOperation("set"#return_type_str"ComponentRelative", &ROSParamService::set##func< return_type , COMPONENT_RELATIVE >, this).doc("Set a " #return_type " in rosparam using the following resolution policy : `component_name/param`"); \
34  this->addOperation("get"#return_type_str"ComponentAbsolute", &ROSParamService::get##func< return_type , COMPONENT_ABSOLUTE >, this).doc("Get a " #return_type " from rosparam using the following resolution policy : `/component_name/param`"); \
35  this->addOperation("set"#return_type_str"ComponentAbsolute", &ROSParamService::set##func< return_type , COMPONENT_ABSOLUTE >, this).doc("Set a " #return_type " in rosparam using the following resolution policy : `/component_name/param`");
36 #endif
37 
38 #ifndef ADD_ROSPARAM_PROPERTY_OPERATION
39 #define ADD_ROSPARAM_PROPERTY_OPERATION(return_type_str, return_type, func) \
40  this->addOperation("addRosParamProperty"#return_type_str, &ROSParamService::addRosParamProperty<return_type, RELATIVE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
41  this->addOperation("addRosParamProperty"#return_type_str"Relative", &ROSParamService::addRosParamProperty<return_type, RELATIVE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
42  this->addOperation("addRosParamProperty"#return_type_str"Absolute", &ROSParamService::addRosParamProperty<return_type, ABSOLUTE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
43  this->addOperation("addRosParamProperty"#return_type_str"Private", &ROSParamService::addRosParamProperty<return_type, PRIVATE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
44  this->addOperation("addRosParamProperty"#return_type_str"ComponentPrivate", &ROSParamService::addRosParamProperty<return_type, COMPONENT_PRIVATE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
45  this->addOperation("addRosParamProperty"#return_type_str"ComponentRelative", &ROSParamService::addRosParamProperty<return_type, COMPONENT_RELATIVE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name"); \
46  this->addOperation("addRosParamProperty"#return_type_str"ComponentAbsolute", &ROSParamService::addRosParamProperty<return_type, COMPONENT_ABSOLUTE>, this).doc("Adds a Property to the owner component that is linked to a ROS property of the same name").arg("name", "name of the ROS parameter, the property generated will use the same name");
47 #endif
48 
49 
50 using namespace RTT;
51 using namespace std;
52 
53 using namespace rtt_rosparam;
54 
56 {
57 public:
58 
60  Service("rosparam", owner)
61  {
62  this->doc("RTT Service for synchronizing ROS parameters with the properties of a corresponding RTT component");
63 
64  this->setValue(new Constant<int>("RELATIVE", static_cast<int>(RELATIVE)));
65  this->setValue(new Constant<int>("ABSOLUTE", static_cast<int>(ABSOLUTE)));
66  this->setValue(new Constant<int>("PRIVATE", static_cast<int>(PRIVATE)));
67  this->setValue(new Constant<int>("COMPONENT", static_cast<int>(COMPONENT)));
68  this->setValue(new Constant<int>("COMPONENT_PRIVATE", static_cast<int>(COMPONENT_PRIVATE)));
69  this->setValue(new Constant<int>("COMPONENT_RELATIVE", static_cast<int>(COMPONENT_RELATIVE)));
70  this->setValue(new Constant<int>("COMPONENT_ABSOLUTE", static_cast<int>(COMPONENT_ABSOLUTE)));
71 
72  this->addOperation("getAllRelative", &ROSParamService::getParamsRelative, this)
73  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the relative namespace.");
74  this->addOperation("getAllAbsolute", &ROSParamService::getParamsAbsolute, this)
75  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the absolute namespace.");
76  this->addOperation("getAllPrivate", &ROSParamService::getParamsPrivate, this)
77  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the node's private namespace.");
78  this->addOperation("getAllComponentPrivate", &ROSParamService::getParamsComponentPrivate, this)
79  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the component's private namespace.");
80  this->addOperation("getAllComponentRelative", &ROSParamService::getParamsComponentRelative, this)
81  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the component's relative namespace.");
82  this->addOperation("getAllComponentAbsolute", &ROSParamService::getParamsComponentAbsolute, this)
83  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the component's absolute namespace.");
84  this->addOperation("getAll", &ROSParamService::getParamsComponentPrivate, this)
85  .doc("Gets all properties of this component (and its sub-services) from the ROS param server in the component's private namespace. This is an alias for getAllComponentPrivate().");
86 
87  this->addOperation("setAllRelative", &ROSParamService::setParamsRelative, this)
88  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the relative namespace.");
89  this->addOperation("setAllAbsolute", &ROSParamService::setParamsAbsolute, this)
90  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the absolute namespace.");
91  this->addOperation("setAllPrivate", &ROSParamService::setParamsPrivate, this)
92  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the node's private namespace.");
93  this->addOperation("setAllComponentPrivate", &ROSParamService::setParamsComponentPrivate, this)
94  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the component's private namespace.");
95  this->addOperation("setAllComponentRelative", &ROSParamService::setParamsComponentRelative, this)
96  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the component's relative namespace.");
97  this->addOperation("setAllComponentAbsolute", &ROSParamService::setParamsComponentAbsolute, this)
98  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the component's absolute namespace.");
99  this->addOperation("setAll", &ROSParamService::setParamsComponentPrivate, this)
100  .doc("Stores all properties of this component (and its sub-services) on the ROS param server from the similarly-named property in the component's private namespace. This is an alias for setAllComponentPrivate().");
101 
102  this->addOperation("get", &ROSParamService::get, this)
103  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server based on the given resolution policy.")
104  .arg("name", "Name of the property / service / parameter.")
105  .arg("policy", "ROS parameter namespace resolution policy.");
106  this->addOperation("getParam", &ROSParamService::getParam, this)
107  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server based on the given ROS parameter name.")
108  .arg("param_name", "Name of the ROS parameter. Use '~' and '/' leaders for private or absolute resolution.")
109  .arg("name", "Name of the RTT property or service.");
110 
111  this->addOperation("getRelative", &ROSParamService::getParamRelative, this)
112  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the relative namespace.")
113  .arg("name", "Name of the property / service / parameter.");
114  this->addOperation("getAbsolute", &ROSParamService::getParamAbsolute, this)
115  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the absolute namespace.")
116  .arg("name", "Name of the property / service / parameter.");
117  this->addOperation("getPrivate", &ROSParamService::getParamPrivate, this)
118  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the node's private namespace.")
119  .arg("name", "Name of the property / service / parameter.");
120  this->addOperation("getComponentPrivate", &ROSParamService::getParamComponentPrivate, this)
121  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the component's private namespace.")
122  .arg("name", "Name of the property / service / parameter.");
123  this->addOperation("getComponentRelative", &ROSParamService::getParamComponentRelative, this)
124  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the component's relative namespace.")
125  .arg("name", "Name of the property / service / parameter.");
126  this->addOperation("getComponentAbsolute", &ROSParamService::getParamComponentAbsolute, this)
127  .doc("Gets one property of this component (or populates the properties of a named RTT sub-service) from the ROS param server in the component's absolute namespace.")
128  .arg("name", "Name of the property / service / parameter.");
129 
130  this->addOperation("set", &ROSParamService::set, this)
131  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the ROS parameter namespace based on the given resolution policy.")
132  .arg("name", "Name of the property / service / parameter.")
133  .arg("policy", "ROS parameter namespace resolution policy.");
134  this->addOperation("setParam", &ROSParamService::setParam, this)
135  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the ROS parameter namespace based on the given ROS parameter name.")
136  .arg("param_name", "Name of the ROS parameter. Use '~' and '/' leaders for private or absolute resolution.")
137  .arg("name", "Name of the RTT property or service.");
138 
139  this->addOperation("setRelative", &ROSParamService::setParamRelative, this)
140  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the relative namespace.")
141  .arg("name", "Name of the property / service / parameter.");
142  this->addOperation("setAbsolute", &ROSParamService::setParamAbsolute, this)
143  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the absolute namespace.")
144  .arg("name", "Name of the property / service / parameter.");
145  this->addOperation("setPrivate", &ROSParamService::setParamPrivate, this)
146  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the node's private namespace.")
147  .arg("name", "Name of the property / service / parameter.");
148  this->addOperation("setComponentPrivate", &ROSParamService::setParamComponentPrivate, this)
149  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the component's private namespace.")
150  .arg("name", "Name of the property / service / parameter.");
151  this->addOperation("setComponentRelative", &ROSParamService::setParamComponentRelative, this)
152  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the component's relative namespace.")
153  .arg("name", "Name of the property / service / parameter.");
154  this->addOperation("setComponentAbsolute", &ROSParamService::setParamComponentAbsolute, this)
155  .doc("Sets one parameter on the ROS param server from the similarly-named property of this component (or stores the properties of a named RTT sub-service) in the component's absolute namespace.")
156  .arg("name", "Name of the property / service / parameter.");
157 
158  ADD_ROSPARAM_OPERATION(String, std::string, ParamImpl)
159  ADD_ROSPARAM_OPERATION(Double, double, ParamImpl)
160  ADD_ROSPARAM_OPERATION(Float, float, ParamImpl)
161  ADD_ROSPARAM_OPERATION(Int, int, ParamImpl)
162  ADD_ROSPARAM_OPERATION(Bool, bool, ParamImpl)
163  ADD_ROSPARAM_PROPERTY_OPERATION(String, std::string, ParamImpl)
164  ADD_ROSPARAM_PROPERTY_OPERATION(Double, double, ParamImpl)
165  ADD_ROSPARAM_PROPERTY_OPERATION(Float, float, ParamImpl)
166  ADD_ROSPARAM_PROPERTY_OPERATION(Int, int, ParamImpl)
167  ADD_ROSPARAM_PROPERTY_OPERATION(Bool, bool, ParamImpl)
168 
169  // Vector parameters
170  ADD_ROSPARAM_OPERATION(VectorOfString, std::vector<std::string>, ParamImpl)
171  ADD_ROSPARAM_OPERATION(VectorOfDouble, std::vector<double>, ParamImpl)
172  ADD_ROSPARAM_OPERATION(VectorOfFloat, std::vector<float>, ParamImpl)
173  ADD_ROSPARAM_OPERATION(VectorOfInt, std::vector<int>, ParamImpl)
174  ADD_ROSPARAM_OPERATION(VectorOfBool, std::vector<bool>, ParamImpl)
175  ADD_ROSPARAM_PROPERTY_OPERATION(VectorOfString, std::vector<std::string>, ParamImpl)
176  ADD_ROSPARAM_PROPERTY_OPERATION(VectorOfDouble, std::vector<double>, ParamImpl)
177  ADD_ROSPARAM_PROPERTY_OPERATION(VectorOfFloat, std::vector<float>, ParamImpl)
178  ADD_ROSPARAM_PROPERTY_OPERATION(VectorOfInt, std::vector<int>, ParamImpl)
179  ADD_ROSPARAM_PROPERTY_OPERATION(VectorOfBool, std::vector<bool>, ParamImpl)
180 
181  ADD_ROSPARAM_OPERATION(EigenVectorXd, double, EigenVectorParamImpl)
182  ADD_ROSPARAM_OPERATION(EigenVectorXf, float, EigenVectorParamImpl)
183 
184  }
185 
186 private:
187 
188  template <typename T, ResolutionPolicy P> bool getParamImpl(const std::string& ros_param_name, T& value)
189  {
190  if (!ros::param::get(resolvedName(ros_param_name,P), value)) {
191  RTT::log(RTT::Debug) << "ROS Parameter \"" << ros_param_name << "\" not found on the parameter server!" << RTT::endlog();
192  return false;
193  }
194  return true;
195  }
196 
197  template <typename T, ResolutionPolicy P> void setParamImpl(const std::string& ros_param_name, const T& value)
198  {
199  ros::param::set(resolvedName(ros_param_name,P), value);
200  }
201 
202  template <typename T, ResolutionPolicy P> bool getEigenVectorParamImpl(const std::string& ros_param_name, Eigen::Matrix<T,Eigen::Dynamic,1>& eigen_vector)
203  {
204  std::vector<T> value;
205  if (!getParamImpl< std::vector<T> , P >(ros_param_name,value)) {
206  return false;
207  }
208  eigen_vector = Eigen::Matrix<T,Eigen::Dynamic,1>::Map(value.data(),value.size());
209  return true;
210  }
211 
212  template <typename T, ResolutionPolicy P> void setEigenVectorParamImpl(const std::string& ros_param_name, const Eigen::Matrix<T,Eigen::Dynamic,1>& eigen_vector)
213  {
214  std::vector<T> value(eigen_vector.data(),eigen_vector.data() + eigen_vector.size() );
215  setParamImpl< std::vector<T> , P >(ros_param_name,value);
216  }
217 
219  const std::string resolvedName(
220  const std::string &param_name,
221  const ResolutionPolicy policy);
222 
223  bool getParams(RTT::Service::shared_ptr service, const std::string& ns);
224  bool getParams(const ResolutionPolicy policy);
225  bool getParamsRelative() { return getParams(RELATIVE); }
226  bool getParamsAbsolute() { return getParams(ABSOLUTE); }
227  bool getParamsPrivate() { return getParams(PRIVATE); }
228  bool getParamsComponentPrivate() { return getParams(COMPONENT_PRIVATE); }
229  bool getParamsComponentRelative() { return getParams(COMPONENT_RELATIVE); }
230  bool getParamsComponentAbsolute() { return getParams(COMPONENT_ABSOLUTE); }
231 
232  bool get(
233  const std::string &param_name,
234  const unsigned int policy = (unsigned int) COMPONENT_PRIVATE);
235  bool getParam(
236  const std::string &ros_name,
237  const std::string &rtt_name);
238  bool getParamRelative(const std::string &name) { return get(name, RELATIVE); }
239  bool getParamAbsolute(const std::string &name) { return get(name, ABSOLUTE); }
240  bool getParamPrivate(const std::string &name) { return get(name, PRIVATE); }
241  bool getParamComponentPrivate(const std::string &name) { return get(name, COMPONENT_PRIVATE); }
242  bool getParamComponentRelative(const std::string &name) { return get(name, COMPONENT_RELATIVE); }
243  bool getParamComponentAbsolute(const std::string &name) { return get(name, COMPONENT_ABSOLUTE); }
244 
245  bool setParams(RTT::Service::shared_ptr service, const std::string& ns);
246  bool setParams(const ResolutionPolicy policy);
247  bool setParamsRelative() { return setParams(RELATIVE); }
248  bool setParamsAbsolute() { return setParams(ABSOLUTE); }
249  bool setParamsPrivate() { return setParams(PRIVATE); }
250  bool setParamsComponentPrivate() { return setParams(COMPONENT_PRIVATE); }
251  bool setParamsComponentRelative() { return setParams(COMPONENT_RELATIVE); }
252  bool setParamsComponentAbsolute() { return setParams(COMPONENT_ABSOLUTE); }
253 
254  bool set(
255  const std::string &param_name,
256  const unsigned int policy = (unsigned int) COMPONENT_PRIVATE);
257  bool setParam(
258  const std::string &ros_name,
259  const std::string &rtt_name);
260  bool setParamRelative(const std::string &name) { return set(name, RELATIVE); }
261  bool setParamAbsolute(const std::string &name) { return set(name, ABSOLUTE); }
262  bool setParamPrivate(const std::string &name) { return set(name, PRIVATE); }
263  bool setParamComponentPrivate(const std::string &name) { return set(name, COMPONENT_PRIVATE); }
264  bool setParamComponentRelative(const std::string &name) { return set(name, COMPONENT_RELATIVE); }
265  bool setParamComponentAbsolute(const std::string &name) { return set(name, COMPONENT_ABSOLUTE); }
266 
277  template<typename T, ResolutionPolicy P>
278  Property<T>& addRosParamProperty( const std::string& name) {
279  const std::string resolved_name = resolvedName(name,P);
281  Property<T>* p = new Property<T>(name, "Property generated by rosparam attached to parameter: " + resolved_name, datasource);
282  this->getOwner()->properties()->ownProperty( p );
283  return *p;
284  }
285 
286 }; // class ROSParamService
287 
289  const std::string &param_name,
290  const ResolutionPolicy policy)
291 {
292  std::string leader = "";
293  std::string resolved_name = "";
294 
295  if(param_name.length() > 0) {
296  leader = param_name[0];
297  }
298 
299  switch(policy) {
300  case RELATIVE:
301  resolved_name = param_name;
302  break;
303  case ABSOLUTE:
304  resolved_name = (leader == "/") ? param_name : std::string("/") + param_name;
305  break;
306  case PRIVATE:
307  resolved_name = (leader == "~") ? param_name : std::string("~") + param_name;
308  break;
309  case COMPONENT_PRIVATE:
310  resolved_name = std::string("~") + ros::names::append(this->getOwner()->getName(),param_name);
311  break;
312  case COMPONENT_RELATIVE:
313  resolved_name = ros::names::append(this->getOwner()->getName(),param_name);
314  break;
315  case COMPONENT_ABSOLUTE:
316  resolved_name = std::string("/") +ros::names::append(this->getOwner()->getName(),param_name);
317  break;
318  };
319 
320  RTT::log(RTT::Debug) << "["<<this->getOwner()->getName()<<"] Resolving ROS param \""<<param_name<<"\" to \""<<resolved_name<<"\"" << RTT::endlog();
321 
322  return resolved_name;
323 }
324 
325 
326 
328 template<class T>
329 bool castable(const RTT::base::PropertyBase *prop);
331 template<class T>
334 template<>
335 XmlRpc::XmlRpcValue rttPropertyToXmlParam<RTT::PropertyBag>(const RTT::PropertyBag &bag);
337 template<class T>
338 XmlRpc::XmlRpcValue rttPropertyToXmlParam(const std::vector<T> &vec);
341 
342 template<class T>
344 {
345  return dynamic_cast<const Property<T>*>(prop);
346 }
347 
348 template<class T>
350 {
351  return XmlRpc::XmlRpcValue(prop);
352 }
353 
354 template<>
356 {
357  return XmlRpc::XmlRpcValue(static_cast<double>(prop));
358 }
359 
360 template<>
362 {
363  return XmlRpc::XmlRpcValue(static_cast<int>(prop));
364 }
365 
366 template<>
368 {
369  return XmlRpc::XmlRpcValue(static_cast<int>(prop));
370 }
371 
372 template<>
374 {
375  return XmlRpc::XmlRpcValue(static_cast<int>(prop));
376 }
377 
378 template<>
379 XmlRpc::XmlRpcValue rttPropertyToXmlParam<RTT::PropertyBag>(const RTT::PropertyBag &bag)
380 {
381  // Make the xml value a struct
382  XmlRpc::XmlRpcValue xml_struct;
383  const XmlRpc::XmlRpcValue::ValueStruct &xml_map = (const XmlRpc::XmlRpcValue::ValueStruct &)(xml_struct);
384 
385  // Get the properties
386  const RTT::PropertyBag::Properties &properties = bag.getProperties();
387 
388  for(RTT::PropertyBag::Properties::const_iterator it = properties.begin();
389  it != properties.end();
390  ++it)
391  {
392  xml_struct[(*it)->getName()] = rttPropertyBaseToXmlParam(*it);
393  }
394 
395  return xml_struct;
396 }
397 
398 template<class T>
399 XmlRpc::XmlRpcValue rttPropertyToXmlParam(const std::vector<T> &vec)
400 {
401  XmlRpc::XmlRpcValue xml_array;
402  xml_array.setSize(vec.size());
403 
404  for(unsigned i=0; i<vec.size(); i++) {
405  xml_array[i] = rttPropertyToXmlParam<T>(vec.at(i));
406  }
407 
408  return xml_array;
409 }
410 
411 template<>
412 XmlRpc::XmlRpcValue rttPropertyToXmlParam(const Eigen::VectorXd &vec)
413 {
414  XmlRpc::XmlRpcValue xml_array;
415  xml_array.setSize(vec.size());
416 
417  for(unsigned i=0; i<vec.size(); i++) {
418  xml_array[i] = rttPropertyToXmlParam<double>(vec(i));
419  }
420 
421  return xml_array;
422 }
423 
424 template<>
425 XmlRpc::XmlRpcValue rttPropertyToXmlParam(const Eigen::VectorXf &vec)
426 {
427  XmlRpc::XmlRpcValue xml_array;
428  xml_array.setSize(vec.size());
429 
430  for(unsigned i=0; i<vec.size(); i++) {
431  xml_array[i] = rttPropertyToXmlParam<double>(vec(i));
432  }
433 
434  return xml_array;
435 }
436 
437 // We assume that a property with an unassignable "size" int member is a sequence.
438 // This is taken from RTT::types::propertyDecomposition
442 
443  return size && !size->isAssignable();
444 }
445 
448 
449  XmlRpc::XmlRpcValue xml_array;
450  xml_array.setSize(size->get());
451 
452  for (int i=0; i<size->get(); i++) {
453  RTT::base::PropertyBase *subProp = bag.getProperty("Element" + boost::lexical_cast<std::string>(i));
454  xml_array[i] = rttPropertyBaseToXmlParam(subProp);
455  }
456 
457  return xml_array;
458 }
459 
460 // These just save typing
461 #define RETURN_RTT_PROPERTY_TO_XML_PARAM(type,prop)\
462  if(castable< type >(prop)) { return rttPropertyToXmlParam< type >(static_cast<const RTT::Property< type >*>(prop)->rvalue()); }
463 
464 #define RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(type,elem_type,prop)\
465  if(castable< type >(prop)) { return rttPropertyToXmlParam< elem_type >(static_cast<const RTT::Property< type >*>(prop)->rvalue()); }
466 
468 {
469  // Primitive parameters
470  RETURN_RTT_PROPERTY_TO_XML_PARAM(std::string, prop);
471  RETURN_RTT_PROPERTY_TO_XML_PARAM(double, prop);
474  RETURN_RTT_PROPERTY_TO_XML_PARAM(unsigned int, prop);
476  RETURN_RTT_PROPERTY_TO_XML_PARAM(unsigned char, prop);
478 
479  // Vector parameters
480  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<std::string>, std::string, prop);
481  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<double>, double, prop);
482  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<float>, float, prop);
483  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<int>, int, prop);
484  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<unsigned int>, unsigned int, prop);
485  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<char>, char, prop);
486  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<unsigned char>, unsigned char, prop);
487  RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(std::vector<bool>, bool, prop);
488 
489  RETURN_RTT_PROPERTY_TO_XML_PARAM(Eigen::VectorXd, prop);
490  RETURN_RTT_PROPERTY_TO_XML_PARAM(Eigen::VectorXf, prop);
491 
492  // Struct parameters
494 
495  // Try to decompose property into a property bag
496  RTT::PropertyBag bag;
497  if (RTT::types::propertyDecomposition(prop, bag)) {
498  if (propertyIsSequence(prop)) {
499  return rttPropertySequenceToXmlParam(prop, bag);
500  } else {
501  return rttPropertyToXmlParam(bag);
502  }
503  }
504 
505  return XmlRpc::XmlRpcValue();
506 }
507 
508 
510  const std::string &param_name,
511  const unsigned int policy)
512 {
513  RTT::Logger::In in("ROSParamService::set");
514 
515  const std::string resolved_name = resolvedName(param_name,ResolutionPolicy(policy));
516 
517  return this->setParam(resolved_name, param_name);
518 }
519 
521  const std::string &ros_name,
522  const std::string &rtt_name)
523 {
524  RTT::Logger::In in("ROSParamService::setParam");
525 
526  XmlRpc::XmlRpcValue xml_value;
527 
528  // Try to find a property named rtt_name
529  RTT::base::PropertyBase *property = this->getOwner()->getProperty(rtt_name);
530  if (property) {
531  xml_value = rttPropertyBaseToXmlParam(this->getOwner()->getProperty(rtt_name));
532  ros::param::set(ros_name, xml_value);
533  return true;
534  }
535 
536  // Try to find a sub-service named rtt_name
537  RTT::Service::shared_ptr service = this->getOwner()->provides()->getService(rtt_name);
538  if (service) {
539  // Set all parameters of the sub-service
540  return setParams(service, ros_name);
541  }
542 
543  RTT::log(RTT::Debug) << "RTT component does not have a property or service named \"" << rtt_name << "\"" << RTT::endlog();
544  return false;
545 }
546 
548 {
549  return setParams(this->getOwner()->provides(), resolvedName(std::string(), policy));
550 }
551 
553  RTT::Service::shared_ptr service,
554  const std::string& ns) {
555  XmlRpc::XmlRpcValue xml_value;
556  xml_value = rttPropertyToXmlParam(*(service->properties()));
557  ros::param::set(ns, xml_value);
558 
559  // Recurse into sub-services
560  RTT::Service::ProviderNames names = service->getProviderNames();
561  for (RTT::Service::ProviderNames::const_iterator it = names.begin(); it != names.end(); ++it)
562  {
563  RTT::Service::shared_ptr sub(service->getService(*it));
564  if (sub) {
565  if (!setParams(sub, ros::names::append(ns,sub->getName()))) return false;
566  }
567  }
568 
569  return true;
570 }
571 
572 // Declarations
574 template <class T>
575 bool xmlParamToProp(const XmlRpc::XmlRpcValue &xml_value, RTT::Property<T>* prop);
577 template <class T>
578 bool xmlParamToProp(const XmlRpc::XmlRpcValue &xml_value, RTT::Property<std::vector<T> >* prop);
580 template <>
582 template <>
585 template <>
586 bool xmlParamToProp<RTT::PropertyBag>(const XmlRpc::XmlRpcValue &xml_value, RTT::Property<RTT::PropertyBag>* prop);
588 bool xmlParamToProp( const XmlRpc::XmlRpcValue &xml_value, RTT::base::PropertyBase* prop_base);
589 
590 template <class XMLRPCType,class PropertyType, class enabled=void> struct XmlParamToValue{
591  static bool assign(const XMLRPCType& xml_value, PropertyType &prop_value)
592  {
593  return false;
594  }
595 };
596 
597 template <class XMLRPCType, class PropertyType >
598 struct XmlParamToValue <XMLRPCType, PropertyType, typename boost::enable_if<boost::is_convertible<XMLRPCType,PropertyType> >::type >{
599  static bool assign(const XMLRPCType& xml_value, PropertyType &prop_value)
600  {
601  prop_value = xml_value;
602  return true;
603  }
604 };
605 
607 template <class PropertyType> bool xmlParamToValue(const XmlRpc::XmlRpcValue &xml_value, PropertyType &value) {
608  switch(xml_value.getType()) {
610  return XmlParamToValue<std::string, PropertyType>::assign(static_cast<const std::string&>(const_cast<XmlRpc::XmlRpcValue &>(xml_value)),value);
612  return XmlParamToValue<double, PropertyType>::assign(static_cast<double>(const_cast<XmlRpc::XmlRpcValue &>(xml_value)),value);
614  return XmlParamToValue<int, PropertyType>::assign(static_cast<int>(const_cast<XmlRpc::XmlRpcValue &>(xml_value)),value);
616  return XmlParamToValue<bool, PropertyType>::assign(static_cast<bool>(const_cast<XmlRpc::XmlRpcValue &>(xml_value)),value);
617  }
618  return false;
619 }
620 
621 template <class T>
623  const XmlRpc::XmlRpcValue &xml_value,
624  RTT::Property<T>* prop)
625 {
626  // Check if the property value is the requested type T
627  if(!prop) {
628  return false;
629  }
630 
631  // Set the value
632  return xmlParamToValue(xml_value, prop->set());
633 
634 }
635 
636 template <class T>
638  const XmlRpc::XmlRpcValue &xml_value,
639  RTT::Property<std::vector<T> >* prop)
640 {
641  // Check if the property value is the requested type T
642  if(!prop) {
643  return false;
644  }
645 
646  // Make sure it's an array
647  if(xml_value.getType() != XmlRpc::XmlRpcValue::TypeArray) {
648  return false;
649  }
650 
651  // Copy the data into the vector property
652  std::vector<T> &vec = prop->value();
653  vec.resize(xml_value.size());
654  bool result = true;
655  for(size_t i=0; i<vec.size(); i++) {
656  result &= xmlParamToValue(xml_value[i], vec[i]);
657  }
658 
659  return result;
660 }
661 
662 template <>
664  const XmlRpc::XmlRpcValue &xml_value,
666 {
667  // Check if the property value is the requested type T
668  if(!prop) {
669  return false;
670  }
671 
672  // Make sure it's an array
673  if(xml_value.getType() != XmlRpc::XmlRpcValue::TypeArray) {
674  return false;
675  }
676 
677  // Copy the data into the vector property
678  std::vector<bool> &vec = prop->value();
679  vec.resize(xml_value.size());
680  bool result = true;
681  for(size_t i=0; i<vec.size(); i++) {
682  bool temp;
683  result &= xmlParamToValue(xml_value[i], temp);
684  vec[i] = temp;
685  }
686 
687  return result;
688 }
689 
690 template <>
692  const XmlRpc::XmlRpcValue &xml_value,
694 {
695  // Check if the property value is the requested type T
696  if(!prop) {
697  return false;
698  }
699 
700  // Make sure it's an array
701  if(xml_value.getType() != XmlRpc::XmlRpcValue::TypeArray) {
702  return false;
703  }
704 
705  // Copy the data into the vector property
706  Eigen::VectorXd &vec = prop->value();
707  vec.resize(xml_value.size());
708  bool result = true;
709  for(size_t i=0; i<vec.size(); i++) {
710  double temp;
711  result &= xmlParamToValue(xml_value[i], temp);
712  vec[i] = temp;
713  }
714 
715  return result;
716 }
717 
718 template <>
720  const XmlRpc::XmlRpcValue &xml_value,
722 {
723  // Check if the property value is the requested type T
724  if(!prop) {
725  return false;
726  }
727 
728  // Make sure it's an array
729  if(xml_value.getType() != XmlRpc::XmlRpcValue::TypeArray) {
730  return false;
731  }
732 
733  // Copy the data into the vector property
734  Eigen::VectorXf &vec = prop->value();
735  vec.resize(xml_value.size());
736  bool result = true;
737  for(size_t i=0; i<vec.size(); i++) {
738  double temp;
739  result &= xmlParamToValue(xml_value[i], temp);
740  vec[i] = temp;
741  }
742 
743  return result;
744 }
745 
747  const XmlRpc::XmlRpcValue &xml_value,
749 {
750  // Copy the properties
751  bool success = true;
752  // We need to copy the struct because XmlRpc++ doesn't have const operations for this
753  XmlRpc::XmlRpcValue xml_value_struct(xml_value);
754  for(XmlRpc::XmlRpcValue::ValueStruct::iterator it = xml_value_struct.begin();
755  it != xml_value_struct.end();
756  ++it)
757  {
758  RTT::base::PropertyBase *sub_prop_base = prop->value().getProperty(it->first);
759  if (sub_prop_base) {
760  success &= xmlParamToProp(it->second, sub_prop_base);
761  } else {
762  // create property based on XmlRpc type?
763  }
764  }
765 
766  return success;
767 }
768 
770  const XmlRpc::XmlRpcValue &xml_value,
772 {
773  bool success = true;
774 
775  for (int idx = 0; idx < xml_value.size(); ++idx) {
776  base::PropertyBase* sub_prop_base = prop->set().getProperty("Element" + boost::lexical_cast<std::string>(idx));
777  if (sub_prop_base) {
778  success &= xmlParamToProp(xml_value[idx], sub_prop_base);
779  } else {
780  // ??
781  }
782  }
783 
784  return success;
785 }
786 
787 template <>
788 bool xmlParamToProp<RTT::PropertyBag>(
789  const XmlRpc::XmlRpcValue &xml_value,
791 {
792  // Check if the property value is the requested type T
793  if(!prop) {
794  return false;
795  }
796 
797  // Make sure it's a struct
798  if(xml_value.getType() == XmlRpc::XmlRpcValue::TypeStruct) {
799  return xmlParamStructToProp(xml_value, prop);
800  } else if (xml_value.getType() == XmlRpc::XmlRpcValue::TypeArray) {
801  return xmlParamArrayToProp(xml_value, prop);
802  } else {
803  return false;
804  }
805 }
806 
808  const XmlRpc::XmlRpcValue &xml_value,
809  RTT::base::PropertyBase* prop_base)
810 {
811  // Switch based on the type of XmlRpcValue
812  switch(xml_value.getType()) {
814  return
815  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::string>*>(prop_base));
816 
818  return
819  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<double>*>(prop_base)) ||
820  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<float>*>(prop_base));
821 
823  return
824  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<double>*>(prop_base)) ||
825  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<float>*>(prop_base)) ||
826  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<int>*>(prop_base)) ||
827  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<unsigned int>*>(prop_base)) ||
828  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<char>*>(prop_base)) ||
829  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<unsigned char>*>(prop_base));
830 
832  return
833  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<bool>*>(prop_base));
834 
836  if (
837  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<std::string> >*>(prop_base)) ||
838  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<double> >*>(prop_base)) ||
839  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<float> >*>(prop_base)) ||
840  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<int> >*>(prop_base)) ||
841  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<unsigned int> >*>(prop_base)) ||
842  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<char> >*>(prop_base)) ||
843  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<unsigned char> >*>(prop_base)) ||
844  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<std::vector<bool> >*>(prop_base)) ||
845  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<Eigen::VectorXd >*>(prop_base)) ||
846  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<Eigen::VectorXf >*>(prop_base)) )
847  {
848  // Return true if it gets parsed into an array structure
849  return true;
850  }
851  break;
852 
854  if (
855  xmlParamToProp(xml_value, dynamic_cast<RTT::Property<RTT::PropertyBag>*>(prop_base)) )
856  {
857  // Return true if it gets parsed into a PropertyBag structure
858  return true;
859  }
860  break;
861  };
862 
863  // try property bag decomposition
864  {
865  if (xml_value.getType() == XmlRpc::XmlRpcValue::TypeArray
866  && !prop_base->getTypeInfo()->resize(prop_base->getDataSource(), xml_value.size())) {
867  RTT::log(RTT::Debug) << "Could not resize property of type \""
868  << prop_base->getName() << "\"" << RTT::endlog();
869  return false;
870  }
871 
872  RTT::Property<RTT::PropertyBag> bag(prop_base->getName());
873  if (RTT::types::propertyDecomposition(prop_base, bag.set()) && xmlParamToProp(xml_value, &bag)) {
874  return true;
875  } else {
876  RTT::log(RTT::Debug) << "Could not decompose property bag for property type \"" << prop_base->getName() << "\"" << RTT::endlog();
877  return false;
878  }
879  }
880 
881  RTT::log(RTT::Debug) << "No appropriate conversion for property \"" << prop_base->getName() << "\"" << RTT::endlog();
882  return false;
883 }
884 
886  const std::string &param_name,
887  const unsigned int policy)
888 {
889  RTT::Logger::In in("ROSParamService::get");
890 
891  const std::string resolved_name = resolvedName(
892  param_name,ResolutionPolicy(policy));
893 
894  return this->getParam(resolved_name, param_name);
895 }
896 
898  const std::string &ros_name,
899  const std::string &rtt_name)
900 {
901  RTT::Logger::In in("ROSParamService::getParam");
902 
903  try {
904  // Get the parameter
905  XmlRpc::XmlRpcValue xml_value;
906 
907  if(!ros::param::get(ros_name, xml_value)) {
908  RTT::log(RTT::Debug) << "ROS Parameter \"" << ros_name << "\" not found on the parameter server!" << RTT::endlog();
909  return false;
910  }
911 
912  // Try to get the property if it exists
913  RTT::base::PropertyBase *prop_base = this->getOwner()->getProperty(rtt_name);
914  if(prop_base) {
915  // Deal with the xml value
916  bool ret = xmlParamToProp(xml_value, prop_base);
917  if(!ret) {
918  RTT::log(RTT::Warning) << "Could not convert \"" << ros_name << "\" from an XMLRPC value to an RTT property." << RTT::endlog();
919  }
920  return ret;
921  }
922 
923  // Try to get the properties of a sub-service if it exists
924  RTT::Service::shared_ptr service = this->getOwner()->provides()->getService(rtt_name);
925  if(service) {
926  // Get all parameters of the sub-service
927  return getParams(service, ros_name);
928  }
929 
930  RTT::log(RTT::Debug) << "RTT component does not have a property or service named \"" << rtt_name << "\"" << RTT::endlog();
931 
932  } catch(XmlRpc::XmlRpcException &err) {
933  RTT::log(RTT::Error) << "XmlRpcException when getting ROS parameter \""<<ros_name<<"\": " << err.getMessage() << RTT::endlog();
934  RTT::log(RTT::Debug) << " -- Make sure your parameters are the right primitive type." << RTT::endlog();
935  }
936 
937  return false;
938 }
939 
940 
942 {
943  return getParams(this->getOwner()->provides(), resolvedName(std::string(), policy));
944 }
945 
947  RTT::Service::shared_ptr service,
948  const std::string& ns)
949 {
950  RTT::Logger::In in("ROSParamService::getParams");
951 
952  // Get the parameter
953  XmlRpc::XmlRpcValue xml_value;
954 
955  if(!ros::param::get(ns, xml_value)) {
956  RTT::log(RTT::Debug) << "ROS Parameter namespace \"" << ns << "\" not found on the parameter server!" << RTT::endlog();
957  return false;
958  }
959 
960  // Create a Property<> wrapper around the propertybag
961  RTT::PropertyBag *properties = service->properties();
963  RTT::Property<RTT::PropertyBag> prop(this->getOwner()->getName(),"",datasource);
964 
965  // Deal with the xml value
966  bool ret = xmlParamToProp(xml_value, &prop);
967  if (!ret) {
968  RTT::log(RTT::Warning) << "Could not convert \"" << ns << "\" from an XMLRPC value to an RTT property." << RTT::endlog();
969  return false;
970  }
971 
972  // Recurse into sub-services
973  RTT::Service::ProviderNames names = service->getProviderNames();
974  for (RTT::Service::ProviderNames::const_iterator it = names.begin(); it != names.end(); ++it)
975  {
976  RTT::Service::shared_ptr sub(service->getService(*it));
977  if (sub) {
978  std::string sub_ns = sub->getName();
979  if (!ns.empty()) sub_ns = ros::names::append(ns,sub_ns);
980  getParams(sub, sub_ns);
981  }
982  }
983 
984  return true;
985 }
986 
bool xmlParamStructToProp(const XmlRpc::XmlRpcValue &xml_value, RTT::Property< RTT::PropertyBag > *prop)
static bool assign(const XMLRPCType &xml_value, PropertyType &prop_value)
const std::string & getMessage() const
virtual result_t get() const =0
ROSParamService(TaskContext *owner)
XmlRpc::XmlRpcValue rttPropertySequenceToXmlParam(RTT::base::PropertyBase *prop, const RTT::PropertyBag &bag)
void setEigenVectorParamImpl(const std::string &ros_param_name, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &eigen_vector)
bool getParamAbsolute(const std::string &name)
XmlRpc::XmlRpcValue rttPropertyToXmlParam< char >(const char &prop)
bool propertyDecomposition(base::PropertyBase *source, PropertyBag &targetbag, bool recurse)
bool propertyIsSequence(RTT::base::PropertyBase *prop)
int size() const
Component resolution: "name" -> "COMPONENT_NAME/name".
Definition: rosparam.h:97
std::string getName(void *handle)
#define ORO_SERVICE_NAMED_PLUGIN(SERVICE, NAME)
XmlRpc::XmlRpcValue rttPropertyToXmlParam(const T &prop)
Convert a value to an XmlRpc value.
bool getParamComponentPrivate(const std::string &name)
bool resize(base::DataSourceBase::shared_ptr arg, int size) const
bool xmlParamToProp< bool >(const XmlRpc::XmlRpcValue &xml_value, RTT::Property< std::vector< bool > > *prop)
std::vector< std::string > ProviderNames
Type const & getType() const
const std::string resolvedName(const std::string &param_name, const ResolutionPolicy policy)
Resolve a parameter name based on the given ResolutionPolicy.
Absolute resolution: "name" -> "/name".
Definition: rosparam.h:94
#define ADD_ROSPARAM_PROPERTY_OPERATION(return_type_str, return_type, func)
reference_t value()
virtual bool isAssignable() const
bool set(const std::string &param_name, const unsigned int policy=(unsigned int) COMPONENT_PRIVATE)
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
bool getParamPrivate(const std::string &name)
std::map< std::string, XmlRpcValue > ValueStruct
bool setParams(RTT::Service::shared_ptr service, const std::string &ns)
XmlRpc::XmlRpcValue rttPropertyToXmlParam< unsigned int >(const unsigned int &prop)
void setSize(int size)
bool setParamPrivate(const std::string &name)
ROSCPP_DECL bool get(const std::string &key, std::string &s)
#define RETURN_RTT_PROPERTY_CONTAINER_TO_XML_PARAM(type, elem_type, prop)
bool getParamImpl(const std::string &ros_param_name, T &value)
bool castable(const RTT::base::PropertyBase *prop)
Determine if the RTT property can be casted into an RTT::Property<T>
XmlRpc::XmlRpcValue rttPropertyBaseToXmlParam(RTT::base::PropertyBase *prop)
Convert an abstract RTT PropertyBase to an XmlRpc value.
bool setParamComponentPrivate(const std::string &name)
bool getParamComponentAbsolute(const std::string &name)
Property< T > & addRosParamProperty(const std::string &name)
bool get(const std::string &param_name, const unsigned int policy=(unsigned int) COMPONENT_PRIVATE)
bool xmlParamToValue(const XmlRpc::XmlRpcValue &xml_value, PropertyType &value)
Convert an XmlRpc value to type T.
boost::intrusive_ptr< DataSource< T > > shared_ptr
bool xmlParamToProp(const XmlRpc::XmlRpcValue &xml_value, RTT::Property< T > *prop)
Convert an XmlRpc value into an RTT property.
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
bool getParamRelative(const std::string &name)
bool setParamAbsolute(const std::string &name)
base::PropertyBase * getProperty(const std::string &name) const
static DataSource< T > * narrow(base::DataSourceBase *db)
bool getParam(const std::string &ros_name, const std::string &rtt_name)
Relative resolution: "name" -> "name".
Definition: rosparam.h:93
XmlRpc::XmlRpcValue rttPropertyToXmlParam< float >(const float &prop)
bool setParam(const std::string &ros_name, const std::string &rtt_name)
Private resolution: "name" -> "~name".
Definition: rosparam.h:95
bool setParamRelative(const std::string &name)
bool getEigenVectorParamImpl(const std::string &ros_param_name, Eigen::Matrix< T, Eigen::Dynamic, 1 > &eigen_vector)
const std::string & getName() const
bool xmlParamArrayToProp(const XmlRpc::XmlRpcValue &xml_value, RTT::Property< RTT::PropertyBag > *prop)
XmlRpc::XmlRpcValue rttPropertyToXmlParam< unsigned char >(const unsigned char &prop)
bool getParamComponentRelative(const std::string &name)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
#define RETURN_RTT_PROPERTY_TO_XML_PARAM(type, prop)
reference_t set()
boost::intrusive_ptr< DataSourceBase > shared_ptr
bool setParamComponentAbsolute(const std::string &name)
bool getParams(RTT::Service::shared_ptr service, const std::string &ns)
static Logger & log()
#define ADD_ROSPARAM_OPERATION(return_type_str, return_type, func)
static Logger::LogFunction endlog()
Component resolution: "name" -> "~COMPONENT_NAME/name".
Definition: rosparam.h:96
bool setParamComponentRelative(const std::string &name)
virtual DataSourceBase::shared_ptr getDataSource() const =0
std::vector< base::PropertyBase * > Properties
void setParamImpl(const std::string &ros_param_name, const T &value)
Component resolution: "name" -> "/COMPONENT_NAME/name".
Definition: rosparam.h:98
virtual const types::TypeInfo * getTypeInfo() const =0


rtt_rosparam
Author(s): Ruben Smits
autogenerated on Mon May 10 2021 02:45:11