.. _program_listing_file_include_tf2_convert.h: Program Listing for File convert.h ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/tf2/convert.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2008, Willow Garage, Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // * Neither the name of the Willow Garage nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef TF2__CONVERT_H_ #define TF2__CONVERT_H_ #include #include #include #include "geometry_msgs/msg/transform_stamped.hpp" #include "rosidl_runtime_cpp/traits.hpp" #include "tf2/exceptions.h" #include "tf2/impl/convert.h" #include "tf2/transform_datatypes.h" #include "tf2/visibility_control.h" namespace tf2 { template void doTransform( const T & data_in, T & data_out, const geometry_msgs::msg::TransformStamped & transform); template tf2::TimePoint getTimestamp(const T & t); template std::string getFrameId(const T & t); template std::array, 6> getCovarianceMatrix(const T & t); template tf2::TimePoint getTimestamp(const tf2::Stamped

& t) { return t.stamp_; } template std::string getFrameId(const tf2::Stamped

& t) { return t.frame_id_; } template std::array, 6> getCovarianceMatrix(const tf2::WithCovarianceStamped

& t) { return t.cov_mat_; } template B toMsg(const A & a); template void fromMsg(const A & a, B & b); template void convert(const A & a, B & b) { impl::Converter::value, rosidl_generator_traits::is_message::value>::convert(a, b); } template void convert(const A & a1, A & a2) { if (&a1 != &a2) { a2 = a1; } } inline std::array, 6> covarianceRowMajorToNested( const std::array & row_major) { std::array, 6> nested_array; std::array::const_iterator ss = row_major.begin(); for (std::array & dd : nested_array) { std::copy_n(ss, dd.size(), dd.begin()); ss += dd.size(); } return nested_array; } inline std::array covarianceNestedToRowMajor( const std::array, 6> & nested_array) { std::array row_major = {}; size_t counter = 0; for (const auto & arr : nested_array) { for (const double & val : arr) { row_major[counter] = val; counter++; } } return row_major; } } // namespace tf2 #endif // TF2__CONVERT_H_