{"id":13649553,"url":"https://github.com/swri-robotics/message_serialization","last_synced_at":"2025-06-20T13:35:33.081Z","repository":{"id":55521484,"uuid":"275897415","full_name":"swri-robotics/message_serialization","owner":"swri-robotics","description":"A utility for serializing C++ structures (specifically ROS messages) into YAML and binary formatted files","archived":false,"fork":false,"pushed_at":"2020-12-24T02:41:02.000Z","size":37,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-10T00:33:09.928Z","etag":null,"topics":["ros","ros-industrial","serialization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swri-robotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-29T18:38:59.000Z","updated_at":"2024-08-07T21:04:13.000Z","dependencies_parsed_at":"2022-08-15T02:20:28.327Z","dependency_job_id":null,"html_url":"https://github.com/swri-robotics/message_serialization","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swri-robotics%2Fmessage_serialization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swri-robotics%2Fmessage_serialization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swri-robotics%2Fmessage_serialization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swri-robotics%2Fmessage_serialization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swri-robotics","download_url":"https://codeload.github.com/swri-robotics/message_serialization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236165365,"owners_count":19105616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ros","ros-industrial","serialization"],"created_at":"2024-08-02T02:00:18.787Z","updated_at":"2025-01-29T10:30:12.177Z","avatar_url":"https://github.com/swri-robotics.png","language":"C++","funding_links":[],"categories":["Other"],"sub_categories":["Sensors"],"readme":"# message_serialization\n![](https://github.com/swri-robotics/message_serialization/workflows/CI/badge.svg)\n[![license - Apache 2.0](https://img.shields.io/:license-Apache%202.0-yellowgreen.svg)](https://opensource.org/licenses/Apache-2.0)\n\nA header-only utility for serializing C++ structures (specifically ROS messages) into YAML-formatted and binary-formatted files that can be loaded to/from disk\n\n## Usage\n\n```c++\n// Serialization headers\n#include \u003cmessage_serialization/serialize.h\u003e\n#include \u003cmessage_serialization/binary_serialization.h\u003e\n\n// Datatype-specific serialization header\n#include \u003cmessage_serialization/geometry_msgs_serialization.h\u003e\n\nint main(int argc, char** argv)\n{\n  // Create a structure to serialize\n  geometry_msgs::PoseStamped ps;\n  ps.header.frame = \"world\";\n  ps.header.stamp = ros::Time::now();\n  ...\n\n  const std::string filename = \"/path/to/save/dir/file.yaml\";\n\n  // YAML Serialization\n  // Serialize the message\n  if(!message_serialization::serialize(filename, ps))\n    return -1;\n\n  // De-serialize the message\n  geometry_msgs::Pose new_ps;\n  if(!message_serialization::deserialize(filename, new_ps))\n    return -1;\n    \n  // Binary serialization (ROS messages only)\n  // Serialize the message\n  if(!message_serialization::serializeToBinary(filename, ps))\n    return -1;\n\n  // De-serialize the message\n  if(!message_serialization::deserializeFromBinary(filename, new_ps))\n    return -1;\n    \n  return 0;\n}\n```\n\n## Customization\n\nAny custom C++ structure can be serialized to YAML with this library, provided that a specific template structure for the custom datatype be specialized in the YAML namespace:\n\n```c++\nstruct CustomStruct;\n\nnamespace YAML\n{\n  template\u003c\u003e\n  struct convert\u003cCustomStruct\u003e\n  {\n    static Node encode(const CustomStruct\u0026 rhs);\n    static bool decode(const Node\u0026 node, CustomStruct\u0026 rhs);\n  };\n}\n```\n\nSee the implementations in the `include` directory for examples on how to implement this structure for a custom data type.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswri-robotics%2Fmessage_serialization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswri-robotics%2Fmessage_serialization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswri-robotics%2Fmessage_serialization/lists"}