> For the complete documentation index, see [llms.txt](https://docs-7.phoenixlidar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-7.phoenixlidar.com/lidarmill-desktop/post-processing/slam-workflow-beta.md).

# SLAM Workflow(Beta)

## Basic SLAM workflow

1. Open the Phoenix LiDAR Systems project file (.plp) from the acquired dataset (Click [here](https://docs.phoenixlidar.com/lidarmill-desktop/post-processing/slam-workflow-beta#performing-acquisition) for more details on dataset acquisition).
2. Optionally, if available, load in a .cg file from InertialExplorer with postprocessed GPS positions (if .cp is only available, it can be renamed to .cg).
3. Close the **System Monitor window** (either by pressing **X** in the upper right corner, or by selecting **Windows** -> **System Monitor**).

   <img src="/files/-MVufyG7zHcw-OjfP4Uo" alt="" data-size="original">&#x20;

   Open the **SLAM** processing window (**Windows** -> **SLAM**).\
   &#x20;<img src="/files/-MVugQvApHuNmqfE_UOc" alt="" data-size="original">&#x20;
4. Click the **Manage SLAM...** button on the SLAM processing window,  and select **Start SLAM**.\
   &#x20;<img src="/files/-MVuh0RumUNxOXqhMPEg" alt="" data-size="original">&#x20;
5. The **Edit SLAM tuning** dialog appears. The previously used SLAM processing settings (also referred to as a *SLAM tuning)* processing are loaded by default.\
   Sets of default recommended settings (*presets*) are available to be loaded as using the **Load from preset...** button in the top left.\
   When running SLAM processing for the first time, settings must be loaded from a preset. The recommended preset is called ***LFTB2**.* \ <img src="/files/-MVuhlh541COP9CVQ6vn" alt="" data-size="original">&#x20;
6. Click **Start SLAM** button to continue.\
   &#x20;<img src="/files/-MVui7xRY2gcPFy7wx6M" alt="" data-size="original">&#x20;
7. Select a time in the dataset to begin SLAM processing at by clicking the timeline (usually slightly before the LIDAR session). Alternatively, a start time may be entered using the **Select Time** window, accessible with the **Clock icon** button, next to the **Play** button. <img src="/files/-MVuiR1-b2O4NoZew923" alt="" data-size="original">&#x20;
8. Hit the **Play** button to start SLAM processing from the selected time in the dataset. Note that after playback is started, seeking during SLAM processing is not possible anymore. Processing can however be paused and resumed using the **Play/Pause** button.
9. Wait for SLAM processing to finish (in the **SLAM** window, the first progress bar is drained to zero in queue, while the second progress bar is filled up to 100%, e.g. 5678/5678, and both numbers are not increasing).\ <img src="/files/-MVuivdM3rpXgLiv8uU9" alt="" data-size="original">&#x20;
10. After processing is finished, you may opt to write out the resulting trajectory in a **.pof/.poq** file for further processing using **Manage SLAM....** -> **Write trajectory**, or you may opt to save the entire SLAM session (which inludes the trajectory and the SLAM cloud) using **Manage SLAM.... -> Finalize and save SLAM session...**\
    &#x20;<img src="/files/-MVujQO9zccu-9dV3KGt" alt="" data-size="original"> \
    The question "Recompute the point cloud according to the final optimized trajectory?" should be answered "Yes" if the cloud quality is satisfactory.  Cloud recompute will take some time, and it is recommended that it is performed at the very end of SLAM processing (e.g. after making other adjustments).\ <img src="/files/-MVujaJFNGhB3HI1_Zgn" alt="" data-size="original">&#x20;

The SLAM cloud, saved as part of the SLAM session, can be opened and examined standalone in a new instance of SpatialExplorer. It, however, cannot be recomputed.To recompute it, the entire SLAM session must be restored. To do this, select **Manage SLAM -> Restore SLAM session** in a new instance of SpatialExplorer. The original project does not have to be opened.

## Performing acquisition

See the following documentation regarding [SLAM data acquistion](/data-acquisition-and-uav-piloting/slam.md).&#x20;

## Things to check

* Make sure that the correct LiDAR, IMU, and GPS antenna (if applicable) mounting calibrations are set up before starting processing. If not, it is a good idea to **Save as...** the project after setting them up, in order to avoid the need to repeat entering them next time.
* Make sure that in the **Manage SLAM...** menu, **Fuse SLAM cloud** and **Automatically refresh poses** are checked (the default settings).

![](/files/-MVr1jVGHSStffw5nOJB)

* At the starting location, SLAM performs 'bootstrapping', i.e. creating the initial map of the surroundings (the first few seconds when the sensor is aligning and creating an understanding of the surroundings to tie to further along the mission.)
* When a trajectory re-visits the same area (*a loop*), the two parts of the trajectory should be correctly registered one against the other. This can be verified at the point cloud-level by coloring the cloud by time or by *submap ID*, and making sure that the old and new points in the cloud are well intermixed, without separation.

![The old and new points are well intermixed without separation (cloud colored by time)](/files/-MVqsjREfdZzxu8g1hC2)

Another helpful way to verify loop closure at trajectory-level is to enable **Manage SLAM... -> Display loop closure constraints**. Different parts of the trajectory which visit the same area should have lines of different colors connecting them.

![Two legs of the trajectory are well constrained ('Display loop closure constraints' setting is enabled, while the SLAM cloud is hidden)](/files/-MVqrXZXCTH0WOQuyRoJ)

* If the accumulated drift gets too large (e.g. in a large loop), loop closures may be missed. This can be countered by increasing the loop closure search windows in the **SLAM tuning** dialog when starting SLAM processing. (Setting the search windows too large may increase the processing time and cause problems in tighter and symmetric environments, e.g. building with similar rooms or similar floors).

![The part of the SLAM tuning dialog containing the loop closure search window settings](/files/-MVr0gr3uS64M3p-G5E_)

## Fine tuning&#x20;

#### Adjusting Optimization Weights

After SLAM processing is finished, using the option **Manage SLAM...** -> **Adjust optimization weights**, some final non-destructive tweaking of the trajectory optimization can be performed. Notably, the strength of georeferencing can be adjusted (if it is too high, it can impact the cloud quality; if it is too low, the cloud may not be accurately georeferenced).

The georeferencing inlier scale specifies the distance from trajectory at which GPS measurement start having diminishing effect. This parameter can be set to a smaller distance at the very end in order to eliminate the effect of outlier measurements.

The gravity alignment weight (1) performs global gravity (i.e. pitch/roll) alignment of the trajectory according to the IMU measurements, while also having a "smoothing" effect on the trajectory positions. Gravity alignment (2) is an alternative implementation of the same (albeit it should not have the "smoothing" effect). In our testing, a moderate (10-200) weight on the gravity alignment 1 has proven to work.

![](/files/-MVr43kc0wKRWLTgNoHF)

To apply changes and see the immediate effect on the trajectory and the cloud, click **Optimize**. For changing other settings in the SLAM tuning, the dataset must be reprocessed.

#### Optimizing to GCPs

The SLAM trajectory can be optimized to better to fit ground control points. This is done by creating a correction from a GCP-laser point combination, similar to the [manual GCP adjustment workflow](/lidarmill-desktop/workflow-kk/ground-control/manual-adjustment-horizontal-and-vertical.md). Corrections can be vertical, horizontal, or full. In the example below, vertical corrections are used to optimize SLAM.

First, remove any existing measurements from the measurement tab. Then, **select the GCP and the and corresponding laser point** by clicking on them individually in a profile view (for horizontal corrections, select them from the plan view):

<figure><img src="/files/ueES2NWrfAc6z7yn70cf" alt=""><figcaption></figcaption></figure>

Once selected, click **Import from Measurements** and select **Vertical** for the correction type:

<figure><img src="/files/aYXOtRlVxcQ6g1O8p3Ae" alt=""><figcaption></figcaption></figure>

In this example, two vertical corrections are needed for different time intervals along the trajectory. Visualizing the point cloud by **GPS time** may be helpful, and may require **updating attributes from cloud**).&#x20;

<figure><img src="/files/ikBCgIqoS1QKrqNhvYSM" alt=""><figcaption></figcaption></figure>

Once the correction(s) are imported, click **Optimize**:

<figure><img src="/files/mGdPq28w6ChhENCofq89" alt=""><figcaption></figcaption></figure>

## Troubleshooting

* When troubleshooting, the first step is to set the georefencing strength to 0 (zero) and to perform SLAM processing again.

![](/files/-MVrFDZ0rOKpuWBzxkdS)

* If the SLAM trajectory and the cloud look correct, try restoring/adjusting the georeferencing strength at this point using the **Optimization weights** section of the **SLAM** window and then pressing **Optimize**.

![](/files/-MVrGdyDgsbbgEa9BPvl)

* If still problematic, try processing with the "LFTB2 no opt" preset, still making sure that the georeferencing strength is at 0 after loading the preset. Process a portion of the dataset. The trajectory and cloud can have global pitch roll, and drift at this point; however, the local cloud quality  should be acceptable.

![](/files/-MVrFmXnrMtkl8SP5OjT)

* Next, pressing **Optimize** in the SLAM dialog should result in gravity alignment being performed; i.e. the pitch and roll of the trajectory should be optimized correctly.
* Mounting the LiDAR with a noticeable pitch is not recommended for SLAM processing. However, in this scenario, the **Submap size (nr. of sweeps)** parameter can be increased from the default 150 scans to a bigger value (e.g. up to 1000 scans). It is also suggested to increase this parameter slightly (e.g. to 200-300) when data acquisition is performed on foot.

![](/files/-MVrJ8kJk6Sajy5qyBPH)
