RML  1.0
Robotics Mathematical Library
Loading...
Searching...
No Matches
PseudoInverse.h
Go to the documentation of this file.
1
8#ifndef INCLUDE_RML_PSEUDOINVERSE_H_
9#define INCLUDE_RML_PSEUDOINVERSE_H_
10
11#include <eigen3/Eigen/Dense>
12
13#include "SVD.h"
14#include "Types.h"
15
16namespace rml {
17
19 double threshold;
20 double lambda;
21
23 : threshold(0.01)
24 , lambda(0.01)
25 {
26 }
27};
28
30 double mu;
31 int flag;
32
34 : mu(0.0)
35 , flag(0)
36 {
37 }
38};
39
56
62void RegPinv(const double* J, int m, int n, double* JPInv, double treshold, double lambda, double* prod, int* flag);
63
82template <class MatT>
83Eigen::Matrix<typename MatT::Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime> RegularizedPseudoInverse(
84 const MatT& mat, RegularizationData& regData) // choose appropriately
85{
86
87 int m = mat.rows(), n = mat.cols();
88 double J[m * n]; // NULL pointer
89 double JPInv[n * m];
90
91 //Here we convert the input type to a double array which is the type used by the GT_RegPinv
92 Eigen::Map<MatT>(J, m, n) = mat;
93
94 RegPinv(J, m, n, JPInv, regData.params.threshold, regData.params.lambda, &(regData.results.mu), &(regData.results.flag));
95
96 //Here the results of the GT_RegPinv algorithm are mapped back to the input type
97 MatT eigenPinv = Eigen::Map<MatT>(JPInv, n, m);
98
99 return eigenPinv;
100}
101
102} //namespace rml
103
104#endif /* INCLUDE_RML_PSEUDOINVERSE_H_ */
Types and algorithms for robotic mobile manipulation.
Definition ArmModel.h:19
void RegPinv(const double *J, int m, int n, double *JPInv, double treshold, double lambda, double *prod, int *flag)
Eigen::Matrix< typename MatT::Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime > RegularizedPseudoInverse(const MatT &mat, RegularizationData &regData)
Computes the SVD-based regularized matrix pseudoinversion (A = U*S*V')
Definition PseudoInverse.h:83
Regularization parameters and results container.
Definition PseudoInverse.h:50
RegularizationResults results
Definition PseudoInverse.h:52
RegularizationParameters params
Definition PseudoInverse.h:51
Definition PseudoInverse.h:18
double lambda
The maximum value of the raised cosine.
Definition PseudoInverse.h:20
double threshold
The value above which the raised cosine becomes 0.
Definition PseudoInverse.h:19
RegularizationParameters()
Definition PseudoInverse.h:22
Definition PseudoInverse.h:29
RegularizationResults()
Definition PseudoInverse.h:33
int flag
The number of time the regularization parameter was not zero.
Definition PseudoInverse.h:31
double mu
Product of singular values.
Definition PseudoInverse.h:30