Skip to content

Commit d236698

Browse files
Fixed RobotVelocity transformation
1 parent 51a4ba8 commit d236698

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

include/franky/robot_velocity.hpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ class RobotVelocity {
2929

3030
[[nodiscard]] franka::CartesianVelocities as_franka_velocity() const;
3131

32-
[[nodiscard]] inline RobotVelocity transform(const Affine &transform) const {
33-
return RobotVelocity(
34-
transform * end_effector_linear_velocity_, transform * end_effector_angular_velocity_, elbow_velocity_);
32+
[[nodiscard]] inline RobotVelocity transform(const Affine &affine) const {
33+
return transform(affine.rotation());
34+
}
35+
36+
template<typename RotationMatrixType>
37+
[[nodiscard]] inline RobotVelocity transform(const RotationMatrixType &rotation) const {
38+
return {rotation * end_effector_linear_velocity_, rotation * end_effector_angular_velocity_, elbow_velocity_};
3539
}
3640

3741
[[nodiscard]] inline RobotVelocity with_elbow_velocity(const std::optional<double> elbow_velocity) const {
38-
return RobotVelocity(end_effector_linear_velocity_, end_effector_angular_velocity_, elbow_velocity);
42+
return {end_effector_linear_velocity_, end_effector_angular_velocity_, elbow_velocity};
3943
}
4044

4145
[[nodiscard]] inline Eigen::Vector3d end_effector_linear_velocity() const {
@@ -56,8 +60,13 @@ class RobotVelocity {
5660
std::optional<double> elbow_velocity_;
5761
};
5862

59-
inline RobotVelocity operator*(const Affine &transform, const RobotVelocity &robot_velocity) {
60-
return robot_velocity.transform(transform);
63+
inline RobotVelocity operator*(const Affine &affine, const RobotVelocity &robot_velocity) {
64+
return robot_velocity.transform(affine);
65+
}
66+
67+
template<typename RotationMatrixType>
68+
inline RobotVelocity operator*(const RotationMatrixType &rotation, const RobotVelocity &robot_velocity) {
69+
return robot_velocity.transform(rotation);
6170
}
6271

6372
} // namespace franky

python/python.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ PYBIND11_MODULE(_franky, m) {
476476
.def("with_elbow_position", &RobotPose::with_elbow_position, "elbow_position"_a)
477477
.def_property_readonly("end_effector_pose", &RobotPose::end_effector_pose)
478478
.def_property_readonly("elbow_position", &RobotPose::elbow_position)
479-
.def("__mul__", py::overload_cast<const RobotPose &, const Affine &>(&operator*), py::is_operator())
479+
.def("__mul__",
480+
[](const RobotPose &robot_pose, const Affine &affine) { return robot_pose * affine; },
481+
py::is_operator())
480482
.def("__rmul__",
481483
[](const RobotPose &robot_pose, const Affine &affine) { return affine * robot_pose; },
482484
py::is_operator())
@@ -506,6 +508,9 @@ PYBIND11_MODULE(_franky, m) {
506508
.def("__rmul__",
507509
[](const RobotVelocity &robot_velocity, const Affine &affine) { return affine * robot_velocity; },
508510
py::is_operator())
511+
.def("__rmul__",
512+
[](const RobotVelocity &robot_velocity, const Eigen::Quaterniond &quaternion) { return quaternion * robot_velocity; },
513+
py::is_operator())
509514
.def("__repr__", robotVelocityToStr)
510515
.def(py::pickle(
511516
[](const RobotVelocity &robot_velocity) { // __getstate__

0 commit comments

Comments
 (0)