> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuronav.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic SLAM

> Essential examples to get started with SLAM in 2 lines of code

Get started quickly with these essential SLAM examples.

## Minimal Example

The simplest possible SLAM application:

```python theme={null}
#!/usr/bin/env python3
from neuronav import RealSenseSensor, run_slam, RTABMapSLAM

sensor = RealSenseSensor()
slam = RTABMapSLAM()
run_slam(sensor, slam)
```

## With Visualization

Enable 3D visualization in your browser:

```python theme={null}
#!/usr/bin/env python3
from neuronav import RealSenseSensor, run_slam, RTABMapSLAM

sensor = RealSenseSensor()
slam = RTABMapSLAM()

print("Open http://localhost:8765 in your browser")
run_slam(sensor, slam, visualize=True)
```

## Using OAK-D Pro

Switch to OAK-D Pro camera:

```python theme={null}
#!/usr/bin/env python3
from neuronav import OAKDSensor, run_slam, RTABMapSLAM

sensor = OAKDSensor()
slam = RTABMapSLAM()
run_slam(sensor, slam, visualize=True)
```

## Custom Configuration

Configure sensor and SLAM parameters:

```python theme={null}
#!/usr/bin/env python3
from neuronav import RealSenseSensor, SensorConfig, RTABMapSLAM, SlamConfig, run_slam

# Configure sensor
sensor_config = SensorConfig(
    rgb_width=1280,
    rgb_height=720,
    fps=30,
    enable_imu=True
)

# Configure SLAM
slam_config = SlamConfig(
    enable_loop_closing=True,
    custom_params={
        "Vis/MaxFeatures": "1000",
        "Vis/MinInliers": "20"
    }
)

sensor = RealSenseSensor(sensor_config)
slam = RTABMapSLAM(slam_config)
run_slam(sensor, slam, visualize=True)
```

## Save and Load Maps

Work with persistent maps:

```python theme={null}
#!/usr/bin/env python3
from neuronav import RealSenseSensor, RTABMapSLAM, run_slam
import os

MAP_FILE = "my_map.db"
sensor = RealSenseSensor()
slam = RTABMapSLAM()

# Load existing map if available
if os.path.exists(MAP_FILE):
    slam.load_map(MAP_FILE)

# Run SLAM
try:
    run_slam(sensor, slam, duration=60)
finally:
    slam.save_map(MAP_FILE)
```

## Running Examples

**Clone and run:**

```bash theme={null}
git clone https://github.com/neuronav-io/neuronav-slam-sdk.git
cd neuronav-slam-sdk/examples
python3 minimal_slam.py
```

**With Docker:**

```bash theme={null}
docker run -it --rm --privileged -v /dev:/dev \
  neuronav-slam python3 /workspace/examples/minimal_slam.py
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Custom SLAM" icon="code" href="/examples/custom-slam">
    Advanced examples and use cases
  </Card>

  <Card title="Configuration" icon="gear" href="/configuration/overview">
    Detailed configuration options
  </Card>

  <Card title="Custom Sensors" icon="plus" href="/sensors/custom-sensors">
    Add your own camera
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/configuration/troubleshooting">
    Solve common issues
  </Card>
</CardGroup>
