Atlas Robotics
Lesson 3/6 · about 20 min

Save maps and read recorded files

PGO keeps the map in memory, if turned off it is lost. Call the save service before turning off SLAM, then read the two files you just recorded.

response:
interface.srv.SaveMaps_Response(success=True, message='SAVE SUCCESS!')

And a folder with exactly two files: map.pcd (map) and poses.txt (robot positions during scanning).

Call the save service

Stop the robot with the k key in teleop. Keep Terminal 1 and 2 running.

Terminal 4

MAP_DIR="$HOME/atlas_sim3D/src/atlas3d_mapPCDs/ramp/run_01"
mkdir -p "$MAP_DIR"
ros2 service call /pgo/save_maps interface/srv/SaveMaps \
  "{file_path: '$MAP_DIR', save_patches: false}"

Dev responds after 0.6 s. Check:

ls -lh "$MAP_DIR"
-rw-r--r-- 1 doanh doanh  20M map.pcd
-rw-rw-r-- 1 doanh doanh  11K poses.txt

Turn off after finishing: Ctrl+C in Terminal 3 (teleop), Terminal 2 (SLAM), then Terminal 1 (simulation).

Service overwrite if the directory already has a map. Each scan uses a new folder: run_01, run_02... The parent folder name is the world name (ramp): the relocalization step must open the correct world.

map.pcd

PCD file point cloud of PCL library: a text header and then binary data. See the first part:

head -c 300 "$MAP_DIR/map.pcd" | strings
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z intensity
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 1285934
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 1285934
DATA binary

1 285 934 points, each storing 4 floating-point values 4 bytes (x, y, z, intensity) = 20.6 MB. Coordinates in frame map, unit meters. These are keyframes assembled by position that have been adjusted by PGO, without filtering out points.

Visual View: pcl_viewer "$MAP_DIR/map.pcd" (package pcl-tools), or CloudCompare.

poses.txt

One keyframe per line:

12.pcd 5.4174 2.5057 0.0293 0.9919 0.0043 -0.0044 0.1270
  │      └ x y z (m)              └ quaternion qw qx qy qz (w first)
  └ keyframe index

This is the position and orientation of frame body (IMU center, right above the robot's rotation center) when capturing that keyframe, after PGO has straightened it. The relocalization step takes line 0 as the initial guess position: the robot that reopens the simulation will stand in that exact place.

Scans in the lesson: 107 lines for 52 m of line, about 0.5 m per keyframe. The keyframe on the platform has a z of about 0.55 m; The keyframe on the slope has a pitch/tilt angle of ±6–7°, matching the 6° slope of the world.

Why are there only two files

relocalization only requires a map to scan and an initial guess location. save_patches: true save each keyframe as a separate PCD file, only used when you want to optimize the map with an external tool. M10 goes into the details of saving and loading maps.

Maps available

Repo comes with a scanned ramp map following the route of lesson 1: src/atlas3d_mapPCDs/ramp/demo. If your scanning or saving step fails, put MAP_DIR in that folder to continue with exercises 3 and 4.

Folder src/atlas3d_mapPCDs/ has file COLCON_IGNORE (colcon ignored when building).

Save the map and read the files it writes · Module 1: One full loop: scan → save → localize → drive — Atlas Robotics