Interface Base

Represents a physical base of a robot.

interface Base {
    getGeometries: (extra?: Struct) => Promise<commonApi.Geometry[]>;
    name: string;
    doCommand(command: Struct): Promise<JsonValue>;
    getProperties(extra?: Struct): Promise<baseApi.GetPropertiesResponse>;
    isMoving(): Promise<boolean>;
    moveStraight(
        distanceMm: number,
        mmPerSec: number,
        extra?: Struct,
    ): Promise<void>;
    setPower(
        linear: PlainMessage,
        angular: PlainMessage,
        extra?: Struct,
    ): Promise<void>;
    setVelocity(
        linear: PlainMessage,
        angular: PlainMessage,
        extra?: Struct,
    ): Promise<void>;
    spin(angleDeg: number, degsPerSec: number, extra?: Struct): Promise<void>;
    stop(extra?: Struct): Promise<void>;
}

Hierarchy (View Summary, Expand)

Implemented by

Properties

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

Get the geometries of the component in their current configuration

const base = new VIAM.BaseClient(machine, 'my_base');
const geometries = await base.getGeometries();

For more information, see Base API.

name: string

The name of the resource.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    Returns Promise<JsonValue>

    const result = await resource.doCommand({
    name: 'myCommand',
    args: { key: 'value' },
    });
  • Return true if the base is in motion.

    Returns Promise<boolean>

    const base = new VIAM.BaseClient(machine, 'my_base');
    const moving = await base.isMoving();

    For more information, see Base API.

  • Move a base in a straight line by a given distance at a given speed. This method blocks until completed or cancelled.

    Parameters

    • distanceMm: number

      Distance to move, in millimeters.

    • mmPerSec: number

      Movement speed, in millimeters per second.

    • Optionalextra: Struct

    Returns Promise<void>

    const base = new VIAM.BaseClient(machine, 'my_base');

    // Move forward 40mm at 90mm/s
    await base.moveStraight(40, 90);

    // Move backward 40mm at -90mm/s (backwards)
    await base.moveStraight(40, -90);

    For more information, see Base API.

  • Set the linear and angular power of a base from -1 to 1 in terms of power for each direction.

    Parameters

    • linear: PlainMessage

      Desired linear power percentage from -1 to 1.

    • angular: PlainMessage

      Desired angular power percentage from -1 to 1.

    • Optionalextra: Struct

    Returns Promise<void>

    const base = new VIAM.BaseClient(machine, 'my_base');

    // Move forward at 75% power
    await base.setPower(
    { x: 0, y: 0.75, z: 0 }, // linear power
    { x: 0, y: 0, z: 0 } // no rotation
    );

    // Move straight back at 100% power
    await base.setPower(
    { x: 0, y: -1, z: 0 }, // linear power
    { x: 0, y: 0, z: 0 } // no rotation
    );

    // Turn counter-clockwise at 50% power
    await base.setPower(
    { x: 0, y: 0, z: 0 }, // no linear movement
    { x: 0, y: 0, z: 0.5 } // rotate around z-axis
    );

    // Turn clockwise at 60% power
    await base.setPower(
    { x: 0, y: 0, z: 0 }, // no linear movement
    { x: 0, y: 0, z: -0.6 } // rotate around z-axis
    );

    For more information, see Base API.

  • Set the linear and angular velocity of a base.

    Parameters

    • linear: PlainMessage

      Desired linear velocity in millimeters per second.

    • angular: PlainMessage

      Desired angular velocity in degrees per second.

    • Optionalextra: Struct

    Returns Promise<void>

    const base = new VIAM.BaseClient(machine, 'my_base');

    // Move forward at 50mm/s while spinning 15 degrees per second to the left
    await base.setVelocity(
    { x: 0, y: 50, z: 0 }, // linear velocity in mm/s
    { x: 0, y: 0, z: 15 } // 15 degrees per second counter-clockwise
    );

    For more information, see Base API.

  • Spin a base by a given angle at a given angular speed. This method blocks until completed or cancelled.

    Parameters

    • angleDeg: number

      Degrees to spin.

    • degsPerSec: number

      Angular speed, in degrees per second.

    • Optionalextra: Struct

    Returns Promise<void>

    const base = new VIAM.BaseClient(machine, 'my_base');

    // Spin 10 degrees clockwise at 15 degrees per second
    await base.spin(10, 15);

    // Spin 180 degrees counter-clockwise at 20 degrees per second
    await base.spin(-180, 20);

    For more information, see Base API.

  • Stop a base

    Parameters

    Returns Promise<void>

    const base = new VIAM.BaseClient(machine, 'my_base');
    await base.stop();

    For more information, see Base API.

MMNEPVFCICPMFPCPTTAAATR