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 <kdl/frames.hpp>
57 return KDL::Frame(KDL::Rotation::Quaternion(t.transform.rotation.x, t.transform.rotation.y,
58 t.transform.rotation.z, t.transform.rotation.w),
59 KDL::Vector(t.transform.translation.x, t.transform.translation.y, t.transform.translation.z));
93 void doTransform(
const geometry_msgs::msg::Vector3Stamped& t_in, geometry_msgs::msg::Vector3Stamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
95 KDL::Vector v_out =
gmTransformToKDL(transform).M * KDL::Vector(t_in.vector.x, t_in.vector.y, t_in.vector.z);
96 t_out.vector.x = v_out[0];
97 t_out.vector.y = v_out[1];
98 t_out.vector.z = v_out[2];
99 t_out.header.stamp = transform.header.stamp;
100 t_out.header.frame_id = transform.header.frame_id;
109 geometry_msgs::msg::Vector3Stamped
toMsg(
const geometry_msgs::msg::Vector3Stamped& in)
120 void fromMsg(
const geometry_msgs::msg::Vector3Stamped& msg, geometry_msgs::msg::Vector3Stamped& out)
157 void doTransform(
const geometry_msgs::msg::PointStamped& t_in, geometry_msgs::msg::PointStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
159 KDL::Vector v_out =
gmTransformToKDL(transform) * KDL::Vector(t_in.point.x, t_in.point.y, t_in.point.z);
160 t_out.point.x = v_out[0];
161 t_out.point.y = v_out[1];
162 t_out.point.z = v_out[2];
163 t_out.header.stamp = transform.header.stamp;
164 t_out.header.frame_id = transform.header.frame_id;
173 geometry_msgs::msg::PointStamped
toMsg(
const geometry_msgs::msg::PointStamped& in)
184 void fromMsg(
const geometry_msgs::msg::PointStamped& msg, geometry_msgs::msg::PointStamped& out)
220 void doTransform(
const geometry_msgs::msg::PoseStamped& t_in, geometry_msgs::msg::PoseStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
222 KDL::Vector v(t_in.pose.position.x, t_in.pose.position.y, t_in.pose.position.z);
223 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);
226 t_out.pose.position.x = v_out.p[0];
227 t_out.pose.position.y = v_out.p[1];
228 t_out.pose.position.z = v_out.p[2];
229 v_out.M.GetQuaternion(t_out.pose.orientation.x, t_out.pose.orientation.y, t_out.pose.orientation.z, t_out.pose.orientation.w);
230 t_out.header.stamp = transform.header.stamp;
231 t_out.header.frame_id = transform.header.frame_id;
240 geometry_msgs::msg::PoseStamped
toMsg(
const geometry_msgs::msg::PoseStamped& in)
251 void fromMsg(
const geometry_msgs::msg::PoseStamped& msg, geometry_msgs::msg::PoseStamped& out)
269 geometry_msgs::msg::Quaternion out;
320 void doTransform(
const geometry_msgs::msg::QuaternionStamped& t_in, geometry_msgs::msg::QuaternionStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
323 transform.transform.rotation.z, transform.transform.rotation.w)*
324 tf2::Quaternion(t_in.quaternion.x, t_in.quaternion.y, t_in.quaternion.z, t_in.quaternion.w);
325 t_out.quaternion =
toMsg(q_out);
326 t_out.header.stamp = transform.header.stamp;
327 t_out.header.frame_id = transform.header.frame_id;
336 geometry_msgs::msg::QuaternionStamped
toMsg(
const geometry_msgs::msg::QuaternionStamped& in)
347 void fromMsg(
const geometry_msgs::msg::QuaternionStamped& msg, geometry_msgs::msg::QuaternionStamped& out)
360 geometry_msgs::msg::QuaternionStamped out;
363 out.quaternion.w = in.getW();
364 out.quaternion.x = in.getX();
365 out.quaternion.y = in.getY();
366 out.quaternion.z = in.getZ();
398 geometry_msgs::msg::Transform out;
399 out.translation.x = in.
getOrigin().getX();
400 out.translation.y = in.
getOrigin().getY();
401 out.translation.z = in.
getOrigin().getZ();
414 out.
setOrigin(tf2::Vector3(in.translation.x, in.translation.y, in.translation.z));
450 void doTransform(
const geometry_msgs::msg::TransformStamped& t_in, geometry_msgs::msg::TransformStamped& t_out,
const geometry_msgs::msg::TransformStamped& transform)
452 KDL::Vector v(t_in.transform.translation.x, t_in.transform.translation.y,
453 t_in.transform.translation.z);
454 KDL::Rotation r = KDL::Rotation::Quaternion(t_in.transform.rotation.x,
455 t_in.transform.rotation.y, t_in.transform.rotation.z, t_in.transform.rotation.w);
458 t_out.transform.translation.x = v_out.p[0];
459 t_out.transform.translation.y = v_out.p[1];
460 t_out.transform.translation.z = v_out.p[2];
461 v_out.M.GetQuaternion(t_out.transform.rotation.x, t_out.transform.rotation.y,
462 t_out.transform.rotation.z, t_out.transform.rotation.w);
463 t_out.header.stamp = transform.header.stamp;
464 t_out.header.frame_id = transform.header.frame_id;
473 geometry_msgs::msg::TransformStamped
toMsg(
const geometry_msgs::msg::TransformStamped& in)
484 void fromMsg(
const geometry_msgs::msg::TransformStamped& msg, geometry_msgs::msg::TransformStamped& out)
512 geometry_msgs::msg::TransformStamped out;
515 out.transform.translation.x = in.getOrigin().getX();
516 out.transform.translation.y = in.getOrigin().getY();
517 out.transform.translation.z = in.getOrigin().getZ();
518 out.transform.rotation =
toMsg(in.getRotation());
547 out.
setOrigin(tf2::Vector3(in.position.x, in.position.y, in.position.z));
554 #endif // TF2_GEOMETRY_MSGS_H