Viam SDK
    Preparing search index...

    Interface Robot

    interface Robot {
        on: (
            type: "connectionstatechange" | MachineConnectionEvent,
            listener: Callback,
        ) => void;
        blockForOperation(id: string): Promise<void>;
        cancelOperation(id: string): Promise<void>;
        frameSystemConfig(
            transform: PlainMessage<commonApi.Transform>[],
        ): Promise<PlainMessage<FrameSystemConfig>[]>;
        getCloudMetadata(): Promise<PlainMessage<GetCloudMetadataResponse>>;
        getMachineStatus(): Promise<PlainMessage<GetMachineStatusResponse>>;
        getModelsFromModules(): Promise<PlainMessage<ModuleModel>[]>;
        getOperations(): Promise<PlainMessage<Operation>[]>;
        getSessions(): Promise<PlainMessage<Session>[]>;
        resourceNames(): Promise<PlainMessage<commonApi.ResourceName>[]>;
        resourceRPCSubtypes(): Promise<PlainMessage<ResourceRPCSubtype>[]>;
        restartModule(moduleId?: string, moduleName?: string): Promise<void>;
        stopAll(extra?: Map<string, Struct>): Promise<void>;
        transformPCD(
            pointCloudPCD: Uint8Array,
            source: string,
            destination: string,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        transformPose(
            source: PoseInFrame,
            destination: string,
            supplementalTransforms: PlainMessage<commonApi.Transform>[],
            callOptions?: CallOptions,
        ): Promise<PlainMessage<commonApi.PoseInFrame>>;
    }

    Implemented by

    Index

    Modules

    • Alpha

      Restarts a module running on the machine with the given id or name.

      Parameters

      • OptionalmoduleId: string

        The id matching the module_id field of the registry module in your part configuration

      • OptionalmoduleName: string

        The name matching the name field of the local/registry module in your part configuration

      Returns Promise<void>

      await machine.restartModule('namespace:module:model', 'my_model_name');
      

    Properties

    on: (
        type: "connectionstatechange" | MachineConnectionEvent,
        listener: Callback,
    ) => void

    Call a function when a connection event occurs.

    Note that direct gRPC connections that disconnect will not emit a disconnect event. WebRTC connections that disconnect will emit a disconnect event. All connections emit events during manual calls of connect and disconnect.

    Type Declaration

      • (
            type: "connectionstatechange" | MachineConnectionEvent,
            listener: Callback,
        ): void
      • Parameters

        • type: "connectionstatechange" | MachineConnectionEvent

          The event MachineConnectionEvent that was triggered, or all connection events with 'connectionstatechange'.

        • listener: Callback

          The function to call

        Returns void

    Methods

    App/Cloud

    Frame System

    • Alpha

      Transform a given source point cloud from the reference frame to a new specified destination which is a reference frame.

      Parameters

      • pointCloudPCD: Uint8Array

        The point clouds to transform. This should be in the PCD format encoded into bytes

      • source: string

        The reference frame of the point cloud.

      • destination: string

        The reference frame into which the source data should be transformed, if unset this defaults to the "world" reference frame. Do not move the robot between the generation of the initial pointcloud and the receipt of the transformed pointcloud because that will make the transformations inaccurate.

      Returns Promise<Uint8Array<ArrayBufferLike>>

    Operations

    • Alpha

      Blocks on the specified operation on the machine. This function will only return when the specific operation has finished or has been cancelled.

      Parameters

      • id: string

        ID of operation to block on.

      Returns Promise<void>

      await machine.blockForOperation('INSERT OPERATION ID');
      
    • Alpha

      Cancels the specified operation on the machine.

      Parameters

      • id: string

        ID of operation to kill.

      Returns Promise<void>

      await machine.cancelOperation('INSERT OPERATION ID');
      
    • Alpha

      Get the list of operations currently running on the machine.

      Returns Promise<PlainMessage<Operation>[]>

      const operations = await machine.getOperations();
      
    • Alpha

      Cancel all current and outstanding operations for the robot and stop all actuators and movement.

      Parameters

      • Optionalextra: Map<string, Struct>

        Any extra parameters to pass to the components' stop methods, keyed on the component's resource name.

      Returns Promise<void>

      await machine.stopAll();
      

    Resources

    • Alpha

      Get the list of models provided by modules on the machine.

      Returns Promise<PlainMessage<ModuleModel>[]>

      const models = await machine.getModelsFromModules();
      

    Sessions

    • Alpha

      Get the list of sessions currently connected to the machine.

      Returns Promise<PlainMessage<Session>[]>

      const sessions = await machine.getSessions();