.. _program_listing_file__tmp_ws_src_gazebo_ros_pkgs_gazebo_ros_include_gazebo_ros_conversions_geometry_msgs.hpp: Program Listing for File geometry_msgs.hpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/gazebo_ros_pkgs/gazebo_ros/include/gazebo_ros/conversions/geometry_msgs.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2018 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef GAZEBO_ROS__CONVERSIONS__GEOMETRY_MSGS_HPP_ #define GAZEBO_ROS__CONVERSIONS__GEOMETRY_MSGS_HPP_ #include #include #include #include #include #include #include #include #include #include "gazebo_ros/conversions/generic.hpp" namespace gazebo_ros { template inline T Convert(const geometry_msgs::msg::Vector3 &) { T::ConversionNotImplemented; } template<> inline ignition::math::Vector3d Convert(const geometry_msgs::msg::Vector3 & msg) { ignition::math::Vector3d vec; vec.X(msg.x); vec.Y(msg.y); vec.Z(msg.z); return vec; } template inline T Convert(const geometry_msgs::msg::Point32 &) { T::ConversionNotImplemented; } template<> inline ignition::math::Vector3d Convert(const geometry_msgs::msg::Point32 & in) { ignition::math::Vector3d vec; vec.X(in.x); vec.Y(in.y); vec.Z(in.z); return vec; } template inline T Convert(const geometry_msgs::msg::Point &) { T::ConversionNotImplemented; } template<> inline geometry_msgs::msg::Vector3 Convert(const geometry_msgs::msg::Point & in) { geometry_msgs::msg::Vector3 msg; msg.x = in.x; msg.y = in.y; msg.z = in.z; return msg; } template<> inline ignition::math::Vector3d Convert(const geometry_msgs::msg::Point & in) { ignition::math::Vector3d out; out.X(in.x); out.Y(in.y); out.Z(in.z); return out; } template<> inline geometry_msgs::msg::Vector3 Convert(const ignition::math::Vector3d & vec) { geometry_msgs::msg::Vector3 msg; msg.x = vec.X(); msg.y = vec.Y(); msg.z = vec.Z(); return msg; } template<> inline geometry_msgs::msg::Point Convert(const ignition::math::Vector3d & vec) { geometry_msgs::msg::Point msg; msg.x = vec.X(); msg.y = vec.Y(); msg.z = vec.Z(); return msg; } template<> inline geometry_msgs::msg::Quaternion Convert(const ignition::math::Quaterniond & in) { geometry_msgs::msg::Quaternion msg; msg.x = in.X(); msg.y = in.Y(); msg.z = in.Z(); msg.w = in.W(); return msg; } template<> inline geometry_msgs::msg::Transform Convert(const ignition::math::Pose3d & in) { geometry_msgs::msg::Transform msg; msg.translation = Convert(in.Pos()); msg.rotation = Convert(in.Rot()); return msg; } template<> inline geometry_msgs::msg::Pose Convert(const ignition::math::Pose3d & in) { geometry_msgs::msg::Pose msg; msg.position = Convert(in.Pos()); msg.orientation = Convert(in.Rot()); return msg; } template inline T Convert(const geometry_msgs::msg::Quaternion &) { T::ConversionNotImplemented; } template<> inline ignition::math::Quaterniond Convert(const geometry_msgs::msg::Quaternion & in) { return ignition::math::Quaterniond(in.w, in.x, in.y, in.z); } template inline T Convert(const geometry_msgs::msg::Transform &) { T::ConversionNotImplemented; } template<> inline ignition::math::Pose3d Convert(const geometry_msgs::msg::Transform & in) { ignition::math::Pose3d msg; msg.Pos() = Convert(in.translation); msg.Rot() = Convert(in.rotation); return msg; } template inline T Convert(const geometry_msgs::msg::Pose &) { T::ConversionNotImplemented; } template<> inline geometry_msgs::msg::Transform Convert(const geometry_msgs::msg::Pose & in) { geometry_msgs::msg::Transform msg; msg.translation = Convert(in.position); msg.rotation = in.orientation; return msg; } template<> inline ignition::math::Pose3d Convert(const geometry_msgs::msg::Pose & in) { return {Convert(in.position), Convert(in.orientation)}; } } // namespace gazebo_ros #endif // GAZEBO_ROS__CONVERSIONS__GEOMETRY_MSGS_HPP_