Skip to content

Commit 0d54e97

Browse files
Added some docstrings
1 parent 5052375 commit 0d54e97

File tree

3 files changed

+172
-12
lines changed

3 files changed

+172
-12
lines changed

include/franky/robot_pose.hpp

+68-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
namespace franky {
1010

11+
/**
12+
* @class RobotPose
13+
* @brief A class to represent the cartesian pose of a robot.
14+
*
15+
* This class encapsulates the cartesian pose of a robot, which comprises the end effector pose and the elbow position.
16+
*/
1117
class RobotPose {
1218
public:
1319
RobotPose();
@@ -17,39 +23,100 @@ class RobotPose {
1723
// Suppress implicit conversion warning
1824
#pragma clang diagnostic push
1925
#pragma clang diagnostic ignored "-Wimplicit-conversion"
26+
/**
27+
* @param end_effector_pose The pose of the end effector.
28+
* @param elbow_position The position of the elbow. Optional.
29+
*/
2030
RobotPose(Affine end_effector_pose, std::optional<double> elbow_position = std::nullopt);
2131
#pragma clang diagnostic pop
2232

33+
/**
34+
* @param vector_repr The vector representation of the pose.
35+
* @param ignore_elbow Whether to ignore the elbow position. Default is false.
36+
*/
2337
explicit RobotPose(const Vector7d &vector_repr, bool ignore_elbow = false);
2438

39+
/**
40+
* @param vector_repr The vector representation of the pose.
41+
* @param elbow_position The position of the elbow. Optional.
42+
*/
2543
explicit RobotPose(const Vector6d &vector_repr, std::optional<double> elbow_position = std::nullopt);
2644

45+
/**
46+
* @param franka_pose The franka pose.
47+
*/
2748
explicit RobotPose(franka::CartesianPose franka_pose);
2849

50+
/**
51+
* @brief Get the vector representation of the pose, which consists of the end effector position and orientation
52+
* (as rotation vector) and the elbow position.
53+
*
54+
* @return The vector representation of the pose.
55+
*/
2956
[[nodiscard]] Vector7d vector_repr() const;
3057

58+
/**
59+
* @brief Convert this pose to a franka pose.
60+
*
61+
* @return The franka pose.
62+
*/
3163
[[nodiscard]] franka::CartesianPose as_franka_pose() const;
3264

65+
/**
66+
* @brief Transform this pose with a given affine transformation from the left side.
67+
*
68+
* @param transform The transform to apply.
69+
* @return The transformed robot pose.
70+
*/
3371
[[nodiscard]] inline RobotPose leftTransform(const Affine &transform) const {
3472
return {transform * end_effector_pose_, elbow_position_};
3573
}
3674

75+
/**
76+
* @brief Transform this pose with a given affine transformation from the right side.
77+
*
78+
* @param transform The transform to apply.
79+
* @return The transformed robot pose.
80+
*/
3781
[[nodiscard]] inline RobotPose rightTransform(const Affine &transform) const {
3882
return {end_effector_pose_ * transform, elbow_position_};
3983
}
4084

85+
/**
86+
* @brief Change the frame of the end effector by applying a transformation from the right side. This is equivalent to
87+
* calling rightTransform(transform).
88+
*
89+
* @param transform The transform to apply.
90+
* @return The robot pose with the new end effector frame.
91+
*/
4192
[[nodiscard]] inline RobotPose changeEndEffectorFrame(const Affine &transform) const {
42-
return {end_effector_pose_ * transform, elbow_position_};
93+
return rightTransform(transform);
4394
}
4495

96+
/**
97+
* @brief Get the pose with a new elbow position.
98+
*
99+
* @param elbow_position The new elbow position.
100+
* @return The pose with the new elbow position.
101+
*/
45102
[[nodiscard]] inline RobotPose withElbowPosition(const std::optional<double> elbow_position) const {
46103
return {end_effector_pose_, elbow_position};
47104
}
48105

106+
/**
107+
* @brief Get the end effector pose.
108+
*
109+
* @return The end effector pose.
110+
*/
49111
[[nodiscard]] inline Affine end_effector_pose() const {
50112
return end_effector_pose_;
51113
}
52114

115+
/**
116+
* @brief Get the elbow position.
117+
*
118+
* @return The elbow position.
119+
*/
53120
[[nodiscard]] inline std::optional<double> elbow_position() const {
54121
return elbow_position_;
55122
}

include/franky/robot_velocity.hpp

+54-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
namespace franky {
1111

12+
/**
13+
* @brief Class to represent the cartesian velocity of a robot. It comprists the twist of the end effector and the
14+
* joint velocity of the elbow.
15+
*/
1216
class RobotVelocity {
1317
public:
1418
RobotVelocity();
@@ -18,38 +22,84 @@ class RobotVelocity {
1822
// Suppress implicit conversion warning
1923
#pragma clang diagnostic push
2024
#pragma clang diagnostic ignored "-Wimplicit-conversion"
25+
/**
26+
* @param end_effector_twist The twist of the end effector.
27+
* @param elbow_velocity The velocity of the elbow. Default is 0.0.
28+
*/
2129
RobotVelocity(Twist end_effector_twist, double elbow_velocity = 0.0);
2230
#pragma clang diagnostic pop
2331

32+
/**
33+
* @param vector_repr The vector representation of the velocity.
34+
*/
2435
explicit RobotVelocity(const Vector7d &vector_repr);
2536

37+
/**
38+
* @param franka_velocity The franka velocity.
39+
*/
2640
explicit RobotVelocity(franka::CartesianVelocities franka_velocity);
2741

42+
/**
43+
* @brief Get the vector representation of the velocity. It consists of the linear and angular velocity of the end
44+
* effector and the joint velocity of the elbow.
45+
*
46+
* @return The vector representation of the velocity.
47+
*/
2848
[[nodiscard]] Vector7d vector_repr() const;
2949

50+
/**
51+
* @brief Get the franka velocity.
52+
*
53+
* @return The franka velocity.
54+
*/
3055
[[nodiscard]] franka::CartesianVelocities as_franka_velocity() const;
3156

57+
/**
58+
* @brief Transform the frame of the velocity by applying the given affine transform.
59+
*
60+
* @param affine The affine to apply.
61+
* @return The velocity after the transformation.
62+
*/
3263
[[nodiscard]] inline RobotVelocity transform(const Affine &affine) const {
3364
return transform(affine.rotation());
3465
}
3566

67+
/**
68+
* @brief Transform the frame of the velocity by applying the given rotation.
69+
*
70+
* @param rotation The rotation to apply.
71+
* @return The velocity after the transformation.
72+
*/
3673
template<typename RotationMatrixType>
3774
[[nodiscard]] inline RobotVelocity transform(const RotationMatrixType &rotation) const {
3875
return {rotation * end_effector_twist_, elbow_velocity_};
3976
}
4077

41-
/// Change the end-effector frame by adding the given offset to the current end-effector frame. Note that the offset
42-
/// must be given in world coordinates.
43-
/// \param offset_world_frame: The offset to add to the current end-effector frame.
44-
/// \return The velocity of the new end-effector frame.
78+
/**
79+
* @brief Change the end-effector frame by adding the given offset to the current end-effector frame. Note that the
80+
* offset must be given in world coordinates.
81+
*
82+
* @param offset_world_frame The offset to add to the current end-effector frame.
83+
* @return The velocity of the new end-effector frame.
84+
*/
4585
[[nodiscard]] inline RobotVelocity changeEndEffectorFrame(const Eigen::Vector3d &offset_world_frame) const {
4686
return {end_effector_twist_.propagateThroughLink(offset_world_frame), elbow_velocity_};
4787
}
4888

89+
/**
90+
* @brief Get the end effector twist.
91+
*
92+
* @return The end effector twist.
93+
*/
4994
[[nodiscard]] inline Twist end_effector_twist() const {
5095
return end_effector_twist_;
5196
}
5297

98+
/**
99+
* @brief Get the elbow velocity.
100+
*
101+
* @return The elbow velocity.
102+
*/
53103
[[nodiscard]] inline std::optional<double> elbow_velocity() const {
54104
return elbow_velocity_;
55105
}

include/franky/twist.hpp

+50-7
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,89 @@
66

77
namespace franky {
88

9+
/**
10+
* @brief Class to represent the twist of a robot.
11+
*/
912
class Twist {
1013
public:
14+
/**
15+
* @brief Default constructor. Initializes linear and angular velocities to zero.
16+
*/
1117
Twist() : linear_velocity_(Eigen::Vector3d::Zero()), angular_velocity_(Eigen::Vector3d::Zero()) {}
1218

1319
Twist(const Twist &twist) = default;
1420

21+
/**
22+
* @param linear_velocity The linear velocity.
23+
* @param angular_velocity The angular velocity.
24+
*/
1525
Twist(Eigen::Vector3d linear_velocity, Eigen::Vector3d angular_velocity)
1626
: linear_velocity_(std::move(linear_velocity)), angular_velocity_(std::move(angular_velocity)) {}
1727

28+
/**
29+
* @param vector_repr The vector representation of the twist.
30+
*/
1831
explicit Twist(const Vector6d &vector_repr)
1932
: linear_velocity_(vector_repr.head<3>()), angular_velocity_(vector_repr.tail<3>()) {}
2033

34+
/**
35+
* @brief Get the vector representation of the twist. It consists of the linear and angular velocities.
36+
*
37+
* @return The vector representation of the twist.
38+
*/
2139
[[nodiscard]] inline Vector6d vector_repr() const {
2240
Vector6d result;
2341
result << linear_velocity_, angular_velocity_;
2442
return result;
2543
}
2644

27-
[[nodiscard]] inline Twist transformWith(const Affine &affine) const {
28-
return transformWith(affine.rotation());
45+
/**
46+
* @brief Transform the frame of the twist by applying the given affine transform.
47+
*
48+
* @param transformation The transformation to apply.
49+
* @return The twist after the transformation.
50+
*/
51+
[[nodiscard]] inline Twist transformWith(const Affine &transformation) const {
52+
return transformWith(transformation.rotation());
2953
}
3054

55+
/**
56+
* @brief Transform the frame of the twist by applying the given rotation.
57+
*
58+
* @param rotation The rotation to apply.
59+
* @return The twist after the transformation.
60+
*/
3161
template<typename RotationMatrixType>
3262
[[nodiscard]] inline Twist transformWith(const RotationMatrixType &rotation) const {
3363
return {rotation * linear_velocity_, rotation * angular_velocity_};
3464
}
3565

36-
/// Propagate the twist through a link with the given translation. Hence, suppose this twist is the twist of a frame
37-
/// A, then this function computes the twist of a frame B that is rigidly attached to frame A by a link with the
38-
/// given translation: B = A + T, where T is the translation.
39-
/// \param link_translation: The translation of the link. Must be in the same reference frame as this twist.
40-
/// \return The twist propagated through the link.
66+
/**
67+
* @brief Propagate the twist through a link with the given translation. Hence, suppose this twist is the twist of a
68+
* frame A, then this function computes the twist of a frame B that is rigidly attached to frame A by a link with the
69+
* given translation: B = A + T, where T is the translation.
70+
*
71+
* @param link_translation: The translation of the link. Must be in the same reference frame as this twist.
72+
* @return The twist propagated through the link.
73+
*/
4174
[[nodiscard]] inline Twist propagateThroughLink(const Eigen::Vector3d &link_translation) const {
4275
return {linear_velocity_ + angular_velocity_.cross(link_translation), angular_velocity_};
4376
}
4477

78+
/**
79+
* @brief Get the linear velocity.
80+
*
81+
* @return The linear velocity.
82+
*/
4583
[[nodiscard]] inline Eigen::Vector3d linear_velocity() const {
4684
return linear_velocity_;
4785
}
4886

87+
/**
88+
* @brief Get the angular velocity.
89+
*
90+
* @return The angular velocity.
91+
*/
4992
[[nodiscard]] inline Eigen::Vector3d angular_velocity() const {
5093
return angular_velocity_;
5194
}

0 commit comments

Comments
 (0)