Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 2.8.3)

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not safe to use this more qualified name ouside of MSVC so we could save the ifdef?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I recalled, it caused compilation errors in GCC\Clang settings but let me test and spin a CI to make sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tfoote Here is the error that if I use this full qualified name. It seems that GCC is okay with a unresolved (yet) function name referenced in the template code, but doesn't like the case where you reference it in the fully qualified form.

15:39:27 [  9%] Building CXX object CMakeFiles/tf2_ros.dir/src/buffer.cpp.o
15:39:31 In file included from /tmp/ws/install_isolated/include/tf2/convert.h:39:0,
15:39:31                  from /tmp/ws/src/geometry2/tf2_ros/include/tf2_ros/buffer_interface.h:40,
15:39:31                  from /tmp/ws/src/geometry2/tf2_ros/include/tf2_ros/buffer.h:35,
15:39:31                  from /tmp/ws/src/geometry2/tf2_ros/src/buffer.cpp:33:
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h: In static member function ‘static void tf2::impl::Converter<IS_MESSAGE_A, IS_MESSAGE_B>::convert(const A&, B&) [with A = A; B = B; bool IS_MESSAGE_A = true; bool IS_MESSAGE_B = false]’:
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h:58:8: error: ‘fromMsg’ is not a member of ‘tf2’
15:39:31    tf2::fromMsg(a, b);
15:39:31         ^~~~~~~
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h: In static member function ‘static void tf2::impl::Converter<IS_MESSAGE_A, IS_MESSAGE_B>::convert(const A&, B&) [with A = A; B = B; bool IS_MESSAGE_A = false; bool IS_MESSAGE_B = true]’:
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h:65:12: error: ‘toMsg’ is not a member of ‘tf2’
15:39:31    b = tf2::toMsg(a);
15:39:31             ^~~~~
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h: In static member function ‘static void tf2::impl::Converter<IS_MESSAGE_A, IS_MESSAGE_B>::convert(const A&, B&) [with A = A; B = B; bool IS_MESSAGE_A = false; bool IS_MESSAGE_B = false]’:
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h:72:8: error: ‘fromMsg’ is not a member of ‘tf2’
15:39:31    tf2::fromMsg(tf2::toMsg(a), b);
15:39:31         ^~~~~~~
15:39:31 /tmp/ws/install_isolated/include/tf2/impl/convert.h:72:21: error: ‘toMsg’ is not a member of ‘tf2’
15:39:31    tf2::fromMsg(tf2::toMsg(a), b);
15:39:31                      ^~~~~
15:39:31 CMakeFiles/tf2_ros.dir/build.make:62: recipe for target 'CMakeFiles/tf2_ros.dir/src/buffer.cpp.o' failed
15:39:31 make[2]: *** [CMakeFiles/tf2_ros.dir/src/buffer.cpp.o] Error 1
15:39:31 CMakeFiles/Makefile2:248: recipe for target 'CMakeFiles/tf2_ros.dir/all' failed
15:39:31 make[1]: *** [CMakeFiles/tf2_ros.dir/all] Error 2
15:39:31 Makefile:140: recipe for target 'all' failed
15:39:31 make: *** [all] Error 2
15:39:31 <== Failed to process package 'tf2_ros': 

#else
fromMsg(toMsg(a), b);
#endif
}

}
Expand Down