// // Copyright (c) 2017 CNRS // // This file is part of tsid // tsid is free software: you can redistribute it // and/or modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation, either version // 3 of the License, or (at your option) any later version. // tsid is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Lesser Public License for more details. You should have // received a copy of the GNU Lesser General Public License along with // tsid If not, see // . // #include namespace tsid { namespace math { void SE3ToXYZQUAT(const pinocchio::SE3 & M, RefVector xyzQuat) { assert(xyzQuat.size()==7); xyzQuat.head<3>() = M.translation(); xyzQuat.tail<4>() = Eigen::Quaterniond(M.rotation()).coeffs(); } void SE3ToVector(const pinocchio::SE3 & M, RefVector vec) { assert(vec.size()==12); vec.head<3>() = M.translation(); typedef Eigen::Matrix Vector9; vec.tail<9>() = Eigen::Map(&M.rotation()(0), 9); } void vectorToSE3(RefVector vec, pinocchio::SE3 & M) { assert(vec.size()==12); M.translation( vec.head<3>() ); typedef Eigen::Matrix Matrix3; M.rotation( Eigen::Map(&vec(3), 3, 3) ); } void errorInSE3 (const pinocchio::SE3 & M, const pinocchio::SE3 & Mdes, pinocchio::Motion & error) { // error = pinocchio::log6(Mdes.inverse() * M); // pinocchio::SE3 M_err = Mdes.inverse() * M; pinocchio::SE3 M_err = M.inverse() * Mdes; error.linear() = M_err.translation(); error.angular() = pinocchio::log3(M_err.rotation()); } void solveWithDampingFromSvd(Eigen::JacobiSVD & svd, ConstRefVector b, RefVector sol, double damping) { assert(svd.rows()==b.size()); const double d2 = damping*damping; const long int nzsv = svd.nonzeroSingularValues(); Eigen::VectorXd tmp(svd.cols()); tmp.noalias() = svd.matrixU().leftCols(nzsv).adjoint() * b; double sv; for(long int i=0; i