franky 1.1.4
A High-Level Motion API for Franka
Loading...
Searching...
No Matches
twist.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4
5#include "franky/types.hpp"
6#include "franky/util.hpp"
7
8namespace franky {
9
13class Twist {
14 public:
19 explicit Twist(
20 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
28 return Twist{vector_repr.head<3>(), vector_repr.tail<3>()};
29 }
30
39 result << linear_velocity_, angular_velocity_;
40 return result;
41 }
42
51 return transformWith(transformation.rotation());
52 }
53
60 template <typename RotationMatrixType>
62 return Twist{rotation * linear_velocity_, rotation * angular_velocity_};
63 }
64
75 [[nodiscard]] Twist propagateThroughLink(const Eigen::Vector3d &link_translation) const {
76 return Twist{linear_velocity_ + angular_velocity_.cross(link_translation), angular_velocity_};
77 }
78
84 [[nodiscard]] Eigen::Vector3d linear_velocity() const { return linear_velocity_; }
85
91 [[nodiscard]] Eigen::Vector3d angular_velocity() const { return angular_velocity_; }
92
93 friend std::ostream &operator<<(std::ostream &os, const Twist &twist);
94
95 private:
96 Eigen::Vector3d linear_velocity_;
97 Eigen::Vector3d angular_velocity_;
98};
99
100inline Twist operator*(const Affine &affine, const Twist &twist) { return twist.transformWith(affine); }
101
102template <typename RotationMatrixType>
106
107inline std::ostream &operator<<(std::ostream &os, const Twist &twist) {
108 os << "Twist(lin=" << twist.linear_velocity_ << ", ang=" << twist.angular_velocity_ << ")";
109 return os;
110}
111
112} // namespace franky
CartesianState transformWith(const Affine &transform) const
Transform the frame of the state by applying the given affine transform.
Definition cartesian_state.hpp:42
Twist of a frame.
Definition twist.hpp:13
Vector6d vector_repr() const
Get the vector representation of the twist. It consists of the linear and angular velocities.
Definition twist.hpp:37
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:50
Eigen::Vector3d linear_velocity() const
Get the linear velocity.
Definition twist.hpp:84
Twist transformWith(const RotationMatrixType &rotation) const
Transform the frame of the twist by applying the given rotation.
Definition twist.hpp:61
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:75
Twist(Eigen::Vector3d linear_velocity=Eigen::Vector3d::Zero(), Eigen::Vector3d angular_velocity=Eigen::Vector3d::Zero())
Definition twist.hpp:19
friend std::ostream & operator<<(std::ostream &os, const Twist &twist)
Definition twist.hpp:107
Eigen::Vector3d angular_velocity() const
Get the angular velocity.
Definition twist.hpp:91
Definition dynamics_limit.cpp:8
std::ostream & operator<<(std::ostream &os, const DynamicsLimit< Vector7d > &limit)
Definition dynamics_limit.cpp:47
std::array< double, dims > toStdD(const Eigen::Matrix< double, dims, 1 > &vector)
Definition util.hpp:18
CartesianState operator*(const Affine &transform, const CartesianState &cartesian_state)
Definition cartesian_state.hpp:76
Eigen::Vector< double, 6 > Vector6d
Definition types.hpp:10
Eigen::Affine3d Affine
Definition types.hpp:16