kdlTypekitConstructors.cpp
Go to the documentation of this file.
1 #include "kdlTypekit.hpp"
2 namespace KDL{
3  // CONSTRUCTORS
4  Frame framevr( const Vector& v, const Rotation& r )
5  {
6  return Frame( r, v );
7  }
8  Frame framerv( const Rotation& r, const Vector& v )
9  {
10  return Frame( r, v );
11  }
12 
13 
14  Wrench wrenchft( const Vector& force, const Vector& torque )
15  {
16  return Wrench( force, torque );
17  }
18 
19  Twist twistvw( const Vector& trans, const Vector& rot )
20  {
21  return Twist( trans, rot );
22  }
23 
24  Vector vectorxyz( double a, double b, double c )
25  {
26  return Vector( a, b, c );
27  }
28 
29 
30  // INDEXING
31  template<class WT>
33  : public std::binary_function<WT,int,double>
34  {
35  double operator()( WT& w, int index) const
36  {
37  if (index > 5 || index <0)
38  return 0.0;
39  else
40  return w[index];
41  }
42  };
43 
44  struct vector_index
45  : public std::binary_function<Vector, int, double>
46  {
47  double operator()( Vector& v, int index ) const
48  {
49  if (index > 2 || index <0)
50  return 0.0;
51  else
52  return v[index];
53  }
54  };
55 
56  // DOTTING
57  template< int I>
58  struct vector_dot
59  : public std::unary_function<Vector, double>
60  {
61  double operator()(const Vector& v ) const
62  {
63  return v[I];
64  }
65  };
66 
67  struct twist_rot
68  : public std::unary_function<Twist, Vector>
69  {
70  Vector operator()(const Twist& t ) const
71  {
72  return t.rot;
73  }
74  };
75 
76  struct twist_vel
77  : public std::unary_function<Twist, Vector>
78  {
79  Vector operator()(const Twist& t ) const
80  {
81  return t.vel;
82  }
83  };
84 
86  : public std::unary_function<Wrench, Vector>
87  {
88  Vector operator()(const Wrench& t ) const
89  {
90  return t.torque;
91  }
92  };
93 
94  struct wrench_force
95  : public std::unary_function<Wrench, Vector>
96  {
97  Vector operator()(const Wrench& t ) const
98  {
99  return t.force;
100  }
101  };
102 
103  struct frame_pos
104  : public std::unary_function<Frame, Vector>
105  {
106  Vector operator()(const Frame& f ) const
107  {
108  return f.p;
109  }
110  };
111 
112  struct frame_rot
113  : public std::unary_function<Frame, Rotation>
114  {
115  Rotation operator()(const Frame& f ) const
116  {
117  return f.M;
118  }
119  };
120 
121  struct frame_inv
122  : public std::unary_function<Frame, Frame>
123  {
124  Frame operator()(const Frame& f ) const
125  {
126  return f.Inverse();
127  }
128  };
129 
131  : public std::unary_function<Rotation, double>
132  {
133  double operator()(const Rotation& rot ) const
134  {
135  double r,p,y;
136  rot.GetRPY(r,p,y);
137  return r;
138  }
139  };
140 
142  : public std::unary_function<Rotation, double>
143  {
144  double operator()(const Rotation& rot ) const
145  {
146  double r,p,y;
147  rot.GetRPY(r,p,y);
148  return p;
149  }
150  };
151 
153  : public std::unary_function<Rotation, double>
154  {
155  double operator()(const Rotation& rot ) const
156  {
157  double r,p,y;
158  rot.GetRPY(r,p,y);
159  return y;
160  }
161  };
162 
164  : public std::unary_function<Rotation, Rotation>
165  {
166  Rotation operator()(const Rotation& rot ) const
167  {
168  return rot.Inverse();
169  }
170  };
171 
172  Rotation rotationAngleAxis( const Vector& axis, double angle )
173  {
174  return Rotation::Rot(axis, angle);
175  }
176 
178  {
179  TypeInfoRepository::shared_ptr ti = TypeInfoRepository::Instance();
180 
181  ti->type("KDL.Vector")->addConstructor( newConstructor(&vectorxyz) );
182  ti->type("KDL.Rotation")->addConstructor( newConstructor( ptr_fun( Rotation::RPY )) );
183  ti->type("KDL.Rotation")->addConstructor( newConstructor(&rotationAngleAxis) );
184  ti->type("KDL.Frame")->addConstructor( newConstructor(&framerv) );
185  ti->type("KDL.Frame")->addConstructor( newConstructor(&framevr) );
186  ti->type("KDL.Wrench")->addConstructor( newConstructor(&wrenchft) );
187  ti->type("KDL.Twist")->addConstructor( newConstructor(&twistvw) );
188 
190 
191  gs->provides("KDL")->provides("Rotation")->addOperation("RotX",&Rotation::RotX).doc("");
192  gs->provides("KDL")->provides("Rotation")->addOperation("RotY",&Rotation::RotY).doc("");
193  gs->provides("KDL")->provides("Rotation")->addOperation("RotZ",&Rotation::RotZ).doc("");
194  gs->provides("KDL")->provides("Rotation")->addOperation("RPY",&Rotation::RPY).doc("");
195  gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYX",&Rotation::EulerZYX).doc("");
196  gs->provides("KDL")->provides("Rotation")->addOperation("EulerZYZ",&Rotation::EulerZYZ).doc("");
197  gs->provides("KDL")->provides("Rotation")->addOperation("Quaternion",&Rotation::Quaternion).doc("");
198 
199  //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor<Frame>() ) );
200  //ti->type("Frame[]")->addConstructor(newConstructor(stdvector_ctor2<Frame>() ) );
201  //ti->type("Frame[]")->addConstructor(new StdVectorBuilder<Frame>() );
202 
203  //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor<Vector>() ) );
204  //ti->type("Vector[]")->addConstructor(newConstructor(stdvector_ctor2<Vector>() ) );
205  //ti->type("Vector[]")->addConstructor(new StdVectorBuilder<Vector>() );
206 
207  //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor<Rotation>() ) );
208  //ti->type("Rotation[]")->addConstructor(newConstructor(stdvector_ctor2<Rotation>() ) );
209  //ti->type("Rotation[]")->addConstructor(new StdVectorBuilder<Rotation>() );
210 
211  //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor<Wrench>() ) );
212  //ti->type("Wrench[]")->addConstructor(newConstructor(stdvector_ctor2<Wrench>() ) );
213  //ti->type("Wrench[]")->addConstructor(new StdVectorBuilder<Wrench>() );
214 
215  //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor<Twist>() ) );
216  //ti->type("Twist[]")->addConstructor(newConstructor(stdvector_ctor2<Twist>() ) );
217  //ti->type("Twist[]")->addConstructor(new StdVectorBuilder<Twist>() );
218 
219  return true;
220  }
221 
222 }
Frame framerv(const Rotation &r, const Vector &v)
Vector operator()(const Wrench &t) const
static Rotation RotX(double angle)
Rotation Inverse() const
pointer_to_ternary_function< ResultT, Arg1T, Arg2T, Arg3T > ptr_fun(ResultT(*fun)(Arg1T, Arg2T, Arg3T))
Vector vel
Twist twistvw(const Vector &trans, const Vector &rot)
double operator()(WT &w, int index) const
static Rotation RotZ(double angle)
Vector operator()(const Frame &f) const
static Rotation Quaternion(double x, double y, double z, double w)
double operator()(const Rotation &rot) const
Vector torque
static Rotation RotY(double angle)
Rotation operator()(const Rotation &rot) const
Vector operator()(const Twist &t) const
Rotation M
static Rotation EulerZYX(double Alfa, double Beta, double Gamma)
boost::shared_ptr< Service > shared_ptr
Wrench wrenchft(const Vector &force, const Vector &torque)
TypeConstructor * newConstructor(Function *foo, bool automatic=false)
Vector rot
static Rotation RPY(double roll, double pitch, double yaw)
Rotation operator()(const Frame &f) const
Frame operator()(const Frame &f) const
Vector vectorxyz(double a, double b, double c)
Vector operator()(const Twist &t) const
Frame framevr(const Vector &v, const Rotation &r)
double operator()(const Vector &v) const
double operator()(const Rotation &rot) const
Vector operator()(const Wrench &t) const
Frame Inverse() const
void GetRPY(double &roll, double &pitch, double &yaw) const
Vector force
double operator()(const Rotation &rot) const
static Rotation EulerZYZ(double Alfa, double Beta, double Gamma)
double operator()(Vector &v, int index) const
static Rotation Rot(const Vector &rotvec, double angle)
Rotation rotationAngleAxis(const Vector &axis, double angle)
static RTT_API Service::shared_ptr Instance()


kdl_typekit
Author(s): Steven Bellens, Ruben Smits
autogenerated on Wed Jul 3 2019 19:39:45