Viam SDK
    Preparing search index...

    Interface Gripper

    Represents a physical robotic gripper.

    interface Gripper {
        getCurrentInputs: (extra?: Struct) => Promise<number[]>;
        getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>;
        goToInputs: (values: number[], extra?: Struct) => Promise<void>;
        grab: (extra?: Struct) => Promise<void>;
        isHoldingSomething: (extra?: Struct) => Promise<boolean>;
        isMoving: () => Promise<boolean>;
        name: string;
        open: (extra?: Struct) => Promise<void>;
        stop: (extra?: Struct) => Promise<void>;
        doCommand(command: Struct | Record<string, JsonValue>): Promise<JsonValue>;
        getStatus(): Promise<JsonValue>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    getCurrentInputs: (extra?: Struct) => Promise<number[]>

    Get the current input values of the gripper.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Get the current inputs of the gripper
    const inputs = await gripper.getCurrentInputs();
    console.log('Current inputs:', inputs);
    getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>

    Get the geometries of the component in their current configuration.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Get the geometries of this component
    const geometries = await gripper.getGeometries();
    console.log('Geometries:', geometries);

    For more information, see Gripper API.

    goToInputs: (values: number[], extra?: Struct) => Promise<void>

    Move the gripper to the given input values.

    Type Declaration

      • (values: number[], extra?: Struct): Promise<void>
      • Parameters

        • values: number[]

          The input values to move the gripper to.

        • Optionalextra: Struct

        Returns Promise<void>

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Move the gripper to specific input values
    await gripper.goToInputs([0.5]);
    grab: (extra?: Struct) => Promise<void>

    Request a gripper of the underlying robot to grab.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Close the gripper to grab
    await gripper.grab();

    For more information, see Gripper API.

    isHoldingSomething: (extra?: Struct) => Promise<boolean>

    Get information about whether the gripper is currently holding onto an object.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Check if the gripper is holding something
    const holding = await gripper.isHoldingSomething();
    console.log('Gripper is holding something:', holding);

    For more information, see Gripper API.

    isMoving: () => Promise<boolean>

    Report if the gripper is in motion.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Check if the gripper is currently moving
    const moving = await gripper.isMoving();
    console.log('Gripper is moving:', moving);

    For more information, see Gripper API.

    name: string

    The name of the resource.

    open: (extra?: Struct) => Promise<void>

    Open a gripper of the underlying robot.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Open the gripper
    await gripper.open();

    For more information, see Gripper API.

    stop: (extra?: Struct) => Promise<void>

    Stop a robot's gripper.

    const gripper = new VIAM.GripperClient(machine, 'my_gripper');

    // Stop the gripper's current motion
    await gripper.stop();

    For more information, see Gripper API.

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