load_composite_map
Service type: map_manager/srv/LoadCompositeMap
Service name: /load_composite_map
Description
Loads the map archive directory in map_path and persists the loaded result. It does not set the initial pose; publish /initialpose after success.
Request (Request)
| Field | Type | Description |
|---|---|---|
| map_path | string | Archive directory to load. |
Response (Response)
| Field | Type | Description |
|---|---|---|
| success | bool | Whether the operation succeeded. |
| message | string | Result or error message. |
| map_info | map_manager/msg/CompositeMapInfo | Loaded map information; on success, map_id is the archive directory name. |
Example
Complete Environment Preparation first: the CLI examples require
ROBOT_NAMESPACEto be set; the Python and C++ examples use relative service names, so append--ros-args -r __ns:=$ROBOT_NAMESPACEwhen running them.
CLI call
ros2 service call $ROBOT_NAMESPACE/load_composite_map map_manager/srv/LoadCompositeMap \
"{map_path: '/data/maps/office'}"
After success, publish the initial pose:
# The subscriber is BEST_EFFORT + TRANSIENT_LOCAL; the publisher must match that QoS,
# and publishing continuously for a few seconds ensures endpoint matching.
timeout 6 ros2 topic pub --qos-reliability best_effort --qos-durability transient_local -r 1 \
$ROBOT_NAMESPACE/initialpose geometry_msgs/msg/PoseWithCovarianceStamped \
"{header: {frame_id: 'map'}, pose: {pose: {position: {x: 1.0, y: 2.0, z: 0.0}, orientation: {z: 0.0, w: 1.0}}}}"
Python example
import rclpy
from rclpy.node import Node
from map_manager.srv import LoadCompositeMap
class MapLoader(Node):
def __init__(self):
super().__init__('map_loader')
self.client = self.create_client(
LoadCompositeMap, 'load_composite_map')
def load(self, map_path: str):
self.client.wait_for_service()
request = LoadCompositeMap.Request()
request.map_path = map_path
future = self.client.call_async(request)
rclpy.spin_until_future_complete(self, future)
return future.result()
rclpy.init()
node = MapLoader()
result = node.load('/data/maps/office')
print(result.message)
node.destroy_node()
rclpy.shutdown()
C++ example
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include <map_manager/srv/load_composite_map.hpp>
auto node = std::make_shared<rclcpp::Node>("map_loader");
auto client = node->create_client<map_manager::srv::LoadCompositeMap>(
"load_composite_map");
client->wait_for_service();
auto request = std::make_shared<map_manager::srv::LoadCompositeMap::Request>();
request->map_path = "/data/maps/office";
auto future = client->async_send_request(request);
if (rclcpp::spin_until_future_complete(node, future) ==
rclcpp::FutureReturnCode::SUCCESS) {
const auto response = future.get();
RCLCPP_INFO(node->get_logger(), "%s", response->message.c_str());
}
Supported map format
Directory format
GRW loads only an archive directory created by save_composite_map. map_path must be that directory, not a file inside it.
The save service writes the map metadata, the navigation map data, and the map.pgm and map.yaml files used for the 2D occupancy grid into the archive directory. Keep the complete directory and its contents when loading: do not copy out individual files, and do not edit the archive by hand.
Unsupported formats
Direct loading of .mmap archives, point-cloud maps, and maps generated by other robot models is not supported. To move a map between GRW devices, copy the complete GRW archive directory.
Related services
- SaveCompositeMap - Saves an archive
- ClearCompositeMap - Clears the runtime map
- Initial pose topic - Sets the pose after loading