.. _file_include_soar_ros_msg_converters.hpp: File converters.hpp =================== |exhale_lsh| :ref:`Parent directory ` (``include/soar_ros/msg``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS Umbrella header for ROS 2 ↔ Soar WME message converters. .. contents:: Contents :local: :backlinks: none Definition (``include/soar_ros/msg/converters.hpp``) ---------------------------------------------------- .. toctree:: :maxdepth: 1 program_listing_file_include_soar_ros_msg_converters.hpp.rst Detailed Description -------------------- Provides two free-function families in the ``soar_ros::msg`` namespace: toSoar — ROS 2 message → Soar working memory sml::Identifier*toSoar(sml::Identifier*parent, constchar*attr, constMsgType&msg); Creates a child ID WME under ``parent`` with attribute ``attr`` and recursively populates it to mirror the ROS 2 message field hierarchy. Returns the newly created ``sml::Identifier*``. Typical use inside a ``soar_ros::Subscriber::parse()`` override: voidparse(geometry_msgs::msg::PoseStampedmsg)override { soar_ros::msg::toSoar(m_pAgent->GetInputLink(),m_topic.c_str(),msg); //ResultingWMEtree: // //+--(ID) //+--header(ID) //|+--frame_id(string) //|+--stamp(ID) //|+--sec(int) //|+--nanosec(int) //+--pose(ID) //+--position(ID) //|+--x(float)y(float)z(float) //+--orientation(ID) //+--x(float)y(float)z(float)w(float) } fromSoar — Soar working memory → ROS 2 message TfromSoar(sml::Identifier*id); Reads the WME subtree rooted at ``id`` and returns the corresponding ROS 2 message of type ``T``. Typical use inside a ``soar_ros::Publisher::parse()`` override: geometry_msgs::msg::Twistparse(sml::Identifier*id)override { //Soarrulewrites: //(^cmd) //(^linear^angular) //(^x1.0^y0.0^z0.0) //(^x0.0^y0.0^z0.5) returnsoar_ros::msg::fromSoar(id); } Supported message types - **std_msgs** : Bool, Int8/16/32/64, UInt8/16/32/64, Float32/64, String, Header - **geometry_msgs** : Vector3, Point, Point32, Quaternion, Pose, PoseStamped, PoseWithCovariance, Twist, TwistStamped, Accel, Transform, TransformStamped WME attribute naming Attribute names match the ROS 2 field names exactly, including underscores (e.g. ``frame_id``, ``child_frame_id``, ``nanosec``). Nested message fields become child ID WMEs. The ``PoseWithCovariance`` covariance matrix is stored as 36 flat float attributes named ``covariance_0`` … ``covariance_35``. Includes -------- - ``soar_ros/msg/geometry_msgs_converters.hpp`` (:ref:`file_include_soar_ros_msg_geometry_msgs_converters.hpp`) - ``soar_ros/msg/std_msgs_converters.hpp`` (:ref:`file_include_soar_ros_msg_std_msgs_converters.hpp`) Included By ----------- - :ref:`file_include_soar_ros_soar_ros.hpp`