Viam SDK
    Preparing search index...

    Interface WorldStateStore

    A service that manages world state transforms, allowing storage and retrieval of spatial relationships between reference frames.

    interface WorldStateStore {
        getTransform: (
            uuid: string,
            extra?: Struct,
        ) => Promise<TransformWithUUID>;
        listUUIDs: (extra?: Struct) => Promise<string[]>;
        name: string;
        streamTransformChanges: (
            extra?: Struct,
        ) => AsyncGenerator<TransformChangeEvent, void>;
        doCommand(command: Struct | Record<string, JsonValue>): Promise<JsonValue>;
        getStatus(): Promise<JsonValue>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    getTransform: (uuid: string, extra?: Struct) => Promise<TransformWithUUID>

    GetTransform returns a world state transform by UUID.

    Type Declaration

    const worldStateStore = new VIAM.WorldStateStoreClient(machine, 'builtin');

    // Get a specific transform by UUID
    const transform = await worldStateStore.getTransform(uuid);
    listUUIDs: (extra?: Struct) => Promise<string[]>

    ListUUIDs returns all world state transform UUIDs.

    Type Declaration

      • (extra?: Struct): Promise<string[]>
      • Parameters

        • Optionalextra: Struct

          Additional arguments to the method

        Returns Promise<string[]>

    const worldStateStore = new VIAM.WorldStateStoreClient(machine, 'builtin');

    // Get all transform UUIDs
    const uuids = await worldStateStore.listUUIDs();
    name: string

    The name of the resource.

    streamTransformChanges: (
        extra?: Struct,
    ) => AsyncGenerator<TransformChangeEvent, void>

    StreamTransformChanges streams changes to world state transforms.

    The returned transform will only contain the fields that have changed.

    Type Declaration

    const worldStateStore = new VIAM.WorldStateStoreClient(machine, 'builtin');

    // Stream transform changes
    const stream = worldStateStore.streamTransformChanges();
    for await (const change of stream) {
    console.log('Transform change:', change.changeType, change.transform);
    }

    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.

      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' } }));