Skip to content

Commit a5dfb74

Browse files
committed
Update tf2_eigen, add toMsg2
Convert a Eigen::Vector3d type to a geometry_msgs::msg::Vector3 while avoiding overloading issues with previous definitions
1 parent 66ecb3a commit a5dfb74

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎tf2_eigen/include/tf2_eigen/tf2_eigen.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,22 @@ geometry_msgs::msg::Pose toMsg(const Eigen::Isometry3d& in) {
353353
return msg;
354354
}
355355

356+
/** \brief Convert a Eigen::Vector3d type to a geometry_msgs::msg::Vector3.
357+
* This function is a specialization of the toMsg template defined in tf2/convert.h.
358+
* The function was renamed to toMsg2 to avoid overloading conflicts with definitions above.
359+
*
360+
* \param in The Eigen::Vector3d to convert.
361+
* \return The Eigen::Vector3d converted to a geometry_msgs::msg::Vector3 message.
362+
*/
363+
inline
364+
geometry_msgs::msg::Vector3 toMsg2(const Eigen::Vector3d& in) {
365+
geometry_msgs::msg::Vector3 msg;
366+
msg.x = in(0);
367+
msg.y = in(1);
368+
msg.z = in(2);
369+
return msg;
370+
}
371+
356372
/** \brief Convert a Pose message transform type to a Eigen Affine3d.
357373
* This function is a specialization of the toMsg template defined in tf2/convert.h.
358374
* \param msg The Pose message to convert.

0 commit comments

Comments
 (0)