NavMap
Loading...
Searching...
No Matches
navmap_io.hpp File Reference

Save/Load utilities for NavMap to/from disk using ROS 2 CDR serialization. More...

#include <string>
#include <system_error>
#include "navmap_core/NavMap.hpp"
#include "navmap_ros_interfaces/msg/nav_map.hpp"
Include dependency graph for navmap_io.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SaveOptions
 Save options. More...

Namespaces

namespace  navmap_ros
 Conversions between core NavMap and ROS-level structures.
namespace  navmap_ros::io
 IO helpers to persist NavMap objects to/from disk.

Enumerations

enum class  Compression { NONE , ZLIB }
 Payload compression. zlib is available on every ROS distro and platform, and in Python. More...

Functions

bool load_from_file (const std::string &path, navmap::NavMap &out_map, std::error_code *ec=nullptr)
 Load a navmap::NavMap by deserializing a message and converting to core.
bool load_msg_from_file (const std::string &path, navmap_ros_interfaces::msg::NavMap &out_msg, std::error_code *ec=nullptr)
 Load a NavMap message from a file created by this saver.
bool save_msg_to_file (const navmap_ros_interfaces::msg::NavMap &msg, const std::string &path, const SaveOptions &options={}, std::error_code *ec=nullptr)
 Save a NavMap message to disk using ROS 2 CDR serialization.
bool save_to_file (const navmap::NavMap &map, const std::string &path, const SaveOptions &options={}, std::error_code *ec=nullptr)
 Save a navmap::NavMap by converting it to a message and serializing to disk.

Detailed Description

Save/Load utilities for NavMap to/from disk using ROS 2 CDR serialization.

Two API layers: 1) Message-level: save/load navmap_ros_interfaces::msg::NavMap directly. 2) Core-level (optional): save/load navmap::NavMap if the core headers are available, using navmap_ros::to_msg / navmap_ros::from_msg.

File format (version 2)
A small binary envelope followed by the ROS 2-serialized payload (little endian):
  • Magic "NAVMAP\0\0"
  • Version (uint32), codec (uint32: 0 none, 1 zlib)
  • Raw (CDR) size and stored size (uint64 each)
  • Payload: the CDR message, compressed by the codec

Version 1 files (magic, version, size, CDR; or a bare CDR payload) are migrated on load, with a deprecation warning, and rewritten in the current format.