18 #ifndef __se3_force_set_hpp__ 19 #define __se3_force_set_hpp__ 22 #include <Eigen/Geometry> 23 #include "pinocchio/spatial/fwd.hpp" 27 template<
typename _Scalar,
int _Options>
31 typedef _Scalar Scalar;
32 enum { Options = _Options };
33 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
34 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
35 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
36 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
39 typedef Eigen::Matrix<Scalar,3,Eigen::Dynamic,Options> Matrix3x;
40 typedef Eigen::Matrix<Scalar,6,Eigen::Dynamic,Options> Matrix6x;
44 ForceSetTpl(
const int & ncols ) : size(ncols),m_f(3,ncols), m_n(3,ncols)
45 { m_f.fill(NAN); m_n.fill(NAN); }
46 ForceSetTpl(
const Matrix3x & linear,
const Matrix3x & angular)
47 : size((
int)linear.cols()),m_f(linear), m_n(angular)
48 { assert( linear.cols() == angular.cols() ); }
50 Matrix6x matrix()
const 52 Matrix6x F(6,size); F << m_f, m_n;
57 operator Matrix6x ()
const {
return matrix(); }
60 const Matrix3x & linear()
const {
return m_f; }
61 const Matrix3x & angular()
const {
return m_n; }
66 Matrix3x Rf (m.rotation()*linear());
73 return ForceSetTpl(m.rotation().transpose()*linear(),
74 m.rotation().transpose()*(angular() -
skew(m.translation())*linear()) );
78 friend std::ostream & operator << (std::ostream & os,
const ForceSetTpl & phi)
81 <<
"F =\n" << phi.linear() << std::endl
82 <<
"Tau =\n" << phi.angular() << std::endl;
92 : ref(ref), idx(idx), len(len) {}
94 Eigen::Block<ForceSetTpl::Matrix3x> linear() {
return ref.m_f.block(0,idx,3,len); }
95 Eigen::Block<ForceSetTpl::Matrix3x> angular() {
return ref.m_n.block(0,idx,3,len); }
96 Eigen::Block<const ForceSetTpl::Matrix3x> linear()
const 97 {
return ((
const ForceSetTpl::Matrix3x &)(ref.m_f)).block(0,idx,3,len); }
98 Eigen::Block<const ForceSetTpl::Matrix3x> angular()
const 99 {
return ((
const ForceSetTpl::Matrix3x &)(ref.m_n)).block(0,idx,3,len); }
101 ForceSetTpl::Matrix6x matrix()
const 103 ForceSetTpl::Matrix6x res(6,len); res << linear(),angular();
109 assert(copy.size == len);
110 linear() = copy.linear();
111 angular() = copy.angular();
117 assert(copy.len == len);
118 linear() = copy.linear();
119 angular() = copy.angular();
123 template <
typename D>
124 Block& operator= (
const Eigen::MatrixBase<D> & m)
126 eigen_assert(D::RowsAtCompileTime == 6);
127 assert(m.cols() == len);
128 linear() = m.template topRows<3>();
129 angular() = m.template bottomRows<3>();
138 Matrix3x Rf ((m.rotation()*linear()));
139 return ForceSetTpl(Rf,
skew(m.translation())*Rf+m.rotation()*angular());
147 return ForceSetTpl(m.rotation().transpose()*linear(),
148 m.rotation().transpose()*(angular() -
skew(m.translation())*linear()) );
154 Block block(
const int & idx,
const int & len) {
return Block(*
this,idx,len); }
175 struct SE3GroupAction<ForceSet::
Block> {
typedef ForceSet ReturnType; };
181 #endif // ifndef __se3_force_set_hpp__
ForceSetTpl se3ActionInverse(const SE3 &m) const
bf = aXb.actInv(af)
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...
ForceSetTpl se3ActionInverse(const SE3 &m) const
bf = aXb.actInv(af)
ForceSetTpl se3Action(const SE3 &m) const
af = aXb.act(bf)
ForceSetTpl se3Action(const SE3 &m) const
af = aXb.act(bf)
void copy(const Model &model, const Data &origin, Data &dest)
Copy part of the data from <orig> to <dest>. Template parameter can be used to select at which differ...