World state store API

The world state store service API allows you to retrieve a list of world objects. You can use this list to create custom visualizers to render spatial data related to a machine on the machine’s VISUALIZE tab.

The world state store service supports the following methods:

Method NameDescription
listUUIDsList all world state transform UUIDs.
GetTransformGet a world state transform by UUID.
StreamTransformChangesStream changes to world state transforms.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this Resource with the given name.
CloseSafely shut down the resource and prevent further use.

API

listUUIDs

List all world state transform UUIDs.

Parameters:

  • extra (Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.
  • timeout (float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

Returns:

Example:

worldstatestore = WorldStateStoreClient.from_robot(robot=machine, name="builtin")

uuids = await worldstatestore.list_uuids()

For more information, see the Python SDK Docs.

Parameters:

  • extra (None) (optional): Additional arguments to the method.
  • callOptions (CallOptions) (optional)

Returns:

  • (Promise<string[]>)

Example:

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

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

For more information, see the TypeScript SDK Docs.

GetTransform

Get a world state transform by UUID.

Parameters:

  • uuid (bytes) (required): The UUID of the transform to retrieve.
  • extra (Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.
  • timeout (float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

Returns:

Example:

worldstatestore = WorldStateStoreClient.from_robot(robot=machine, name="builtin")

transform = await worldstatestore.get_transform(uuid=b"some-uuid")

For more information, see the Python SDK Docs.

Parameters:

  • uuid (string) (required): The UUID of the transform to retrieve.
  • extra (None) (optional): Additional arguments to the method.
  • callOptions (CallOptions) (optional)

Returns:

Example:

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

// Get a specific transform by UUID
const transform = await worldStateStore.getTransform(uuid);

For more information, see the TypeScript SDK Docs.

StreamTransformChanges

Stream changes to world state transforms.

Parameters:

  • extra (Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.
  • timeout (float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

Returns:

Example:

worldstatestore = WorldStateStoreClient.from_robot(robot=machine, name="builtin")

async for change in worldstatestore.stream_transform_changes():
    print(f"Transform {change.transform.uuid} {change.change_type}")

For more information, see the Python SDK Docs.

Parameters:

  • extra (None) (optional): Additional arguments to the method.
  • callOptions (CallOptions) (optional)

Returns:

Example:

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

For more information, see the TypeScript SDK Docs.

DoCommand

Execute model-specific commands that are not otherwise defined by the service API. Most models do not implement DoCommand. Any available model-specific commands should be covered in the model’s documentation. If you are implementing your own vision service and want to add features that have no corresponding built-in API method, you can implement them with DoCommand.

Parameters:

  • command (Mapping[str, ValueTypes]) (required): The command to execute.
  • timeout (float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

Returns:

  • (Mapping[str, viam.utils.ValueTypes])

Example:

my_world_state_store_svc = World_State_StoreClient.from_robot(robot=machine, "my_world_state_store_svc")

my_command = {
  "cmnd": "dosomething",
  "someparameter": 52
}

await my_world_state_store_svc.do_command(command=my_command)

For more information, see the Python SDK Docs.

Parameters:

  • command (Struct) (required): The command to execute.
  • callOptions (CallOptions) (optional)

Returns:

Example:

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

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

For more information, see the TypeScript SDK Docs.

GetResourceName

Get the ResourceName for this Resource with the given name.

Parameters:

  • name (str) (required): The name of the Resource.

Returns:

Example:

my_world_state_store_svc_name = WorldStateStoreClient.get_resource_name("my_world_state_store_svc")

For more information, see the Python SDK Docs.

Parameters:

  • None.

Returns:

  • (string): The name of the resource.

Example:

world_state_store.name

For more information, see the TypeScript SDK Docs.

Close

Safely shut down the resource and prevent further use.

Parameters:

  • None.

Returns:

  • None.

Example:

my_world_state_store_svc = World_State_StoreClient.from_robot(robot=machine, name="my_world_state_store_svc")
await my_world_state_store_svc.close()

For more information, see the Python SDK Docs.