Mapping Service Interfaces
Introduction
Mapping Service Interfaces:
Provides SLAM map creation, loading, and management functionality. A map must be loaded and localization completed before using navigation interfaces.
| Purpose | Python |
|---|---|
| Start Mapping | ✔ |
| Stop Mapping and Save | ✔ |
| Load Map | ✔ |
| Get Available Maps | ✔ |
Mapping Mode
Python Interface
start_mapping(timeout=120)
Function Description
Start SLAM mapping mode. The robot begins scanning and building a point cloud map of the surrounding environment. After starting, manually drive the robot through the target area to achieve full coverage.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
timeout | int | 120 | Timeout in seconds for mapping mode to start. |
Return Value
| Type | Description |
|---|---|
StartMappingResponse | state.code == 0 and success is True indicates mapping mode has started. |
Example
from daystar_api.lowlevel_skills import start_mapping, stop_mapping
import time
# Start mapping
result = start_mapping()
if result.success:
print("Mapping started, drive the robot to scan the area...")
time.sleep(300) # Drive robot for 5 minutes to scan
stop_mapping("office_map")stop_mapping(map_name, auto_reload=False, need_2d_map=True, block=True, timeout=30)
Function Description
Stop SLAM mapping, save the map file, and switch back to map localization mode.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
map_name | str | Required | Name to save the map as. |
auto_reload | bool | False | If True, automatically load this map after saving for immediate use. |
need_2d_map | bool | True | Whether to also generate a 2D grid map. |
block | bool | True | If True, block until map saving completes. |
timeout | int | 30 | Timeout in seconds for the map saving operation. |
Return Value
| Type | Description |
|---|---|
StopMappingResponse | state.code == 0 and success is True indicates map was saved successfully. |
Example
from daystar_api.lowlevel_skills import stop_mapping
# Stop mapping and save, then auto-load
result = stop_mapping("office_floor1", auto_reload=True)
if result.success:
print("Map saved and loaded")Map Operations
Python Interface
load_map(map_name, auto_reload=True, timeout=30)
Function Description
Load an existing map from the map resource directory (/root/data/daystar_api/maps). After loading, automatically switches to localization mode.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
map_name | str | Required | Map name (must exist in the resource directory). |
auto_reload | bool | True | If True, load permanently (also used on next startup); if False, only for current session. |
timeout | int | 30 | Timeout in seconds for loading to complete. |
Return Value
| Type | Description |
|---|---|
LoadMapResponse | state.code == 0 and success is True indicates map loaded successfully. |
Example
from daystar_api.lowlevel_skills import load_map
# Load map permanently
result = load_map("office_floor1")
if result.success:
print("Map loaded successfully")
# Temporary load (current session only)
result = load_map("warehouse_map", auto_reload=False)
# Large map needs longer timeout
result = load_map("large_outdoor_map", timeout=60)get_available_maps(timeout=5)
Function Description
Get a list of all available map names in the map resource directory.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
timeout | int | 5 | Query timeout in seconds. |
Return Value
| Type | Description |
|---|---|
GetAvailableMapsResponse | state.code == 0 indicates query succeeded; response.map_names is the list of map names; response.success is a boolean. |
Example
from daystar_api.lowlevel_skills import get_available_maps, load_map
result = get_available_maps()
if result.response.success:
print("Available maps:")
for name in result.response.map_names:
print(f" - {name}")
# Check if target map exists
if "office_map" in result.response.map_names:
load_map("office_map")