14 static Eigen::Matrix<typename MatT::Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime>
15 pseudoinverse(
const MatT &mat,
typename MatT::Scalar tolerance =
typename MatT::Scalar{1e-4}) {
16 typedef typename MatT::Scalar Scalar;
17 auto svd = mat.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV);
18 const auto &singularValues = svd.singularValues();
19 Eigen::Matrix<Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime> singularValuesInv(mat.cols(), mat.rows());
20 singularValuesInv.setZero();
21 for (
unsigned int i = 0; i < singularValues.size(); ++i) {
22 if (singularValues(i) > tolerance) {
23 singularValuesInv(i, i) = Scalar{1} / singularValues(i);
26 singularValuesInv(i, i) = Scalar{0};
29 return svd.matrixV() * singularValuesInv * svd.matrixU().adjoint();
43 static Eigen::Matrix<double, 6, 1>
forwardEuler(
const Eigen::Matrix<double, 7, 1> &q);
45 static Eigen::Matrix<double, 6, 7>
jacobian(
const Eigen::Matrix<double, 7, 1> &q);
47 static Eigen::Matrix<double, 7, 1>
48 inverse(
const Eigen::Matrix<double, 6, 1> &x_target,
const Eigen::Matrix<double, 7, 1> &q0,
49 std::optional<NullSpaceHandling> null_space = std::nullopt);
54 struct DenavitHartenbergParameter {
58 Affine get_transformation(
double theta)
const {
60 rot1.linear() =
Euler(theta, 0, 0).toRotationMatrix();
62 trans1.affine() = Eigen::Vector3d(0, 0, d);
64 trans2.affine() = Eigen::Vector3d(a, 0, 0);
66 rot2.linear() =
Euler(0, 0, alpha).toRotationMatrix();
67 return rot2 * trans2 * rot1 * trans1;
71 std::array<DenavitHartenbergParameter, DoFs> parameters;
75 explicit KinematicChain(
const std::array<DenavitHartenbergParameter, DoFs> ¶meters,
const Affine &base)
76 : parameters(parameters), base(base) {}
80 for (
size_t i = 0; i < DoFs; ++i) {
81 result = result * parameters[i].get_transformation(q[i]);
Definition: kinematics.hpp:53
KinematicChain(const std::array< DenavitHartenbergParameter, DoFs > ¶meters, const Affine &base)
Definition: kinematics.hpp:75
Affine forward_chain(const std::array< double, DoFs > &q) const
Definition: kinematics.hpp:78
Definition: gripper.cpp:3
Eigen::EulerAngles< double, Eigen::EulerSystemXYZ > Euler
Definition: types.hpp:11
Eigen::Affine3d Affine
Definition: types.hpp:13
Definition: kinematics.hpp:32
size_t joint_index
Definition: kinematics.hpp:33
double value
Definition: kinematics.hpp:34
NullSpaceHandling(size_t joint_index, double value)
Definition: kinematics.hpp:36
Definition: kinematics.hpp:12
static Affine forward(const Eigen::Matrix< double, 7, 1 > &q)
Definition: kinematics.cpp:5
static Eigen::Matrix< double, 6, 1 > forwardEuler(const Eigen::Matrix< double, 7, 1 > &q)
Definition: kinematics.cpp:107
static Eigen::Matrix< typename MatT::Scalar, MatT::ColsAtCompileTime, MatT::RowsAtCompileTime > pseudoinverse(const MatT &mat, typename MatT::Scalar tolerance=typename MatT::Scalar{1e-4})
Definition: kinematics.hpp:15
static Eigen::Matrix< double, 7, 1 > inverse(const Eigen::Matrix< double, 6, 1 > &x_target, const Eigen::Matrix< double, 7, 1 > &q0, std::optional< NullSpaceHandling > null_space=std::nullopt)
Definition: kinematics.cpp:344
static Affine forwardElbow(const Eigen::Matrix< double, 7, 1 > &q)
Definition: kinematics.cpp:73
static Eigen::Matrix< double, 6, 7 > jacobian(const Eigen::Matrix< double, 7, 1 > &q)
Definition: kinematics.cpp:163