SLAM

All research

How each robot builds a map of a building and keeps track of where it is on that map.

M20 Pro

The M20 has two ways to map and localize: DEEP Robotics’ 2D mapping stack, which is the one connected to navigation, and Lightning-LM, which maps and localizes in 3D. Lightning-LM runs beside the 2D stack on AOS, produces its own map and pose, and doesn’t drive the planner.

2D mapping

Provided by DEEP Robotics: a FAST-LIO-style filter for odometry and mapping, and GTSAM plus ICP for localization, fed by the RoboSense LiDAR (/LIDAR/POINTS) and Yesense IMU (/IMU_YESENSE).

  Odometry Mapping Localization
Host AOS, always running NOS, on demand NOS, always running
Program lio_ddsnode (dr_lio) slam_ddsnode (dr_lio) localization_ddsnode (graph_loc, v3.2.3)
Method IKFoM iterated Kalman filter with a multi-level voxel map Same filter; README adds pose graph optimization 3-second GTSAM fixed-lag IMU smoother plus fast_icp
Output /LIO_ODOM, which feeds the height map full_cloud.pcd and a 2D occupancy grid /ODOM
  • Separate estimates: localization reads raw LiDAR and IMU, not /LIO_ODOM, so two position estimates run at once.

2D mapping commands

Maps are stored in /var/opt/robot/data/maps, and active points to the one in use.

Action Command
Start mapping drmap mapping -n NAME -s (in tmux; -s skips RViz)
Stop mapping drmap stop_mapping
Use a map drmap apply PATH
Stop localization localization_stop.sh
Start localization Probably the localization systemd service; untested
Set pose /initialpose

Status topics: /LOCATION_STATUS, /ODOM, /ALIGNED_POINTS, plus /SLAM_ODOM and /SLAM_ALIGNED_POINTS while mapping.

3D mapping: Lightning-LM

Lightning-LM (DEEP Robotics’ fork of gaoxiang12/lightning-lm, BSD-3) is another way to map and localize on the M20, this time in 3D. It is built on AOS at /home/user/lightning-lm.

  • LiDAR-inertial odometry: a FAST-LIO-style filter fuses the IMU and LiDAR and tracks full 3D motion, with no flat-floor assumption.
  • Scan skipping: LiDAR corrections run on every 2nd scan to save CPU, while the IMU still handles every scan.
  • Loop closure: revisited places are matched and a pose graph removes accumulated drift.
  • Start-anywhere localization: a place-recognition index lets the robot localize from anywhere in a saved map.
  • Tiled maps: maps are saved as tiles, and distant tiles are unloaded during localization to save memory.
Lightning-LM 3D point-cloud map of the Levine hallway, viewed from above

A Lightning-LM map (global.pcd) of the Levine hallway, viewed in pcl_viewer.

Installing. To install Lightning-LM on the M20, follow the steps in the DEEP Robotics Lightning-LM repository.

Before each session:

  1. Start the point-cloud relay on NOS. It exists since V1.2.x but isn’t enabled at boot:
    ssh -J user@10.21.41.1 user@10.21.31.106
    sudo systemctl start multicast-relay.service
    
  2. Open the AOS root shell. onboard.py refuses to run as user on the M20:
    ssh user@10.21.41.1
    cd ~/lightning-lm
    sudo bash
    export LIGHTNING_DIR=/home/user/lightning-lm && cd "$LIGHTNING_DIR"
    

Mapping, saving and localizing:

tmux new-session -s lightning -c "$LIGHTNING_DIR"
python3 scripts/onboard.py status                     # must print SUCCESS
python3 scripts/onboard.py slam                       # map; add --record-bag to keep its inputs
python3 scripts/onboard.py save run1                  # from a 2nd root shell; wait for "response: 0"
python3 scripts/onboard.py localize data/run1 --global-init
  • Keep the robot still until it initializes, then walk it around. Revisiting earlier spots gives loop closure a chance.
  • A map is saved only by save; stopping without it loses the map. Use a new name each run, because a non-empty folder won’t be overwritten.
  • --global-init uses places.bin to start anywhere in the map, confirming over three observations. Without it, start near where mapping began.
  • Stop with Ctrl+C and wait for the prompt. Localization writes accepted poses to data/localization_onboard.tum, replaced each run.

Map files

Map file Purpose
global.pcd Full point cloud, for viewing
index.txt + numbered .pcd tiles Required for localization
places.bin Place-recognition index for --global-init
map_view.json Display leveling for the onboard map viewer

Topics

Output / input Topic
Estimator pose /lightning/pose
Live scan / matching pose /lightning/current_scan, /lightning/current_pose
Trajectory /lightning/trajectory
Transforms /lightning/tf, /lightning/tf_static
Manual initial pose (frame map) /lightning/initialpose

Viewing. Copy the map to a laptop and open it with pcl_viewer:

# on your laptop
mkdir -p ~/m20_runs
rsync -aP user@10.21.41.1:/home/user/lightning-lm/data/run1/ ~/m20_runs/map_run1/
pcl_viewer ~/m20_runs/map_run1/global.pcd -ps 2

Files are written by root, so run sudo chown -R user:user /home/user/lightning-lm/data on AOS first if copying fails. To visualize live in RViz, follow the steps in the DEEP Robotics Lightning-LM repository.

Troubleshooting

Symptom Cause / fix
onboard.py: “need the root shell” Use the AOS root shell (step 2).
status says NOT READY Check multicast-relay.service on NOS and the firmware sensor services.
/LIDAR/POINTS has 0 publishers, but /IMU works Running as user or with the robot’s DDS profile. See Visualization.
save returns 3 No map data yet, or the destination folder isn’t empty. Use a new name.
Wi-Fi dropped tmux keeps running. Reconnect and tmux attach -t lightning from a root shell.
Localization won’t initialize Keep the robot still; start near the mapping origin or use --global-init.

X30 Pro

What DEEP Robotics provides

The X30 runs two LiDAR-based estimators at once: DEEP Robotics’ SLAM and localization on the navigation computer, which builds the building map and tracks the robot on it for navigation, and a FAST-LIO odometry on the perception computer, which only feeds the local height map used for walking and obstacle checks. Both read the four MID-360s merged into one cloud.

  Mapping Localization Perception odometry
Host Navigation (.106), on demand Navigation (.106), at boot or on demand Perception (.105), with the height map
Program run_mapping_online (package slam 2.1.5, ~/jy_cog/slam) localization_rosnode (package localization 3.0.0, ~/jy_cog/localization) fastlio_mapping (FAST-LIO, in ~/jy_cog/height_map), with ekf_quat and height_map
Method LiDAR mapping in three modes (below); loop detection and keyframe maps in indoor and outdoor modes Matches live scans against the map’s prior point cloud (jueying.pcd) FAST-LIO LiDAR-inertial odometry; ignores points within 4 m, and its world frame isn’t gravity-aligned
Output A map folder: 3D cloud, 2D grid per floor, keyframes and mapping path /odom: the robot’s pose in the map frame, 10 Hz; /location_status Registered cloud for the elevation map
  • Separate estimates: the height map’s FAST-LIO pose and the navigation computer’s map pose are independent, and live on different ROS masters. Our own code uses leg odometry (/leg_odom) between map corrections instead of either.
  • The mapping and localization algorithms aren’t documented by the vendor beyond the modes below.

Mapping modes

Mode Use Loop closure and keyframes Multi-floor
fast Quick maps No Yes, by saving a new grid at each landing
indoor Indoor, narrow or small spaces Yes Yes, with a floor label per keyframe (slam_ctl.sh floor <n>)
outdoor Large, open outdoor areas Yes Yes

Limits from the vendor’s manual: single-floor indoor maps up to 50 × 50 m, multi-floor up to 50 × 50 m and 10 floors, large single-floor maps up to 500 × 500 m. Mapping isn’t supported in mixed indoor–outdoor scenes, featureless tunnels and long corridors, very open spaces, crowded scenes, or long routes with few loops. Start mapping with the robot standing still, keep it still for 5–8 s, then walk it steadily without blocking the LiDARs.

Autostart. ~/jy_cog/system/conf/autorun_slam (true or false) sets whether localization and navigation start at boot. It takes effect after the navigation computer restarts.

Localization topics

Topic Type Direction What it is
/initialpose geometry_msgs/PoseWithCovarianceStamped In Reset the robot’s pose (Foxglove’s Publish pose estimate)
/map_request/pcd std_msgs/String In Switch localization to another map’s .pcd
/odom nav_msgs/Odometry Out The robot’s pose on the map
/globalmap sensor_msgs/PointCloud2 Out The map’s point cloud
/location_status std_msgs/Int8 Out 0 = localized, 1 = lost

All of these are on the navigation computer’s ROS master; /odom doesn’t exist on the perception computer, so anything there that needs the map pose has to have it relayed.

Our addition

The vendor exposes mapping and localization through shell scripts on the navigation computer. We wrapped them in a ROS node with a Foxglove panel, so an operator can start mapping in a chosen mode, save the map, start localization and switch to the newest map from a laptop. Every map on the robot is recorded in a manifest in the repository, with its creation time, completeness and associated routes.

Mapping and localization driven from the Foxglove SLAM panel (8× speed). The point cloud builds up as the robot walks, and the panel then switches to localization on the saved map.

3D LiDAR point-cloud map of intersecting hallways

3D point-cloud map of a hallway intersection in the Levine building, colored by height, produced by the vendor SLAM.

Commands

On the navigation computer, our slam_ctl.sh (in ~/X30_dev/hosts/nav-106/x30_tools) wraps the vendor’s scripts and runs each long job in tmux, so it survives an SSH disconnect. The SLAM Control panel in Foxglove calls the same commands.

Action Command
Start mapping slam_ctl.sh map_start [fast\|indoor\|outdoor] [name] (stops localization first)
Mark a new floor slam_ctl.sh floor <n>, at the landing where floor n starts (indoor and outdoor modes)
Stop mapping slam_ctl.sh map_stop (builds the final map and makes it active)
Start localization slam_ctl.sh loc_start [map\|latest]
Stop localization slam_ctl.sh loc_stop
Use a map slam_ctl.sh use_map <name\|latest>
List maps / status slam_ctl.sh maps, slam_ctl.sh status
Foxglove buttons slam_ctl.sh ui_start
  • Maps are saved as <name>-<date>-<time> in ~/jy_cog/system/maps/; ~/jy_cog/system/map links to the active one.
  • Watch mapping with tmux attach -t slam_mapping.
  • Set the starting pose with Publish pose estimate in Foxglove’s 3D panel. On a multi-floor map, check the robot sits at the right floor’s height.

Map files

File Purpose
jueying.pcd 3D point cloud, used for localization
jueying.pgm, jueying.yaml 2D grid of the first floor, used for path planning
jueying1.pgm, … Grids of further floors (multi-floor maps)
loc_map/ Localization data; a map without it is incomplete
details/ The mapping path, with a floor label per keyframe, used by our floor and staircase tools