Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test_tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0.2)

project(test_tf2)

find_package(catkin REQUIRED COMPONENTS rosconsole roscpp rostest tf tf2 tf2_bullet tf2_ros tf2_geometry_msgs tf2_kdl tf2_msgs)
find_package(catkin REQUIRED COMPONENTS rosconsole roscpp rostest tf tf2 tf2_bullet tf2_ros tf2_geometry_msgs tf2_kdl tf2_msgs tf2_eigen)
find_package(Boost REQUIRED COMPONENTS thread)
find_package(orocos_kdl REQUIRED)

Expand Down
2 changes: 2 additions & 0 deletions test_tf2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<build_depend>tf2_geometry_msgs</build_depend>
<build_depend>tf2_kdl</build_depend>
<build_depend>tf2_msgs</build_depend>
<build_depend>tf2_eigen</build_depend>

<run_depend>rosconsole</run_depend>
<run_depend>roscpp</run_depend>
Expand All @@ -34,6 +35,7 @@
<run_depend>tf2_geometry_msgs</run_depend>
<run_depend>tf2_kdl</run_depend>
<run_depend>tf2_msgs</run_depend>
<run_depend>tf2_eigen</run_depend>

<test_depend>rosunit</test_depend>
<test_depend>rosbash</test_depend>
Expand Down
13 changes: 13 additions & 0 deletions test_tf2/test/test_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <tf2_kdl/tf2_kdl.h>
#include <tf2_bullet/tf2_bullet.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <tf2_eigen/tf2_eigen.h>
#include <ros/time.h>

TEST(tf2Convert, kdlToBullet)
Expand Down Expand Up @@ -97,6 +98,18 @@ TEST(tf2Convert, kdlBulletROSConversions)
EXPECT_NEAR(b1.z(), b4.z(), epsilon);
}

TEST(tf2Convert, ConvertTf2Quaternion)
{
tf2::Quaternion tq(1,2,3,4);
Eigen::Quaterniond eq;
tf2::convert(tq, eq);

EXPECT_EQ(tq.w(), eq.w());
EXPECT_EQ(tq.x(), eq.x());
EXPECT_EQ(tq.y(), eq.y());
EXPECT_EQ(tq.z(), eq.z());
}

int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
Expand Down
12 changes: 12 additions & 0 deletions tf2/include/tf2/impl/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,33 @@ template <>
template <typename A, typename B>
inline void Converter<true, false>::convert(const A& a, B& b)
{
#ifdef _MSC_VER
tf2::fromMsg(a, b);
#else
fromMsg(a, b);
#endif
}

template <>
template <typename A, typename B>
inline void Converter<false, true>::convert(const A& a, B& b)
{
#ifdef _MSC_VER
b = tf2::toMsg(a);
#else
b = toMsg(a);
#endif
}

template <>
template <typename A, typename B>
inline void Converter<false, false>::convert(const A& a, B& b)
{
#ifdef _MSC_VER
tf2::fromMsg(tf2::toMsg(a), b);
#else
fromMsg(toMsg(a), b);
#endif
}

}
Expand Down