Navigation Module

Capability overview

The navigation module provides capabilities for robot mapping, map saving, and localization management, supporting starting or stopping mapping, saving maps to the robot body, and starting or stopping localization based on existing maps. It also supports switching between the robot's built-in navigation mode and a user-defined navigation mode, allowing developers to choose how navigation is implemented based on their specific scenarios.

start_mapping interface reference
FieldDetails
Functionstart_mapping()
Signaturedef start_mapping(timeout) -> ExecutionResult
DescriptionStart mapping
ParameterNone
Return ValueExecutionResult
NotesNone

Example:

robot.navigation.start_mapping()
stop_mapping interface reference
FieldDetails
Functionstop_mapping()
Signaturedef stop_mapping(save_map_param: SaveMapParam, timeout) -> ExecutionResult
DescriptionStop mapping and save the map
Parametersave_map_param: SaveMapParam. map_name: Name of the map to save. Maps can currently be saved only on the robot.
Return ValueExecutionResult
NotesNone

Example:

robot.navigation.stop_mapping(
    SaveMapParam(map_name="test")
)
set_navigation_mode interface reference
FieldDetails
Functionset_navigation_mode()
Signaturedef set_navigation_mode(navigation_mode_param: NavigationModeParam, timeout) -> ExecutionResult
DescriptionSet the navigation mode
Parameternavigation_mode_param: NavigationModeParam. mode: Navigation mode. BUILT_IN_NAVIGATION: Use the robot's built-in navigation. USER_CUSTOM_NAVIGATION: Disable built-in navigation so that the user can implement custom navigation control.
Return ValueExecutionResult
NotesNone

Example:

robot.navigation.set_navigation_mode(
    NavigationModeParam(
        mode=NavigationMode.USER_CUSTOM_NAVIGATION
    )
)
start_localization interface reference
FieldDetails
Functionstart_localization()
Signaturedef start_localization(start_localization_param: StartLocalizationParam, timeout) -> ExecutionResult
DescriptionStart localization using a specified map
ParameterStartLocalizationParam.name: Name of the map used to start localization
Return ValueExecutionResult
Notes

Example:

result = robot.navigation.start_localization(StartLocalizationParam(map_name=map_name, use_init_pose=False))
print(f"start localization success: {result.is_success}")
stop_localization interface reference
FieldDetails
Functionstop_localization()
Signaturedef stop_localization(timeout) -> ExecutionResult
DescriptionStop localization
ParameterNone
Return ValueExecutionResult
NotesNone

Example:

robot.navigation.stop_localization()
cancel_navigation interface reference
FieldDetails
Functioncancel_navigation()
Signaturedef cancel_navigation(timeout=None) -> ExecutionResult
DescriptionCancel the current navigation task.
Parametertimeout: Optional RPC timeout in seconds. None means that no explicit timeout is set for this call.
Return ValueExecutionResult:
is_success: Whether the operation succeeded;
error_message: Failure message;
error_code: Failure category.
NotesThis interface cancels only the current navigation task. It does not delete maps or stop the localization service. If there is no task to cancel, use the returned result to determine the outcome. A connection loss or RPC timeout may raise a gRPC connection exception.

Example:

result = robot.navigation.cancel_navigation(timeout=10)

if result.is_success:
    print("cancel navigation success")
else:
    print(
        "cancel navigation failed: "
        f"error_code={result.error_code}, "
        f"error_message={result.error_message}"
    )
load_map interface reference
FieldDetails
Functionload_map()
Signaturedef load_map(map_name: str, map_path: str) -> TransferResult
DescriptionPackage a map directory on the SDK client computer and upload it to the robot.
Parametermap_name: Map name, not a path. It must not contain /, , or .. and must not begin with a period.
map_path: Parent directory of the map on the SDK client computer, not a path on the robot. The interface reads <map_path>/<map_name>/.
Return ValueTransferResult:
success: Whether packaging and upload succeeded;
message: Failure reason; normally empty on success.
NotesA non-empty <map_path>/<map_name>/ directory must exist on the client. Symbolic links and hard links in the directory are not included in the map package. The robot cannot run another map import or export operation at the same time. Path, packaging, transfer, or robot-side processing failures are normally returned through success=False and message.

Example:

# Read /home/user/maps/office_1/ on the client computer
result = robot.navigation.load_map(
    map_name="office_1",
    map_path="/home/user/maps",
)

if result.success:
    print("load map success")
else:
    print(f"load map failed: {result.message}")
export_map interface reference
FieldDetails
Functionexport_map()
Signaturedef export_map(map_name: str, target_path: str) -> TransferResult
DescriptionDownload a specified map from the robot and extract it on the SDK client computer.
Parametermap_name: Name of an existing map on the robot, not a path. It must not contain /, , or .. and must not begin with a period.
target_path: Destination parent directory on the SDK client computer, not a path on the robot. The interface writes to <target_path>/<map_name>/.
Return ValueTransferResult:
success: Whether download and extraction succeeded;
message: Failure reason; normally empty on success.
NotesThe specified map must exist on the robot. target_path and any existing <target_path>/<map_name> must be directories. Export to a map directory that does not yet exist or is empty to avoid mixing the export with old files. The robot cannot run another map import or export operation at the same time.

Example:

result = robot.navigation.export_map(
    map_name="office_1",
    target_path="/home/user/exported_maps",
)

if result.success:
    print("map exported to /home/user/exported_maps/office_1")
else:
    print(f"export map failed: {result.message}")
get_map_list interface reference
FieldDetails
Functionget_map_list()
Signaturedef get_map_list(timeout: Optional[float] = None) -> GetMapListResponse
DescriptionQuery the list of map names saved on the robot.
Parametertimeout: Optional RPC timeout in seconds. None means that no explicit timeout is set for this call.
Return ValueGetMapListResponse:
header: Call status, determined through is_success, error_code, and error_message;
map_list: List of map names; empty when no maps are available.
Notesmap_list contains map names only, not client-side or robot-side file-system paths. A connection loss or RPC timeout may raise a gRPC connection exception.

Example:

result = robot.navigation.get_map_list(timeout=10)

if result.header is not None and result.header.is_success:
    print("saved maps:")
    for map_name in result.map_list:
        print(f"- {map_name}")
else:
    error_code = result.header.error_code if result.header is not None else "UNKNOWN"
    error_message = (
        result.header.error_message
        if result.header is not None
        else "response header is missing"
    )
    print(
        "get map list failed: "
        f"error_code={error_code}, error_message={error_message}"
    )

On this page