- 3.0.2 rigid body dynamics module.
JacobiSingularity.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 
7 namespace ct {
8 namespace rbd {
9 
10 template <size_t ROWS, size_t COLS>
12 {
13  J_ = J;
14 }
15 
16 
17 template <size_t ROWS, size_t COLS>
19 {
20  SingularValues sv = calc_singular_values();
21  return sv.maxCoeff() / sv.minCoeff();
22 }
23 
24 
25 template <size_t ROWS, size_t COLS>
27 {
28  double w = 1;
29 
30  switch (method)
31  {
32  case DIRECT:
33  {
34  // see Siciliano p. 153
35  w = std::sqrt((J_ * J_.transpose()).determinant());
36  break;
37  }
38  case SINGULAR_VALUES:
39  {
40  // can also be calculated by multiplying the singular values of J
41  SingularValues sv = calc_singular_values();
42  for (int i = 0; i < sv.size(); ++i)
43  w *= sv(i);
44  break;
45  }
46  }
47  return w;
48 }
49 
50 
51 template <size_t ROWS, size_t COLS>
53 {
54  // matrix is not neccesarily square, so eigenvalues do not exist -> use singular values instead
55  Eigen::JacobiSVD<Eigen::MatrixXd> svd(J_, Eigen::ComputeThinU | Eigen::ComputeThinV);
56  return svd.singularValues();
57 }
58 
59 
60 template <size_t ROWS, size_t COLS>
62  const EndeffectorVelocities& des_ee_vel) const
63 {
64  // Use SVD to compute Pseudo Inverse of J = J'(JJ')^-1 = VSU*
65  Eigen::JacobiSVD<Eigen::MatrixXd> svd(J_, Eigen::ComputeThinU | Eigen::ComputeThinV);
66  JointVelocities qd_des = svd.solve(des_ee_vel);
67 
68  // just for comparison, see if same solution can be reached
69  PseudoInverse J_inv = J_.transpose() * (J_ * J_.transpose()).inverse();
70  JointVelocities qd_des_pseudo = J_inv * des_ee_vel;
71 
72  //assert(qd_des == qd_des_pseudo);
73 
74  return qd_des;
75 }
76 
77 
78 } // namespace rbd
79 } // namespace ct
A class computing codition numbers and singular velues of a Jacobian.
Definition: JacobiSingularity.h:18
Eigen::Matrix< double, ROWS, 1 > SingularValues
Definition: JacobiSingularity.h:25
Eigen::Matrix< double, ROWS, 1 > EndeffectorVelocities
Definition: JacobiSingularity.h:26
Eigen::Matrix< double, COLS, 1 > JointVelocities
Definition: JacobiSingularity.h:27
double calc_condition_number() const
Definition: JacobiSingularity.h:18
Eigen::Matrix< double, COLS, ROWS > PseudoInverse
Definition: JacobiSingularity.h:24
SingularValues calc_singular_values() const
Definition: JacobiSingularity.h:52
JacobiSingularity(const Jacobian &J)
Definition: JacobiSingularity.h:11
for i
ManipulabilityMethod
Definition: JacobiSingularity.h:29
double calc_manipulability(ManipulabilityMethod method=DIRECT) const
Definition: JacobiSingularity.h:26