chain_coupling.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 // Modified by Juan A. Corrales (ISIR, UPMC) in order to include coupling
9 
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 
25 #include <ros/ros.h>
26 
27 namespace KDL
28 {
30  Chain(),
31  nrOfIndJoints(0),
32  updateFunction(NULL),
33  cm()
34  {
35  }
36 
38  Chain((const Chain &) in),
39  nrOfIndJoints(0),
40  updateFunction(NULL),
41  cm()
42  {
44  }
45 
47  Chain(in),
49  updateFunction(NULL),
50  cm(Eigen::MatrixXd::Identity(in.getNrOfJoints(), in.getNrOfJoints()))
51  {
52  }
53 
55  {
56  // Copy KDL Chains
57  Chain &c1 = (Chain &) (*this);
58  const Chain &c2 = (const Chain &) (in);
59  c1 = c2;
60  // Copy Coupling Components (coupling matrix and coupling function)
62  return *this;
63  }
64 
66  {
67  // Copy KDL Chains
68  Chain &c1 = (Chain &) (*this);
69  c1 = in;
70  // The number of independent joints is the same as the total number of joints
71  this->nrOfIndJoints = in.getNrOfJoints();
72  this->cm = Eigen::MatrixXd::Identity(in.getNrOfJoints(), in.getNrOfJoints());
73  return *this;
74  }
75 
77  {
78  return (nrOfIndJoints != this->getNrOfJoints());
79  }
80 
82  {
83  if (updateFunc == NULL)
84  {
85  this->updateFunction = NULL;
86  return 0;
87  }
88  // Verify that the update function generates a coupling matrix with correct size
89  JntArray jnt(this->getNrOfJoints());
90  KDL::SetToZero(jnt);
91  Eigen::MatrixXd cm_init = updateFunc(jnt);
92  if (cm_init.rows() != this->getNrOfJoints())
93  {
94  ROS_ERROR("Number of rows of coupling matrix has to match total number of joints");
95  return -1;
96  }
97  // Initialize number of independent joints
98  nrOfIndJoints = cm_init.cols();
99  // Initialize update function
100  this->updateFunction = updateFunc;
101  // Initialize coupling matrix
102  this->cm = cm_init;
103  return 0;
104  }
105 
107  {
108  return this->updateFunction;
109  }
110 
112  {
113  if (this->updateFunction != NULL)
114  {
115  this->cm = this->updateFunction(q);
116  }
117  }
118 
120  {
121  }
122 } // namespace KDL
123 
unsigned int nrOfIndJoints
void updateCoupling(const JntArray &q)
bool setUpdateCouplingFunction(updateFuncPtr updateFunc)
Chain_coupling & operator=(const Chain_coupling &in)
updateFuncPtr updateFunction
Eigen::MatrixXd cm
unsigned int getNrOfJoints() const
updateFuncPtr getUpdateCouplingFunction() const
void SetToZero(Jacobian &jac)
#define ROS_ERROR(...)
bool isCoupled() const
Eigen::MatrixXd(* updateFuncPtr)(const JntArray &q)


kdl_coupling
Author(s): Juan Antonio Corrales Ramon (UPMC)
autogenerated on Wed Oct 14 2020 04:05:04