Skip to content

Commit 036ca90

Browse files
committed
Fix doTransform for Eigen::Quaterniond
1 parent e1f891b commit 036ca90

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

tf2_eigen/include/tf2_eigen/tf2_eigen.h

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -184,36 +184,20 @@ struct defaultMessage<Eigen::Quaterniond>
184184
* although it can not be used in tf2_ros::BufferInterface::transform because this
185185
* functions rely on the existence of a time stamp and a frame id in the type which should
186186
* get transformed.
187-
* \param t_in The vector to transform, as a Eigen Quaterniond data type.
188-
* \param t_out The transformed vector, as a Eigen Quaterniond data type.
189-
* \param transform The timestamped transform to apply, as a TransformStamped message.
187+
* \param[in] t_in The vector to transform, as a Eigen Quaterniond data type.
188+
* \param[in,out] t_out The transformed vector, as a Eigen Quaterniond data type.
189+
* \param[in] transform The timestamped transform to apply, as a TransformStamped message.
190190
*/
191191
template<>
192192
inline
193-
void doTransform(const Eigen::Quaterniond& t_in,
194-
Eigen::Quaterniond& t_out,
195-
const geometry_msgs::msg::TransformStamped& transform) {
193+
void doTransform(
194+
const Eigen::Quaterniond & t_in,
195+
Eigen::Quaterniond & t_out,
196+
const geometry_msgs::msg::TransformStamped & transform)
197+
{
196198
Eigen::Quaterniond t;
197-
fromMsg(transform.transform.rotation, t);
198-
t_out = t.inverse() * t_in * t;
199-
}
200-
201-
/** \brief Apply a geometry_msgs TransformStamped to an Eigen-specific Quaterniond type.
202-
* This function is a specialization of the doTransform template defined in tf2/convert.h.
203-
* \param t_in The vector to transform, as a timestamped Eigen Quaterniond data type.
204-
* \param t_out The transformed vector, as a timestamped Eigen Quaterniond data type.
205-
* \param transform The timestamped transform to apply, as a TransformStamped message.
206-
*/
207-
template <>
208-
inline
209-
void doTransform(const tf2::Stamped<Eigen::Quaterniond>& t_in,
210-
tf2::Stamped<Eigen::Quaterniond>& t_out,
211-
const geometry_msgs::msg::TransformStamped& transform) {
212-
t_out.frame_id_ = transform.header.frame_id;
213-
tf2::fromMsg(transform.header.stamp, t_out.stamp_);
214-
doTransform(
215-
static_cast<const Eigen::Quaterniond &>(t_in), static_cast<Eigen::Quaterniond &>(t_out),
216-
transform);
199+
tf2::fromMsg<>(transform.transform.rotation, t);
200+
t_out = Eigen::Quaterniond(t.toRotationMatrix() * t_in.toRotationMatrix());
217201
}
218202

219203
namespace impl

0 commit comments

Comments
 (0)