OpenWalker Project
Documentation of the ROS Packages
vector_dof.h
Go to the documentation of this file.
1 
34 #ifndef OPEN_WALKER_CORE_VECTOR_DOF_H
35 #define OPEN_WALKER_CORE_VECTOR_DOF_H
36 
37 #include <Eigen/Dense>
38 #include <ow_core/configuration.h>
39 
40 namespace ow_core
41 {
48 template <typename _Scalar, int _Rows>
49 class VectorDof :
50  public Eigen::Matrix<_Scalar, _Rows, 1>
51 {
52 public:
53  typedef _Scalar Scalar;
54 
55  enum
56  {
57  Rows = _Rows,
58  };
59 
60  typedef Eigen::Matrix<Scalar, Rows, 1> Base;
61 
62 public:
69  static typename Base::ConstantReturnType Zero()
70  {
71  return Base::Zero(OW_ROBOT_DOF);
72  }
73 
77  static typename Base::ConstantReturnType Ones()
78  {
79  return Base::Ones(OW_ROBOT_DOF);
80  }
81 
85  static typename Base::ConstantReturnType Constant(const Scalar& value)
86  {
87  return Base::Constant(OW_ROBOT_DOF,value);
88  }
89 
93  static const typename Base::RandomReturnType Random()
94  {
95  return Base::Random(OW_ROBOT_DOF);
96  }
97 
101  static const typename Base::BasisReturnType Unit(typename Base::Index i)
102  {
103  return Base::Unit(OW_ROBOT_DOF,i);
104  }
105 
106 
107 public:
111  explicit VectorDof()
112  {}
113 
120  template<typename OtherDerived>
121  VectorDof(const Eigen::EigenBase<OtherDerived>& other)
122  : Base(other)
123  {}
124 
128  using Base::operator=;
129 
130 
131  VectorDof& setConstant(const Scalar& value)
132  {
133  Base::setConstant(OW_ROBOT_DOF,value);
134  return *this;
135  }
136 
137  VectorDof& setLinSpaced(const Scalar& low, const Scalar& high)
138  {
139  Base::setLinSpaced(OW_ROBOT_DOF,low,high);
140  return *this;
141  }
142 
143  VectorDof& setZero()
144  {
145  Base::setZero(OW_ROBOT_DOF);
146  return *this;
147  }
148 
149  VectorDof& setOnes()
150  {
151  Base::setOnes(OW_ROBOT_DOF);
152  return *this;
153  }
154 
155  VectorDof& setRandom()
156  {
157  Base::setRandom(OW_ROBOT_DOF);
158  return *this;
159  }
160 
161 
165  std::string toString() const
166  {
167  std::ostringstream out;
168  out << this->transpose();
169  return out.str();
170  }
171 
172 private:
173 
177  using Base::resize;
178  using Base::resizeLike;
179  using Base::conservativeResize;
180 
184  using Base::LinSpaced;
185 
186 };
187 
188 } // namespace ow_core
189 
190 
191 #endif // OPEN_WALKER_CORE_VECTOR_DOF_H
static const Base::BasisReturnType Unit(typename Base::Index i)
Returns an expression where all coefficients represent the i-th basis vector.
Definition: vector_dof.h:101
static Base::ConstantReturnType Zero()
Returns an expression where all coefficients equal zero.
Definition: vector_dof.h:69
static Base::ConstantReturnType Constant(const Scalar &value)
Returns an expression where all coefficients equal the given value.
Definition: vector_dof.h:85
The VectorDof class.
Definition: vector_dof.h:49
Contains the global configurations.
Definition: angular_acceleration.h:39
VectorDof()
Default Constructor.
Definition: vector_dof.h:111
std::string toString() const
Conversion to std::string.
Definition: vector_dof.h:165
#define OW_ROBOT_DOF
A definition to set degrees of freedom of the robot.
Definition: configuration.h:45
static const Base::RandomReturnType Random()
Returns an expression where all coefficients are random.
Definition: vector_dof.h:93
VectorDof(const Eigen::EigenBase< OtherDerived > &other)
Copy constructor.
Definition: vector_dof.h:121
static Base::ConstantReturnType Ones()
Returns an expression where all coefficients equal one.
Definition: vector_dof.h:77