Franky  0.9.1
A High-Level Motion API for Franka
quartic_blend_path.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
5 #include "franky/path/path.hpp"
6 
7 namespace franky {
8 
9 template<size_t state_dimensions>
10 class QuarticBlendPath : public Path<state_dimensions> {
11  using Vector = Eigen::Matrix<double, state_dimensions, 1>;
12 
13  public:
14  QuarticBlendPath() : QuarticBlendPath(Vector::Zero(), Vector::Zero(), Vector::Ones(), 0.0, 0.0, 0.0) {}
15 
17  : length_(quartic_blend_path.length_), b_(quartic_blend_path.b_), c_(quartic_blend_path.c_),
18  e_(quartic_blend_path.e_), f_(quartic_blend_path.f_), lm_(quartic_blend_path.lm_),
19  rm_(quartic_blend_path.rm_) {}
20 
21  explicit QuarticBlendPath(
22  const Vector &lb, const Vector &lm, const Vector &rm,
23  double s_mid, double max_diff, double s_abs_max) : lb_(lb), lm_(lm), rm_(rm) {
24  Vector s_abs = ((-16 * max_diff) / (3. * (lm - rm).array())).abs();
25  double s_abs_min = std::min<double>({s_abs.minCoeff(), s_abs_max});
26  length_ = 2 * s_abs_min;
27  b_ = (lm - rm).array() / (16. * std::pow(s_abs_min, 3));
28  c_ = (-lm + rm).array() / (4. * std::pow(s_abs_min, 2));
29  e_ = lm;
30  f_ = lb.array() + lm.array() * (-s_abs_min + s_mid);
31  }
32 
33  PathStep<state_dimensions> operator()(double s) const override {
34  return {
35  f_ + s * (e_ + s * (s * (c_ + s * b_))),
36  e_ + s * (s * (3 * c_ + s * 4 * b_)),
37  s * (6 * c_ + s * 12 * b_),
38  6 * c_ + s * 24 * b_
39  };
40  }
41 
42  [[nodiscard]] inline double length() const override {
43  return length_;
44  }
45 
46  Vector max_ddq() const override {
47  return (-3 * (lm_ - rm_)) / (4. * this->length() / 2);
48  }
49 
50  Vector max_dddq() const override {
51  return (3 * (lm_ - rm_)) / (2. * std::pow(this->length() / 2, 2));
52  }
53 
54  private:
55  double length_{};
56  Vector7d b_, c_, e_, f_;
57  const Vector7d lb_, lm_, rm_;
58 };
59 
60 } // namespace franky
Definition: path.hpp:16
Definition: quartic_blend_path.hpp:10
double length() const override
Definition: quartic_blend_path.hpp:42
QuarticBlendPath(const QuarticBlendPath< state_dimensions > &quartic_blend_path)
Definition: quartic_blend_path.hpp:16
Vector max_ddq() const override
Definition: quartic_blend_path.hpp:46
Vector max_dddq() const override
Definition: quartic_blend_path.hpp:50
QuarticBlendPath(const Vector &lb, const Vector &lm, const Vector &rm, double s_mid, double max_diff, double s_abs_max)
Definition: quartic_blend_path.hpp:21
QuarticBlendPath()
Definition: quartic_blend_path.hpp:14
PathStep< state_dimensions > operator()(double s) const override
Definition: quartic_blend_path.hpp:33
Definition: gripper.cpp:3
Eigen::Vector< double, 7 > Vector7d
Definition: types.hpp:9
Definition: path.hpp:8