bfl_toolkit.cpp
Go to the documentation of this file.
1 // Copyright (C) 2009 Tinne De Laet <tinne dot delaet at mech dot kuleuven dot be>
2 
3 // Author: Tinne De Laet
4 // Maintainer: Tinne De Laet
5 
6 
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 #include "bfl_toolkit.hpp"
22 #include <rtt/Property.hpp>
23 #include <rtt/PropertyBag.hpp>
24 #include <rtt/TemplateTypeInfo.hpp>
25 #include <rtt/Operators.hpp>
26 #include <rtt/OperatorTypes.hpp>
27 #include <rtt/Types.hpp>
28 #include <rtt/Logger.hpp>
29 #include <rtt/DataSources.hpp>
30 #include <rtt/mystd.hpp>
31 #include <rtt/os/StartStopManager.hpp>
32 #include <rtt/Toolkit.hpp>
33 
34 #include "../../wrappers/matrix/vector_wrapper.h"
35 #include "../../wrappers/matrix/matrix_wrapper.h"
36 #include "../../bfl_constants.h"
37 #include "../../sample/sample.h"
38 
39 #include <rtt/VectorTemplateComposition.hpp>
40 #include "SampleComposition.hpp"
41 
42 
43 /*
44 std::ostream& operator<<(std::ostream& os, const Probability p) {
45  return os << (double)p;
46 }
47 
48 std::istream& operator>>(std::istream& is, Probability p) {
49  char c;
50  double p;
51  return os >> p ;
52 }
53 */
54 
55 
56 
57 #ifndef __PROB_STREAM__
58 #define __PROB_STREAM__
59 namespace BFL
60 {
61  using namespace std;
62  ostream & operator<< (ostream & stream, Probability& prob)
63  {
64  stream << prob.getValue() << endl;
65  return stream;
66  }
67 
68  istream & operator>> (istream & stream, Probability& prob)
69  {
70  double value;
71  stream >> value;
72  prob = Probability(value);
73  return stream;
74  }
75 };
76 #endif //__PROBSTREAM__
77 
78 
79 using namespace MatrixWrapper;
80 namespace BFL{
81 
82  using namespace RTT;
83  using namespace RTT::detail;
84 
86 
87  struct ProbabilityTypeInfo : public TemplateTypeInfo<Probability,true>
88  {
89  ProbabilityTypeInfo():TemplateTypeInfo<Probability,true>("Probability")
90  {
91  };
92  virtual bool decomposeTypeImpl(const Probability& prob, PropertyBag& targetbag) const
93  {
94  targetbag.setType("Probability");
95  double probDouble = prob.getValue();
96  targetbag.add( new Property<double>("Probability","Probability value", probDouble ) ); // Put variables in the bag
97  return true;
98  };
99  virtual bool composeTypeImpl(const PropertyBag& bag, Probability& prob) const
100  {
101  Property<double>* probability = bag.getProperty<double>("Probability");
102  if (!probability)
103  return false;
104  prob = (probability)->get();
105  return true;
106  };
107  };
108 
109 
110 
111  struct VectorTypeInfo : public TemplateContainerTypeInfo<ColumnVector,int,double,ArrayIndexChecker<ColumnVector >, VectorAssignChecker<ColumnVector >,true>
112  {
113  VectorTypeInfo():TemplateContainerTypeInfo<ColumnVector,int,double,ArrayIndexChecker<ColumnVector>, VectorAssignChecker<ColumnVector >, true >("ColumnVector")
114  {
115  };
116 
117  bool decomposeTypeImpl(const ColumnVector& vec, PropertyBag& targetbag) const
118  {
119  targetbag.setType("ColumnVector");
120  int dimension = vec.size();
121  std::string str;
122 
123  for ( int i=1; i <= dimension ; i++){
124  std::stringstream out;
125  out << i;
126  str = out.str();
127  targetbag.add( new Property<double>(str, str +"th element of vector",vec(i)) ); // Put variables in the bag
128  }
129 
130  return true;
131  };
132 
133  bool composeTypeImpl(const PropertyBag& bag, ColumnVector& result) const{
134 
135  if ( bag.getType() == "ColumnVector" ) {
136  int dimension = bag.size();
137  result.resize( dimension );
138 
139  // Get values
140  for (int i = 1; i <= dimension ; i++) {
141  std::stringstream out;
142  out << i;
143  Property<double>* elem = bag.getProperty<double>(out.str());
144  if(elem->ready())
145  result(i) = elem->get();
146  else{
147  log(Error)<<"Could not read element "<<i<<endlog();
148  return false;
149  }
150  }
151  }else{
152  log(Error) << "Composing Property< ColumnVector > :"
153  << " type mismatch, got type '"<< bag.getType()
154  << "', expected type "<<"ColumnVector."<<endlog();
155  return false;
156  }
157  return true;
158  };
159  };
160 
161  struct RVectorTypeInfo : public TemplateContainerTypeInfo<RowVector,int,double,ArrayIndexChecker<RowVector >, VectorAssignChecker<RowVector >,true>
162  {
163  RVectorTypeInfo():TemplateContainerTypeInfo<RowVector,int,double,ArrayIndexChecker<RowVector>, VectorAssignChecker<RowVector >, true >("RowVector")
164  {
165  };
166 
167  bool decomposeTypeImpl(const RowVector& vec, PropertyBag& targetbag) const
168  {
169  targetbag.setType("RowVector");
170  int dimension = vec.size();
171  std::string str;
172 
173 
174  for ( int i=1; i <= dimension ; i++){
175  std::stringstream out;
176  out << i;
177  str = out.str();
178  targetbag.add( new Property<double>(str, str +"th element of vector",vec(i)) ); // Put variables in the bag
179  }
180 
181  return true;
182  };
183 
184  bool composeTypeImpl(const PropertyBag& bag, RowVector& result) const{
185 
186  if ( bag.getType() == "RowVector" ) {
187  int dimension = bag.size();
188  result.resize( dimension );
189 
190  // Get values
191  for (int i = 1; i <= dimension ; i++) {
192  std::stringstream out;
193  out << i;
194  Property<double>* elem = bag.getProperty<double>(out.str());
195  if(elem->ready())
196  result(i) = elem->get();
197  else{
198  log(Error)<<"Could not read element "<<i<<endlog();
199  return false;
200  }
201  }
202  }else{
203  log(Error) << "Composing Property< RowVector > :"
204  << " type mismatch, got type '"<< bag.getType()
205  << "', expected type "<<"RowVector."<<endlog();
206  return false;
207  }
208  return true;
209  };
210  };
211 
212  struct MatrixTypeInfo : public TemplateContainerTypeInfo<Matrix,int,RowVector,MatrixIndexChecker<Matrix>, MatrixAssignChecker<Matrix>, true>
213  {
214  MatrixTypeInfo():TemplateContainerTypeInfo<Matrix,int,RowVector,MatrixIndexChecker<Matrix>, MatrixAssignChecker<Matrix>,true>("Matrix"){
215  };
216 
217  bool decomposeTypeImpl(const Matrix& mat, PropertyBag& targetbag) const{
218  targetbag.setType("Matrix");
219  unsigned int dimension = mat.rows();
220 
221  for ( unsigned int i=1; i <= dimension ; i++){
222  std::stringstream out;
223  out << i;
224  Property<PropertyBag>* row_bag = new Property<PropertyBag>(out.str(), out.str() +"th row of matrix");
225  Property<RowVector> row(out.str(), out.str() +"th row of matrix",mat.rowCopy(i)) ;
226  row.getTypeInfo()->decomposeType(row.getDataSource(),row_bag->value());
227  targetbag.add( row_bag ); // Put variables in the bag
228  }
229 
230  return true;
231  };
232 
233  bool composeTypeImpl(const PropertyBag& bag, Matrix& result) const{
234  if ( bag.getType() == "Matrix" ) {
235  unsigned int rows = bag.size();
236  unsigned int cols = 0;
237  // Get values
238  for (unsigned int i = 1; i <= rows ; i++) {
239  std::stringstream out;
240  out << i;
241  Property<PropertyBag>* row_bag = bag.getProperty<PropertyBag>(out.str());
242  if(row_bag==NULL){
243  log(Error)<<"Could not read row "<<i<<endlog();
244  return false;
245  }
246  Property<RowVector> row_p(row_bag->getName(),row_bag->getDescription());
247  if(!(row_p.getDataSource()->composeType(row_bag->getDataSource()))){
248  log(Error)<<"Could not decompose row "<<i<<endlog();
249  return false;
250  }
251  if(row_p.ready()){
252  if(i==1){
253  cols = row_p.get().size();
254  result.resize(rows,cols);
255  } else
256  if(row_p.get().size()!=cols){
257  log(Error)<<"Row "<<i+1<<" size does not match matrix columns"<<endlog();
258  return false;
259  }
260  for ( unsigned int j=1; j <= row_p.get().size() ; j++){
261  result(i,j)=row_p.get()(j);
262  }
263  }else{
264  log(Error)<<"Property of Row "<<i<<"was not ready for use"<<endlog();
265  return false;
266  }
267  }
268  }else {
269  log(Error) << "Composing Property< Matrix > :"
270  << " type mismatch, got type '"<< bag.getType()
271  << "', expected type "<<"Matrix."<<endlog();
272  return false;
273  }
274  return true;
275  };
276  };
277 
278  struct SymmetricMatrixTypeInfo : public TemplateContainerTypeInfo<SymmetricMatrix,int,RowVector,MatrixIndexChecker<SymmetricMatrix>, MatrixAssignChecker<SymmetricMatrix>, true>
279  {
280  SymmetricMatrixTypeInfo():TemplateContainerTypeInfo<SymmetricMatrix,int,RowVector,MatrixIndexChecker<SymmetricMatrix>, MatrixAssignChecker<SymmetricMatrix>,true>("SymmetricMatrix"){
281  };
282 
283  bool decomposeTypeImpl(const SymmetricMatrix& mat, PropertyBag& targetbag) const{
284  targetbag.setType("SymmetricMatrix");
285  unsigned int dimension = mat.rows();
286 
287  for ( unsigned int i=1; i <= dimension ; i++){
288  std::stringstream out;
289  out << i;
290  //targetbag.add( new Property<RowVector >(out.str(), out.str() +"th row of matrix",((Matrix)mat).rowCopy(i) )); // Put variables in the bag
291  Property<PropertyBag>* row_bag = new Property<PropertyBag>(out.str(), out.str() +"th row of matrix");
292  Property<RowVector> row(out.str(), out.str() +"th row of matrix",((Matrix)mat).rowCopy(i)) ;
293  row.getTypeInfo()->decomposeType(row.getDataSource(),row_bag->value());
294  targetbag.add( row_bag ); // Put variables in the bag
295  }
296 
297  return true;
298  };
299 
300  bool composeTypeImpl(const PropertyBag& bag, SymmetricMatrix& result) const{
301  Matrix matrix;
302  if ( bag.getType() == "SymmetricMatrix" ) {
303  unsigned int rows = bag.size();
304  unsigned int cols = 0;
305  // Get values
306  for (unsigned int i = 1; i <= rows ; i++) {
307  std::stringstream out;
308  out << i;
309  Property<PropertyBag>* row_bag = bag.getProperty<PropertyBag>(out.str());
310  if(row_bag==NULL){
311  log(Error)<<"Could not read row "<<i<<endlog();
312  return false;
313  }
314  Property<RowVector > row_p(row_bag->getName(),row_bag->getDescription());
315  if(!(row_p.getDataSource()->composeType(row_bag->getDataSource()))){
316  log(Error)<<"Could not decompose row "<<i<<endlog();
317  return false;
318  }
319  if(row_p.ready()){
320  if(i==1){
321  cols = row_p.get().size();
322  matrix.resize(rows,cols);
323  } else
324  if(row_p.get().size()!=cols){
325  log(Error)<<"Row "<<i+1<<" size does not match matrix columns"<<endlog();
326  return false;
327  }
328  for ( unsigned int j=1; j <= row_p.get().size() ; j++){
329  matrix(i,j)=row_p.get()(j);
330  }
331  }else{
332  log(Error)<<"Property of Row "<<i<<"was not ready for use"<<endlog();
333  return false;
334  }
335  }
336  }else {
337  log(Error) << "Composing Property< SymmetricMatrix > :"
338  << " type mismatch, got type '"<< bag.getType()
339  << "', expected type "<<"SymmetricMatrix."<<endlog();
340  return false;
341  }
342  matrix.convertToSymmetricMatrix(result);
343  return true;
344  };
345  };
346 
348  : public std::binary_function<const ColumnVector&, int, double>
349  {
350  double operator()(const ColumnVector& v, int index) const
351  {
352  if ( index > (int)(v.size()) || index < 1)
353  return NAN;
354  return v(index);
355  }
356  };
357 
359  : public std::binary_function<const RowVector&, int, double>
360  {
361  double operator()(const RowVector& v, int index) const
362  {
363  if ( index > (int)(v.size()) || index < 1)
364  return NAN;
365  return v(index);
366  }
367  };
368 
369  struct get_size
370  : public std::unary_function<const ColumnVector&, int>
371  {
372  int operator()(const ColumnVector& cont ) const
373  {
374  return cont.size();
375  }
376  };
377 
378  struct rget_size
379  : public std::unary_function<const RowVector&, int>
380  {
381  int operator()(const RowVector& cont ) const
382  {
383  return cont.size();
384  }
385  };
386 
388  : public std::unary_function<int,const ColumnVector&>
389  {
390  typedef const ColumnVector& (Signature)( int );
393  ptr( new ColumnVector() ){}
394  const ColumnVector& operator()(int size ) const
395  {
396  ptr->resize(size);
397  return *(ptr);
398  }
399  };
400 
402  : public std::unary_function<int,const RowVector&>
403  {
404  typedef const RowVector& (Signature)( int );
407  ptr( new RowVector() ){}
408  const RowVector& operator()(int size ) const
409  {
410  ptr->resize(size);
411  return *(ptr);
412  }
413  };
414 
416  : public std::binary_function<const Matrix&, int, const RowVector&>
417  {
418  const RowVector& operator()(const Matrix& m, int index) const
419  {
420  if ( index > (int)(m.rows()) || index < 1)
421  {
422  log(Error) << "index error" << endlog();
423  return RowVector(0);
424  }
425  return m.rowCopy(index);
426  }
427  };
428 
429  //struct matrix_index
430  // : public std::ternary_function<const Matrix&, int, int, double>
431  //{
432  // double operator()(const Matrix& m, int i, int j) const{
433  // if ( i > (int)(m.rows()) || i < 1 || j<1 || j> (int)(m.columns()))
434  // return NAN;
435  // return m(i,j);
436  // }
437  //};
438 
440  : public std::binary_function<int,int,const Matrix&>
441  {
442  typedef const Matrix& (Signature)( int, int );
445  ptr( new Matrix() ){}
446  const Matrix& operator()(int size1,int size2) const
447  {
448  ptr->resize(size1,size2);
449  return *(ptr);
450  }
451  };
452 
454  : public std::unary_function<int,const SymmetricMatrix&>
455  {
456  typedef const SymmetricMatrix& (Signature)( int );
459  ptr( new SymmetricMatrix() ){}
460  const SymmetricMatrix& operator()(int size) const
461  {
462  ptr->resize(size);
463  return *(ptr);
464  }
465  };
466 
468  : public std::unary_function<double, const Probability&>
469  {
470  typedef const Probability& (Signature)( double );
473  : ptr( new Probability() ) {}
474  const Probability& operator()( double value ) const
475  {
476  //ptr = new Probability(value);
477  //return *(ptr);
478  return *(new Probability(value));
479  }
480  };
481 
483  {
484  return "bfl_toolkit";
485  }
486 
488  {
489  RTT::TypeInfoRepository::Instance()->addType( new VectorTypeInfo() );
490  RTT::TypeInfoRepository::Instance()->addType( new RVectorTypeInfo() );
491  RTT::TypeInfoRepository::Instance()->addType( new MatrixTypeInfo() );
492  RTT::TypeInfoRepository::Instance()->addType( new SymmetricMatrixTypeInfo() );
493  RTT::TypeInfoRepository::Instance()->addType( new SampleTypeInfo<int>("SampleInt") );
494  RTT::TypeInfoRepository::Instance()->addType( new SampleTypeInfo<double>("SampleDouble") );
495  RTT::TypeInfoRepository::Instance()->addType( new SampleTypeInfo<ColumnVector>("SampleColumnVector") );
496  RTT::TypeInfoRepository::Instance()->addType( new WeightedSampleTypeInfo<int>("WeightedSampleInt") );
497  RTT::TypeInfoRepository::Instance()->addType( new WeightedSampleTypeInfo<double>("WeightedSampleDouble") );
498  RTT::TypeInfoRepository::Instance()->addType( new WeightedSampleTypeInfo<ColumnVector>("WeightedSampleColumnVector") );
499  RTT::TypeInfoRepository::Instance()->addType( new ProbabilityTypeInfo() );
500 
501  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<ColumnVector,true>("ColumnVectors") );
502  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<RowVector,true>("RowVectors") );
503  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<Matrix,true>("Matrixs") );
504  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<SymmetricMatrix,true>("SymmetricMatrixs") );
505  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<Sample<int>,false>("SampleInts") );
506  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<Sample<double>,false>("SampleDoubles") );
507  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<Sample<ColumnVector>,false>("SampleColumnVectors") );
508  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<WeightedSample<int>,false>("WeightedSampleInts") );
509  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<WeightedSample<double>,false>("WeightedSampleDoubles") );
510  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<WeightedSample<ColumnVector>,false>("WeightedSampleColumnVectors") );
511  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<Probability,false>("Probabilitys") );
512 
513  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<Sample<int> >,false>("VecSampleInts") );
514  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<Sample<double> >,false>("VecSampleDoubles") );
515  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<Sample<ColumnVector> >,false>("VecSampleColumnVectors") );
516  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<WeightedSample<int> >,false>("VecWeightedSampleInts") );
517  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<WeightedSample<double> >,false>("VecWeightedSampleDoubles") );
518  RTT::TypeInfoRepository::Instance()->addType( new StdVectorTemplateTypeInfo<vector<WeightedSample<ColumnVector> >,false>("VecWeightedSampleColumnVectors") );
519  return true;
520  }
521 
523  {
524  RTT::TypeInfoRepository::Instance()->type("ColumnVector")->addConstructor(newConstructor(vector_index_constructor()));
525  RTT::TypeInfoRepository::Instance()->type("RowVector")->addConstructor(newConstructor(rvector_index_constructor()));
526  RTT::TypeInfoRepository::Instance()->type("Matrix")->addConstructor(newConstructor(matrix_i_j_constructor()));
527  RTT::TypeInfoRepository::Instance()->type("SymmetricMatrix")->addConstructor(newConstructor(symmetricMatrix_index_constructor()));
528  //RTT::TypeInfoRepository::Instance()->type("ColumnVector")->addConstructor(newConstructor(vector_index_value_constructor()));
529  //
530  RTT::TypeInfoRepository::Instance()->type("ColumnVectors")->addConstructor(newConstructor(stdvector_ctor<ColumnVector>() ) );
531  RTT::TypeInfoRepository::Instance()->type("ColumnVectors")->addConstructor(newConstructor(stdvector_ctor2<ColumnVector>() ) );
532  RTT::TypeInfoRepository::Instance()->type("ColumnVectors")->addConstructor(new StdVectorBuilder<ColumnVector>() );
533 
534  RTT::TypeInfoRepository::Instance()->type("RowVectors")->addConstructor(newConstructor(stdvector_ctor<RowVector>() ) );
535  RTT::TypeInfoRepository::Instance()->type("RowVectors")->addConstructor(newConstructor(stdvector_ctor2<RowVector>() ) );
536  RTT::TypeInfoRepository::Instance()->type("RowVectors")->addConstructor(new StdVectorBuilder<RowVector>() );
537 
538  RTT::TypeInfoRepository::Instance()->type("Matrixs")->addConstructor(newConstructor(stdvector_ctor<Matrix>() ) );
539  RTT::TypeInfoRepository::Instance()->type("Matrixs")->addConstructor(newConstructor(stdvector_ctor2<Matrix>() ) );
540  RTT::TypeInfoRepository::Instance()->type("Matrixs")->addConstructor(new StdVectorBuilder<Matrix>() );
541 
542  RTT::TypeInfoRepository::Instance()->type("SymmetricMatrixs")->addConstructor(newConstructor(stdvector_ctor<SymmetricMatrix>() ) );
543  RTT::TypeInfoRepository::Instance()->type("SymmetricMatrixs")->addConstructor(newConstructor(stdvector_ctor2<SymmetricMatrix>() ) );
544  RTT::TypeInfoRepository::Instance()->type("SymmetricMatrixs")->addConstructor(new StdVectorBuilder<SymmetricMatrix>() );
545 
546  RTT::TypeInfoRepository::Instance()->type("SampleInts")->addConstructor(newConstructor(stdvector_ctor<Sample<int> >() ) );
547  RTT::TypeInfoRepository::Instance()->type("SampleInts")->addConstructor(newConstructor(stdvector_ctor2<Sample<int> >() ) );
548  RTT::TypeInfoRepository::Instance()->type("SampleInts")->addConstructor(new StdVectorBuilder<Sample<int> >() );
549 
550  RTT::TypeInfoRepository::Instance()->type("SampleDoubles")->addConstructor(newConstructor(stdvector_ctor<Sample<double> >() ) );
551  RTT::TypeInfoRepository::Instance()->type("SampleDoubles")->addConstructor(newConstructor(stdvector_ctor2<Sample<double> >() ) );
552  RTT::TypeInfoRepository::Instance()->type("SampleDoubles")->addConstructor(new StdVectorBuilder<Sample<double> >() );
553 
554  RTT::TypeInfoRepository::Instance()->type("SampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor<Sample<ColumnVector> >() ) );
555  RTT::TypeInfoRepository::Instance()->type("SampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor2<Sample<ColumnVector> >() ) );
556  RTT::TypeInfoRepository::Instance()->type("SampleColumnVectors")->addConstructor(new StdVectorBuilder<Sample<ColumnVector> >() );
557 
558 
559  RTT::TypeInfoRepository::Instance()->type("WeightedSampleInts")->addConstructor(newConstructor(stdvector_ctor<WeightedSample<int> >() ) );
560  RTT::TypeInfoRepository::Instance()->type("WeightedSampleInts")->addConstructor(newConstructor(stdvector_ctor2<WeightedSample<int> >() ) );
561  RTT::TypeInfoRepository::Instance()->type("WeightedSampleInts")->addConstructor(new StdVectorBuilder<WeightedSample<int> >() );
562 
563  RTT::TypeInfoRepository::Instance()->type("WeightedSampleDoubles")->addConstructor(newConstructor(stdvector_ctor<WeightedSample<double> >() ) );
564  RTT::TypeInfoRepository::Instance()->type("WeightedSampleDoubles")->addConstructor(newConstructor(stdvector_ctor2<WeightedSample<double> >() ) );
565  RTT::TypeInfoRepository::Instance()->type("WeightedSampleDoubles")->addConstructor(new StdVectorBuilder<WeightedSample<double> >() );
566 
567  RTT::TypeInfoRepository::Instance()->type("WeightedSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor<WeightedSample<ColumnVector> >() ) );
568  RTT::TypeInfoRepository::Instance()->type("WeightedSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor2<WeightedSample<ColumnVector> >() ) );
569  RTT::TypeInfoRepository::Instance()->type("WeightedSampleColumnVectors")->addConstructor(new StdVectorBuilder<WeightedSample<ColumnVector> >() );
570 
571  RTT::TypeInfoRepository::Instance()->type("VecSampleInts")->addConstructor(newConstructor(stdvector_ctor<vector<Sample<int> > >() ) );
572  RTT::TypeInfoRepository::Instance()->type("VecSampleInts")->addConstructor(newConstructor(stdvector_ctor2<vector<Sample<int> > >() ) );
573  RTT::TypeInfoRepository::Instance()->type("VecSampleInts")->addConstructor(new StdVectorBuilder<vector<Sample<int> > >() );
574 
575  RTT::TypeInfoRepository::Instance()->type("VecSampleDoubles")->addConstructor(newConstructor(stdvector_ctor<vector<Sample<double> > >() ) );
576  RTT::TypeInfoRepository::Instance()->type("VecSampleDoubles")->addConstructor(newConstructor(stdvector_ctor2<vector<Sample<double> > >() ) );
577  RTT::TypeInfoRepository::Instance()->type("VecSampleDoubles")->addConstructor(new StdVectorBuilder<vector<Sample<double> > >() );
578 
579  RTT::TypeInfoRepository::Instance()->type("VecSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor<vector<Sample<ColumnVector> > >() ) );
580  RTT::TypeInfoRepository::Instance()->type("VecSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor2<vector<Sample<ColumnVector> > >() ) );
581  RTT::TypeInfoRepository::Instance()->type("VecSampleColumnVectors")->addConstructor(new StdVectorBuilder<vector<Sample<ColumnVector> > >() );
582 
583  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleInts")->addConstructor(newConstructor(stdvector_ctor<vector<WeightedSample<int> > >() ) );
584  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleInts")->addConstructor(newConstructor(stdvector_ctor2<vector<WeightedSample<int> > >() ) );
585  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleInts")->addConstructor(new StdVectorBuilder<vector<WeightedSample<int> > >() );
586 
587  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleDoubles")->addConstructor(newConstructor(stdvector_ctor<vector<WeightedSample<double> > >() ) );
588  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleDoubles")->addConstructor(newConstructor(stdvector_ctor2<vector<WeightedSample<double> > >() ) );
589  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleDoubles")->addConstructor(new StdVectorBuilder<vector<WeightedSample<double> > >() );
590 
591  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor<vector<WeightedSample<ColumnVector> > >() ) );
592  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleColumnVectors")->addConstructor(newConstructor(stdvector_ctor2<vector<WeightedSample<ColumnVector> > >() ) );
593  RTT::TypeInfoRepository::Instance()->type("VecWeightedSampleColumnVectors")->addConstructor(new StdVectorBuilder<vector<WeightedSample<ColumnVector> > >() );
594 
595  RTT::TypeInfoRepository::Instance()->type("Probabilitys")->addConstructor(newConstructor(stdvector_ctor<Probability>() ) );
596  RTT::TypeInfoRepository::Instance()->type("Probabilitys")->addConstructor(newConstructor(stdvector_ctor2<Probability>() ) );
597  RTT::TypeInfoRepository::Instance()->type("Probabilitys")->addConstructor(new StdVectorBuilder<Probability>() );
598 
599  RTT::OperatorRepository::Instance()->add( newBinaryOperator( "[]", stdvector_index<ColumnVector>() ) );
600  RTT::OperatorRepository::Instance()->add( newDotOperator( "size", RTT::get_size<const std::vector<ColumnVector>&>() ) );
601 
602  RTT::TypeInfoRepository::Instance()->type("SampleInt")->addConstructor(newConstructor(Sample_ctor<int>() ) );
603  RTT::TypeInfoRepository::Instance()->type("SampleDouble")->addConstructor(newConstructor(Sample_ctor<double>() ) );
604  RTT::TypeInfoRepository::Instance()->type("SampleColumnVector")->addConstructor(newConstructor(Sample_ctor<ColumnVector>() ) );
605  RTT::TypeInfoRepository::Instance()->type("WeightedSampleInt")->addConstructor(newConstructor(WeightedSample_ctor<int>() ) );
606  RTT::TypeInfoRepository::Instance()->type("WeightedSampleDouble")->addConstructor(newConstructor(WeightedSample_ctor<double>() ) );
607  RTT::TypeInfoRepository::Instance()->type("WeightedSampleColumnVector")->addConstructor(newConstructor(WeightedSample_ctor<ColumnVector>() ) );
608 
609  RTT::TypeInfoRepository::Instance()->type("Probability")->addConstructor(newConstructor(Probability_ctor() ) );
610 
611  return true;
612  }
613 
615  {
616  RTT::OperatorRepository::Instance()->add( newBinaryOperator( "[]", vector_index() ) );
617  RTT::OperatorRepository::Instance()->add( newBinaryOperator( "[]", rvector_index() ) );
618  RTT::OperatorRepository::Instance()->add( newDotOperator( "size", get_size() ) );
619  RTT::OperatorRepository::Instance()->add( newDotOperator( "size", rget_size() ) );
620  RTT::OperatorRepository::Instance()->add( newBinaryOperator( "+", std::plus<ColumnVector>() ) );
621  RTT::OperatorRepository::Instance()->add( newBinaryOperator( "+", std::plus<RowVector>() ) );
622  //RTT::OperatorRepository::Instance()->add( newTernaryOperator( "[,]", matrix_index() ) );
623  //RTT::OperatorRepository::Instance()->add( newBinaryOperator( "[]", matrix_index() ) );
624  return true;
625  }
626 }
627 
628 ORO_TOOLKIT_PLUGIN(BFL::bflToolkit)
const RowVector &( Signature)(int)
boost::shared_ptr< SymmetricMatrix > ptr
ostream & operator<<(ostream &stream, Probability &prob)
Definition: bfl_toolkit.cpp:62
boost::shared_ptr< RowVector > ptr
boost::shared_ptr< ColumnVector > ptr
const ColumnVector &( Signature)(int)
const Probability & operator()(double value) const
const ColumnVector & operator()(int size) const
const SymmetricMatrix &( Signature)(int)
bool decomposeTypeImpl(const ColumnVector &vec, PropertyBag &targetbag) const
bool decomposeTypeImpl(const RowVector &vec, PropertyBag &targetbag) const
bool composeTypeImpl(const PropertyBag &bag, SymmetricMatrix &result) const
bool composeTypeImpl(const PropertyBag &bag, RowVector &result) const
bool composeTypeImpl(const PropertyBag &bag, ColumnVector &result) const
int operator()(const ColumnVector &cont) const
const Matrix & operator()(int size1, int size2) const
boost::shared_ptr< Probability > ptr
virtual bool loadTypes()
bool composeTypeImpl(const PropertyBag &bag, Matrix &result) const
istream & operator>>(istream &stream, Probability &prob)
Definition: bfl_toolkit.cpp:68
virtual std::string getName()
virtual bool loadOperators()
boost::shared_ptr< Matrix > ptr
const SymmetricMatrix & operator()(int size) const
const RowVector & operator()(int size) const
bool decomposeTypeImpl(const SymmetricMatrix &mat, PropertyBag &targetbag) const
virtual bool loadConstructors()
int operator()(const RowVector &cont) const
bflToolkitPlugin bflToolkit
Definition: bfl_toolkit.cpp:85
double operator()(const ColumnVector &v, int index) const
const Matrix &( Signature)(int, int)
Class representing a probability (a double between 0 and 1)
Definition: bfl_constants.h:39
const RowVector & operator()(const Matrix &m, int index) const
virtual bool composeTypeImpl(const PropertyBag &bag, Probability &prob) const
Definition: bfl_toolkit.cpp:99
const Probability &( Signature)(double)
double getValue() const
Definition: bfl_constants.h:71
virtual bool decomposeTypeImpl(const Probability &prob, PropertyBag &targetbag) const
Definition: bfl_toolkit.cpp:92
bool decomposeTypeImpl(const Matrix &mat, PropertyBag &targetbag) const
double operator()(const RowVector &v, int index) const


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Jun 10 2019 12:47:58