Viam SDK
    Preparing search index...

    Interface Arm

    Represents a physical robot arm that exists in three-dimensional space.

    interface Arm {
        get3DModels: (extra?: Struct) => Promise<Record<string, Mesh>>;
        getEndPosition: (extra?: Struct) => Promise<PlainMessage<commonApi.Pose>>;
        getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>;
        getJointPositions: (
            extra?: Struct,
        ) => Promise<PlainMessage<JointPositions>>;
        getKinematics: (extra?: Struct) => Promise<GetKinematicsResult>;
        isMoving: () => Promise<boolean>;
        moveToJointPositions: (
            jointPositionsList: number[],
            extra?: Struct,
        ) => Promise<void>;
        moveToPosition: (pose: Pose, extra?: Struct) => Promise<void>;
        name: string;
        stop: (extra?: Struct) => Promise<void>;
        doCommand(command: Struct | Record<string, JsonValue>): Promise<JsonValue>;
        getStatus(): Promise<JsonValue>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    get3DModels: (extra?: Struct) => Promise<Record<string, Mesh>>

    Get the 3D models of the component

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const models = await arm.get3DModels();
    console.log(models);
    getEndPosition: (extra?: Struct) => Promise<PlainMessage<commonApi.Pose>>

    Get the position of the end of the arm expressed as a pose

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const pose = await arm.getEndPosition();

    For more information, see Arm API.

    getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>

    Get the geometries of the component in their current configuration

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const geometries = await arm.getGeometries();
    console.log(geometries);

    For more information, see Arm API.

    getJointPositions: (extra?: Struct) => Promise<PlainMessage<JointPositions>>

    Gets the current position of each joint.

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const jointPositions = await arm.getJointPositions();

    For more information, see Arm API.

    getKinematics: (extra?: Struct) => Promise<GetKinematicsResult>

    Get the kinematics information associated with the arm.

    Type Declaration

      • (extra?: Struct): Promise<GetKinematicsResult>
      • Parameters

        Returns Promise<GetKinematicsResult>

        The legacy kinematics data shape or the newer object containing kinematics data plus a map of URDF mesh file paths to mesh data.

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const kinematics = await arm.getKinematics();
    console.log(kinematics);

    For more information, see [Arm
    API](https://docs.viam.com/dev/reference/apis/components/arm/#getkinematics).
    isMoving: () => Promise<boolean>

    Get if the arm is currently moving.

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    const isMoving = await arm.isMoving();
    console.log(isMoving);

    For more information, see Arm API.

    moveToJointPositions: (
        jointPositionsList: number[],
        extra?: Struct,
    ) => Promise<void>

    Move each joint of the arm based on the angles on the joint positions.

    Type Declaration

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

        • jointPositionsList: number[]

          List of angles (0-360) to move each joint to.

        • Optionalextra: Struct

        Returns Promise<void>

    const arm = new VIAM.ArmClient(machine, 'my_arm');

    // Move an arm with 6 joints (6 DoF)
    await arm.moveToJointPositions([90, 0, 0, 0, 15, 0]);

    For more information, see Arm API.

    moveToPosition: (pose: Pose, extra?: Struct) => Promise<void>

    Move the end of the arm to the pose.

    Type Declaration

      • (pose: Pose, extra?: Struct): Promise<void>
      • Parameters

        • pose: Pose

          The destination pose for the arm.

        • Optionalextra: Struct

        Returns Promise<void>

    const arm = new VIAM.ArmClient(machine, 'my_arm');

    // Create a pose for the arm to move to
    const pose: Pose = {
    x: -500,
    y: -200,
    z: 62,
    oX: 1,
    oY: 0,
    oZ: 1,
    theta: 90,
    };

    // Move the arm to the pose
    await arm.moveToPosition(pose);

    For more information, see Arm API.

    name: string

    The name of the resource.

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

    Stop the motion of the arm.

    const arm = new VIAM.ArmClient(machine, 'my_arm');
    await arm.stop();

    For more information, see Arm 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' } }));