@wandelbots/nova-js 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/v1/NovaClient.d.ts.map +1 -1
- package/dist/lib/v1/index.cjs +3 -1
- package/dist/lib/v1/index.cjs.map +1 -1
- package/dist/lib/v1/index.js +3 -1
- package/dist/lib/v1/index.js.map +1 -1
- package/dist/lib/v2/NovaClient.d.ts.map +1 -1
- package/dist/lib/v2/index.cjs +3 -1
- package/dist/lib/v2/index.cjs.map +1 -1
- package/dist/lib/v2/index.js +3 -1
- package/dist/lib/v2/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/v1/NovaClient.ts +9 -3
- package/src/lib/v2/NovaClient.ts +9 -3
package/dist/lib/v2/index.js
CHANGED
|
@@ -1610,7 +1610,9 @@ var NovaClient = class {
|
|
|
1610
1610
|
}
|
|
1611
1611
|
const axiosInstance = axios2.create({
|
|
1612
1612
|
baseURL: urlJoin(this.config.instanceUrl, "/api/v2"),
|
|
1613
|
-
headers
|
|
1613
|
+
// TODO - backend needs to set proper CORS headers for this
|
|
1614
|
+
headers: typeof window !== "undefined" && window.location.origin.includes("localhost") ? {} : {
|
|
1615
|
+
// Identify the client to the backend for logging purposes
|
|
1614
1616
|
"X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK"
|
|
1615
1617
|
}
|
|
1616
1618
|
});
|
package/dist/lib/v2/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/v2/index.ts","../../../src/lib/v2/ConnectedMotionGroup.ts","../../../src/lib/v2/motionStateUpdate.ts","../../../src/lib/v2/vectorUtils.ts","../../../src/lib/v2/JoggerConnection.ts","../../../src/lib/v2/MotionStreamConnection.ts","../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/ProgramStateConnection.ts"],"sourcesContent":["export * from \"@wandelbots/nova-api/v2\"\nexport * from \"./ConnectedMotionGroup\"\nexport * from \"./JoggerConnection\"\nexport * from \"./MotionStreamConnection\"\nexport * from \"./NovaCellAPIClient\"\nexport * from \"./NovaClient\"\nexport * from \"./ProgramStateConnection\"\n","import type {\n Controller,\n MotionGroupPhysical,\n MotionGroupSpecification,\n MotionGroupState,\n RobotTcp,\n SafetySetup,\n} from \"@wandelbots/nova-api/v2\"\nimport { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport { jointValuesEqual, tcpPoseEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nexport type MotionGroupOption = {\n selectionId: string\n} & MotionGroupPhysical\n\n/**\n * Store representing the current state of a connected motion group.\n */\nexport class ConnectedMotionGroup {\n static async connect(\n nova: NovaClient,\n motionGroupId: string,\n controllers: Controller[],\n ) {\n const [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n const controller = controllers.find((c) => c.controller === controllerId)\n const motionGroup = controller?.motion_groups.find(\n (mg) => mg.motion_group === motionGroupId,\n )\n if (!controller || !motionGroup) {\n throw new Error(\n `Controller ${controllerId} or motion group ${motionGroupId} not found`,\n )\n }\n\n const motionStateSocket = nova.openReconnectingWebsocket(\n `/motion-groups/${motionGroupId}/state-stream`,\n )\n\n // Wait for the first message to get the initial state\n const firstMessage = await motionStateSocket.firstMessage()\n const initialMotionState = tryParseJson(firstMessage.data)\n ?.result as MotionGroupState\n\n if (!initialMotionState) {\n throw new Error(\n `Unable to parse initial motion state message ${firstMessage.data}`,\n )\n }\n\n console.log(\n `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\\n `,\n initialMotionState,\n )\n\n // This is used to determine if the robot is virtual or physical\n let isVirtual = false\n try {\n const opMode =\n await nova.api.virtualRobotMode.getOperationMode(controllerId)\n\n if (opMode) isVirtual = true\n } catch (err) {\n if (err instanceof AxiosError) {\n console.log(\n `Received ${err.status} from getOperationMode, concluding that ${controllerId} is physical`,\n )\n } else {\n throw err\n }\n }\n\n // Find out what TCPs this motion group has (we need it for jogging)\n const { tcps } = await nova.api.motionGroupInfos.listTcps(motionGroupId)\n\n const motionGroupSpecification =\n await nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId)\n\n const safetySetup =\n await nova.api.motionGroupInfos.getSafetySetup(motionGroupId)\n\n return new ConnectedMotionGroup(\n nova,\n controller,\n motionGroup,\n initialMotionState,\n motionStateSocket,\n isVirtual,\n tcps!,\n motionGroupSpecification,\n safetySetup,\n )\n }\n\n connectedJoggingCartesianSocket: WebSocket | null = null\n connectedJoggingJointsSocket: WebSocket | null = null\n planData: any | null // tmp\n joggingVelocity: number = 10\n\n // Not mobx-observable as this changes very fast; should be observed\n // using animation frames\n rapidlyChangingMotionState: MotionGroupState\n\n constructor(\n readonly nova: NovaClient,\n readonly controller: Controller,\n readonly motionGroup: MotionGroupPhysical,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n readonly isVirtual: boolean,\n readonly tcps: RobotTcp[],\n readonly motionGroupSpecification: MotionGroupSpecification,\n readonly safetySetup: SafetySetup,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const motionStateResponse = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!motionStateResponse) {\n throw new Error(\n `Failed to get motion state for ${this.motionGroupId}: ${event.data}`,\n )\n }\n\n // handle motionState message\n if (\n !jointValuesEqual(\n this.rapidlyChangingMotionState.joint_position.joints,\n motionStateResponse.joint_position.joints,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = motionStateResponse\n })\n }\n\n // handle tcpPose message\n if (\n !tcpPoseEqual(\n this.rapidlyChangingMotionState.tcp_pose,\n motionStateResponse.tcp_pose,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState.tcp_pose =\n motionStateResponse.tcp_pose\n })\n }\n })\n makeAutoObservable(this)\n }\n\n get motionGroupId() {\n return this.motionGroup.motion_group\n }\n\n get controllerId() {\n return this.controller.controller\n }\n\n get modelFromController() {\n return this.motionGroup.model_from_controller\n }\n\n get wandelscriptIdentifier() {\n const num = this.motionGroupId.split(\"@\")[0]\n return `${this.controllerId.replaceAll(\"-\", \"_\")}_${num}`\n }\n\n /** Jogging velocity in radians for rotation and joint movement */\n get joggingVelocityRads() {\n return (this.joggingVelocity * Math.PI) / 180\n }\n\n get joints() {\n return this.initialMotionState.joint_position.joints.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n get dhParameters() {\n return this.motionGroupSpecification.dh_parameters\n }\n\n get safetyZones() {\n return this.safetySetup.safety_zones\n }\n\n dispose() {\n this.motionStateSocket.close()\n if (this.connectedJoggingCartesianSocket)\n this.connectedJoggingCartesianSocket.close()\n if (this.connectedJoggingJointsSocket)\n this.connectedJoggingJointsSocket.close()\n }\n\n setJoggingVelocity(velocity: number) {\n this.joggingVelocity = velocity\n }\n}\n","import type { TcpPose } from \"@wandelbots/nova-api/v2\"\n\nexport function jointValuesEqual(\n oldJointValues: number[],\n newJointValues: number[],\n changeDeltaThreshold: number,\n): boolean {\n if (newJointValues.length !== oldJointValues.length) {\n return true\n }\n\n for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) {\n if (\n Math.abs(newJointValues[jointIndex]! - oldJointValues[jointIndex]!) >\n changeDeltaThreshold\n ) {\n return false\n }\n }\n\n return true\n}\n\nexport function tcpPoseEqual(\n oldTcp: TcpPose | undefined,\n newTcp: TcpPose | undefined,\n changeDeltaThreshold: number,\n): boolean {\n // undefined -> defined (+reverse) transition\n if ((oldTcp === undefined && newTcp) || (oldTcp && newTcp === undefined)) {\n return false\n }\n\n // the typechecker cannot resolve states to \"!= undefined\" if \"&&\" is used\n if (oldTcp === undefined || newTcp === undefined) {\n return true\n }\n\n let changedDelta = 0\n changedDelta += Math.abs(oldTcp.orientation[0] - newTcp.orientation[0])\n changedDelta += Math.abs(oldTcp.orientation[1] - newTcp.orientation[1])\n changedDelta += Math.abs(oldTcp.orientation[2] - newTcp.orientation[2])\n changedDelta += Math.abs(oldTcp.position[0] - newTcp.position[0])\n changedDelta += Math.abs(oldTcp.position[1] - newTcp.position[1])\n changedDelta += Math.abs(oldTcp.position[2] - newTcp.position[2])\n\n if (changedDelta > changeDeltaThreshold) {\n return false\n }\n\n return (\n oldTcp.coordinate_system === newTcp.coordinate_system &&\n oldTcp.tcp === newTcp.tcp\n )\n}\n","import * as THREE from \"three\"\n\n// Vector used by api endpoints\nexport type Vector3d = [number, number, number]\n\nexport function axisToIndex(axis: \"x\" | \"y\" | \"z\"): number {\n switch (axis) {\n case \"x\":\n return 0\n case \"y\":\n return 1\n case \"z\":\n return 2\n }\n}\n\nexport function indexToAxis(index: number): \"x\" | \"y\" | \"z\" | null {\n switch (index) {\n case 0:\n return \"x\"\n case 1:\n return \"y\"\n case 2:\n return \"z\"\n default:\n return null\n }\n}\n\nexport function vector3FromArray(vector: Vector3d): THREE.Vector3 {\n return new THREE.Vector3(vector[0], vector[1], vector[2])\n}\n\nexport function vector3ToArray(vector: THREE.Vector3): Vector3d {\n return [vector.x, vector.y, vector.z]\n}\n","import type {\n InitializeJoggingRequest,\n JoggingResponse,\n JointVelocityRequest,\n MotionGroupState,\n TcpVelocityRequest,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { NovaClient } from \"./NovaClient\"\nimport { axisToIndex } from \"./vectorUtils\"\n\nexport type JoggerConnectionOpts = {\n /**\n * When an error message is received from the jogging websocket, it\n * will be passed here. If this handler is not provided, the error will\n * instead be thrown as an unhandled error.\n */\n onError?: (err: unknown) => void\n} & Omit<InitializeJoggingRequest, \"message_type\">\n\nexport class JoggerConnection {\n // Currently a separate websocket is needed for each mode, pester API people\n // to merge these for simplicity\n joggingWebsocket: AutoReconnectingWebsocket | null = null\n lastVelocityRequest: JointVelocityRequest | TcpVelocityRequest | null = null\n lastResponse: JoggingResponse | null = null\n\n static async open(\n nova: NovaClient,\n cell: string,\n motionGroupId: string,\n opts: JoggerConnectionOpts,\n ) {\n const motionGroupState =\n await nova.api.motionGroupInfos.getCurrentMotionGroupState(motionGroupId)\n\n return new JoggerConnection(\n nova,\n cell,\n motionGroupId,\n motionGroupState,\n opts,\n )\n }\n\n constructor(\n readonly nova: NovaClient,\n readonly cell: string,\n readonly motionGroupId: string,\n readonly motionGroupState: MotionGroupState,\n readonly opts: JoggerConnectionOpts,\n ) {\n this.joggingWebsocket = nova.openReconnectingWebsocket(\n `/cells/${cell}/execution/jogging`,\n )\n this.joggingWebsocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data) as JoggingResponse\n if (data && \"error\" in data) {\n if (this.opts.onError) {\n this.opts.onError(ev.data)\n } else {\n throw new Error(ev.data)\n }\n }\n })\n\n this.joggingWebsocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data)\n if (data && \"error\" in data) {\n if (this.opts.onError) {\n this.opts.onError(ev.data)\n } else {\n throw new Error(ev.data)\n }\n }\n })\n }\n\n get jointCount() {\n return this.motionGroupState.joint_current?.joints.length\n }\n\n get activeWebsocket() {\n return this.joggingWebsocket\n }\n\n async stop() {\n // Why not call the stopJogging API endpoint?\n // Because this results in the websocket closing and we\n // would like to keep it open for now.\n if (!this.joggingWebsocket) {\n return\n }\n\n if (this.lastVelocityRequest?.message_type === \"JointVelocityRequest\") {\n this.joggingWebsocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity: {\n joints: Array.from(new Array(this.jointCount).keys()).map(() => 0),\n },\n } as JointVelocityRequest)\n }\n\n if (this.lastVelocityRequest?.message_type === \"TcpVelocityRequest\") {\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n rotation: [0, 0, 0],\n translation: [0, 0, 0],\n } as TcpVelocityRequest)\n }\n }\n\n dispose() {\n if (this.joggingWebsocket) {\n this.joggingWebsocket.dispose()\n }\n }\n\n /**\n * Start rotation of a single robot joint at the specified velocity\n */\n async startJointRotation({\n joint,\n velocityRadsPerSec,\n }: {\n /** Index of the joint to rotate */\n joint: number\n /** Speed of the rotation in radians per second */\n velocityRadsPerSec: number\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Joint jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const jointVelocities = new Array(this.jointCount).fill(0)\n jointVelocities[joint] = velocityRadsPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity: {\n joints: jointVelocities,\n },\n } as JointVelocityRequest)\n }\n\n /**\n * Start the TCP moving along a specified axis at a given velocity\n */\n async startTCPTranslation({\n axis,\n velocityMmPerSec,\n useToolCoordinateSystem,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n velocityMmPerSec: number\n useToolCoordinateSystem: boolean\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const joggingVector = [0, 0, 0]\n joggingVector[axisToIndex(axis)] = velocityMmPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n\n translation: joggingVector,\n rotation: [0, 0, 0],\n use_tool_coordinate_system: useToolCoordinateSystem,\n } as TcpVelocityRequest)\n }\n\n /**\n * Start the TCP rotating around a specified axis at a given velocity\n */\n async startTCPRotation({\n axis,\n velocityRadsPerSec,\n useToolCoordinateSystem,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n velocityRadsPerSec: number\n useToolCoordinateSystem: boolean\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const joggingVector = [0, 0, 0]\n joggingVector[axisToIndex(axis)] = velocityRadsPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n rotation: joggingVector,\n translation: [0, 0, 0],\n use_tool_coordinate_system: useToolCoordinateSystem,\n } as TcpVelocityRequest)\n }\n}\n","import type {\n Controller,\n MotionGroupPhysical,\n MotionGroupState,\n} from \"@wandelbots/nova-api/v2\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport * as THREE from \"three\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport { jointValuesEqual, tcpPoseEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\nimport { Vector3d, vector3ToArray } from \"./vectorUtils\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nfunction unwrapRotationVector(\n newRotationVectorApi: Vector3d,\n currentRotationVectorApi: Vector3d,\n): Vector3d {\n const currentRotationVector = new THREE.Vector3(\n currentRotationVectorApi[0],\n currentRotationVectorApi[1],\n currentRotationVectorApi[2],\n )\n\n const newRotationVector = new THREE.Vector3(\n newRotationVectorApi[0],\n newRotationVectorApi[1],\n newRotationVectorApi[2],\n )\n\n const currentAngle = currentRotationVector.length()\n const currentAxis = currentRotationVector.normalize()\n\n let newAngle = newRotationVector.length()\n let newAxis = newRotationVector.normalize()\n\n // Align rotation axes\n if (newAxis.dot(currentAxis) < 0) {\n newAngle = -newAngle\n newAxis = newAxis.multiplyScalar(-1.0)\n }\n\n // Shift rotation angle close to previous one to extend domain of rotation angles beyond [0, pi]\n // - this simplifies interpolation and prevents abruptly changing signs of the rotation angles\n let angleDifference = newAngle - currentAngle\n angleDifference -=\n 2.0 * Math.PI * Math.floor((angleDifference + Math.PI) / (2.0 * Math.PI))\n\n newAngle = currentAngle + angleDifference\n\n return vector3ToArray(newAxis.multiplyScalar(newAngle))\n}\n\n/**\n * Store representing the current state of a connected motion group.\n */\nexport class MotionStreamConnection {\n static async open(nova: NovaClient, motionGroupId: string) {\n const { controllers: controllers } =\n await nova.api.controller.listControllers()\n\n const [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n const controller = controllers.find((c) => c.controller === controllerId)\n const motionGroup = controller?.motion_groups.find(\n (mg) => mg.motion_group === motionGroupId,\n )\n if (!controller || !motionGroup) {\n throw new Error(\n `Controller ${controllerId} or motion group ${motionGroupId} not found`,\n )\n }\n\n const motionStateSocket = nova.openReconnectingWebsocket(\n `/motion-groups/${motionGroupId}/state-stream`,\n )\n\n // Wait for the first message to get the initial state\n const firstMessage = await motionStateSocket.firstMessage()\n console.log(\"got first message\", firstMessage)\n const initialMotionState = tryParseJson(firstMessage.data)\n ?.result as MotionGroupState\n\n if (!initialMotionState) {\n throw new Error(\n `Unable to parse initial motion state message ${firstMessage.data}`,\n )\n }\n\n console.log(\n `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\\n `,\n initialMotionState,\n )\n\n return new MotionStreamConnection(\n nova,\n controller,\n motionGroup,\n initialMotionState,\n motionStateSocket,\n )\n }\n\n // Not mobx-observable as this changes very fast; should be observed\n // using animation frames\n rapidlyChangingMotionState: MotionGroupState\n\n constructor(\n readonly nova: NovaClient,\n readonly controller: Controller,\n readonly motionGroup: MotionGroupPhysical,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const motionState = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!motionState) {\n throw new Error(\n `Failed to get motion state for ${this.motionGroupId}: ${event.data}`,\n )\n }\n\n // handle motionState message\n if (\n !jointValuesEqual(\n this.rapidlyChangingMotionState.joint_position.joints,\n motionState.joint_position.joints,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = motionState\n })\n }\n\n // handle tcpPose message\n if (\n !tcpPoseEqual(\n this.rapidlyChangingMotionState.tcp_pose,\n motionState.tcp_pose,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n if (this.rapidlyChangingMotionState.tcp_pose == undefined) {\n this.rapidlyChangingMotionState.tcp_pose = motionState.tcp_pose\n } else {\n this.rapidlyChangingMotionState.tcp_pose = {\n position: motionState.tcp_pose!.position,\n orientation: unwrapRotationVector(\n motionState.tcp_pose!.orientation as Vector3d,\n this.rapidlyChangingMotionState.tcp_pose!\n .orientation as Vector3d,\n ),\n tcp: motionState.tcp_pose!.tcp,\n coordinate_system: motionState.tcp_pose!.coordinate_system,\n }\n }\n })\n }\n })\n makeAutoObservable(this)\n }\n\n get motionGroupId() {\n return this.motionGroup.motion_group\n }\n\n get controllerId() {\n return this.controller.controller\n }\n\n get modelFromController() {\n return this.motionGroup.model_from_controller\n }\n\n get wandelscriptIdentifier() {\n const num = this.motionGroupId.split(\"@\")[0]\n return `${this.controllerId.replaceAll(\"-\", \"_\")}_${num}`\n }\n\n get joints() {\n return this.initialMotionState.joint_position.joints.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n dispose() {\n this.motionStateSocket.close()\n }\n}\n","import type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n CoordinateSystemsApi,\n JoggingApi,\n MotionGroupApi,\n MotionGroupInfoApi,\n MotionGroupKinematicsApi,\n ProgramApi,\n ProgramOperatorApi,\n StoreCollisionComponentsApi,\n StoreCollisionScenesApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualRobotApi,\n VirtualRobotBehaviorApi,\n VirtualRobotModeApi,\n VirtualRobotSetupApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { BaseAPI } from \"@wandelbots/nova-api/v2/base\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupInfos = this.withCellId(MotionGroupInfoApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly program = this.withCellId(ProgramApi)\n readonly programOperator = this.withCellId(ProgramOperatorApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly motionGroupKinematic = this.withCellId(MotionGroupKinematicsApi)\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n\n readonly coordinateSystems = this.withCellId(CoordinateSystemsApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly virtualRobot = this.withCellId(VirtualRobotApi)\n readonly virtualRobotSetup = this.withCellId(VirtualRobotSetupApi)\n readonly virtualRobotMode = this.withCellId(VirtualRobotModeApi)\n readonly virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi)\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionScenes = this.withCellId(StoreCollisionScenesApi)\n}\n","import type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { ConnectedMotionGroup } from \"./ConnectedMotionGroup\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\n/**\n * EXPERIMENTAL\n *\n * This client provides a starting point to migrate NOVA api v2.\n * As v2 is still in development, this client has to be considered unstable\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n console.warn(\"Using experimental NOVA v2 client\")\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n }\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n headers: {\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(config.username + \":\" + config.password)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.config.instanceUrl, \"/api/v1\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n this.authPromise = loginWithAuth0(this.config.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.config.instanceUrl,\n `/api/v1/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n\n /**\n * Connect to the motion state websocket(s) for a given motion group\n */\n async connectMotionStream(motionGroupId: string) {\n return await MotionStreamConnection.open(this, motionGroupId)\n }\n\n async connectMotionGroups(\n motionGroupIds: string[],\n ): Promise<ConnectedMotionGroup[]> {\n const { controllers } = await this.api.controller.listControllers()\n\n return Promise.all(\n motionGroupIds.map((motionGroupId) =>\n ConnectedMotionGroup.connect(this, motionGroupId, controllers),\n ),\n )\n }\n\n async connectMotionGroup(\n motionGroupId: string,\n ): Promise<ConnectedMotionGroup> {\n const motionGroups = await this.connectMotionGroups([motionGroupId])\n return motionGroups[0]!\n }\n}\n","import type {\n ControllersList,\n MotionGroupSpecification,\n MotionGroupState,\n RobotController,\n SafetySetup,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\n\n/**\n * EXPERIMENTAL\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return {\n controllers: [\n {\n controller: \"mock-ur5e\",\n model_name: \"UniversalRobots::Controller\",\n host: \"mock-ur5e\",\n allow_software_install_on_controller: true,\n motion_groups: [\n {\n motion_group: \"0@mock-ur5e\",\n name_from_controller: \"UR5e\",\n active: false,\n model_from_controller: \"UniversalRobots_UR5e\",\n },\n ],\n has_error: false,\n error_details: \"\",\n },\n ],\n } satisfies ControllersList\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/specification\",\n handle() {\n return {\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n theta: 0,\n a: 0,\n d: 162.25,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: -425,\n d: 0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: -392.2,\n d: 0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 1.5707963267948966,\n theta: 0,\n a: 0,\n d: 133.3,\n reverse_rotation_direction: false,\n },\n {\n alpha: -1.5707963267948966,\n theta: 0,\n a: 0,\n d: 99.7,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: 0,\n d: 99.6,\n reverse_rotation_direction: false,\n },\n ],\n mechanical_joint_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n ],\n } satisfies MotionGroupSpecification\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/safety-setup\",\n handle() {\n return {\n safety_settings: [\n {\n safety_state: \"SAFETY_NORMAL\",\n settings: {\n joint_position_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n lower_limit: -2.96705961227417,\n upper_limit: 2.96705961227417,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n lower_limit: -1.7453292608261108,\n upper_limit: 2.7925267219543457,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n lower_limit: -3.3161256313323975,\n upper_limit: 0.40142571926116943,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n lower_limit: -3.4906585216522217,\n upper_limit: 3.4906585216522217,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n lower_limit: -2.4434609413146973,\n upper_limit: 2.4434609413146973,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n lower_limit: -4.71238899230957,\n upper_limit: 4.71238899230957,\n unlimited: false,\n },\n ],\n joint_velocity_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n limit: 3.1415927410125732,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n limit: 3.1415927410125732,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n limit: 3.4906585216522217,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n limit: 6.108652591705322,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n limit: 6.108652591705322,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n limit: 6.981317043304443,\n },\n ],\n joint_acceleration_limits: [],\n joint_torque_limits: [],\n tcp_velocity_limit: 1800,\n },\n },\n ],\n safety_zones: [\n {\n id: 1,\n priority: 0,\n geometry: {\n compound: {\n child_geometries: [\n {\n convex_hull: {\n vertices: [\n { vertex: [-800, -1330, -1820] },\n { vertex: [1650, -1330, -1820] },\n { vertex: [1650, 1330, -1820] },\n { vertex: [-800, 1330, -1820] },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [-800, -1330, -1820],\n },\n {\n vertex: [1650, -1330, -1820],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [-800, -1330, -1820],\n },\n {\n vertex: [-800, 1330, -1820],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, 1330, -1820],\n },\n {\n vertex: [1650, 1330, -1820],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n {\n vertex: [1650, -1330, -1820],\n },\n {\n vertex: [1650, 1330, -1820],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Cell workzone\",\n },\n motion_group_uid: 1,\n },\n {\n id: 2,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, -1850],\n },\n {\n vertex: [865, 1330, -1850],\n },\n {\n vertex: [865, -720, -1850],\n },\n {\n vertex: [1650, -720, -1850],\n },\n {\n vertex: [1650, 1330, -920],\n },\n {\n vertex: [865, 1330, -920],\n },\n {\n vertex: [865, -720, -920],\n },\n {\n vertex: [1650, -720, -920],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Transport\",\n },\n motion_group_uid: 1,\n },\n {\n id: 3,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, -600],\n },\n {\n vertex: [865, 1330, -600],\n },\n {\n vertex: [865, 430, -600],\n },\n {\n vertex: [1650, 430, -600],\n },\n {\n vertex: [1650, 1330, -1250],\n },\n {\n vertex: [865, 1330, -1250],\n },\n {\n vertex: [865, 430, -1250],\n },\n {\n vertex: [1650, 430, -1250],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Tunel\",\n },\n motion_group_uid: 1,\n },\n {\n id: 4,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, -760, -440],\n },\n {\n vertex: [900, -760, -440],\n },\n {\n vertex: [900, -1330, -440],\n },\n {\n vertex: [1650, -1330, -440],\n },\n {\n vertex: [1650, -760, -1800],\n },\n {\n vertex: [900, -760, -1800],\n },\n {\n vertex: [900, -1330, -1800],\n },\n {\n vertex: [1650, -1330, -1800],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Fanuc controller\",\n },\n motion_group_uid: 1,\n },\n {\n id: 6,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [-200, -200, -1900],\n },\n {\n vertex: [200, -200, -1900],\n },\n {\n vertex: [200, 200, -1900],\n },\n {\n vertex: [-200, 200, -1900],\n },\n {\n vertex: [-200, -200, -350],\n },\n {\n vertex: [200, -200, -350],\n },\n {\n vertex: [200, 200, -350],\n },\n {\n vertex: [-200, 200, -350],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Robot base\",\n },\n motion_group_uid: 1,\n },\n ],\n robot_model_geometries: [\n {\n link_index: 1,\n geometry: {\n sphere: {\n radius: 270,\n },\n init_pose: {\n position: [-70, -70, -50],\n orientation: [0, 0, 0, 1],\n },\n id: \"link1_sphere\",\n },\n },\n {\n link_index: 2,\n geometry: {\n capsule: {\n radius: 160,\n cylinder_height: 800,\n },\n init_pose: {\n position: [-450, 40, 170],\n orientation: [\n 0, -0.7071067811865475, 0, 0.7071067811865476,\n ],\n },\n id: \"link2_capsule\",\n },\n },\n {\n link_index: 3,\n geometry: {\n sphere: {\n radius: 270,\n },\n init_pose: {\n position: [-110, 10, -100],\n orientation: [0, 0, 0, 1],\n },\n id: \"link3_sphere\",\n },\n },\n {\n link_index: 4,\n geometry: {\n capsule: {\n radius: 110,\n cylinder_height: 600,\n },\n init_pose: {\n position: [0, 300, 40],\n orientation: [\n -0.7071067811865475, 0, 0, 0.7071067811865476,\n ],\n },\n id: \"link4_capsule\",\n },\n },\n {\n link_index: 5,\n geometry: {\n sphere: {\n radius: 75,\n },\n init_pose: {\n position: [0, 0, -50],\n orientation: [0, 0, 0, 1],\n },\n id: \"link5_sphere\",\n },\n },\n ],\n tool_geometries: [],\n } satisfies SafetySetup\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/coordinate-systems\",\n handle() {\n return {\n coordinatesystems: [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_uid: \"\",\n position: [0, 0, 0],\n rotation: {\n angles: [0, 0, 0],\n type: \"ROTATION_VECTOR\",\n },\n },\n ],\n } //satisfies CoordinateSystems\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/tcps\",\n handle() {\n return {\n tcps: [\n {\n id: \"Flange\",\n readable_name: \"Default-Flange\",\n position: [0, 0, 0],\n rotation: {\n angles: [0, 0, 0, 0],\n type: \"ROTATION_VECTOR\",\n },\n },\n {\n id: \"complex-tcp-position\",\n readable_name: \"Complex TCP Position\",\n position: [-200, 300, 150],\n rotation: {\n angles: [\n -0.12139440409113832, -0.06356210998212003,\n -0.2023240068185639, 0,\n ],\n type: \"ROTATION_VECTOR\",\n },\n },\n ],\n }\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = \"/cells\" + config.url?.split(\"/cells\")[1]?.split(\"?\")[0]\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path || \"\")\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n\n // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\n // }\n }\n\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/move-joint\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n motion_group: \"0@ur\",\n state: {\n controller: \"ur\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n timestamp: \"2024-09-18T12:48:26.096266444Z\",\n velocity_override: 100,\n motion_groups: [\n {\n motion_group: \"0@ur\",\n controller: \"ur\",\n joint_position: {\n joints: [\n 1.3492152690887451, -1.5659207105636597,\n 1.6653711795806885, -1.0991662740707397,\n -1.829018235206604, 1.264623761177063,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [\n 6.437331889439328, -628.4123774830913,\n 577.0569957147832,\n ],\n orientation: {\n x: -1.683333649797158,\n y: -1.9783363827298732,\n z: -0.4928031860165713,\n },\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [\n 6.437331889439328, -628.4123774830913,\n 577.0569957147832,\n ],\n orientation: {\n x: -1.683333649797158,\n y: -1.9783363827298732,\n z: -0.4928031860165713,\n },\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: {\n x: 0,\n y: 0,\n z: 0,\n },\n angular: {\n x: -0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n force: {\n force: {\n x: 0,\n y: 0,\n z: 0,\n },\n moment: {\n x: 0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [\n false,\n false,\n false,\n false,\n false,\n false,\n ],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n sequence_number: \"671259\",\n },\n ],\n sequence_number: \"671259\",\n },\n movement_state: \"MOVEMENT_STATE_MOVING\",\n },\n }),\n }),\n )\n }\n\n if (socket.url.includes(\"/move-tcp\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n motion_group: \"0@ur\",\n state: {\n controller: \"ur\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n timestamp: \"2024-09-18T12:43:12.188335774Z\",\n velocity_override: 100,\n motion_groups: [\n {\n motion_group: \"0@ur\",\n controller: \"ur\",\n joint_position: {\n joints: [\n 1.3352527618408203, -1.5659207105636597,\n 1.6653711795806885, -1.110615611076355,\n -1.829018235206604, 1.264623761177063,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [\n -2.763015284002938, -630.2151479701106,\n 577.524509114342,\n ],\n orientation: {\n x: -1.704794877102097,\n y: -1.9722372952861567,\n z: -0.4852079204210754,\n },\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [\n -2.763015284002938, -630.2151479701106,\n 577.524509114342,\n ],\n orientation: {\n x: -1.704794877102097,\n y: -1.9722372952861567,\n z: -0.4852079204210754,\n },\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: {\n x: 0,\n y: 0,\n z: 0,\n },\n angular: {\n x: -0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n force: {\n force: {\n x: 0,\n y: 0,\n z: 0,\n },\n moment: {\n x: 0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [\n false,\n false,\n false,\n false,\n false,\n false,\n ],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n sequence_number: \"627897\",\n },\n ],\n sequence_number: \"627897\",\n },\n movement_state: \"MOVEMENT_STATE_MOVING\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n joint_position: {\n joints: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: [0, 0, 0],\n angular: [0, 0, 0],\n coordinate_system: \"\",\n },\n force: {\n force: [0, 0, 0],\n moment: [0, 0, 0],\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n } satisfies MotionGroupState,\n}\n","import { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport type { NovaClient } from \"./NovaClient\"\n\nexport type ProgramRunnerLogEntry = {\n timestamp: number\n message: string\n level?: \"warn\" | \"error\"\n}\n\nexport enum ProgramState {\n NotStarted = \"not started\",\n Running = \"running\",\n Stopped = \"stopped\",\n Failed = \"failed\",\n Completed = \"completed\",\n}\n\nexport type CurrentProgram = {\n id?: string\n wandelscript?: string\n state?: ProgramState\n}\n\ntype ProgramStateMessage = {\n type: string\n runner: {\n id: string\n state: ProgramState\n start_time?: number | null\n execution_time?: number | null\n }\n}\n\n/**\n * Interface for running Wandelscript programs on the Nova instance and\n * tracking their progress and output\n */\nexport class ProgramStateConnection {\n currentProgram: CurrentProgram = {}\n logs: ProgramRunnerLogEntry[] = []\n\n executionState = \"idle\" as \"idle\" | \"starting\" | \"executing\" | \"stopping\"\n currentlyExecutingProgramRunnerId = null as string | null\n\n programStateSocket: AutoReconnectingWebsocket\n\n constructor(readonly nova: NovaClient) {\n makeAutoObservable(this, {}, { autoBind: true })\n\n this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`)\n\n this.programStateSocket.addEventListener(\"message\", (ev) => {\n const msg = tryParseJson(ev.data)\n\n if (!msg) {\n console.error(\"Failed to parse program state message\", ev.data)\n return\n }\n if (msg.type === \"update\") {\n this.handleProgramStateMessage(msg)\n }\n })\n }\n\n /** Handle a program state update from the backend */\n async handleProgramStateMessage(msg: ProgramStateMessage) {\n const { runner } = msg\n\n // Ignoring other programs for now\n // TODO - show if execution state is busy from another source\n if (runner.id !== this.currentlyExecutingProgramRunnerId) return\n\n if (runner.state === ProgramState.Failed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n // TODO - wandelengine should send print statements in real time over\n // websocket as well, rather than at the end\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n this.logError(\n `Program runner ${runner.id} failed with error: ${runnerState.error}\\n${runnerState.traceback}`,\n )\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.currentProgram.state = ProgramState.Failed\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Stopped) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n\n this.currentProgram.state = ProgramState.Stopped\n this.log(`Program runner ${runner.id} stopped`)\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Completed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n this.log(\n `Program runner ${runner.id} finished successfully in ${runner.execution_time?.toFixed(2)} seconds`,\n )\n\n this.currentProgram.state = ProgramState.Completed\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Running) {\n this.currentProgram.state = ProgramState.Running\n this.log(`Program runner ${runner.id} now running`)\n } else if (runner.state !== ProgramState.NotStarted) {\n console.error(runner)\n this.logError(\n `Program runner ${runner.id} entered unexpected state: ${runner.state}`,\n )\n this.currentProgram.state = ProgramState.NotStarted\n this.gotoIdleState()\n }\n }\n\n /** Call when a program is no longer executing */\n gotoIdleState() {\n runInAction(() => {\n this.executionState = \"idle\"\n })\n this.currentlyExecutingProgramRunnerId = null\n }\n\n async executeProgram(\n wandelscript: string,\n initial_state?: Object,\n activeRobot?: MotionStreamConnection,\n ) {\n this.currentProgram = {\n wandelscript: wandelscript,\n state: ProgramState.NotStarted,\n }\n\n const { currentProgram: openProgram } = this\n if (!openProgram) return\n runInAction(() => {\n this.executionState = \"starting\"\n })\n\n // WOS-1539: Wandelengine parser currently breaks if there are empty lines with indentation\n const trimmedCode = openProgram.wandelscript!.replaceAll(/^\\s*$/gm, \"\")\n\n try {\n const programRunnerRef = await this.nova.api.program.createProgramRun(\n {\n code: trimmedCode,\n initial_state: initial_state,\n default_robot: activeRobot?.wandelscriptIdentifier,\n } as any,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n )\n\n this.log(`Created program runner ${programRunnerRef.id}\"`)\n runInAction(() => {\n this.executionState = \"executing\"\n })\n this.currentlyExecutingProgramRunnerId = programRunnerRef.id\n } catch (error) {\n if (error instanceof AxiosError && error.response && error.request) {\n this.logError(\n `${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`,\n )\n } else {\n this.logError(JSON.stringify(error))\n }\n runInAction(() => {\n this.executionState = \"idle\"\n })\n }\n }\n\n async stopProgram() {\n if (!this.currentlyExecutingProgramRunnerId) return\n runInAction(() => {\n this.executionState = \"stopping\"\n })\n\n try {\n await this.nova.api.program.stopProgramRun(\n this.currentlyExecutingProgramRunnerId,\n )\n } catch (err) {\n // Reactivate the stop button so user can try again\n runInAction(() => {\n this.executionState = \"executing\"\n })\n throw err\n }\n }\n\n reset() {\n this.currentProgram = {}\n }\n\n log(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n })\n }\n\n logError(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n level: \"error\",\n })\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,cAAc;;;ACQd,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,mBAAmB;;;ACPzC,SAAS,iBACd,gBACA,gBACA,sBACS;AACT,MAAI,eAAe,WAAW,eAAe,QAAQ;AACnD,WAAO;AAAA,EACT;AAEA,WAAS,aAAa,GAAG,aAAa,eAAe,QAAQ,cAAc;AACzE,QACE,KAAK,IAAI,eAAe,UAAU,IAAK,eAAe,UAAU,CAAE,IAClE,sBACA;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,aACd,QACA,QACA,sBACS;AAET,MAAK,WAAW,UAAa,UAAY,UAAU,WAAW,QAAY;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,UAAa,WAAW,QAAW;AAChD,WAAO;AAAA,EACT;AAEA,MAAI,eAAe;AACnB,kBAAgB,KAAK,IAAI,OAAO,YAAY,CAAC,IAAI,OAAO,YAAY,CAAC,CAAC;AACtE,kBAAgB,KAAK,IAAI,OAAO,YAAY,CAAC,IAAI,OAAO,YAAY,CAAC,CAAC;AACtE,kBAAgB,KAAK,IAAI,OAAO,YAAY,CAAC,IAAI,OAAO,YAA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S,MAAM,SAAS,OAAO,GAAG,IAAI,KAAK,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,UAChI;AAAA,QACF,OAAO;AACL,eAAK,SAAS,KAAK,UAAU,KAAK,CAAC;AAAA,QACrC;AACA,QAAAD,aAAY,MAAM;AAChB,eAAK,iBAAiB;AAAA,QACxB,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AAAA,EAEM,cAAc;AAAA;AAClB,UAAI,CAAC,KAAK,kCAAmC;AAC7C,MAAAA,aAAY,MAAM;AAChB,aAAK,iBAAiB;AAAA,MACxB,CAAC;AAED,UAAI;AACF,cAAM,KAAK,KAAK,IAAI,QAAQ;AAAA,UAC1B,KAAK;AAAA,QACP;AAAA,MACF,SAAS,KAAK;AAEZ,QAAAA,aAAY,MAAM;AAChB,eAAK,iBAAiB;AAAA,QACxB,CAAC;AACD,cAAM;AAAA,MACR;AAAA,IACF;AAAA;AAAA,EAEA,QAAQ;AACN,SAAK,iBAAiB,CAAC;AAAA,EACzB;AAAA,EAEA,IAAI,SAAiB;AACnB,YAAQ,IAAI,OAAO;AACnB,SAAK,KAAK,KAAK;AAAA,MACb,WAAW,KAAK,IAAI;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,SAAiB;AACxB,YAAQ,IAAI,OAAO;AACnB,SAAK,KAAK,KAAK;AAAA,MACb,WAAW,KAAK,IAAI;AAAA,MACpB;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":["makeAutoObservable","runInAction","THREE","MOTION_DELTA_THRESHOLD","runInAction","makeAutoObservable","axios","AxiosError","match","AxiosError","axios","_a","config","AxiosError","makeAutoObservable","runInAction","ProgramState","makeAutoObservable","runInAction","AxiosError"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/v2/index.ts","../../../src/lib/v2/ConnectedMotionGroup.ts","../../../src/lib/v2/motionStateUpdate.ts","../../../src/lib/v2/vectorUtils.ts","../../../src/lib/v2/JoggerConnection.ts","../../../src/lib/v2/MotionStreamConnection.ts","../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/ProgramStateConnection.ts"],"sourcesContent":["export * from \"@wandelbots/nova-api/v2\"\nexport * from \"./ConnectedMotionGroup\"\nexport * from \"./JoggerConnection\"\nexport * from \"./MotionStreamConnection\"\nexport * from \"./NovaCellAPIClient\"\nexport * from \"./NovaClient\"\nexport * from \"./ProgramStateConnection\"\n","import type {\n Controller,\n MotionGroupPhysical,\n MotionGroupSpecification,\n MotionGroupState,\n RobotTcp,\n SafetySetup,\n} from \"@wandelbots/nova-api/v2\"\nimport { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport { jointValuesEqual, tcpPoseEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nexport type MotionGroupOption = {\n selectionId: string\n} & MotionGroupPhysical\n\n/**\n * Store representing the current state of a connected motion group.\n */\nexport class ConnectedMotionGroup {\n static async connect(\n nova: NovaClient,\n motionGroupId: string,\n controllers: Controller[],\n ) {\n const [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n const controller = controllers.find((c) => c.controller === controllerId)\n const motionGroup = controller?.motion_groups.find(\n (mg) => mg.motion_group === motionGroupId,\n )\n if (!controller || !motionGroup) {\n throw new Error(\n `Controller ${controllerId} or motion group ${motionGroupId} not found`,\n )\n }\n\n const motionStateSocket = nova.openReconnectingWebsocket(\n `/motion-groups/${motionGroupId}/state-stream`,\n )\n\n // Wait for the first message to get the initial state\n const firstMessage = await motionStateSocket.firstMessage()\n const initialMotionState = tryParseJson(firstMessage.data)\n ?.result as MotionGroupState\n\n if (!initialMotionState) {\n throw new Error(\n `Unable to parse initial motion state message ${firstMessage.data}`,\n )\n }\n\n console.log(\n `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\\n `,\n initialMotionState,\n )\n\n // This is used to determine if the robot is virtual or physical\n let isVirtual = false\n try {\n const opMode =\n await nova.api.virtualRobotMode.getOperationMode(controllerId)\n\n if (opMode) isVirtual = true\n } catch (err) {\n if (err instanceof AxiosError) {\n console.log(\n `Received ${err.status} from getOperationMode, concluding that ${controllerId} is physical`,\n )\n } else {\n throw err\n }\n }\n\n // Find out what TCPs this motion group has (we need it for jogging)\n const { tcps } = await nova.api.motionGroupInfos.listTcps(motionGroupId)\n\n const motionGroupSpecification =\n await nova.api.motionGroupInfos.getMotionGroupSpecification(motionGroupId)\n\n const safetySetup =\n await nova.api.motionGroupInfos.getSafetySetup(motionGroupId)\n\n return new ConnectedMotionGroup(\n nova,\n controller,\n motionGroup,\n initialMotionState,\n motionStateSocket,\n isVirtual,\n tcps!,\n motionGroupSpecification,\n safetySetup,\n )\n }\n\n connectedJoggingCartesianSocket: WebSocket | null = null\n connectedJoggingJointsSocket: WebSocket | null = null\n planData: any | null // tmp\n joggingVelocity: number = 10\n\n // Not mobx-observable as this changes very fast; should be observed\n // using animation frames\n rapidlyChangingMotionState: MotionGroupState\n\n constructor(\n readonly nova: NovaClient,\n readonly controller: Controller,\n readonly motionGroup: MotionGroupPhysical,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n readonly isVirtual: boolean,\n readonly tcps: RobotTcp[],\n readonly motionGroupSpecification: MotionGroupSpecification,\n readonly safetySetup: SafetySetup,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const motionStateResponse = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!motionStateResponse) {\n throw new Error(\n `Failed to get motion state for ${this.motionGroupId}: ${event.data}`,\n )\n }\n\n // handle motionState message\n if (\n !jointValuesEqual(\n this.rapidlyChangingMotionState.joint_position.joints,\n motionStateResponse.joint_position.joints,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = motionStateResponse\n })\n }\n\n // handle tcpPose message\n if (\n !tcpPoseEqual(\n this.rapidlyChangingMotionState.tcp_pose,\n motionStateResponse.tcp_pose,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState.tcp_pose =\n motionStateResponse.tcp_pose\n })\n }\n })\n makeAutoObservable(this)\n }\n\n get motionGroupId() {\n return this.motionGroup.motion_group\n }\n\n get controllerId() {\n return this.controller.controller\n }\n\n get modelFromController() {\n return this.motionGroup.model_from_controller\n }\n\n get wandelscriptIdentifier() {\n const num = this.motionGroupId.split(\"@\")[0]\n return `${this.controllerId.replaceAll(\"-\", \"_\")}_${num}`\n }\n\n /** Jogging velocity in radians for rotation and joint movement */\n get joggingVelocityRads() {\n return (this.joggingVelocity * Math.PI) / 180\n }\n\n get joints() {\n return this.initialMotionState.joint_position.joints.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n get dhParameters() {\n return this.motionGroupSpecification.dh_parameters\n }\n\n get safetyZones() {\n return this.safetySetup.safety_zones\n }\n\n dispose() {\n this.motionStateSocket.close()\n if (this.connectedJoggingCartesianSocket)\n this.connectedJoggingCartesianSocket.close()\n if (this.connectedJoggingJointsSocket)\n this.connectedJoggingJointsSocket.close()\n }\n\n setJoggingVelocity(velocity: number) {\n this.joggingVelocity = velocity\n }\n}\n","import type { TcpPose } from \"@wandelbots/nova-api/v2\"\n\nexport function jointValuesEqual(\n oldJointValues: number[],\n newJointValues: number[],\n changeDeltaThreshold: number,\n): boolean {\n if (newJointValues.length !== oldJointValues.length) {\n return true\n }\n\n for (let jointIndex = 0; jointIndex < newJointValues.length; jointIndex++) {\n if (\n Math.abs(newJointValues[jointIndex]! - oldJointValues[jointIndex]!) >\n changeDeltaThreshold\n ) {\n return false\n }\n }\n\n return true\n}\n\nexport function tcpPoseEqual(\n oldTcp: TcpPose | undefined,\n newTcp: TcpPose | undefined,\n changeDeltaThreshold: number,\n): boolean {\n // undefined -> defined (+reverse) transition\n if ((oldTcp === undefined && newTcp) || (oldTcp && newTcp === undefined)) {\n return false\n }\n\n // the typechecker cannot resolve states to \"!= undefined\" if \"&&\" is used\n if (oldTcp === undefined || newTcp === undefined) {\n return true\n }\n\n let changedDelta = 0\n changedDelta += Math.abs(oldTcp.orientation[0] - newTcp.orientation[0])\n changedDelta += Math.abs(oldTcp.orientation[1] - newTcp.orientation[1])\n changedDelta += Math.abs(oldTcp.orientation[2] - newTcp.orientation[2])\n changedDelta += Math.abs(oldTcp.position[0] - newTcp.position[0])\n changedDelta += Math.abs(oldTcp.position[1] - newTcp.position[1])\n changedDelta += Math.abs(oldTcp.position[2] - newTcp.position[2])\n\n if (changedDelta > changeDeltaThreshold) {\n return false\n }\n\n return (\n oldTcp.coordinate_system === newTcp.coordinate_system &&\n oldTcp.tcp === newTcp.tcp\n )\n}\n","import * as THREE from \"three\"\n\n// Vector used by api endpoints\nexport type Vector3d = [number, number, number]\n\nexport function axisToIndex(axis: \"x\" | \"y\" | \"z\"): number {\n switch (axis) {\n case \"x\":\n return 0\n case \"y\":\n return 1\n case \"z\":\n return 2\n }\n}\n\nexport function indexToAxis(index: number): \"x\" | \"y\" | \"z\" | null {\n switch (index) {\n case 0:\n return \"x\"\n case 1:\n return \"y\"\n case 2:\n return \"z\"\n default:\n return null\n }\n}\n\nexport function vector3FromArray(vector: Vector3d): THREE.Vector3 {\n return new THREE.Vector3(vector[0], vector[1], vector[2])\n}\n\nexport function vector3ToArray(vector: THREE.Vector3): Vector3d {\n return [vector.x, vector.y, vector.z]\n}\n","import type {\n InitializeJoggingRequest,\n JoggingResponse,\n JointVelocityRequest,\n MotionGroupState,\n TcpVelocityRequest,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { NovaClient } from \"./NovaClient\"\nimport { axisToIndex } from \"./vectorUtils\"\n\nexport type JoggerConnectionOpts = {\n /**\n * When an error message is received from the jogging websocket, it\n * will be passed here. If this handler is not provided, the error will\n * instead be thrown as an unhandled error.\n */\n onError?: (err: unknown) => void\n} & Omit<InitializeJoggingRequest, \"message_type\">\n\nexport class JoggerConnection {\n // Currently a separate websocket is needed for each mode, pester API people\n // to merge these for simplicity\n joggingWebsocket: AutoReconnectingWebsocket | null = null\n lastVelocityRequest: JointVelocityRequest | TcpVelocityRequest | null = null\n lastResponse: JoggingResponse | null = null\n\n static async open(\n nova: NovaClient,\n cell: string,\n motionGroupId: string,\n opts: JoggerConnectionOpts,\n ) {\n const motionGroupState =\n await nova.api.motionGroupInfos.getCurrentMotionGroupState(motionGroupId)\n\n return new JoggerConnection(\n nova,\n cell,\n motionGroupId,\n motionGroupState,\n opts,\n )\n }\n\n constructor(\n readonly nova: NovaClient,\n readonly cell: string,\n readonly motionGroupId: string,\n readonly motionGroupState: MotionGroupState,\n readonly opts: JoggerConnectionOpts,\n ) {\n this.joggingWebsocket = nova.openReconnectingWebsocket(\n `/cells/${cell}/execution/jogging`,\n )\n this.joggingWebsocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data) as JoggingResponse\n if (data && \"error\" in data) {\n if (this.opts.onError) {\n this.opts.onError(ev.data)\n } else {\n throw new Error(ev.data)\n }\n }\n })\n\n this.joggingWebsocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data)\n if (data && \"error\" in data) {\n if (this.opts.onError) {\n this.opts.onError(ev.data)\n } else {\n throw new Error(ev.data)\n }\n }\n })\n }\n\n get jointCount() {\n return this.motionGroupState.joint_current?.joints.length\n }\n\n get activeWebsocket() {\n return this.joggingWebsocket\n }\n\n async stop() {\n // Why not call the stopJogging API endpoint?\n // Because this results in the websocket closing and we\n // would like to keep it open for now.\n if (!this.joggingWebsocket) {\n return\n }\n\n if (this.lastVelocityRequest?.message_type === \"JointVelocityRequest\") {\n this.joggingWebsocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity: {\n joints: Array.from(new Array(this.jointCount).keys()).map(() => 0),\n },\n } as JointVelocityRequest)\n }\n\n if (this.lastVelocityRequest?.message_type === \"TcpVelocityRequest\") {\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n rotation: [0, 0, 0],\n translation: [0, 0, 0],\n } as TcpVelocityRequest)\n }\n }\n\n dispose() {\n if (this.joggingWebsocket) {\n this.joggingWebsocket.dispose()\n }\n }\n\n /**\n * Start rotation of a single robot joint at the specified velocity\n */\n async startJointRotation({\n joint,\n velocityRadsPerSec,\n }: {\n /** Index of the joint to rotate */\n joint: number\n /** Speed of the rotation in radians per second */\n velocityRadsPerSec: number\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Joint jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const jointVelocities = new Array(this.jointCount).fill(0)\n jointVelocities[joint] = velocityRadsPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity: {\n joints: jointVelocities,\n },\n } as JointVelocityRequest)\n }\n\n /**\n * Start the TCP moving along a specified axis at a given velocity\n */\n async startTCPTranslation({\n axis,\n velocityMmPerSec,\n useToolCoordinateSystem,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n velocityMmPerSec: number\n useToolCoordinateSystem: boolean\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const joggingVector = [0, 0, 0]\n joggingVector[axisToIndex(axis)] = velocityMmPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n\n translation: joggingVector,\n rotation: [0, 0, 0],\n use_tool_coordinate_system: useToolCoordinateSystem,\n } as TcpVelocityRequest)\n }\n\n /**\n * Start the TCP rotating around a specified axis at a given velocity\n */\n async startTCPRotation({\n axis,\n velocityRadsPerSec,\n useToolCoordinateSystem,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n velocityRadsPerSec: number\n useToolCoordinateSystem: boolean\n }) {\n if (!this.joggingWebsocket) {\n throw new Error(\n \"Cartesian jogging websocket not connected. Wait for reconnect or open new jogging connection\",\n )\n }\n\n const joggingVector = [0, 0, 0]\n joggingVector[axisToIndex(axis)] = velocityRadsPerSec\n\n this.joggingWebsocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n rotation: joggingVector,\n translation: [0, 0, 0],\n use_tool_coordinate_system: useToolCoordinateSystem,\n } as TcpVelocityRequest)\n }\n}\n","import type {\n Controller,\n MotionGroupPhysical,\n MotionGroupState,\n} from \"@wandelbots/nova-api/v2\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport * as THREE from \"three\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport { jointValuesEqual, tcpPoseEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\nimport { Vector3d, vector3ToArray } from \"./vectorUtils\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nfunction unwrapRotationVector(\n newRotationVectorApi: Vector3d,\n currentRotationVectorApi: Vector3d,\n): Vector3d {\n const currentRotationVector = new THREE.Vector3(\n currentRotationVectorApi[0],\n currentRotationVectorApi[1],\n currentRotationVectorApi[2],\n )\n\n const newRotationVector = new THREE.Vector3(\n newRotationVectorApi[0],\n newRotationVectorApi[1],\n newRotationVectorApi[2],\n )\n\n const currentAngle = currentRotationVector.length()\n const currentAxis = currentRotationVector.normalize()\n\n let newAngle = newRotationVector.length()\n let newAxis = newRotationVector.normalize()\n\n // Align rotation axes\n if (newAxis.dot(currentAxis) < 0) {\n newAngle = -newAngle\n newAxis = newAxis.multiplyScalar(-1.0)\n }\n\n // Shift rotation angle close to previous one to extend domain of rotation angles beyond [0, pi]\n // - this simplifies interpolation and prevents abruptly changing signs of the rotation angles\n let angleDifference = newAngle - currentAngle\n angleDifference -=\n 2.0 * Math.PI * Math.floor((angleDifference + Math.PI) / (2.0 * Math.PI))\n\n newAngle = currentAngle + angleDifference\n\n return vector3ToArray(newAxis.multiplyScalar(newAngle))\n}\n\n/**\n * Store representing the current state of a connected motion group.\n */\nexport class MotionStreamConnection {\n static async open(nova: NovaClient, motionGroupId: string) {\n const { controllers: controllers } =\n await nova.api.controller.listControllers()\n\n const [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n const controller = controllers.find((c) => c.controller === controllerId)\n const motionGroup = controller?.motion_groups.find(\n (mg) => mg.motion_group === motionGroupId,\n )\n if (!controller || !motionGroup) {\n throw new Error(\n `Controller ${controllerId} or motion group ${motionGroupId} not found`,\n )\n }\n\n const motionStateSocket = nova.openReconnectingWebsocket(\n `/motion-groups/${motionGroupId}/state-stream`,\n )\n\n // Wait for the first message to get the initial state\n const firstMessage = await motionStateSocket.firstMessage()\n console.log(\"got first message\", firstMessage)\n const initialMotionState = tryParseJson(firstMessage.data)\n ?.result as MotionGroupState\n\n if (!initialMotionState) {\n throw new Error(\n `Unable to parse initial motion state message ${firstMessage.data}`,\n )\n }\n\n console.log(\n `Connected motion state websocket to motion group ${motionGroup.motion_group}. Initial state:\\n `,\n initialMotionState,\n )\n\n return new MotionStreamConnection(\n nova,\n controller,\n motionGroup,\n initialMotionState,\n motionStateSocket,\n )\n }\n\n // Not mobx-observable as this changes very fast; should be observed\n // using animation frames\n rapidlyChangingMotionState: MotionGroupState\n\n constructor(\n readonly nova: NovaClient,\n readonly controller: Controller,\n readonly motionGroup: MotionGroupPhysical,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const motionState = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!motionState) {\n throw new Error(\n `Failed to get motion state for ${this.motionGroupId}: ${event.data}`,\n )\n }\n\n // handle motionState message\n if (\n !jointValuesEqual(\n this.rapidlyChangingMotionState.joint_position.joints,\n motionState.joint_position.joints,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = motionState\n })\n }\n\n // handle tcpPose message\n if (\n !tcpPoseEqual(\n this.rapidlyChangingMotionState.tcp_pose,\n motionState.tcp_pose,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n if (this.rapidlyChangingMotionState.tcp_pose == undefined) {\n this.rapidlyChangingMotionState.tcp_pose = motionState.tcp_pose\n } else {\n this.rapidlyChangingMotionState.tcp_pose = {\n position: motionState.tcp_pose!.position,\n orientation: unwrapRotationVector(\n motionState.tcp_pose!.orientation as Vector3d,\n this.rapidlyChangingMotionState.tcp_pose!\n .orientation as Vector3d,\n ),\n tcp: motionState.tcp_pose!.tcp,\n coordinate_system: motionState.tcp_pose!.coordinate_system,\n }\n }\n })\n }\n })\n makeAutoObservable(this)\n }\n\n get motionGroupId() {\n return this.motionGroup.motion_group\n }\n\n get controllerId() {\n return this.controller.controller\n }\n\n get modelFromController() {\n return this.motionGroup.model_from_controller\n }\n\n get wandelscriptIdentifier() {\n const num = this.motionGroupId.split(\"@\")[0]\n return `${this.controllerId.replaceAll(\"-\", \"_\")}_${num}`\n }\n\n get joints() {\n return this.initialMotionState.joint_position.joints.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n dispose() {\n this.motionStateSocket.close()\n }\n}\n","import type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n CoordinateSystemsApi,\n JoggingApi,\n MotionGroupApi,\n MotionGroupInfoApi,\n MotionGroupKinematicsApi,\n ProgramApi,\n ProgramOperatorApi,\n StoreCollisionComponentsApi,\n StoreCollisionScenesApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualRobotApi,\n VirtualRobotBehaviorApi,\n VirtualRobotModeApi,\n VirtualRobotSetupApi,\n} from \"@wandelbots/nova-api/v2\"\nimport type { BaseAPI } from \"@wandelbots/nova-api/v2/base\"\nimport type { AxiosInstance } from \"axios\"\nimport axios from \"axios\"\n\ntype OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R\n ? (...args: P) => R\n : never\n\ntype UnwrapAxiosResponseReturn<T> = T extends (...a: any) => any\n ? (\n ...a: Parameters<T>\n ) => Promise<Awaited<ReturnType<T>> extends { data: infer D } ? D : never>\n : never\n\nexport type WithCellId<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<OmitFirstArg<T[P]>>\n}\n\nexport type WithUnwrappedAxiosResponse<T> = {\n [P in keyof T]: UnwrapAxiosResponseReturn<T[P]>\n}\n\n/**\n * API client providing type-safe access to all the Nova API REST endpoints\n * associated with a specific cell id.\n */\nexport class NovaCellAPIClient {\n constructor(\n readonly cellId: string,\n readonly opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n },\n ) {}\n\n /**\n * Some TypeScript sorcery which alters the API class methods so you don't\n * have to pass the cell id to every single one, and de-encapsulates the\n * response data\n */\n private withCellId<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, [this.cellId, ...args])\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithCellId<T>\n }\n\n /**\n * As withCellId, but only does the response unwrapping\n */\n private withUnwrappedResponsesOnly<T extends BaseAPI>(\n ApiConstructor: new (\n config: BaseConfiguration,\n basePath: string,\n axios: AxiosInstance,\n ) => T,\n ) {\n const apiClient = new ApiConstructor(\n {\n ...this.opts,\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n },\n this.opts.basePath ?? \"\",\n this.opts.axiosInstance ?? axios.create(),\n ) as {\n [key: string | symbol]: any\n }\n\n for (const key of Reflect.ownKeys(Reflect.getPrototypeOf(apiClient)!)) {\n if (key !== \"constructor\" && typeof apiClient[key] === \"function\") {\n const originalFunction = apiClient[key]\n apiClient[key] = (...args: any[]) => {\n return originalFunction\n .apply(apiClient, args)\n .then((res: any) => res.data)\n }\n }\n }\n\n return apiClient as WithUnwrappedAxiosResponse<T>\n }\n\n readonly system = this.withUnwrappedResponsesOnly(SystemApi)\n readonly cell = this.withUnwrappedResponsesOnly(CellApi)\n\n readonly motionGroup = this.withCellId(MotionGroupApi)\n readonly motionGroupInfos = this.withCellId(MotionGroupInfoApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly program = this.withCellId(ProgramApi)\n readonly programOperator = this.withCellId(ProgramOperatorApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly motionGroupKinematic = this.withCellId(MotionGroupKinematicsApi)\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n\n readonly coordinateSystems = this.withCellId(CoordinateSystemsApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly virtualRobot = this.withCellId(VirtualRobotApi)\n readonly virtualRobotSetup = this.withCellId(VirtualRobotSetupApi)\n readonly virtualRobotMode = this.withCellId(VirtualRobotModeApi)\n readonly virtualRobotBehavior = this.withCellId(VirtualRobotBehaviorApi)\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionScenes = this.withCellId(StoreCollisionScenesApi)\n}\n","import type { Configuration as BaseConfiguration } from \"@wandelbots/nova-api/v2\"\nimport type { AxiosRequestConfig } from \"axios\"\nimport axios, { isAxiosError } from \"axios\"\nimport urlJoin from \"url-join\"\nimport { loginWithAuth0 } from \"../../LoginWithAuth0\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { availableStorage } from \"../availableStorage\"\nimport { ConnectedMotionGroup } from \"./ConnectedMotionGroup\"\nimport { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\n\nexport type NovaClientConfig = {\n /**\n * Url of the deployed Nova instance to connect to\n * e.g. https://saeattii.instance.wandelbots.io\n */\n instanceUrl: string | \"https://mock.example.com\"\n\n /**\n * Identifier of the cell on the Nova instance to connect this client to.\n * If omitted, the default identifier \"cell\" is used.\n **/\n cellId?: string\n\n /**\n * Username for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n username?: string\n\n /**\n * Password for basic auth to the Nova instance.\n * @deprecated use accessToken instead\n */\n password?: string\n\n /**\n * Access token for Bearer authentication.\n */\n accessToken?: string\n} & Omit<BaseConfiguration, \"isJsonMime\" | \"basePath\">\n\ntype NovaClientConfigWithDefaults = NovaClientConfig & { cellId: string }\n\n/**\n * EXPERIMENTAL\n *\n * This client provides a starting point to migrate NOVA api v2.\n * As v2 is still in development, this client has to be considered unstable\n *\n * Client for connecting to a Nova instance and controlling robots.\n */\nexport class NovaClient {\n readonly api: NovaCellAPIClient\n readonly config: NovaClientConfigWithDefaults\n readonly mock?: MockNovaInstance\n authPromise: Promise<string | null> | null = null\n accessToken: string | null = null\n\n constructor(config: NovaClientConfig) {\n console.warn(\"Using experimental NOVA v2 client\")\n const cellId = config.cellId ?? \"cell\"\n this.config = {\n cellId,\n ...config,\n }\n this.accessToken =\n config.accessToken ||\n availableStorage.getString(\"wbjs.access_token\") ||\n null\n\n if (this.config.instanceUrl === \"https://mock.example.com\") {\n this.mock = new MockNovaInstance()\n }\n\n // Set up Axios instance with interceptor for token fetching\n const axiosInstance = axios.create({\n baseURL: urlJoin(this.config.instanceUrl, \"/api/v2\"),\n // TODO - backend needs to set proper CORS headers for this\n headers:\n typeof window !== \"undefined\" &&\n window.location.origin.includes(\"localhost\")\n ? {}\n : {\n // Identify the client to the backend for logging purposes\n \"X-Wandelbots-Client\": \"Wandelbots-Nova-JS-SDK\",\n },\n })\n\n axiosInstance.interceptors.request.use(async (request) => {\n if (!request.headers.Authorization) {\n if (this.accessToken) {\n request.headers.Authorization = `Bearer ${this.accessToken}`\n } else if (this.config.username && this.config.password) {\n request.headers.Authorization = `Basic ${btoa(config.username + \":\" + config.password)}`\n }\n }\n return request\n })\n\n if (typeof window !== \"undefined\") {\n axiosInstance.interceptors.response.use(\n (r) => r,\n async (error) => {\n if (isAxiosError(error)) {\n if (error.response?.status === 401) {\n // If we hit a 401, attempt to login the user and retry with\n // a new access token\n try {\n await this.renewAuthentication()\n\n if (error.config) {\n if (this.accessToken) {\n error.config.headers.Authorization = `Bearer ${this.accessToken}`\n } else {\n delete error.config.headers.Authorization\n }\n return axiosInstance.request(error.config)\n }\n } catch (err) {\n return Promise.reject(err)\n }\n } else if (error.response?.status === 503) {\n // Check if the server as a whole is down\n const res = await fetch(window.location.href)\n if (res.status === 503) {\n // Go to 503 page\n window.location.reload()\n }\n }\n }\n\n return Promise.reject(error)\n },\n )\n }\n\n this.api = new NovaCellAPIClient(cellId, {\n ...config,\n basePath: urlJoin(this.config.instanceUrl, \"/api/v1\"),\n isJsonMime: (mime: string) => {\n return mime === \"application/json\"\n },\n baseOptions: {\n ...(this.mock\n ? ({\n adapter: (config) => {\n return this.mock!.handleAPIRequest(config)\n },\n } satisfies AxiosRequestConfig)\n : {}),\n ...config.baseOptions,\n },\n axiosInstance,\n })\n }\n\n async renewAuthentication(): Promise<void> {\n if (this.authPromise) {\n // Don't double up\n return\n }\n\n this.authPromise = loginWithAuth0(this.config.instanceUrl)\n try {\n this.accessToken = await this.authPromise\n if (this.accessToken) {\n // Cache access token so we don't need to log in every refresh\n availableStorage.setString(\"wbjs.access_token\", this.accessToken)\n } else {\n availableStorage.delete(\"wbjs.access_token\")\n }\n } finally {\n this.authPromise = null\n }\n }\n\n makeWebsocketURL(path: string): string {\n const url = new URL(\n urlJoin(\n this.config.instanceUrl,\n `/api/v1/cells/${this.config.cellId}`,\n path,\n ),\n )\n url.protocol = url.protocol.replace(\"http\", \"ws\")\n url.protocol = url.protocol.replace(\"https\", \"wss\")\n\n // If provided, add basic auth credentials to the URL\n // NOTE - basic auth is deprecated on websockets and doesn't work in Safari\n // use tokens instead\n if (this.accessToken) {\n url.searchParams.append(\"token\", this.accessToken)\n } else if (this.config.username && this.config.password) {\n url.username = this.config.username\n url.password = this.config.password\n }\n\n return url.toString()\n }\n\n /**\n * Retrieve an AutoReconnectingWebsocket to the given path on the Nova instance.\n * If you explicitly want to reconnect an existing websocket, call `reconnect`\n * on the returned object.\n */\n openReconnectingWebsocket(path: string) {\n return new AutoReconnectingWebsocket(this.makeWebsocketURL(path), {\n mock: this.mock,\n })\n }\n\n /**\n * Connect to the motion state websocket(s) for a given motion group\n */\n async connectMotionStream(motionGroupId: string) {\n return await MotionStreamConnection.open(this, motionGroupId)\n }\n\n async connectMotionGroups(\n motionGroupIds: string[],\n ): Promise<ConnectedMotionGroup[]> {\n const { controllers } = await this.api.controller.listControllers()\n\n return Promise.all(\n motionGroupIds.map((motionGroupId) =>\n ConnectedMotionGroup.connect(this, motionGroupId, controllers),\n ),\n )\n }\n\n async connectMotionGroup(\n motionGroupId: string,\n ): Promise<ConnectedMotionGroup> {\n const motionGroups = await this.connectMotionGroups([motionGroupId])\n return motionGroups[0]!\n }\n}\n","import type {\n ControllersList,\n MotionGroupSpecification,\n MotionGroupState,\n RobotController,\n SafetySetup,\n} from \"@wandelbots/nova-api/v2\"\nimport type { AxiosResponse, InternalAxiosRequestConfig } from \"axios\"\nimport { AxiosError } from \"axios\"\nimport * as pathToRegexp from \"path-to-regexp\"\nimport type { AutoReconnectingWebsocket } from \"../../AutoReconnectingWebsocket\"\n\n/**\n * EXPERIMENTAL\n * Ultra-simplified mock Nova server for testing stuff\n */\nexport class MockNovaInstance {\n readonly connections: AutoReconnectingWebsocket[] = []\n\n async handleAPIRequest(\n config: InternalAxiosRequestConfig,\n ): Promise<AxiosResponse> {\n const apiHandlers = [\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers\",\n handle() {\n return {\n controllers: [\n {\n controller: \"mock-ur5e\",\n model_name: \"UniversalRobots::Controller\",\n host: \"mock-ur5e\",\n allow_software_install_on_controller: true,\n motion_groups: [\n {\n motion_group: \"0@mock-ur5e\",\n name_from_controller: \"UR5e\",\n active: false,\n model_from_controller: \"UniversalRobots_UR5e\",\n },\n ],\n has_error: false,\n error_details: \"\",\n },\n ],\n } satisfies ControllersList\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId\",\n handle() {\n return {\n configuration: {\n kind: \"VirtualController\",\n manufacturer: \"universalrobots\",\n position: \"[0,-1.571,-1.571,-1.571,1.571,-1.571,0]\",\n type: \"universalrobots-ur5e\",\n },\n name: \"mock-ur5\",\n } satisfies RobotController\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/specification\",\n handle() {\n return {\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n theta: 0,\n a: 0,\n d: 162.25,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: -425,\n d: 0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: -392.2,\n d: 0,\n reverse_rotation_direction: false,\n },\n {\n alpha: 1.5707963267948966,\n theta: 0,\n a: 0,\n d: 133.3,\n reverse_rotation_direction: false,\n },\n {\n alpha: -1.5707963267948966,\n theta: 0,\n a: 0,\n d: 99.7,\n reverse_rotation_direction: false,\n },\n {\n alpha: 0,\n theta: 0,\n a: 0,\n d: 99.6,\n reverse_rotation_direction: false,\n },\n ],\n mechanical_joint_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n lower_limit: -6.335545063018799,\n upper_limit: 6.335545063018799,\n unlimited: false,\n },\n ],\n } satisfies MotionGroupSpecification\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/safety-setup\",\n handle() {\n return {\n safety_settings: [\n {\n safety_state: \"SAFETY_NORMAL\",\n settings: {\n joint_position_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n lower_limit: -2.96705961227417,\n upper_limit: 2.96705961227417,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n lower_limit: -1.7453292608261108,\n upper_limit: 2.7925267219543457,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n lower_limit: -3.3161256313323975,\n upper_limit: 0.40142571926116943,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n lower_limit: -3.4906585216522217,\n upper_limit: 3.4906585216522217,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n lower_limit: -2.4434609413146973,\n upper_limit: 2.4434609413146973,\n unlimited: false,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n lower_limit: -4.71238899230957,\n upper_limit: 4.71238899230957,\n unlimited: false,\n },\n ],\n joint_velocity_limits: [\n {\n joint: \"JOINTNAME_AXIS_1\",\n limit: 3.1415927410125732,\n },\n {\n joint: \"JOINTNAME_AXIS_2\",\n limit: 3.1415927410125732,\n },\n {\n joint: \"JOINTNAME_AXIS_3\",\n limit: 3.4906585216522217,\n },\n {\n joint: \"JOINTNAME_AXIS_4\",\n limit: 6.108652591705322,\n },\n {\n joint: \"JOINTNAME_AXIS_5\",\n limit: 6.108652591705322,\n },\n {\n joint: \"JOINTNAME_AXIS_6\",\n limit: 6.981317043304443,\n },\n ],\n joint_acceleration_limits: [],\n joint_torque_limits: [],\n tcp_velocity_limit: 1800,\n },\n },\n ],\n safety_zones: [\n {\n id: 1,\n priority: 0,\n geometry: {\n compound: {\n child_geometries: [\n {\n convex_hull: {\n vertices: [\n { vertex: [-800, -1330, -1820] },\n { vertex: [1650, -1330, -1820] },\n { vertex: [1650, 1330, -1820] },\n { vertex: [-800, 1330, -1820] },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [-800, -1330, -1820],\n },\n {\n vertex: [1650, -1330, -1820],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [-800, -1330, -1820],\n },\n {\n vertex: [-800, 1330, -1820],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, -1330, 1500],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [-800, 1330, 1500],\n },\n {\n vertex: [-800, 1330, -1820],\n },\n {\n vertex: [1650, 1330, -1820],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, 1500],\n },\n {\n vertex: [1650, -1330, 1500],\n },\n {\n vertex: [1650, -1330, -1820],\n },\n {\n vertex: [1650, 1330, -1820],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"box\",\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Cell workzone\",\n },\n motion_group_uid: 1,\n },\n {\n id: 2,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, -1850],\n },\n {\n vertex: [865, 1330, -1850],\n },\n {\n vertex: [865, -720, -1850],\n },\n {\n vertex: [1650, -720, -1850],\n },\n {\n vertex: [1650, 1330, -920],\n },\n {\n vertex: [865, 1330, -920],\n },\n {\n vertex: [865, -720, -920],\n },\n {\n vertex: [1650, -720, -920],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Transport\",\n },\n motion_group_uid: 1,\n },\n {\n id: 3,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, 1330, -600],\n },\n {\n vertex: [865, 1330, -600],\n },\n {\n vertex: [865, 430, -600],\n },\n {\n vertex: [1650, 430, -600],\n },\n {\n vertex: [1650, 1330, -1250],\n },\n {\n vertex: [865, 1330, -1250],\n },\n {\n vertex: [865, 430, -1250],\n },\n {\n vertex: [1650, 430, -1250],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Tunel\",\n },\n motion_group_uid: 1,\n },\n {\n id: 4,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [1650, -760, -440],\n },\n {\n vertex: [900, -760, -440],\n },\n {\n vertex: [900, -1330, -440],\n },\n {\n vertex: [1650, -1330, -440],\n },\n {\n vertex: [1650, -760, -1800],\n },\n {\n vertex: [900, -760, -1800],\n },\n {\n vertex: [900, -1330, -1800],\n },\n {\n vertex: [1650, -1330, -1800],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Fanuc controller\",\n },\n motion_group_uid: 1,\n },\n {\n id: 6,\n priority: 0,\n geometry: {\n convex_hull: {\n vertices: [\n {\n vertex: [-200, -200, -1900],\n },\n {\n vertex: [200, -200, -1900],\n },\n {\n vertex: [200, 200, -1900],\n },\n {\n vertex: [-200, 200, -1900],\n },\n {\n vertex: [-200, -200, -350],\n },\n {\n vertex: [200, -200, -350],\n },\n {\n vertex: [200, 200, -350],\n },\n {\n vertex: [-200, 200, -350],\n },\n ],\n },\n init_pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0, 1],\n },\n id: \"Robot base\",\n },\n motion_group_uid: 1,\n },\n ],\n robot_model_geometries: [\n {\n link_index: 1,\n geometry: {\n sphere: {\n radius: 270,\n },\n init_pose: {\n position: [-70, -70, -50],\n orientation: [0, 0, 0, 1],\n },\n id: \"link1_sphere\",\n },\n },\n {\n link_index: 2,\n geometry: {\n capsule: {\n radius: 160,\n cylinder_height: 800,\n },\n init_pose: {\n position: [-450, 40, 170],\n orientation: [\n 0, -0.7071067811865475, 0, 0.7071067811865476,\n ],\n },\n id: \"link2_capsule\",\n },\n },\n {\n link_index: 3,\n geometry: {\n sphere: {\n radius: 270,\n },\n init_pose: {\n position: [-110, 10, -100],\n orientation: [0, 0, 0, 1],\n },\n id: \"link3_sphere\",\n },\n },\n {\n link_index: 4,\n geometry: {\n capsule: {\n radius: 110,\n cylinder_height: 600,\n },\n init_pose: {\n position: [0, 300, 40],\n orientation: [\n -0.7071067811865475, 0, 0, 0.7071067811865476,\n ],\n },\n id: \"link4_capsule\",\n },\n },\n {\n link_index: 5,\n geometry: {\n sphere: {\n radius: 75,\n },\n init_pose: {\n position: [0, 0, -50],\n orientation: [0, 0, 0, 1],\n },\n id: \"link5_sphere\",\n },\n },\n ],\n tool_geometries: [],\n } satisfies SafetySetup\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/coordinate-systems\",\n handle() {\n return {\n coordinatesystems: [\n {\n coordinate_system: \"\",\n name: \"world\",\n reference_uid: \"\",\n position: [0, 0, 0],\n rotation: {\n angles: [0, 0, 0],\n type: \"ROTATION_VECTOR\",\n },\n },\n ],\n } //satisfies CoordinateSystems\n },\n },\n {\n method: \"GET\",\n path: \"/cells/:cellId/motion-groups/:motionGroupId/tcps\",\n handle() {\n return {\n tcps: [\n {\n id: \"Flange\",\n readable_name: \"Default-Flange\",\n position: [0, 0, 0],\n rotation: {\n angles: [0, 0, 0, 0],\n type: \"ROTATION_VECTOR\",\n },\n },\n {\n id: \"complex-tcp-position\",\n readable_name: \"Complex TCP Position\",\n position: [-200, 300, 150],\n rotation: {\n angles: [\n -0.12139440409113832, -0.06356210998212003,\n -0.2023240068185639, 0,\n ],\n type: \"ROTATION_VECTOR\",\n },\n },\n ],\n }\n },\n },\n ]\n\n const method = config.method?.toUpperCase() || \"GET\"\n const path = \"/cells\" + config.url?.split(\"/cells\")[1]?.split(\"?\")[0]\n\n for (const handler of apiHandlers) {\n const match = pathToRegexp.match(handler.path)(path || \"\")\n if (method === handler.method && match) {\n const json = handler.handle()\n return {\n status: 200,\n statusText: \"Success\",\n data: JSON.stringify(json),\n headers: {},\n config,\n request: {\n responseURL: config.url,\n },\n }\n }\n }\n\n throw new AxiosError(\n `No mock handler matched this request: ${method} ${path}`,\n \"404\",\n config,\n )\n\n // return {\n // status: 404,\n // statusText: \"Not Found\",\n // data: \"\",\n // headers: {},\n // config,\n // request: {\n // responseURL: config.url,\n // },\n // }\n }\n\n handleWebsocketConnection(socket: AutoReconnectingWebsocket) {\n this.connections.push(socket)\n\n setTimeout(() => {\n socket.dispatchEvent(new Event(\"open\"))\n\n console.log(\"Websocket connection opened from\", socket.url)\n\n if (socket.url.includes(\"/state-stream\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify(defaultMotionState),\n }),\n )\n }\n\n if (socket.url.includes(\"/move-joint\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n motion_group: \"0@ur\",\n state: {\n controller: \"ur\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n timestamp: \"2024-09-18T12:48:26.096266444Z\",\n velocity_override: 100,\n motion_groups: [\n {\n motion_group: \"0@ur\",\n controller: \"ur\",\n joint_position: {\n joints: [\n 1.3492152690887451, -1.5659207105636597,\n 1.6653711795806885, -1.0991662740707397,\n -1.829018235206604, 1.264623761177063,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [\n 6.437331889439328, -628.4123774830913,\n 577.0569957147832,\n ],\n orientation: {\n x: -1.683333649797158,\n y: -1.9783363827298732,\n z: -0.4928031860165713,\n },\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [\n 6.437331889439328, -628.4123774830913,\n 577.0569957147832,\n ],\n orientation: {\n x: -1.683333649797158,\n y: -1.9783363827298732,\n z: -0.4928031860165713,\n },\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: {\n x: 0,\n y: 0,\n z: 0,\n },\n angular: {\n x: -0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n force: {\n force: {\n x: 0,\n y: 0,\n z: 0,\n },\n moment: {\n x: 0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [\n false,\n false,\n false,\n false,\n false,\n false,\n ],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n sequence_number: \"671259\",\n },\n ],\n sequence_number: \"671259\",\n },\n movement_state: \"MOVEMENT_STATE_MOVING\",\n },\n }),\n }),\n )\n }\n\n if (socket.url.includes(\"/move-tcp\")) {\n socket.dispatchEvent(\n new MessageEvent(\"message\", {\n data: JSON.stringify({\n result: {\n motion_group: \"0@ur\",\n state: {\n controller: \"ur\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n timestamp: \"2024-09-18T12:43:12.188335774Z\",\n velocity_override: 100,\n motion_groups: [\n {\n motion_group: \"0@ur\",\n controller: \"ur\",\n joint_position: {\n joints: [\n 1.3352527618408203, -1.5659207105636597,\n 1.6653711795806885, -1.110615611076355,\n -1.829018235206604, 1.264623761177063,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [\n -2.763015284002938, -630.2151479701106,\n 577.524509114342,\n ],\n orientation: {\n x: -1.704794877102097,\n y: -1.9722372952861567,\n z: -0.4852079204210754,\n },\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [\n -2.763015284002938, -630.2151479701106,\n 577.524509114342,\n ],\n orientation: {\n x: -1.704794877102097,\n y: -1.9722372952861567,\n z: -0.4852079204210754,\n },\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: {\n x: 0,\n y: 0,\n z: 0,\n },\n angular: {\n x: -0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n force: {\n force: {\n x: 0,\n y: 0,\n z: 0,\n },\n moment: {\n x: 0,\n y: 0,\n z: 0,\n },\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [\n false,\n false,\n false,\n false,\n false,\n false,\n ],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n sequence_number: \"627897\",\n },\n ],\n sequence_number: \"627897\",\n },\n movement_state: \"MOVEMENT_STATE_MOVING\",\n },\n }),\n }),\n )\n }\n }, 10)\n }\n\n handleWebsocketMessage(socket: AutoReconnectingWebsocket, message: string) {\n console.log(`Received message on ${socket.url}`, message)\n }\n}\n\nconst defaultMotionState = {\n result: {\n motion_group: \"0@universalrobots-ur5e\",\n controller: \"universalrobots-ur5e\",\n joint_position: {\n joints: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n },\n joint_velocity: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n coordinate_system: \"\",\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n coordinate_system: \"\",\n tcp: \"Flange\",\n },\n velocity: {\n linear: [0, 0, 0],\n angular: [0, 0, 0],\n coordinate_system: \"\",\n },\n force: {\n force: [0, 0, 0],\n moment: [0, 0, 0],\n coordinate_system: \"\",\n },\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_current: {\n joints: [0, 0, 0, 0, 0, 0],\n },\n } satisfies MotionGroupState,\n}\n","import { AxiosError } from \"axios\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport type { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport type { NovaClient } from \"./NovaClient\"\n\nexport type ProgramRunnerLogEntry = {\n timestamp: number\n message: string\n level?: \"warn\" | \"error\"\n}\n\nexport enum ProgramState {\n NotStarted = \"not started\",\n Running = \"running\",\n Stopped = \"stopped\",\n Failed = \"failed\",\n Completed = \"completed\",\n}\n\nexport type CurrentProgram = {\n id?: string\n wandelscript?: string\n state?: ProgramState\n}\n\ntype ProgramStateMessage = {\n type: string\n runner: {\n id: string\n state: ProgramState\n start_time?: number | null\n execution_time?: number | null\n }\n}\n\n/**\n * Interface for running Wandelscript programs on the Nova instance and\n * tracking their progress and output\n */\nexport class ProgramStateConnection {\n currentProgram: CurrentProgram = {}\n logs: ProgramRunnerLogEntry[] = []\n\n executionState = \"idle\" as \"idle\" | \"starting\" | \"executing\" | \"stopping\"\n currentlyExecutingProgramRunnerId = null as string | null\n\n programStateSocket: AutoReconnectingWebsocket\n\n constructor(readonly nova: NovaClient) {\n makeAutoObservable(this, {}, { autoBind: true })\n\n this.programStateSocket = nova.openReconnectingWebsocket(`/programs/state`)\n\n this.programStateSocket.addEventListener(\"message\", (ev) => {\n const msg = tryParseJson(ev.data)\n\n if (!msg) {\n console.error(\"Failed to parse program state message\", ev.data)\n return\n }\n if (msg.type === \"update\") {\n this.handleProgramStateMessage(msg)\n }\n })\n }\n\n /** Handle a program state update from the backend */\n async handleProgramStateMessage(msg: ProgramStateMessage) {\n const { runner } = msg\n\n // Ignoring other programs for now\n // TODO - show if execution state is busy from another source\n if (runner.id !== this.currentlyExecutingProgramRunnerId) return\n\n if (runner.state === ProgramState.Failed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n // TODO - wandelengine should send print statements in real time over\n // websocket as well, rather than at the end\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n this.logError(\n `Program runner ${runner.id} failed with error: ${runnerState.error}\\n${runnerState.traceback}`,\n )\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.currentProgram.state = ProgramState.Failed\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Stopped) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n\n this.currentProgram.state = ProgramState.Stopped\n this.log(`Program runner ${runner.id} stopped`)\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Completed) {\n try {\n const runnerState = await this.nova.api.program.getProgramRun(runner.id)\n\n const stdout = (runnerState as any).stdout\n if (stdout) {\n this.log(stdout)\n }\n this.log(\n `Program runner ${runner.id} finished successfully in ${runner.execution_time?.toFixed(2)} seconds`,\n )\n\n this.currentProgram.state = ProgramState.Completed\n } catch (err) {\n this.logError(\n `Failed to retrieve results for program ${runner.id}: ${err}`,\n )\n }\n\n this.gotoIdleState()\n } else if (runner.state === ProgramState.Running) {\n this.currentProgram.state = ProgramState.Running\n this.log(`Program runner ${runner.id} now running`)\n } else if (runner.state !== ProgramState.NotStarted) {\n console.error(runner)\n this.logError(\n `Program runner ${runner.id} entered unexpected state: ${runner.state}`,\n )\n this.currentProgram.state = ProgramState.NotStarted\n this.gotoIdleState()\n }\n }\n\n /** Call when a program is no longer executing */\n gotoIdleState() {\n runInAction(() => {\n this.executionState = \"idle\"\n })\n this.currentlyExecutingProgramRunnerId = null\n }\n\n async executeProgram(\n wandelscript: string,\n initial_state?: Object,\n activeRobot?: MotionStreamConnection,\n ) {\n this.currentProgram = {\n wandelscript: wandelscript,\n state: ProgramState.NotStarted,\n }\n\n const { currentProgram: openProgram } = this\n if (!openProgram) return\n runInAction(() => {\n this.executionState = \"starting\"\n })\n\n // WOS-1539: Wandelengine parser currently breaks if there are empty lines with indentation\n const trimmedCode = openProgram.wandelscript!.replaceAll(/^\\s*$/gm, \"\")\n\n try {\n const programRunnerRef = await this.nova.api.program.createProgramRun(\n {\n code: trimmedCode,\n initial_state: initial_state,\n default_robot: activeRobot?.wandelscriptIdentifier,\n } as any,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n )\n\n this.log(`Created program runner ${programRunnerRef.id}\"`)\n runInAction(() => {\n this.executionState = \"executing\"\n })\n this.currentlyExecutingProgramRunnerId = programRunnerRef.id\n } catch (error) {\n if (error instanceof AxiosError && error.response && error.request) {\n this.logError(\n `${error.response.status} ${error.response.statusText} from ${error.response.config.url} ${JSON.stringify(error.response.data)}`,\n )\n } else {\n this.logError(JSON.stringify(error))\n }\n runInAction(() => {\n this.executionState = \"idle\"\n })\n }\n }\n\n async stopProgram() {\n if (!this.currentlyExecutingProgramRunnerId) return\n runInAction(() => {\n this.executionState = \"stopping\"\n })\n\n try {\n await this.nova.api.program.stopProgramRun(\n this.currentlyExecutingProgramRunnerId,\n )\n } catch (err) {\n // Reactivate the stop button so user can try again\n runInAction(() => {\n this.executionState = \"executing\"\n })\n throw err\n }\n }\n\n reset() {\n this.currentProgram = {}\n }\n\n log(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n })\n }\n\n logError(message: string) {\n console.log(message)\n this.logs.push({\n timestamp: Date.now(),\n message,\n level: \"error\",\n })\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,cAAc;;;ACQd,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,mBAAmB;;;ACPzC,SAAS,iBACd,gBACA,gBACA,sBACS;AACT,MAAI,eAAe,WAAW,eAAe,QAAQ;AACnD,WAAO;AAAA,EACT;AAEA,WAAS,aAAa,GAAG,aAAa,eAAe,QAAQ,cAAc;AACzE,QACE,KAAK,IAAI,eAAe,UAAU,IAAK,eAAe,UAAU,CAAE,IAClE,sBACA;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,aACd,QACA,QACA,sBACS;AAET,MAAK,WAAW,UAAa,UAAY,UAAU,WAAW,QAAY;AACxE,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,UAAa,WAAW,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;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":["makeAutoObservable","runInAction","THREE","MOTION_DELTA_THRESHOLD","runInAction","makeAutoObservable","axios","AxiosError","match","AxiosError","axios","_a","config","AxiosError","makeAutoObservable","runInAction","ProgramState","makeAutoObservable","runInAction","AxiosError"]}
|
package/package.json
CHANGED
package/src/lib/v1/NovaClient.ts
CHANGED
|
@@ -72,9 +72,15 @@ export class NovaClient {
|
|
|
72
72
|
// Set up Axios instance with interceptor for token fetching
|
|
73
73
|
const axiosInstance = axios.create({
|
|
74
74
|
baseURL: urlJoin(this.config.instanceUrl, "/api/v1"),
|
|
75
|
-
headers
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// TODO - backend needs to set proper CORS headers for this
|
|
76
|
+
headers:
|
|
77
|
+
typeof window !== "undefined" &&
|
|
78
|
+
window.location.origin.includes("localhost")
|
|
79
|
+
? {}
|
|
80
|
+
: {
|
|
81
|
+
// Identify the client to the backend for logging purposes
|
|
82
|
+
"X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK",
|
|
83
|
+
},
|
|
78
84
|
})
|
|
79
85
|
|
|
80
86
|
axiosInstance.interceptors.request.use(async (request) => {
|
package/src/lib/v2/NovaClient.ts
CHANGED
|
@@ -77,9 +77,15 @@ export class NovaClient {
|
|
|
77
77
|
// Set up Axios instance with interceptor for token fetching
|
|
78
78
|
const axiosInstance = axios.create({
|
|
79
79
|
baseURL: urlJoin(this.config.instanceUrl, "/api/v2"),
|
|
80
|
-
headers
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
// TODO - backend needs to set proper CORS headers for this
|
|
81
|
+
headers:
|
|
82
|
+
typeof window !== "undefined" &&
|
|
83
|
+
window.location.origin.includes("localhost")
|
|
84
|
+
? {}
|
|
85
|
+
: {
|
|
86
|
+
// Identify the client to the backend for logging purposes
|
|
87
|
+
"X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK",
|
|
88
|
+
},
|
|
83
89
|
})
|
|
84
90
|
|
|
85
91
|
axiosInstance.interceptors.request.use(async (request) => {
|