.. _program_listing_file_include_proto2ros_conversions.hpp: Program Listing for File conversions.hpp ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/proto2ros/conversions.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright (c) 2024 Boston Dynamics AI Institute LLC. All rights reserved. #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace proto2ros::conversions { template void Convert(const proto2ros::msg::AnyProto &ros_msg, T *proto_msg) { proto_msg->Clear(); auto wrapper = google::protobuf::Any(); wrapper.set_type_url(ros_msg.type_url); auto *value = wrapper.mutable_value(); value->reserve(ros_msg.value.size()); value->assign(ros_msg.value.begin(), ros_msg.value.end()); if (!wrapper.UnpackTo(proto_msg)) { throw std::runtime_error("failed to unpack AnyProto message"); } } template void Convert(const T &proto_msg, proto2ros::msg::AnyProto *ros_msg) { auto wrapper = google::protobuf::Any(); wrapper.PackFrom(proto_msg); ros_msg->type_url = wrapper.type_url(); const auto &value = wrapper.value(); ros_msg->value.reserve(value.size()); ros_msg->value.assign(value.begin(), value.end()); } void Convert(const proto2ros::msg::AnyProto &ros_msg, google::protobuf::Any *proto_msg); void Convert(const google::protobuf::Any &proto_msg, proto2ros::msg::AnyProto *ros_msg); void Convert(const builtin_interfaces::msg::Duration &ros_msg, google::protobuf::Duration *proto_msg); void Convert(const google::protobuf::Duration &proto_msg, builtin_interfaces::msg::Duration *ros_msg); void Convert(const builtin_interfaces::msg::Time &ros_msg, google::protobuf::Timestamp *proto_msg); void Convert(const google::protobuf::Timestamp &proto_msg, builtin_interfaces::msg::Time *ros_msg); void Convert(const std_msgs::msg::Float64 &ros_msg, google::protobuf::DoubleValue *proto_msg); void Convert(const google::protobuf::DoubleValue &proto_msg, std_msgs::msg::Float64 *ros_msg); void Convert(const std_msgs::msg::Float32 &ros_msg, google::protobuf::FloatValue *proto_msg); void Convert(const google::protobuf::FloatValue &proto_msg, std_msgs::msg::Float32 *ros_msg); void Convert(const std_msgs::msg::Int64 &ros_msg, google::protobuf::Int64Value *proto_msg); void Convert(const google::protobuf::Int64Value &proto_msg, std_msgs::msg::Int64 *ros_msg); void Convert(const std_msgs::msg::Int32 &ros_msg, google::protobuf::Int32Value *proto_msg); void Convert(const google::protobuf::Int32Value &proto_msg, std_msgs::msg::Int32 *ros_msg); void Convert(const std_msgs::msg::UInt64 &ros_msg, google::protobuf::UInt64Value *proto_msg); void Convert(const google::protobuf::UInt64Value &proto_msg, std_msgs::msg::UInt64 *ros_msg); void Convert(const std_msgs::msg::UInt32 &ros_msg, google::protobuf::UInt32Value *proto_msg); void Convert(const google::protobuf::UInt32Value &proto_msg, std_msgs::msg::UInt32 *ros_msg); void Convert(const std_msgs::msg::Bool &ros_msg, google::protobuf::BoolValue *proto_msg); void Convert(const google::protobuf::BoolValue &proto_msg, std_msgs::msg::Bool *ros_msg); void Convert(const std_msgs::msg::String &ros_msg, google::protobuf::StringValue *proto_msg); void Convert(const google::protobuf::StringValue &proto_msg, std_msgs::msg::String *ros_msg); void Convert(const proto2ros::msg::Bytes &ros_msg, google::protobuf::BytesValue *proto_msg); void Convert(const google::protobuf::BytesValue &proto_msg, proto2ros::msg::Bytes *ros_msg); void Convert(const proto2ros::msg::Value &ros_msg, google::protobuf::Value *proto_msg); void Convert(const google::protobuf::Value &proto_msg, proto2ros::msg::Value *ros_msg); void Convert(const proto2ros::msg::List &ros_msg, google::protobuf::ListValue *proto_msg); void Convert(const google::protobuf::ListValue &proto_msg, proto2ros::msg::List *ros_msg); void Convert(const proto2ros::msg::Struct &ros_msg, google::protobuf::Struct *proto_msg); void Convert(const google::protobuf::Struct &proto_msg, proto2ros::msg::Struct *ros_msg); } // namespace proto2ros::conversions