Franky  0.9.1
A High-Level Motion API for Franka
robot_pose.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <optional>
4 #include <Eigen/Core>
5 #include <franka/control_types.h>
6 
7 #include "franky/types.hpp"
8 
9 namespace franky {
10 
16 class RobotPose {
17  public:
18  RobotPose();
19 
20  RobotPose(const RobotPose &robot_pose);
21 
22  // Suppress implicit conversion warning
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wimplicit-conversion"
29  RobotPose(Affine end_effector_pose, std::optional<double> elbow_position = std::nullopt);
30 #pragma clang diagnostic pop
31 
36  explicit RobotPose(const Vector7d &vector_repr, bool ignore_elbow = false);
37 
42  explicit RobotPose(const Vector6d &vector_repr, std::optional<double> elbow_position = std::nullopt);
43 
47  explicit RobotPose(franka::CartesianPose franka_pose);
48 
55  [[nodiscard]] Vector7d vector_repr() const;
56 
62  [[nodiscard]] franka::CartesianPose as_franka_pose() const;
63 
70  [[nodiscard]] inline RobotPose leftTransform(const Affine &transform) const {
71  return {transform * end_effector_pose_, elbow_position_};
72  }
73 
80  [[nodiscard]] inline RobotPose rightTransform(const Affine &transform) const {
81  return {end_effector_pose_ * transform, elbow_position_};
82  }
83 
91  [[nodiscard]] inline RobotPose changeEndEffectorFrame(const Affine &transform) const {
92  return rightTransform(transform);
93  }
94 
101  [[nodiscard]] inline RobotPose withElbowPosition(const std::optional<double> elbow_position) const {
102  return {end_effector_pose_, elbow_position};
103  }
104 
110  [[nodiscard]] inline Affine end_effector_pose() const {
111  return end_effector_pose_;
112  }
113 
119  [[nodiscard]] inline std::optional<double> elbow_position() const {
120  return elbow_position_;
121  }
122 
123  private:
124  Affine end_effector_pose_;
125  std::optional<double> elbow_position_;
126 };
127 
128 inline RobotPose operator*(const RobotPose &robot_pose, const Affine &right_transform) {
129  return robot_pose.rightTransform(right_transform);
130 }
131 
132 inline RobotPose operator*(const Affine &left_transform, const RobotPose &robot_pose) {
133  return robot_pose.leftTransform(left_transform);
134 }
135 
136 } // namespace franky
Cartesian pose of a robot.
Definition: robot_pose.hpp:16
RobotPose changeEndEffectorFrame(const Affine &transform) const
Change the frame of the end effector by applying a transformation from the right side....
Definition: robot_pose.hpp:91
RobotPose()
Definition: robot_pose.cpp:49
RobotPose(const RobotPose &robot_pose)
std::optional< double > elbow_position() const
Get the elbow position.
Definition: robot_pose.hpp:119
Vector7d vector_repr() const
Get the vector representation of the pose, which consists of the end effector position and orientatio...
Definition: robot_pose.cpp:32
RobotPose withElbowPosition(const std::optional< double > elbow_position) const
Get the pose with a new elbow position.
Definition: robot_pose.hpp:101
franka::CartesianPose as_franka_pose() const
Convert this pose to a franka pose.
Definition: robot_pose.cpp:40
Affine end_effector_pose() const
Get the end effector pose.
Definition: robot_pose.hpp:110
RobotPose leftTransform(const Affine &transform) const
Transform this pose with a given affine transformation from the left side.
Definition: robot_pose.hpp:70
RobotPose rightTransform(const Affine &transform) const
Transform this pose with a given affine transformation from the right side.
Definition: robot_pose.hpp:80
Definition: gripper.cpp:3
CartesianState operator*(const Affine &transform, const CartesianState &cartesian_state)
Definition: cartesian_state.hpp:76
Eigen::Vector< double, 7 > Vector7d
Definition: types.hpp:9
Eigen::Vector< double, 6 > Vector6d
Definition: types.hpp:8
@ CartesianPose
Definition: control_signal_type.hpp:13
Eigen::Affine3d Affine
Definition: types.hpp:13