Franky  0.9.1
A High-Level Motion API for Franka
twist.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 
5 #include "franky/types.hpp"
6 
7 namespace franky {
8 
12 class Twist {
13  public:
14  Twist(const Twist &twist) = default;
15 
20  explicit Twist(Eigen::Vector3d linear_velocity = Eigen::Vector3d::Zero(),
21  Eigen::Vector3d angular_velocity = Eigen::Vector3d::Zero())
22  : linear_velocity_(std::move(linear_velocity)), angular_velocity_(std::move(angular_velocity)) {}
23 
27  [[nodiscard]] static inline Twist fromVectorRepr(const Vector6d &vector_repr) {
28  return Twist{vector_repr.head<3>(), vector_repr.tail<3>()};
29  }
30 
36  [[nodiscard]] inline Vector6d vector_repr() const {
37  Vector6d result;
38  result << linear_velocity_, angular_velocity_;
39  return result;
40  }
41 
48  [[nodiscard]] inline Twist transformWith(const Affine &transformation) const {
49  return transformWith(transformation.rotation());
50  }
51 
58  template<typename RotationMatrixType>
59  [[nodiscard]] inline Twist transformWith(const RotationMatrixType &rotation) const {
60  return Twist{rotation * linear_velocity_, rotation * angular_velocity_};
61  }
62 
71  [[nodiscard]] inline Twist propagateThroughLink(const Eigen::Vector3d &link_translation) const {
72  return Twist{linear_velocity_ + angular_velocity_.cross(link_translation), angular_velocity_};
73  }
74 
80  [[nodiscard]] inline Eigen::Vector3d linear_velocity() const {
81  return linear_velocity_;
82  }
83 
89  [[nodiscard]] inline Eigen::Vector3d angular_velocity() const {
90  return angular_velocity_;
91  }
92 
93  private:
94  Eigen::Vector3d linear_velocity_;
95  Eigen::Vector3d angular_velocity_;
96 };
97 
98 inline Twist operator*(const Affine &affine, const Twist &twist) {
99  return twist.transformWith(affine);
100 }
101 
102 template<typename RotationMatrixType>
103 inline Twist operator*(const RotationMatrixType &rotation, const Twist &twist) {
104  return twist.transformWith(rotation);
105 }
106 
107 } // namespace franky
Twist of a frame.
Definition: twist.hpp:12
Vector6d vector_repr() const
Get the vector representation of the twist. It consists of the linear and angular velocities.
Definition: twist.hpp:36
static Twist fromVectorRepr(const Vector6d &vector_repr)
Definition: twist.hpp:27
Twist transformWith(const Affine &transformation) const
Transform the frame of the twist by applying the given affine transform.
Definition: twist.hpp:48
Eigen::Vector3d linear_velocity() const
Get the linear velocity.
Definition: twist.hpp:80
Twist transformWith(const RotationMatrixType &rotation) const
Transform the frame of the twist by applying the given rotation.
Definition: twist.hpp:59
Twist propagateThroughLink(const Eigen::Vector3d &link_translation) const
Propagate the twist through a link with the given translation. Hence, suppose this twist is the twist...
Definition: twist.hpp:71
Twist(Eigen::Vector3d linear_velocity=Eigen::Vector3d::Zero(), Eigen::Vector3d angular_velocity=Eigen::Vector3d::Zero())
Definition: twist.hpp:20
Twist(const Twist &twist)=default
Eigen::Vector3d angular_velocity() const
Get the angular velocity.
Definition: twist.hpp:89
Definition: gripper.cpp:3
CartesianState operator*(const Affine &transform, const CartesianState &cartesian_state)
Definition: cartesian_state.hpp:76
Eigen::Vector< double, 6 > Vector6d
Definition: types.hpp:8
Eigen::Affine3d Affine
Definition: types.hpp:13