1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
// Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Version: 1.0
// Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
// URL: http://www.orocos.org/kdl
// This library 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 2.1 of the License, or (at your option) any later version.
// This library 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
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "jntarray.hpp"
namespace KDL
{
USING_PART_OF_NAMESPACE_EIGEN
JntArray::JntArray()
{
}
JntArray::JntArray(unsigned int _size):
data(_size)
{
data.setZero();
}
JntArray::JntArray(const JntArray& arg):
data(arg.data)
{
}
JntArray& JntArray::operator = (const JntArray& arg)
{
data=arg.data;
return *this;
}
JntArray::~JntArray()
{
}
void JntArray::resize(unsigned int newSize)
{
data.resize(newSize);
}
double JntArray::operator()(unsigned int i,unsigned int j)const
{
assert(j==0);
return data(i);
}
double& JntArray::operator()(unsigned int i,unsigned int j)
{
assert(j==0);
return data(i);
}
unsigned int JntArray::rows()const
{
return data.rows();
}
unsigned int JntArray::columns()const
{
return data.cols();
}
void Add(const JntArray& src1,const JntArray& src2,JntArray& dest)
{
dest.data=src1.data+src2.data;
}
void Subtract(const JntArray& src1,const JntArray& src2,JntArray& dest)
{
dest.data=src1.data-src2.data;
}
void Multiply(const JntArray& src,const double& factor,JntArray& dest)
{
dest.data=factor*src.data;
}
void Divide(const JntArray& src,const double& factor,JntArray& dest)
{
dest.data=src.data/factor;
}
void MultiplyJacobian(const Jacobian& jac, const JntArray& src, Twist& dest)
{
Eigen::Matrix<double,6,1> t=(jac.data*src.data).lazy();
dest=Twist(Vector(t(0),t(1),t(2)),Vector(t(3),t(4),t(5)));
}
void SetToZero(JntArray& array)
{
array.data.setZero();
}
bool Equal(const JntArray& src1, const JntArray& src2,double eps)
{
if(src1.rows()!=src2.rows())
return false;
return src1.data.isApprox(src2.data,eps);
}
bool operator==(const JntArray& src1,const JntArray& src2){return Equal(src1,src2);};
//bool operator!=(const JntArray& src1,const JntArray& src2){return Equal(src1,src2);};
}
|