Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion tests for toMsg() #423

Merged
merged 5 commits into from
May 28, 2021
Merged

Conversion tests for toMsg() #423

merged 5 commits into from
May 28, 2021

Conversation

gleichdick
Copy link
Contributor

Vectors can be converted to a Vector message or a Point Message, some libraries behave differently. This unit test will make sure that the default return value for toMsg() will stay the same.

This was separated from #368.

Comment on lines 35 to 39
if(WIN32)
set(BULLET_ROOT $ENV{ChocolateyInstall}/lib/bullet)
endif()
find_package(Bullet REQUIRED)
include_directories(include ${BULLET_INCLUDE_DIRS})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually need any of this? We aren't using bullet directly in this package, and hence all of this should be inherited from tf2_bullet. If it is not, then that seems like a bug in the tf2_bullet package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there seems to be a bug. #428 opened

Comment on lines +102 to +110
const tf2::Quaternion tq(1, 2, 3, 4);
Eigen::Quaterniond eq;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add needed includes for these at the top:

#include <tf2/LinearMath/Quaternion.h>
#include <Eigen/Eigen>

Also, I think we need to declare a dependency on eigen in the package.xml and the CMakeLists.txt.

{
const tf2::Quaternion tq(1, 2, 3, 4);
Eigen::Quaterniond eq;
//tf2::convert(tq, eq);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this dead code.

{
// Bullet
const tf2::Stamped<btVector3> b1{btVector3{1.0, 3.0, 4.0}, tf2::TimePoint(), "my_frame"};
const geometry_msgs::msg::PointStamped msg = tf2::toMsg(b1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the include at the top of the file:

#include <geometry_msgs/msg/point_stamped.hpp>

{
// Eigen
const Eigen::Vector3d e1{2.0, 4.0, 5.0};
const geometry_msgs::msg::Point msg = tf2::toMsg(e1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the include at the top of the file.

{
// tf2
const tf2::Vector3 t1{2.0, 4.0, 5.0};
const geometry_msgs::msg::Vector3 msg = tf2::toMsg(t1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the include at the top of the file.

* \return The Vector3 converted to a geometry_msgs message type.
*/
inline
geometry_msgs::msg::Vector3 toMsg(const tf2::Vector3& in)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the include for geometry_msgs::msg::Vector3 at the top of the file.

Also, style nit: there should be a space before and after the reference symbol (&). We aren't enforcing it in this package yet (and I don't think we should in this PR), but we may as well make one less thing we have to change later.

The same comment goes several other times below.

* \return The Vector3 converted to a geometry_msgs message type.
*/
inline
geometry_msgs::msg::Point& toMsg(const tf2::Vector3& in, geometry_msgs::msg::Point& out)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the include for geometry_msgs::msg::Point at the top of the file.

@gleichdick
Copy link
Contributor Author

I hope I addressed all of the remarks. There seems to be a blocking issue with bullet dependencies, see #428.

@gleichdick gleichdick marked this pull request as ready for review May 28, 2021 15:59
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

This looks good. I'll run CI on it next.

@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@clalancette clalancette merged commit e9da371 into ros2:ros2 May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants