Robotics Library  0.7.0
ForceVector.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MATH_FORCEVECTOR_H
28 #define RL_MATH_FORCEVECTOR_H
29 
30 #include <Eigen/Core>
31 
32 namespace rl
33 {
34  namespace math
35  {
36  namespace spatial
37  {
38  template<typename Scalar> class ArticulatedBodyInertia;
39  template<typename Scalar> class MotionVector;
40 
44  template<typename Scalar>
46  {
47  public:
48  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
49 
50  typedef Scalar ScalarType;
51 
52  typedef typename ::Eigen::Matrix<Scalar, 6, 1> MatrixType;
53 
54  typedef const MatrixType ConstMatrixType;
55 
56  typedef ::Eigen::Block<MatrixType, 3, 1> MomentType;
57 
58  typedef const ::Eigen::Block<ConstMatrixType, 3, 1> ConstMomentType;
59 
60  typedef ::Eigen::Block<MatrixType, 3, 1> ForceType;
61 
62  typedef const ::Eigen::Block<ConstMatrixType, 3, 1> ConstForceType;
63 
65  {
66  }
67 
68  template<typename OtherDerived>
69  ForceVector(const ::Eigen::MatrixBase<OtherDerived>& other) :
70  data(other)
71  {
72  }
73 
74  virtual ~ForceVector()
75  {
76  }
77 
78  template<typename OtherScalar>
79  Scalar dot(const MotionVector<OtherScalar>& other) const;
80 
82  {
83  return data.template segment<3>(3);
84  }
85 
87  {
88  return data.template segment<3>(3);
89  }
90 
92  {
93  return data;
94  }
95 
97  {
98  return data.template segment<3>(0);
99  }
100 
102  {
103  return data.template segment<3>(0);
104  }
105 
106  template<typename OtherDerived>
107  ForceVector& operator=(const ::Eigen::MatrixBase<OtherDerived>& other)
108  {
109  data = other;
110  return *this;
111  }
112 
113  ForceVector operator+(const ForceVector& other) const
114  {
115  ForceVector res;
116  res.moment() = moment() + other.moment();
117  res.force() = force() + other.force();
118  return res;
119  }
120 
121  ForceVector operator-(const ForceVector& other) const
122  {
123  ForceVector res;
124  res.moment() = moment() - other.moment();
125  res.force() = force() - other.force();
126  return res;
127  }
128 
129  template<typename OtherScalar>
130  ForceVector operator*(const OtherScalar& other) const
131  {
132  ForceVector res;
133  res.moment() = moment() * other;
134  res.force() = force() * other;
135  return res;
136  }
137 
138  template<typename OtherScalar>
139  ForceVector operator/(const OtherScalar& other) const
140  {
141  ForceVector res;
142  res.moment() = moment() / other;
143  res.force() = force() / other;
144  return res;
145  }
146 
148 
149  void setZero()
150  {
151  moment().setZero();
152  force().setZero();
153  }
154 
155  protected:
156 
157  private:
159  };
160  }
161  }
162 }
163 
164 #endif // RL_MATH_FORCEVECTOR_H
rl::math::spatial::ArticulatedBodyInertia
Articulated-body inertia.
Definition: ArticulatedBodyInertia.h:47
rl::math::spatial::ForceVector::moment
ConstMomentType moment() const
Definition: ForceVector.h:101
rl::math::spatial::ForceVector::ForceVector
ForceVector(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: ForceVector.h:69
rl::math::ArticulatedBodyInertia
spatial::ArticulatedBodyInertia< Real > ArticulatedBodyInertia
Definition: Spatial.h:52
rl::math::spatial::ForceVector::operator*
ForceVector operator*(const OtherScalar &other) const
Definition: ForceVector.h:130
rl::math::spatial::ForceVector::operator+
ForceVector operator+(const ForceVector &other) const
Definition: ForceVector.h:113
rl::math::MotionVector
spatial::MotionVector< Real > MotionVector
Definition: Spatial.h:56
rl::math::spatial::ForceVector::ConstForceType
const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstForceType
Definition: ForceVector.h:62
rl::math::spatial::ForceVector::operator=
ForceVector & operator=(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: ForceVector.h:107
rl::math::spatial::ForceVector::matrix
ConstMatrixType & matrix() const
Definition: ForceVector.h:91
rl::math::spatial::ForceVector::dot
Scalar dot(const MotionVector< OtherScalar > &other) const
Definition: ForceVector.hxx:40
rl::math::spatial::ForceVector::force
ForceType force()
Definition: ForceVector.h:81
rl::math::spatial::ForceVector::ScalarType
Scalar ScalarType
Definition: ForceVector.h:50
rl::math::spatial::ForceVector::ForceType
::Eigen::Block< MatrixType, 3, 1 > ForceType
Definition: ForceVector.h:60
rl::math::spatial::ForceVector::ConstMomentType
const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstMomentType
Definition: ForceVector.h:58
rl::math::spatial::ForceVector::operator*
ArticulatedBodyInertia< Scalar > operator*(const ForceVector &other) const
rl::math::spatial::ForceVector::data
MatrixType data
Definition: ForceVector.h:158
rl::math::spatial::ForceVector::ConstMatrixType
const MatrixType ConstMatrixType
Definition: ForceVector.h:54
rl::math::spatial::ForceVector::MomentType
::Eigen::Block< MatrixType, 3, 1 > MomentType
Definition: ForceVector.h:56
rl::math::spatial::ForceVector::operator/
ForceVector operator/(const OtherScalar &other) const
Definition: ForceVector.h:139
rl::math::spatial::ForceVector
Force vector.
Definition: ForceVector.h:46
rl::math::spatial::ForceVector::~ForceVector
virtual ~ForceVector()
Definition: ForceVector.h:74
rl::math::spatial::MotionVector
Motion vector.
Definition: MotionVector.h:45
rl::math::spatial::ForceVector::moment
MomentType moment()
Definition: ForceVector.h:96
rl::math::spatial::ForceVector::ForceVector
ForceVector()
Definition: ForceVector.h:64
rl::math::spatial::ForceVector::MatrixType
::Eigen::Matrix< Scalar, 6, 1 > MatrixType
Definition: ForceVector.h:52
rl::math::spatial::ForceVector::operator-
ForceVector operator-(const ForceVector &other) const
Definition: ForceVector.h:121
rl::math::spatial::ForceVector::setZero
void setZero()
Definition: ForceVector.h:149
rl::math::spatial::ForceVector::force
ConstForceType force() const
Definition: ForceVector.h:86
rl
Robotics Library.
Definition: AnalogInput.cpp:30