Frankx  0.2.0
A High-Level Motion API for Franka
kinematics.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <affx/affine.hpp>
4 
5 
6 namespace movex {
7 
8 template<size_t DoFs>
10  using Affine = affx::Affine;
11 
12  struct DenavitHartenbergParameter {
13  double alpha; // [rad]
14  double d, a; // [m]
15 
16  Affine get_transformation(double theta) const {
17  Affine rot1 {0, 0, 0, theta, 0, 0};
18  Affine trans1 {0, 0, d, 0, 0, 0};
19  Affine trans2 {a, 0, 0, 0, 0, 0};
20  Affine rot2 {0, 0, 0, 0, 0, alpha};
21  return rot2 * trans2 * rot1 * trans1;
22  }
23  };
24 
25  std::array<DenavitHartenbergParameter, DoFs> parameters;
26  Affine base;
27 
28 public:
29  explicit KinematicChain(const std::array<DenavitHartenbergParameter, DoFs>& parameters, const Affine& base): parameters(parameters), base(base) { }
30 
31  Affine forward_chain(const std::array<double, DoFs>& q) const {
32  Affine result;
33  for (size_t i = 0; i < DoFs; ++i) {
34  result = result * parameters[i].get_transformation(q[i]);
35  }
36  return result * base;
37  }
38 };
39 
40 } // namespace movex
movex::KinematicChain::KinematicChain
KinematicChain(const std::array< DenavitHartenbergParameter, DoFs > &parameters, const Affine &base)
Definition: kinematics.hpp:29
movex::KinematicChain::forward_chain
Affine forward_chain(const std::array< double, DoFs > &q) const
Definition: kinematics.hpp:31
movex::KinematicChain
Definition: kinematics.hpp:9
frankx::Affine
affx::Affine Affine
Definition: motion_generator.hpp:15
movex
Definition: motion_impedance.hpp:13