From 95943f78f45173e2974adcec8094261579243619 Mon Sep 17 00:00:00 2001 From: v4hn Date: Tue, 5 Sep 2023 13:16:52 +0200 Subject: [PATCH 1/2] add torque due to force offset adapted patch by @pac48 . Taken from https://github.com/ros2/geometry2/pull/538 . --- .../include/tf2_geometry_msgs/tf2_geometry_msgs.h | 7 +++++++ tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h b/tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h index f0ef5f74f..fc929e0af 100644 --- a/tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h +++ b/tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h @@ -1040,6 +1040,13 @@ void doTransform(const geometry_msgs::Wrench& t_in, geometry_msgs::Wrench& t_out { doTransform(t_in.force, t_out.force, transform); doTransform(t_in.torque, t_out.torque, transform); + // add additional torque created by translating the force + tf2::Vector3 offset = {transform.transform.translation.x, transform.transform.translation.y, + transform.transform.translation.z}; + tf2::Vector3 added_torque = offset.cross({t_out.force.x, t_out.force.y, t_out.force.z}); + t_out.torque.x += added_torque.getX(); + t_out.torque.y += added_torque.getY(); + t_out.torque.z += added_torque.getZ(); } diff --git a/tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp b/tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp index 860db53f6..da5f7e667 100644 --- a/tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp +++ b/tf2_geometry_msgs/test/test_tf2_geometry_msgs.cpp @@ -336,9 +336,9 @@ TEST(TfGeometry, doTransformWrench) v1.torque.z = 3; geometry_msgs::TransformStamped trafo; - trafo.transform.translation.x = -1; - trafo.transform.translation.y = 2; - trafo.transform.translation.z = -3; + trafo.transform.translation.x = 0; + trafo.transform.translation.y = -2; + trafo.transform.translation.z = 0; trafo.transform.rotation = tf2::toMsg(tf2::Quaternion(tf2::Vector3(0,0,1), -M_PI / 2.0)); tf2::doTransform(v1, res, trafo); @@ -346,9 +346,9 @@ TEST(TfGeometry, doTransformWrench) EXPECT_NEAR(res.force.y, -2, EPS); EXPECT_NEAR(res.force.z, 3, EPS); - EXPECT_NEAR(res.torque.x, 1, EPS); + EXPECT_NEAR(res.torque.x, -5, EPS); EXPECT_NEAR(res.torque.y, -2, EPS); - EXPECT_NEAR(res.torque.z, 3, EPS); + EXPECT_NEAR(res.torque.z, 5, EPS); } int main(int argc, char **argv){ From 9b922e7f0c2888aa8dd62a9837b9ad9ab2a23417 Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Fri, 23 Feb 2024 16:12:09 +0900 Subject: [PATCH 2/2] fix catkin_symlink_install error. see https://github.com/ros/geometry2/issues/486#issue-751145776 --- tf2_py/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tf2_py/CMakeLists.txt b/tf2_py/CMakeLists.txt index bb53f9d35..d522928d1 100644 --- a/tf2_py/CMakeLists.txt +++ b/tf2_py/CMakeLists.txt @@ -144,7 +144,7 @@ set_target_properties(tf2_py PROPERTIES # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # ) -install(FILES $ +install(TARGETS tf2_py DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} )