NavMap
Loading...
Searching...
No Matches
navmap_ros::io Namespace Reference

IO helpers to persist NavMap objects to/from disk. More...

Classes

struct  SaveOptions
 Save options. 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

IO helpers to persist NavMap objects to/from disk.

Function Documentation

◆ load_from_file()

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.

Requires navmap_core headers and navmap_ros::from_msg.

Parameters
[in]pathSource file path.
[out]out_mapOutput core map.
[out]ecOptional error code; if not null, it will be set on failure.
Returns
true on success, false otherwise.
See also
load_msg_from_file()

◆ load_msg_from_file()

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.

The loader first tries to parse the header; if the magic header is missing, it falls back to treating the whole file as a raw CDR payload.

Parameters
[in]pathSource file path.
[out]out_msgOutput message deserialized from file.
[out]ecOptional error code; if not null, it will be set on failure.
Returns
true on success, false otherwise (and ec is set if provided).

◆ save_msg_to_file()

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.

The resulting file contains a small header (magic, version, size) followed by the CDR payload.

Parameters
[in]msgMessage to save.
[in]pathDestination file path.
[in]optionsSave options (currently unused, reserved).
[out]ecOptional error code; if not null, it will be set on failure.
Returns
true on success, false otherwise (and ec is set if provided).
Note
The format is portable across ROS 2 nodes using the same message type.

◆ save_to_file()

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.

Requires navmap_core headers and navmap_ros::to_msg.

Parameters
[in]mapCore map to save.
[in]pathDestination file path.
[in]optionsSave options (currently unused, reserved).
[out]ecOptional error code; if not null, it will be set on failure.
Returns
true on success, false otherwise.
See also
save_msg_to_file()