articulatedbodyinertia.cpp
Go to the documentation of this file.
1 // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
2 
3 // Version: 1.0
4 // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
5 // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
6 // URL: http://www.orocos.org/kdl
7 
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 
23 
24 #include <Eigen/Core>
25 
26 using namespace Eigen;
27 
28 namespace KDL{
29 
30  ArticulatedBodyInertia::ArticulatedBodyInertia(const RigidBodyInertia& rbi)
31  {
32  this->M=Matrix3d::Identity()*rbi.m;
33  this->I=Map<const Matrix3d>(rbi.I.data);
34  this->H << 0,-rbi.h[2],rbi.h[1],
35  rbi.h[2],0,-rbi.h[0],
36  -rbi.h[1],rbi.h[0],0;
37  }
38 
39  ArticulatedBodyInertia::ArticulatedBodyInertia(double m, const Vector& c, const RotationalInertia& Ic)
40  {
41  *this = RigidBodyInertia(m,c,Ic);
42  }
43 
44  ArticulatedBodyInertia::ArticulatedBodyInertia(const Matrix3d& M, const Matrix3d& H, const Matrix3d& I)
45  {
46  this->M=M;
47  this->I=I;
48  this->H=H;
49  }
50 
52  return ArticulatedBodyInertia(a*I.M,a*I.H,a*I.I);
53  }
54 
56  return ArticulatedBodyInertia(Ia.M+Ib.M,Ia.H+Ib.H,Ia.I+Ib.I);
57  }
58 
60  return ArticulatedBodyInertia(Ia)+Ib;
61  }
63  return ArticulatedBodyInertia(Ia.M-Ib.M,Ia.H-Ib.H,Ia.I-Ib.I);
64  }
65 
67  return ArticulatedBodyInertia(Ia)-Ib;
68  }
69 
71  Wrench result;
72  Vector3d::Map(result.force.data)=I.M*Vector3d::Map(t.vel.data)+I.H.transpose()*Vector3d::Map(t.rot.data);
73  Vector3d::Map(result.torque.data)=I.I*Vector3d::Map(t.rot.data)+I.H*Vector3d::Map(t.vel.data);
74  return result;
75  }
76 
78  Frame X=T.Inverse();
79  //mb=ma
80  //hb=R*(h-m*r)
81  //Ib = R(Ia+r x h x + (h-m*r) x r x)R'
82  Map<Matrix3d> E(X.M.data);
83  Matrix3d rcross;
84  rcross << 0,-X.p[2],X.p[1],
85  X.p[2],0,-X.p[0],
86  -X.p[1],X.p[0],0;
87 
88  Matrix3d HrM=I.H-rcross*I.M;
89  return ArticulatedBodyInertia(E*I.M*E.transpose(),E*HrM*E.transpose(),E*(I.I-rcross*I.H.transpose()+HrM*rcross)*E.transpose());
90  }
91 
93  Map<const Matrix3d> E(M.data);
94  return ArticulatedBodyInertia(E.transpose()*I.M*E,E.transpose()*I.H*E,E.transpose()*I.I*E);
95  }
96 
97  ArticulatedBodyInertia ArticulatedBodyInertia::RefPoint(const Vector& p){
98  //mb=ma
99  //hb=R*(h-m*r)
100  //Ib = R(Ia+r x h x + (h-m*r) x r x)R'
101  Matrix3d rcross;
102  rcross << 0,-p[2],p[1],
103  p[2],0,-p[0],
104  -p[1],p[0],0;
105 
106  Matrix3d HrM=this->H-rcross*this->M;
107  return ArticulatedBodyInertia(this->M,HrM,this->I-rcross*this->H.transpose()+HrM*rcross);
108  }
109 }//namespace
represents rotations in 3 dimensional space.
Definition: frames.hpp:301
Vector vel
The velocity of that point.
Definition: frames.hpp:722
6D Inertia of a rigid body
Vector torque
Torque that is applied at the origin of the current ref frame.
Definition: frames.hpp:882
Rotation M
Orientation of the Frame.
Definition: frames.hpp:573
ArticulatedBodyInertia operator+(const RigidBodyInertia &Ia, const ArticulatedBodyInertia &Ib)
represents both translational and rotational velocities.
Definition: frames.hpp:720
6D Inertia of a articulated body
A concrete implementation of a 3 dimensional vector class.
Definition: frames.hpp:160
Vector rot
The rotational velocity of that point.
Definition: frames.hpp:723
ArticulatedBodyInertia operator*(const Rotation &M, const ArticulatedBodyInertia &I)
double data[3]
Definition: frames.hpp:163
Vector p
origine of the Frame
Definition: frames.hpp:572
Frame Inverse() const
Gives back inverse transformation of a Frame.
Definition: frames.hpp:423
Vector force
Force that is applied at the origin of the current ref frame.
Definition: frames.hpp:881
represents a frame transformation in 3D space (rotation + translation)
Definition: frames.hpp:570
represents both translational and rotational acceleration.
Definition: frames.hpp:878
ArticulatedBodyInertia operator-(const RigidBodyInertia &Ia, const ArticulatedBodyInertia &Ib)
double data[9]
Definition: frames.hpp:304


orocos_kdl
Author(s):
autogenerated on Fri Mar 12 2021 03:05:43