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

Commit 5072c57

Browse files
committed
add templated function definition.
1 parent 75e9a6b commit 5072c57

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

tf2/include/tf2/impl/convert.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ namespace tf2 {
3939
* \return the conversion as a ROS message
4040
*/
4141
template<typename A, typename B>
42-
B toMsg(const A& a);
42+
B toMsg(const A& a)
43+
{
44+
return tf2::toMsg(a);
45+
}
4346

4447
/** Function that converts from a ROS message type to another type. It has to be
4548
* implemented by each data type in tf2_* (except ROS messages) as it is used
@@ -48,7 +51,10 @@ template<typename A, typename B>
4851
* \param b the object to convert to
4952
*/
5053
template<typename A, typename B>
51-
void fromMsg(const A&, B& b);
54+
void fromMsg(const A& a, B& b)
55+
{
56+
tf2::fromMsg(a, b);
57+
}
5258

5359
namespace impl {
5460

tf2_geometry_msgs/include/tf2_geometry_msgs/tf2_geometry_msgs.h

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,6 @@ geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)
381381
return out;
382382
}
383383

384-
template <>
385-
inline
386-
ROS_DEPRECATED geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in);
387-
388-
389-
//Backwards compatibility remove when forked for Lunar or newer
390-
template <>
391-
inline
392-
geometry_msgs::QuaternionStamped toMsg(const tf2::Stamped<tf2::Quaternion>& in)
393-
{
394-
return toMsg(in);
395-
}
396-
397384
/** \brief Convert a QuaternionStamped message to its equivalent tf2 representation.
398385
* This function is a specialization of the fromMsg template defined in tf2/convert.h.
399386
* \param in A QuaternionStamped message type.
@@ -409,18 +396,6 @@ void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quate
409396
out.setData(tmp);
410397
}
411398

412-
template<>
413-
inline
414-
ROS_DEPRECATED void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out);
415-
416-
//Backwards compatibility remove when forked for Lunar or newer
417-
template<>
418-
inline
419-
void fromMsg(const geometry_msgs::QuaternionStamped& in, tf2::Stamped<tf2::Quaternion>& out)
420-
{
421-
fromMsg(in, out);
422-
}
423-
424399
/**********/
425400
/** Pose **/
426401
/**********/
@@ -529,6 +504,18 @@ void fromMsg(const geometry_msgs::PoseStamped& msg, tf2::Stamped<tf2::Transform>
529504
/** PoseWithCovarianceStamped **/
530505
/*******************************/
531506

507+
/** \brief Convert a geometry_msgs PoseWithCovariance message to an equivalent tf2 Transform type.
508+
* \param in A PoseWithCovariance message.
509+
* \param out The PoseWithCovariance converted to a tf2 Transform type.
510+
*/
511+
inline
512+
void fromMsg(const geometry_msgs::PoseWithCovariance& in, tf2::Transform& out)
513+
{
514+
out.setOrigin(tf2::Vector3(in.pose.position.x, in.pose.position.y, in.pose.position.z));
515+
// w at the end in the constructor
516+
out.setRotation(tf2::Quaternion(in.pose.orientation.x, in.pose.orientation.y, in.pose.orientation.z, in.pose.orientation.w));
517+
}
518+
532519
/** \brief Extract a timestamp from the header of a PoseWithCovarianceStamped message.
533520
* This function is a specialization of the getTimestamp template defined in tf2/convert.h.
534521
* \param t PoseWithCovarianceStamped message to extract the timestamp from.

0 commit comments

Comments
 (0)