32 #ifndef TF2_GEOMETRY_MSGS_H
33 #define TF2_GEOMETRY_MSGS_H
39 #include <geometry_msgs/msg/point_stamped.hpp>
40 #include <geometry_msgs/msg/quaternion_stamped.hpp>
41 #include <geometry_msgs/msg/transform_stamped.hpp>
42 #include <geometry_msgs/msg/vector3_stamped.hpp>
43 #include <geometry_msgs/msg/pose.hpp>
44 #include <geometry_msgs/msg/pose_stamped.hpp>
45 #include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
46 #include <kdl/frames.hpp>
58 return KDL::Frame(KDL::Rotation::Quaternion(t.transform.rotation.x, t.transform.rotation.y,
59 t.transform.rotation.z, t.transform.rotation.w),
60 KDL::Vector(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
94 void doTransform(
const geometry_msgs::msg::Vector3Stamped& t_in, geometry_msgs::msg::Vector3Stamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
96 KDL::Vector v_out =
gmTransformToKDL(transform).M * KDL::Vector(t_in.vector.x, t_in.vector.y, t_in.vector.z);
97 t_out.vector.x = v_out[0];
98 t_out.vector.y = v_out[1];
99 t_out.vector.z = v_out[2];
100 t_out.header.stamp = transform.header.stamp;
101 t_out.header.frame_id = transform.header.frame_id;
110 geometry_msgs::msg::Vector3Stamped
toMsg(
const geometry_msgs::msg::Vector3Stamped& in)
121 void fromMsg(
const geometry_msgs::msg::Vector3Stamped& msg, geometry_msgs::msg::Vector3Stamped& out)
158 void doTransform(
const geometry_msgs::msg::PointStamped& t_in, geometry_msgs::msg::PointStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
160 KDL::Vector v_out =
gmTransformToKDL(transform) * KDL::Vector(t_in.point.x, t_in.point.y, t_in.point.z);
161 t_out.point.x = v_out[0];
162 t_out.point.y = v_out[1];
163 t_out.point.z = v_out[2];
164 t_out.header.stamp = transform.header.stamp;
165 t_out.header.frame_id = transform.header.frame_id;
174 geometry_msgs::msg::PointStamped
toMsg(
const geometry_msgs::msg::PointStamped& in)
185 void fromMsg(
const geometry_msgs::msg::PointStamped& msg, geometry_msgs::msg::PointStamped& out)
221 void doTransform(
const geometry_msgs::msg::PoseStamped& t_in, geometry_msgs::msg::PoseStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
223 KDL::Vector v(t_in.pose.position.x, t_in.pose.position.y, t_in.pose.position.z);
224 KDL::Rotation r = KDL::Rotation::Quaternion(t_in.pose.orientation.x, t_in.pose.orientation.y, t_in.pose.orientation.z, t_in.pose.orientation.w);
227 t_out.pose.position.x = v_out.p[0];
228 t_out.pose.position.y = v_out.p[1];
229 t_out.pose.position.z = v_out.p[2];
230 v_out.M.GetQuaternion(t_out.pose.orientation.x, t_out.pose.orientation.y, t_out.pose.orientation.z, t_out.pose.orientation.w);
231 t_out.header.stamp = transform.header.stamp;
232 t_out.header.frame_id = transform.header.frame_id;
241 geometry_msgs::msg::PoseStamped
toMsg(
const geometry_msgs::msg::PoseStamped& in)
252 void fromMsg(
const geometry_msgs::msg::PoseStamped& msg, geometry_msgs::msg::PoseStamped& out)
297 void doTransform(
const geometry_msgs::msg::PoseWithCovarianceStamped& t_in, geometry_msgs::msg::PoseWithCovarianceStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
299 KDL::Vector v(t_in.pose.pose.position.x, t_in.pose.pose.position.y, t_in.pose.pose.position.z);
300 KDL::Rotation r = KDL::Rotation::Quaternion(t_in.pose.pose.orientation.x, t_in.pose.pose.orientation.y, t_in.pose.pose.orientation.z, t_in.pose.pose.orientation.w);
303 t_out.pose.pose.position.x = v_out.p[0];
304 t_out.pose.pose.position.y = v_out.p[1];
305 t_out.pose.pose.position.z = v_out.p[2];
306 v_out.M.GetQuaternion(t_out.pose.pose.orientation.x, t_out.pose.pose.orientation.y, t_out.pose.pose.orientation.z, t_out.pose.pose.orientation.w);
307 t_out.header.stamp = transform.header.stamp;
308 t_out.header.frame_id = transform.header.frame_id;
309 t_out.pose.covariance = t_in.pose.covariance;
318 geometry_msgs::msg::PoseWithCovarianceStamped
toMsg(
const geometry_msgs::msg::PoseWithCovarianceStamped& in)
329 void fromMsg(
const geometry_msgs::msg::PoseWithCovarianceStamped& msg, geometry_msgs::msg::PoseWithCovarianceStamped& out)
343 geometry_msgs::msg::PoseWithCovarianceStamped out;
347 out.pose.pose.orientation.x = in.getRotation().getX();
348 out.pose.pose.orientation.y = in.getRotation().getY();
349 out.pose.pose.orientation.z = in.getRotation().getZ();
350 out.pose.pose.orientation.w = in.getRotation().getW();
351 out.pose.pose.position.x = in.getOrigin().getX();
352 out.pose.pose.position.y = in.getOrigin().getY();
353 out.pose.pose.position.z = in.getOrigin().getZ();
386 geometry_msgs::msg::Quaternion out;
437 void doTransform(
const geometry_msgs::msg::QuaternionStamped& t_in, geometry_msgs::msg::QuaternionStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
440 transform.transform.rotation.z, transform.transform.rotation.w)*
441 tf2::Quaternion(t_in.quaternion.x, t_in.quaternion.y, t_in.quaternion.z, t_in.quaternion.w);
442 t_out.quaternion =
toMsg(q_out);
443 t_out.header.stamp = transform.header.stamp;
444 t_out.header.frame_id = transform.header.frame_id;
453 geometry_msgs::msg::QuaternionStamped
toMsg(
const geometry_msgs::msg::QuaternionStamped& in)
464 void fromMsg(
const geometry_msgs::msg::QuaternionStamped& msg, geometry_msgs::msg::QuaternionStamped& out)
477 geometry_msgs::msg::QuaternionStamped out;
480 out.quaternion.w = in.getW();
481 out.quaternion.x = in.getX();
482 out.quaternion.y = in.getY();
483 out.quaternion.z = in.getZ();
515 geometry_msgs::msg::Transform out;
516 out.translation.x = in.
getOrigin().getX();
517 out.translation.y = in.
getOrigin().getY();
518 out.translation.z = in.
getOrigin().getZ();
531 out.
setOrigin(tf2::Vector3(in.translation.x, in.translation.y, in.translation.z));
567 void doTransform(
const geometry_msgs::msg::TransformStamped& t_in, geometry_msgs::msg::TransformStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
569 KDL::Vector v(t_in.transform.translation.x, t_in.transform.translation.y,
570 t_in.transform.translation.z);
571 KDL::Rotation r = KDL::Rotation::Quaternion(t_in.transform.rotation.x,
572 t_in.transform.rotation.y, t_in.transform.rotation.z, t_in.transform.rotation.w);
575 t_out.transform.translation.x = v_out.p[0];
576 t_out.transform.translation.y = v_out.p[1];
577 t_out.transform.translation.z = v_out.p[2];
578 v_out.M.GetQuaternion(t_out.transform.rotation.x, t_out.transform.rotation.y,
579 t_out.transform.rotation.z, t_out.transform.rotation.w);
580 t_out.header.stamp = transform.header.stamp;
581 t_out.header.frame_id = transform.header.frame_id;
590 geometry_msgs::msg::TransformStamped
toMsg(
const geometry_msgs::msg::TransformStamped& in)
601 void fromMsg(
const geometry_msgs::msg::TransformStamped& msg, geometry_msgs::msg::TransformStamped& out)
629 geometry_msgs::msg::TransformStamped out;
632 out.transform.translation.x = in.getOrigin().getX();
633 out.transform.translation.y = in.getOrigin().getY();
634 out.transform.translation.z = in.getOrigin().getZ();
635 out.transform.rotation =
toMsg(in.getRotation());
664 out.
setOrigin(tf2::Vector3(in.position.x, in.position.y, in.position.z));
671 #endif // TF2_GEOMETRY_MSGS_H