Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Conversation

@gleichdick
Copy link

Workaround for #430. Snippet now compiles (with convert.h included last)

#include <tf2/LinearMath/Quaternion.h>
#include <Eigen/Geometry>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <tf2_eigen/tf2_eigen.h>
#include <tf2/convert.h>
#include <iostream>

int main() {
  Eigen::Quaterniond eq;

  const tf2::Quaternion tq(0,1,0,1);
  tf2::convert(tq, eq);
  std::cout << eq.toRotationMatrix();
}

Note that it still depends on the include order, if convert.h is included first it does not work (compiler picks forward declaration of templated fromMsg which is not resolved later on).

all fromMsg/toMsg overloads have to be defined before <tf2/convert.h> is
included. So only the forward declarations are included.
@gleichdick gleichdick mentioned this pull request Dec 1, 2019
6 tasks
@v4hn
Copy link
Contributor

v4hn commented Dec 2, 2019

C++ includes should be independent of the include order.
Is it difficult to resolve the problem altogether?

@gleichdick
Copy link
Author

TL;DR Please a look at my branch. toMsg is redefined (so, client code which uses toMsg breaks) but tf2::convert should be fine. Include order does not matter anymore.

I converted all toMsg overloads to template specialisations with two parameters (because the return value does not count for template parameter deduction). All overloads (without template<>) are gone:

template<class A, class B> B& toMsg(const A&, B&);

For converting two non-Message types (lets say tf2::Vector3 and Eigen::Vector3d), I'm writing a python script which generates type mapping (both have conversions to/from geometry_msgs::Point in common), like

template<>
struct commonMsgType<tf2::Vector3, Eigen::Vector3> {
    using type = geometry_msgs::Point;
};

This struct is then read by tf2::convert with some SFINAE Magic which then selects the correct fromMsg / toMsg methods.

Please note that this branch is more or less a proof of concept, so documentation and tests are missing. I'm happy to contine, but please let me know whether this solution fits your needs.

@gleichdick
Copy link
Author

replaced by #491

@gleichdick gleichdick closed this Dec 11, 2020
ooeygui pushed a commit to ms-iot/geometry2 that referenced this pull request Oct 12, 2022
…_pose_with_covariance_stamped (ros#453)

* -Fixed the issue of covariance not being transformed in do_transform_pose_with_covariance_stamped, corresponding to ros2/geometry2#431 and made the same changes as the C++ API

Co-authored-by: Abrar Rahman Protyasha <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants