Viam SDK
    Preparing search index...

    Class SlamClient

    A gRPC-web client for a SLAM service.

    Implements

    • Slam
    Index

    Constructors

    Properties

    callOptions: CallOptions = ...
    name: string

    The name of the resource.

    Methods

    • Send/Receive arbitrary commands to the resource.

      Parameters

      • command: Struct | Record<string, JsonValue>

        The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>

      // Plain object (recommended)
      const result = await resource.doCommand({
      myCommand: { key: 'value' },
      });

      // Struct (still supported)
      import { Struct } from '@viamrobotics/sdk';

      const result = await resource.doCommand(Struct.fromJson({ myCommand: { key: 'value' } }));
    • Get the internal state of the SLAM algorithm required to continue mapping/localization.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<Uint8Array<ArrayBufferLike>>

      const slam = new VIAM.SlamClient(machine, 'my_slam');

      // Get the internal state of the SLAM algorithm
      const internalState = await slam.getInternalState();

      For more information, see SLAM API.

    • Get the point cloud SLAM map.

      Parameters

      • OptionalreturnEditedMap: boolean
      • callOptions: CallOptions = ...

      Returns Promise<Uint8Array<ArrayBufferLike>>

      const slam = new VIAM.SlamClient(machine, 'my_slam');

      // Get the point cloud map
      const pointCloudMap = await slam.getPointCloudMap();

      // Get the edited point cloud map
      const editedMap = await slam.getPointCloudMap(true);

      For more information, see SLAM API.

    • Get the current position of the specified source component in the point cloud SLAM map.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<slamApi.GetPositionResponse>

      const slam = new VIAM.SlamClient(machine, 'my_slam');

      // Get the current position of the robot in the SLAM map
      const position = await slam.getPosition();
      console.log('Current position:', position);

      For more information, see SLAM API.

    • Get information on the properties of the current SLAM service.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<slamApi.GetPropertiesResponse>

      const slam = new VIAM.SlamClient(machine, 'my_slam');

      // Get the properties of the SLAM service
      const properties = await slam.getProperties();
      console.log('SLAM properties:', properties);

      For more information, see SLAM API.

    • Get the status of the resource.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>