UNPKG

@wandelbots/nova-js

Version:

Official JS client for the Wandelbots API

349 lines (348 loc) 14 kB
import { r as MockNovaInstance, t as AutoReconnectingWebsocket } from "./AutoReconnectingWebsocket-dHe-kceU.mjs"; import { AxiosInstance } from "axios"; import * as THREE from "three"; import * as _wandelbots_nova_api_v10 from "@wandelbots/nova-api/v1"; import { ApplicationApi, CellApi, Configuration, ControllerApi, ControllerIOsApi, ControllerInstance, CoordinateSystemsApi, DeviceConfigurationApi, Joints, LibraryProgramApi, LibraryProgramMetadataApi, LibraryRecipeApi, LibraryRecipeMetadataApi, MotionApi, MotionGroupApi, MotionGroupInfosApi, MotionGroupJoggingApi, MotionGroupKinematicApi, MotionGroupPhysical, MotionGroupSpecification, MotionGroupStateResponse, Mounting, Pose, ProgramApi, ProgramValuesApi, RobotControllerState, RobotTcp, SafetySetup, StoreCollisionComponentsApi, StoreCollisionScenesApi, StoreObjectApi, SystemApi, TcpPose, VirtualRobotApi, VirtualRobotBehaviorApi, VirtualRobotModeApi, VirtualRobotSetupApi } from "@wandelbots/nova-api/v1"; //#region src/lib/v1/wandelscriptUtils.d.ts /** * Convert a Pose object representing a motion group position * into a string which represents that pose in Wandelscript. */ declare function poseToWandelscriptString(pose: Pick<Pose, "position" | "orientation">): string; //#endregion //#region src/lib/v1/ConnectedMotionGroup.d.ts type MotionGroupOption = { selectionId: string; } & MotionGroupPhysical; /** * Store representing the current state of a connected motion group. */ declare class ConnectedMotionGroup { readonly nova: NovaClient; readonly controller: ControllerInstance; readonly motionGroup: MotionGroupPhysical; readonly initialMotionState: MotionGroupStateResponse; readonly motionStateSocket: AutoReconnectingWebsocket; readonly isVirtual: boolean; readonly tcps: RobotTcp[]; readonly motionGroupSpecification: MotionGroupSpecification; readonly safetySetup: SafetySetup; readonly mounting: Mounting | null; readonly initialControllerState: RobotControllerState; readonly controllerStateSocket: AutoReconnectingWebsocket; static connect(nova: NovaClient, motionGroupId: string, controllers: ControllerInstance[]): Promise<ConnectedMotionGroup>; connectedJoggingCartesianSocket: WebSocket | null; connectedJoggingJointsSocket: WebSocket | null; planData: any | null; joggingVelocity: number; rapidlyChangingMotionState: MotionGroupStateResponse; controllerState: RobotControllerState; /** * Reflects activation state of the motion group / robot servos. The * movement controls in the UI should only be enabled in the "active" state */ activationState: "inactive" | "activating" | "deactivating" | "active"; constructor(nova: NovaClient, controller: ControllerInstance, motionGroup: MotionGroupPhysical, initialMotionState: MotionGroupStateResponse, motionStateSocket: AutoReconnectingWebsocket, isVirtual: boolean, tcps: RobotTcp[], motionGroupSpecification: MotionGroupSpecification, safetySetup: SafetySetup, mounting: Mounting | null, initialControllerState: RobotControllerState, controllerStateSocket: AutoReconnectingWebsocket); get motionGroupId(): string; get controllerId(): string; get modelFromController(): string | undefined; get wandelscriptIdentifier(): string; /** Jogging velocity in radians for rotation and joint movement */ get joggingVelocityRads(): number; get joints(): { index: number; }[]; get dhParameters(): _wandelbots_nova_api_v10.DHParameter[] | undefined; get safetyZones(): _wandelbots_nova_api_v10.SafetySetupSafetyZone[] | undefined; /** Gets the robot mounting position offset in 3D viz coordinates */ get mountingPosition(): [number, number, number]; /** Gets the robot mounting position rotation in 3D viz coordinates */ get mountingQuaternion(): THREE.Quaternion; /** * Whether the controller is currently in a safety state * corresponding to an emergency stop */ get isEstopActive(): boolean; /** * Whether the controller is in a safety state * that may be non-functional for robot pad purposes */ get isMoveableSafetyState(): boolean; /** * Whether the controller is in an operation mode that allows movement */ get isMoveableOperationMode(): boolean; /** * Whether the robot is currently active and can be moved, based on the * safety state, operation mode and servo toggle activation state. */ get canBeMoved(): boolean; deactivate(): Promise<void>; activate(): Promise<void>; toggleActivation(): void; dispose(): void; setJoggingVelocity(velocity: number): void; } //#endregion //#region src/lib/v1/MotionStreamConnection.d.ts /** * Store representing the current state of a connected motion group. */ declare class MotionStreamConnection { readonly nova: NovaClient; readonly controller: ControllerInstance; readonly motionGroup: MotionGroupPhysical; readonly initialMotionState: MotionGroupStateResponse; readonly motionStateSocket: AutoReconnectingWebsocket; static open(nova: NovaClient, motionGroupId: string): Promise<MotionStreamConnection>; rapidlyChangingMotionState: MotionGroupStateResponse; constructor(nova: NovaClient, controller: ControllerInstance, motionGroup: MotionGroupPhysical, initialMotionState: MotionGroupStateResponse, motionStateSocket: AutoReconnectingWebsocket); get motionGroupId(): string; get controllerId(): string; get modelFromController(): string | undefined; get wandelscriptIdentifier(): string; get joints(): { index: number; }[]; dispose(): void; } //#endregion //#region src/lib/v1/JoggerConnection.d.ts type JoggerConnectionOpts = { /** * When an error message is received from the jogging websocket, it * will be passed here. If this handler is not provided, the error will * instead be thrown as an unhandled error. */ onError?: (err: unknown) => void; }; declare class JoggerConnection { readonly motionStream: MotionStreamConnection; readonly opts: JoggerConnectionOpts; cartesianWebsocket: AutoReconnectingWebsocket | null; jointWebsocket: AutoReconnectingWebsocket | null; cartesianJoggingOpts: { tcpId?: string; coordSystemId?: string; }; static open(nova: NovaClient, motionGroupId: string, opts?: JoggerConnectionOpts): Promise<JoggerConnection>; constructor(motionStream: MotionStreamConnection, opts?: JoggerConnectionOpts); get motionGroupId(): string; get nova(): NovaClient; get numJoints(): number; get activeJoggingMode(): "cartesian" | "joint" | "increment"; get activeWebsocket(): AutoReconnectingWebsocket | null; stop(): Promise<void>; dispose(): void; setJoggingMode(mode: "cartesian" | "joint" | "increment", cartesianJoggingOpts?: { tcpId?: string; coordSystemId?: string; }): void; /** * Start rotation of a single robot joint at the specified velocity */ startJointRotation({ joint, direction, velocityRadsPerSec }: { /** Index of the joint to rotate */ joint: number; /** Direction of rotation ("+" or "-") */ direction: "+" | "-"; /** Speed of the rotation in radians per second */ velocityRadsPerSec: number; }): Promise<void>; /** * Start the TCP moving along a specified axis at a given velocity */ startTCPTranslation({ axis, direction, velocityMmPerSec }: { axis: "x" | "y" | "z"; direction: "-" | "+"; velocityMmPerSec: number; }): Promise<void>; /** * Start the TCP rotating around a specified axis at a given velocity */ startTCPRotation({ axis, direction, velocityRadsPerSec }: { axis: "x" | "y" | "z"; direction: "-" | "+"; velocityRadsPerSec: number; }): Promise<void>; /** * Move the robot by a fixed distance in a single cartesian * axis, either rotating or translating relative to the TCP. * Promise resolves only after the motion has completed. */ runIncrementalCartesianMotion({ currentTcpPose, currentJoints, coordSystemId, velocityInRelevantUnits, axis, direction, motion }: { currentTcpPose: TcpPose; currentJoints: Joints; coordSystemId: string; velocityInRelevantUnits: number; axis: "x" | "y" | "z"; direction: "-" | "+"; motion: { type: "rotate"; distanceRads: number; } | { type: "translate"; distanceMm: number; }; }): Promise<void>; /** * Rotate a single robot joint by a fixed number of radians * Promise resolves only after the motion has completed. */ runIncrementalJointRotation({ joint, currentJoints, velocityRadsPerSec, direction, distanceRads }: { joint: number; currentJoints: Joints; velocityRadsPerSec: number; direction: "-" | "+"; distanceRads: number; }): Promise<void>; } //#endregion //#region src/lib/v1/NovaCellAPIClient.d.ts type OmitFirstArg<F> = F extends ((x: any, ...args: infer P) => infer R) ? (...args: P) => R : never; type UnwrapAxiosResponseReturn<T> = T extends ((...a: any) => any) ? (...a: Parameters<T>) => Promise<Awaited<ReturnType<T>> extends { data: infer D; } ? D : never> : never; type WithCellId<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>> }; type WithUnwrappedAxiosResponse<T> = { [P in keyof T]: UnwrapAxiosResponseReturn<T[P]> }; /** * API client providing type-safe access to all the Nova API REST endpoints * associated with a specific cell id. */ declare class NovaCellAPIClient { readonly cellId: string; readonly opts: Configuration & { axiosInstance?: AxiosInstance; mock?: boolean; }; constructor(cellId: string, opts: Configuration & { axiosInstance?: AxiosInstance; mock?: boolean; }); /** * Some TypeScript sorcery which alters the API class methods so you don't * have to pass the cell id to every single one, and de-encapsulates the * response data */ private withCellId; /** * As withCellId, but only does the response unwrapping */ private withUnwrappedResponsesOnly; readonly system: WithUnwrappedAxiosResponse<SystemApi>; readonly cell: WithUnwrappedAxiosResponse<CellApi>; readonly deviceConfig: WithCellId<DeviceConfigurationApi>; readonly motionGroup: WithCellId<MotionGroupApi>; readonly motionGroupInfos: WithCellId<MotionGroupInfosApi>; readonly controller: WithCellId<ControllerApi>; readonly program: WithCellId<ProgramApi>; readonly programValues: WithCellId<ProgramValuesApi>; readonly controllerIOs: WithCellId<ControllerIOsApi>; readonly motionGroupKinematic: WithCellId<MotionGroupKinematicApi>; readonly motion: WithCellId<MotionApi>; readonly coordinateSystems: WithCellId<CoordinateSystemsApi>; readonly application: WithCellId<ApplicationApi>; readonly applicationGlobal: WithUnwrappedAxiosResponse<ApplicationApi>; readonly motionGroupJogging: WithCellId<MotionGroupJoggingApi>; readonly virtualRobot: WithCellId<VirtualRobotApi>; readonly virtualRobotSetup: WithCellId<VirtualRobotSetupApi>; readonly virtualRobotMode: WithCellId<VirtualRobotModeApi>; readonly virtualRobotBehavior: WithCellId<VirtualRobotBehaviorApi>; readonly libraryProgramMetadata: WithCellId<LibraryProgramMetadataApi>; readonly libraryProgram: WithCellId<LibraryProgramApi>; readonly libraryRecipeMetadata: WithCellId<LibraryRecipeMetadataApi>; readonly libraryRecipe: WithCellId<LibraryRecipeApi>; readonly storeObject: WithCellId<StoreObjectApi>; readonly storeCollisionComponents: WithCellId<StoreCollisionComponentsApi>; readonly storeCollisionScenes: WithCellId<StoreCollisionScenesApi>; } //#endregion //#region src/lib/v1/NovaClient.d.ts type NovaClientConfig = { /** * Url of the deployed Nova instance to connect to * e.g. https://saeattii.instance.wandelbots.io */ instanceUrl: string | "https://mock.example.com"; /** * Identifier of the cell on the Nova instance to connect this client to. * If omitted, the default identifier "cell" is used. **/ cellId?: string; /** * Username for basic auth to the Nova instance. * @deprecated use accessToken instead */ username?: string; /** * Password for basic auth to the Nova instance. * @deprecated use accessToken instead */ password?: string; /** * Access token for Bearer authentication. */ accessToken?: string; } & Omit<Configuration, "isJsonMime" | "basePath">; type NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string; }; /** * Client for connecting to a Nova instance and controlling robots. * @deprecated The nova v1 client is deprecated. Please use the v2 client from `@wandelbots/nova-js/v2` instead. */ declare class NovaClient { readonly api: NovaCellAPIClient; readonly config: NovaClientConfigWithDefaults; readonly mock?: MockNovaInstance; authPromise: Promise<string | null> | null; accessToken: string | null; constructor(config: NovaClientConfig); renewAuthentication(): Promise<void>; makeWebsocketURL(path: string): string; /** * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance. * If you explicitly want to reconnect an existing websocket, call `reconnect` * on the returned object. */ openReconnectingWebsocket(path: string): AutoReconnectingWebsocket; /** * Connect to the motion state websocket(s) for a given motion group */ connectMotionStream(motionGroupId: string): Promise<MotionStreamConnection>; /** * Connect to the jogging websocket(s) for a given motion group */ connectJogger(motionGroupId: string): Promise<JoggerConnection>; connectMotionGroups(motionGroupIds: string[]): Promise<ConnectedMotionGroup[]>; connectMotionGroup(motionGroupId: string): Promise<ConnectedMotionGroup>; } //#endregion export { WithUnwrappedAxiosResponse as a, MotionStreamConnection as c, poseToWandelscriptString as d, WithCellId as i, ConnectedMotionGroup as l, NovaClientConfig as n, JoggerConnection as o, NovaCellAPIClient as r, JoggerConnectionOpts as s, NovaClient as t, MotionGroupOption as u }; //# sourceMappingURL=NovaClient-qJnHcx2s.d.mts.map