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): Promise<JsonValue>;
}

Hierarchy (View Summary)

Implemented by

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

      The command to execute.

    Returns Promise<JsonValue>

    import { Struct } from '@viamrobotics/sdk';

    const result = await resource.doCommand(
    Struct.fromJson({
    myCommand: { key: 'value' },
    })
    );