27 #include <rtt/types/Types.hpp> 35 #include <boost/lexical_cast.hpp> 81 if (index >= (
int) (v.size()) || index < 0)
88 if (index >= (
int) (v.size()) || index < 0)
100 #if (RTT_VERSION_MAJOR*100+RTT_VERSION_MINOR) >= 206 108 #if (RTT_VERSION_MAJOR*100+RTT_VERSION_MINOR) >= 206 109 bool installTypeInfoObject(
TypeInfo* ti) {
111 boost::shared_ptr< VectorTypeInfo > mthis = boost::dynamic_pointer_cast<
VectorTypeInfo >( this->getSharedPtr() );
124 if (arg->isAssignable()) {
126 asarg->
set().resize( size );
135 std::vector<std::string> result;
136 result.push_back(
"size");
137 result.push_back(
"capacity");
144 unsigned int indx = boost::lexical_cast<
unsigned int>(name);
158 if ( id_name->
get() ==
"size" || id_name->
get() ==
"capacity") {
167 if ( item->isAssignable() )
174 log(
Error) <<
"EigenVectorTypeInfo: No such member : " << id_name->
get() <<
endlog();
179 if ( !id_name && ! id_indx)
180 log(
Error) <<
"EigenVectorTypeInfo: Not a member or index : " <<
id <<
":"<<
id->getTypeName() <<
endlog();
187 targetbag.
setType(
"eigen_vector");
188 int dimension = vec.rows();
191 if(!targetbag.
empty())
194 for (
int i=0; i < dimension ; i++){
195 std::stringstream out;
206 if ( bag.
getType() ==
"eigen_vector" ) {
207 int dimension = bag.
size();
208 result.resize( dimension );
211 for (
int i = 0; i < dimension ; i++) {
212 std::stringstream out;
216 result(i) = elem.
get();
223 log(
Error) <<
"Composing Property< VectorXd > :" 224 <<
" type mismatch, got type '"<< bag.
getType()
225 <<
"', expected type "<<
"eigen_vector."<<
endlog();
238 targetbag.
setType(
"eigen_matrix");
239 unsigned int dimension = mat.rows();
240 if(!targetbag.
empty())
243 for (
unsigned int i=0; i < dimension ; i++){
244 std::stringstream out;
253 if ( bag.
getType() ==
"eigen_matrix" ) {
254 unsigned int rows = bag.
size();
255 unsigned int cols = 0;
257 for (
unsigned int i = 0; i < rows ; i++) {
258 std::stringstream out;
261 if(!row_bag.
ready()){
266 if(!(row_p.compose(row_bag))){
272 cols = row_p.get().size();
273 result.resize(rows,cols);
275 if(row_p.get().rows()!=(int)cols){
276 log(
Error)<<
"Row "<<i+1<<
" size does not match matrix columns"<<
endlog();
279 result.row(i)=row_p.get();
281 log(
Error)<<
"Property of Row "<<i+1<<
"was not ready for use"<<
endlog();
286 log(
Error) <<
"Composing Property< MatrixXd > :" 287 <<
" type mismatch, got type '"<< bag.
getType()
288 <<
"', expected type "<<
"ublas_matrix."<<
endlog();
296 :
public std::binary_function<const VectorXd&, int, double>
300 if ( index >= (
int)(v.size()) || index < 0)
307 :
public std::unary_function<const VectorXd&, int>
316 :
public std::binary_function<int,double,const VectorXd&>
319 mutable boost::shared_ptr< VectorXd >
ptr;
321 ptr( new VectorXd ){}
325 (*ptr)=Eigen::VectorXd::Constant(size,value);
331 :
public std::unary_function<std::vector<double >,const VectorXd&>
333 typedef const VectorXd& (
Signature)( std::vector<double > );
334 mutable boost::shared_ptr< VectorXd >
ptr;
336 ptr( new VectorXd ){}
337 const VectorXd&
operator()(std::vector<double > values)
const 339 (*ptr)=VectorXd::Map(&values[0],values.size());
345 :
public std::unary_function<int,const VectorXd&>
348 mutable boost::shared_ptr< VectorXd >
ptr;
350 ptr( new VectorXd() ){}
362 if ( i >= (
int)(m.rows()) || i < 0 || j<0 || j>= (
int)(m.cols()))
369 :
public std::binary_function<int,int,const MatrixXd&>
372 mutable boost::shared_ptr< MatrixXd >
ptr;
374 ptr( new MatrixXd() ){}
377 ptr->resize(size1,size2);
383 std::string EigenTypekitPlugin::getName()
388 bool EigenTypekitPlugin::loadTypes()
395 bool EigenTypekitPlugin::loadConstructors()
404 bool EigenTypekitPlugin::loadOperators()
#define ORO_TYPEKIT_PLUGIN(TYPEKIT)
boost::shared_ptr< VectorXd > ptr
DataSourceType get() const
const VectorXd &( Signature)(int)
virtual result_t get() const =0
double operator()(const VectorXd &v, int index) const
void add(base::PropertyBase *p)
virtual bool decomposeTypeImpl(const VectorXd &vec, PropertyBag &targetbag) const
const MatrixXd & operator()(int size1, int size2) const
base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, base::DataSourceBase::shared_ptr id) const
std::istream & operator>>(std::istream &is, BufferPolicy &bp)
const VectorXd & operator()(int size) const
const std::string & getType() const
static shared_ptr Instance()
const MatrixXd &( Signature)(int, int)
virtual bool composeTypeImpl(const PropertyBag &bag, VectorXd &result) const
virtual void set(param_t t)=0
void setType(const std::string &newtype)
double get_item_copy(const VectorXd &v, int index)
base::DataSourceBase * newFunctorDataSource(Function f, const std::vector< base::DataSourceBase::shared_ptr > &args)
const VectorXd & operator()(std::vector< double > values) const
vector_index_constructor()
const VectorXd &( Signature)(int, double)
double & get_item(VectorXd &v, int index)
bool composeTypeImpl(const PropertyBag &bag, MatrixXd &result) const
bool decomposeTypeImpl(const MatrixXd &mat, PropertyBag &targetbag) const
TypeConstructor * newConstructor(Function *foo, bool automatic=false)
vector_index_value_constructor()
BinaryOperator< function > * newBinaryOperator(const char *op, function f)
const std::string & getDescription() const
virtual std::vector< std::string > getMemberNames() const
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
void setMemberFactory(MemberFactoryPtr mf)
TypeInfoRepository::shared_ptr Types()
boost::shared_ptr< MatrixXd > ptr
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
vector_index_array_constructor()
base::PropertyBase * getProperty(const std::string &name) const
static shared_ptr Instance()
static DataSource< T > * narrow(base::DataSourceBase *db)
const VectorXd &( Signature)(std::vector< double >)
base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string &name) const
virtual std::string getTypeName() const
const std::string & getName() const
boost::intrusive_ptr< DataSourceBase > shared_ptr
boost::shared_ptr< VectorXd > ptr
double operator()(const MatrixXd &m, int i, int j) const
const VectorXd & operator()(int size, double value) const
int operator()(const VectorXd &cont) const
bool resize(base::DataSourceBase::shared_ptr arg, int size) const
static Logger::LogFunction endlog()
boost::shared_ptr< VectorXd > ptr