@wandelbots/nova-js 3.2.0-pr.dev-e2e-jogging-test.143.4f02caf → 3.2.0-pr.feat-v2.155.e91b019

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.
Files changed (66) hide show
  1. package/README.md +60 -50
  2. package/dist/{AutoReconnectingWebsocket-BI1ckzP8.d.ts → AutoReconnectingWebsocket-CoU4ZyD2.d.cts} +1 -3
  3. package/dist/AutoReconnectingWebsocket-CoU4ZyD2.d.cts.map +1 -0
  4. package/dist/{AutoReconnectingWebsocket-Cr7f9016.d.cts → AutoReconnectingWebsocket-D0gTrkzu.d.ts} +1 -3
  5. package/dist/AutoReconnectingWebsocket-D0gTrkzu.d.ts.map +1 -0
  6. package/dist/{LoginWithAuth0-0g0wWRUC.js → LoginWithAuth0-CaX7yo7d.js} +58 -5
  7. package/dist/LoginWithAuth0-CaX7yo7d.js.map +1 -0
  8. package/dist/{LoginWithAuth0-C82OCyDy.cjs → LoginWithAuth0-DaPnTz2I.cjs} +99 -4
  9. package/dist/LoginWithAuth0-DaPnTz2I.cjs.map +1 -0
  10. package/dist/index.cjs +11 -10
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +11 -8
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.ts +11 -8
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/lib/v1/index.cjs +17 -19
  18. package/dist/lib/v1/index.cjs.map +1 -1
  19. package/dist/lib/v1/index.d.cts +4 -2
  20. package/dist/lib/v1/index.d.cts.map +1 -1
  21. package/dist/lib/v1/index.d.ts +4 -2
  22. package/dist/lib/v1/index.d.ts.map +1 -1
  23. package/dist/lib/v1/index.js +7 -10
  24. package/dist/lib/v1/index.js.map +1 -1
  25. package/dist/lib/v2/index.cjs +1087 -11
  26. package/dist/lib/v2/index.cjs.map +1 -1
  27. package/dist/lib/v2/index.d.cts +256 -7
  28. package/dist/lib/v2/index.d.cts.map +1 -1
  29. package/dist/lib/v2/index.d.ts +256 -7
  30. package/dist/lib/v2/index.d.ts.map +1 -1
  31. package/dist/lib/v2/index.js +1082 -12
  32. package/dist/lib/v2/index.js.map +1 -1
  33. package/dist/wandelscriptUtils-CO5GYRij.js +24 -0
  34. package/dist/wandelscriptUtils-CO5GYRij.js.map +1 -0
  35. package/dist/wandelscriptUtils-COHpTIme.d.cts +12 -0
  36. package/dist/wandelscriptUtils-COHpTIme.d.cts.map +1 -0
  37. package/dist/wandelscriptUtils-Cl3GBxOp.d.ts +12 -0
  38. package/dist/wandelscriptUtils-Cl3GBxOp.d.ts.map +1 -0
  39. package/dist/wandelscriptUtils-DwpJ4jCy.cjs +30 -0
  40. package/dist/wandelscriptUtils-DwpJ4jCy.cjs.map +1 -0
  41. package/package.json +2 -2
  42. package/src/LoginWithAuth0.ts +3 -3
  43. package/src/index.ts +1 -0
  44. package/src/lib/converters.ts +5 -23
  45. package/src/lib/v1/MotionStreamConnection.ts +1 -1
  46. package/src/lib/v1/NovaClient.ts +6 -0
  47. package/src/lib/v1/index.ts +6 -0
  48. package/src/lib/v1/mock/MockNovaInstance.ts +0 -1
  49. package/src/lib/v1/wandelscriptUtils.ts +22 -0
  50. package/src/lib/v2/ConnectedMotionGroup.ts +415 -0
  51. package/src/lib/v2/JoggerConnection.ts +647 -0
  52. package/src/lib/v2/MotionStreamConnection.ts +222 -0
  53. package/src/lib/v2/NovaClient.ts +43 -8
  54. package/src/lib/v2/index.ts +5 -0
  55. package/src/lib/v2/mock/MockNovaInstance.ts +385 -1
  56. package/src/lib/v2/motionStateUpdate.ts +76 -0
  57. package/src/lib/v2/types/vector3.ts +1 -0
  58. package/src/lib/v2/wandelscriptUtils.ts +27 -0
  59. package/dist/AutoReconnectingWebsocket-BI1ckzP8.d.ts.map +0 -1
  60. package/dist/AutoReconnectingWebsocket-Cr7f9016.d.cts.map +0 -1
  61. package/dist/LoginWithAuth0-0g0wWRUC.js.map +0 -1
  62. package/dist/LoginWithAuth0-C82OCyDy.cjs.map +0 -1
  63. package/dist/converters-DP2EIVv6.cjs +0 -108
  64. package/dist/converters-DP2EIVv6.cjs.map +0 -1
  65. package/dist/converters-DY6Lf7mb.js +0 -66
  66. package/dist/converters-DY6Lf7mb.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","SystemApi","CellApi","MotionGroupApi","MotionGroupModelsApi","ControllerApi","ControllerInputsOutputsApi","TrajectoryPlanningApi","TrajectoryExecutionApi","TrajectoryCachingApi","ApplicationApi","JoggingApi","KinematicsApi","BUSInputsOutputsApi","VirtualControllerApi","VirtualControllerBehaviorApi","VirtualControllerInputsOutputsApi","StoreObjectApi","StoreCollisionComponentsApi","StoreCollisionSetupsApi","pathToRegexp","AxiosError","availableStorage","config","loginWithAuth0","AutoReconnectingWebsocket"],"sources":["../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/NovaClient.ts"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\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 motionGroupModels = this.withCellId(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","import type { MotionGroupState, RobotController } 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 }\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 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 } // Mock motion group specification\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: [0, -Math.SQRT1_2, 0, Math.SQRT1_2],\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: [-Math.SQRT1_2, 0, 0, Math.SQRT1_2],\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 } // Mock safety setup\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 1.3492152690887451, -1.5659207105636597,\n 1.6653711795806885, -1.0991662740707397,\n -1.829018235206604, 1.264623761177063,\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 timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n } satisfies MotionGroupState,\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport 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 { MockNovaInstance } from \"./mock/MockNovaInstance\"\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\nfunction permissiveInstanceUrlParse(url: string): string {\n if (!url.startsWith(\"http\")) {\n url = `http://${url}`\n }\n\n return new URL(url).toString()\n}\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 instanceUrl: permissiveInstanceUrlParse(config.instanceUrl),\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"],"mappings":";;;;;;;;;;;;;;;AAoDA,IAAa,oBAAb,MAA+B;CAC7B,YACE,AAASA,QACT,AAASC,MAIT;EALS;EACA;gBAkFO,KAAK,2BAA2BC,mCAAU;cAC5C,KAAK,2BAA2BC,iCAAQ;qBAEjC,KAAK,WAAWC,wCAAe;2BACzB,KAAK,WAAWC,8CAAqB;oBAE5C,KAAK,WAAWC,uCAAc;uBAE3B,KAAK,WAAWC,oDAA2B;4BAEtC,KAAK,WAAWC,+CAAsB;6BACrC,KAAK,WAAWC,gDAAuB;2BACzC,KAAK,WAAWC,8CAAqB;qBAE3C,KAAK,WAAWC,wCAAe;2BACzB,KAAK,2BAA2BA,wCAAe;iBAEzD,KAAK,WAAWC,oCAAW;oBAExB,KAAK,WAAWC,uCAAc;0BAExB,KAAK,WAAWC,6CAAoB;2BAEnC,KAAK,WAAWC,8CAAqB;mCAC7B,KAAK,WACxCC,sDACD;8BAC+B,KAAK,WACnCC,2DACD;qBAEsB,KAAK,WAAWC,wCAAe;kCAClB,KAAK,WACvCC,qDACD;8BAC+B,KAAK,WAAWC,iDAAwB;;;;;;;CA1GxE,AAAQ,WACN,gBAKA;EACA,MAAM,YAAY,IAAI,eACpB;GACE,GAAG,KAAK;GACR,aAAa,SAAiB;AAC5B,WAAO,SAAS;;GAEnB,EACD,KAAK,KAAK,YAAY,IACtB,KAAK,KAAK,iBAAiB,cAAM,QAAQ,CAC1C;AAID,OAAK,MAAM,OAAO,QAAQ,QAAQ,QAAQ,eAAe,UAAU,CAAE,CACnE,KAAI,QAAQ,iBAAiB,OAAO,UAAU,SAAS,YAAY;GACjE,MAAM,mBAAmB,UAAU;AACnC,aAAU,QAAQ,GAAG,SAAgB;AACnC,WAAO,iBACJ,MAAM,WAAW,CAAC,KAAK,QAAQ,GAAG,KAAK,CAAC,CACxC,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,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACF;MACD,yBAAyB;OACvB;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACF;MACF;;IAEJ;GACD;IACE,QAAQ;IACR,MAAM;IACN,SAAS;AACP,YAAO;MACL,iBAAiB,CACf;OACE,cAAc;OACd,UAAU;QACR,uBAAuB;SACrB;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACD;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACD;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACD;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACD;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACD;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,WAAW;UACZ;SACF;QACD,uBAAuB;SACrB;UACE,OAAO;UACP,OAAO;UACR;SACD;UACE,OAAO;UACP,OAAO;UACR;SACD;UACE,OAAO;UACP,OAAO;UACR;SACD;UACE,OAAO;UACP,OAAO;UACR;SACD;UACE,OAAO;UACP,OAAO;UACR;SACD;UACE,OAAO;UACP,OAAO;UACR;SACF;QACD,2BAA2B,EAAE;QAC7B,qBAAqB,EAAE;QAC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,OAAO,MAAM;IAE/B;AAGH,OAAK,MAAM,IAAI,kBAAkB,QAAQ;GACvC,GAAG;GACH,gCAAkB,KAAK,OAAO,aAAa,UAAU;GACrD,aAAa,SAAiB;AAC5B,WAAO,SAAS;;GAElB,aAAa;IACX,GAAI,KAAK,OACJ,EACC,UAAU,aAAW;AACnB,YAAO,KAAK,KAAM,iBAAiBC,SAAO;OAE7C,GACD,EAAE;IACN,GAAG,OAAO;IACX;GACD;GACD,CAAC;;CAGJ,MAAM,sBAAqC;AACzC,MAAI,KAAK,YAEP;AAGF,OAAK,cAAcC,sCAAe,KAAK,OAAO,YAAY;AAC1D,MAAI;AACF,QAAK,cAAc,MAAM,KAAK;AAC9B,OAAI,KAAK,YAEP,yCAAiB,UAAU,qBAAqB,KAAK,YAAY;OAEjE,yCAAiB,OAAO,oBAAoB;YAEtC;AACR,QAAK,cAAc;;;CAIvB,iBAAiB,MAAsB;EACrC,MAAM,MAAM,IAAI,0BAEZ,KAAK,OAAO,aACZ,iBAAiB,KAAK,OAAO,UAC7B,KACD,CACF;AACD,MAAI,WAAW,IAAI,SAAS,QAAQ,QAAQ,KAAK;AACjD,MAAI,WAAW,IAAI,SAAS,QAAQ,SAAS,MAAM;AAKnD,MAAI,KAAK,YACP,KAAI,aAAa,OAAO,SAAS,KAAK,YAAY;WACzC,KAAK,OAAO,YAAY,KAAK,OAAO,UAAU;AACvD,OAAI,WAAW,KAAK,OAAO;AAC3B,OAAI,WAAW,KAAK,OAAO;;AAG7B,SAAO,IAAI,UAAU;;;;;;;CAQvB,0BAA0B,MAAc;AACtC,SAAO,IAAIC,iDAA0B,KAAK,iBAAiB,KAAK,EAAE,EAChE,MAAM,KAAK,MACZ,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["MOTION_DELTA_THRESHOLD","tryParseJson","tcps: RobotTcpLike[]","nova: NovaClient","controller: RobotControllerState","motionGroup: MotionGroupState","initialMotionState: MotionGroupState","motionStateSocket: AutoReconnectingWebsocket","isVirtual: boolean","description: MotionGroupDescription","initialControllerState: RobotControllerState","controllerStateSocket: AutoReconnectingWebsocket","THREE","cellId: string","opts: BaseConfiguration & {\n axiosInstance?: AxiosInstance\n mock?: boolean\n }","SystemApi","CellApi","MotionGroupApi","MotionGroupModelsApi","ControllerApi","ControllerInputsOutputsApi","TrajectoryPlanningApi","TrajectoryExecutionApi","TrajectoryCachingApi","ApplicationApi","JoggingApi","KinematicsApi","BUSInputsOutputsApi","VirtualControllerApi","VirtualControllerBehaviorApi","VirtualControllerInputsOutputsApi","StoreObjectApi","StoreCollisionComponentsApi","StoreCollisionSetupsApi","pathToRegexp","AxiosError","Vector3","tryParseJson","nova: NovaClient","controller: RobotControllerState","motionGroup: MotionGroupState","description: MotionGroupDescription","initialMotionState: MotionGroupState","motionStateSocket: AutoReconnectingWebsocket","motionStream: MotionStreamConnection","options: JoggerConnectionOptions | undefined","tryParseJson","XYZ_TO_VECTOR","commands: MotionCommand[]","Vector3","availableStorage","config","loginWithAuth0","AutoReconnectingWebsocket"],"sources":["../../../src/lib/v2/motionStateUpdate.ts","../../../src/lib/v2/ConnectedMotionGroup.ts","../../../src/lib/v2/NovaCellAPIClient.ts","../../../src/lib/v2/mock/MockNovaInstance.ts","../../../src/lib/v2/MotionStreamConnection.ts","../../../src/lib/v2/JoggerConnection.ts","../../../src/lib/v2/NovaClient.ts","../../../src/lib/v2/wandelscriptUtils.ts"],"sourcesContent":["import type { MotionGroupState, Pose } 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 // biome-ignore lint/style/noNonNullAssertion: legacy code\n Math.abs(newJointValues[jointIndex]! - oldJointValues[jointIndex]!) >\n changeDeltaThreshold\n ) {\n return false\n }\n }\n\n return true\n}\n\nexport function poseEqual(\n oldTcp: Pose | undefined,\n newTcp: Pose | 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 // Poses might be incomplete (missing orientation or position)\n if (\n oldTcp?.orientation === undefined ||\n newTcp?.orientation === undefined ||\n oldTcp?.position === undefined ||\n newTcp?.position === undefined\n ) {\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 return changedDelta <= changeDeltaThreshold\n}\n\n// Runs poseEqual check + coordinate system/tcp name equality\nexport function tcpMotionEqual(\n oldMotionState: MotionGroupState,\n newMotionState: MotionGroupState,\n changeDeltaThreshold: number,\n): boolean {\n return (\n oldMotionState.coordinate_system === newMotionState.coordinate_system &&\n oldMotionState.tcp === newMotionState.tcp &&\n poseEqual(\n oldMotionState.tcp_pose,\n newMotionState.tcp_pose,\n changeDeltaThreshold,\n )\n )\n}\n","import type {\n MotionGroupDescription,\n MotionGroupState,\n RobotControllerState,\n OperationMode,\n SafetyStateType,\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, tcpMotionEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\nimport type { Vector3Simple } from \"./types/vector3\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nexport type RobotTcpLike = {\n id: string\n readable_name: string\n position: Vector3Simple\n orientation: Vector3Simple\n}\n\nexport type MotionGroupOption = {\n selectionId: string\n}\n\n/**\n * Store representing the current state of a connected motion group.\n */\nexport class ConnectedMotionGroup {\n static async connect(nova: NovaClient, motionGroupId: string) {\n const [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n\n const controller =\n await nova.api.controller.getCurrentRobotControllerState(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 `/controllers/${controllerId}/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 // Check if robot is virtual or physical\n const config = await nova.api.controller.getRobotController(\n controller.controller,\n )\n const isVirtual = config.configuration.kind === \"VirtualController\"\n\n // If there's a configured mounting, we need it to show the right\n // position of the robot model\n const description = await nova.api.motionGroup.getMotionGroupDescription(\n controllerId,\n motionGroup.motion_group,\n )\n\n // Find out what TCPs this motion group has (we need it for jogging)\n // There are converted into a RobotTcpLike for easier use in the UI\n const tcps: RobotTcpLike[] = Object.entries(description.tcps || {}).map(\n ([id, tcp]) => ({\n id,\n readable_name: tcp.name,\n position: tcp.pose.position as Vector3Simple,\n orientation: tcp.pose.orientation as Vector3Simple,\n }),\n )\n\n // Open the websocket to monitor controller state for e.g. e-stop\n const controllerStateSocket = nova.openReconnectingWebsocket(\n `/controllers/${controller.controller}/state-stream?response_rate=1000`,\n )\n\n // Wait for the first message to get the initial state\n const firstControllerMessage = await controllerStateSocket.firstMessage()\n const initialControllerState = tryParseJson(firstControllerMessage.data)\n ?.result as RobotControllerState\n\n if (!initialControllerState) {\n throw new Error(\n `Unable to parse initial controller state message ${firstControllerMessage.data}`,\n )\n }\n\n console.log(\n `Connected controller state websocket to controller ${controller.controller}. Initial state:\\n `,\n initialControllerState,\n )\n\n return new ConnectedMotionGroup(\n nova,\n controller,\n motionGroup,\n initialMotionState,\n motionStateSocket,\n isVirtual,\n tcps,\n description,\n initialControllerState,\n controllerStateSocket,\n )\n }\n\n connectedJoggingSocket: WebSocket | null = null\n // biome-ignore lint/suspicious/noExplicitAny: legacy code\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 // Response rate on the websocket should be a bit slower on this one since\n // we don't use the motion data\n controllerState: RobotControllerState\n\n /**\n * Reflects activation state of the motion group / robot servos. The\n * movement controls in the UI should only be enabled in the \"active\" state\n */\n activationState: \"inactive\" | \"activating\" | \"deactivating\" | \"active\" =\n \"inactive\"\n\n constructor(\n readonly nova: NovaClient,\n readonly controller: RobotControllerState,\n readonly motionGroup: MotionGroupState,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n readonly isVirtual: boolean,\n readonly tcps: RobotTcpLike[],\n readonly description: MotionGroupDescription,\n readonly initialControllerState: RobotControllerState,\n readonly controllerStateSocket: AutoReconnectingWebsocket,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n this.controllerState = initialControllerState\n\n // Track controller state updates (e.g. safety state and operation mode)\n controllerStateSocket.addEventListener(\"message\", (event) => {\n const data = tryParseJson(event.data)?.result\n\n if (!data) {\n return\n }\n\n runInAction(() => {\n this.controllerState = data\n })\n })\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const latestMotionState = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!latestMotionState) {\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,\n latestMotionState.joint_position,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = latestMotionState\n })\n }\n\n // handle tcpPose message\n if (\n !tcpMotionEqual(\n this.rapidlyChangingMotionState,\n latestMotionState,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState.tcp_pose = latestMotionState.tcp_pose\n })\n }\n\n // handle standstill changes\n if (\n this.rapidlyChangingMotionState.standstill !==\n latestMotionState.standstill\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState.standstill =\n latestMotionState.standstill\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.description.motion_group_model\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.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n get dhParameters() {\n return this.description.dh_parameters\n }\n\n get safetyZones() {\n return this.description.safety_zones\n }\n\n /** Gets the robot mounting position offset in 3D viz coordinates */\n get mountingPosition(): [number, number, number] {\n if (!this.description.mounting) {\n return [0, 0, 0]\n }\n\n return [\n (this.description.mounting.position?.[0] || 0) / 1000,\n (this.description.mounting.position?.[1] || 0) / 1000,\n (this.description.mounting.position?.[2] || 0) / 1000,\n ]\n }\n\n /** Gets the robot mounting position rotation in 3D viz coordinates */\n get mountingQuaternion() {\n const rotationVector = new THREE.Vector3(\n this.description.mounting?.orientation?.[0] || 0,\n this.description.mounting?.orientation?.[1] || 0,\n this.description.mounting?.orientation?.[2] || 0,\n )\n\n const magnitude = rotationVector.length()\n const axis = rotationVector.normalize()\n\n return new THREE.Quaternion().setFromAxisAngle(axis, magnitude)\n }\n\n /**\n * Whether the controller is currently in a safety state\n * corresponding to an emergency stop\n */\n get isEstopActive() {\n const estopStates: SafetyStateType[] = [\n \"SAFETY_STATE_ROBOT_EMERGENCY_STOP\",\n \"SAFETY_STATE_DEVICE_EMERGENCY_STOP\",\n ]\n\n return estopStates.includes(this.controllerState.safety_state)\n }\n\n /**\n * Whether the controller is in a safety state\n * that may be non-functional for robot pad purposes\n */\n get isMoveableSafetyState() {\n const goodSafetyStates: SafetyStateType[] = [\n \"SAFETY_STATE_NORMAL\",\n \"SAFETY_STATE_REDUCED\",\n ]\n\n return goodSafetyStates.includes(this.controllerState.safety_state)\n }\n\n /**\n * Whether the controller is in an operation mode that allows movement\n */\n get isMoveableOperationMode() {\n const goodOperationModes: OperationMode[] = [\n \"OPERATION_MODE_AUTO\",\n \"OPERATION_MODE_MANUAL\",\n \"OPERATION_MODE_MANUAL_T1\",\n \"OPERATION_MODE_MANUAL_T2\",\n ]\n\n return goodOperationModes.includes(this.controllerState.operation_mode)\n }\n\n /**\n * Whether the robot is currently active and can be moved, based on the\n * safety state, operation mode and servo toggle activation state.\n */\n get canBeMoved() {\n return (\n this.isMoveableSafetyState &&\n this.isMoveableOperationMode &&\n this.activationState === \"active\"\n )\n }\n\n async deactivate() {\n if (this.activationState !== \"active\") {\n console.error(\"Tried to deactivate while already deactivating\")\n return\n }\n\n runInAction(() => {\n this.activationState = \"deactivating\"\n })\n\n try {\n await this.nova.api.controller.setDefaultMode(\n this.controllerId,\n \"ROBOT_SYSTEM_MODE_MONITOR\",\n )\n\n runInAction(() => {\n this.activationState = \"inactive\"\n })\n } catch (err) {\n runInAction(() => {\n this.activationState = \"active\"\n })\n throw err\n }\n }\n\n async activate() {\n if (this.activationState !== \"inactive\") {\n console.error(\"Tried to activate while already activating\")\n return\n }\n\n runInAction(() => {\n this.activationState = \"activating\"\n })\n\n try {\n await this.nova.api.controller.setDefaultMode(\n this.controllerId,\n \"ROBOT_SYSTEM_MODE_CONTROL\",\n )\n\n runInAction(() => {\n this.activationState = \"active\"\n })\n } catch (err) {\n runInAction(() => {\n this.activationState = \"inactive\"\n })\n throw err\n }\n }\n\n toggleActivation() {\n if (this.activationState === \"inactive\") {\n this.activate()\n } else if (this.activationState === \"active\") {\n this.deactivate()\n }\n }\n\n dispose() {\n this.motionStateSocket.close()\n if (this.connectedJoggingSocket) this.connectedJoggingSocket.close()\n }\n\n setJoggingVelocity(velocity: number) {\n this.joggingVelocity = velocity\n }\n}\n","/** biome-ignore-all lint/suspicious/noExplicitAny: legacy code */\n/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport type {\n BaseAPI,\n Configuration as BaseConfiguration,\n} from \"@wandelbots/nova-api/v2\"\nimport {\n ApplicationApi,\n BUSInputsOutputsApi,\n CellApi,\n ControllerApi,\n ControllerInputsOutputsApi,\n JoggingApi,\n KinematicsApi,\n MotionGroupApi,\n MotionGroupModelsApi,\n StoreCollisionComponentsApi,\n StoreCollisionSetupsApi,\n StoreObjectApi,\n SystemApi,\n TrajectoryCachingApi,\n TrajectoryExecutionApi,\n TrajectoryPlanningApi,\n VirtualControllerApi,\n VirtualControllerBehaviorApi,\n VirtualControllerInputsOutputsApi,\n} from \"@wandelbots/nova-api/v2\"\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 motionGroupModels = this.withCellId(MotionGroupModelsApi)\n\n readonly controller = this.withCellId(ControllerApi)\n\n readonly controllerIOs = this.withCellId(ControllerInputsOutputsApi)\n\n readonly trajectoryPlanning = this.withCellId(TrajectoryPlanningApi)\n readonly trajectoryExecution = this.withCellId(TrajectoryExecutionApi)\n readonly trajectoryCaching = this.withCellId(TrajectoryCachingApi)\n\n readonly application = this.withCellId(ApplicationApi)\n readonly applicationGlobal = this.withUnwrappedResponsesOnly(ApplicationApi)\n\n readonly jogging = this.withCellId(JoggingApi)\n\n readonly kinematics = this.withCellId(KinematicsApi)\n\n readonly busInputsOutputs = this.withCellId(BUSInputsOutputsApi)\n\n readonly virtualController = this.withCellId(VirtualControllerApi)\n readonly virtualControllerBehavior = this.withCellId(\n VirtualControllerBehaviorApi,\n )\n readonly virtualControllerIOs = this.withCellId(\n VirtualControllerInputsOutputsApi,\n )\n\n readonly storeObject = this.withCellId(StoreObjectApi)\n readonly storeCollisionComponents = this.withCellId(\n StoreCollisionComponentsApi,\n )\n readonly storeCollisionSetups = this.withCellId(StoreCollisionSetupsApi)\n}\n","import type { MotionGroupState, RobotController } 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 * 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/:controllerId/state\",\n handle() {\n return {\n mode: \"MODE_CONTROL\",\n last_error: [],\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n controller: \"mock-ur5e\",\n operation_mode: \"OPERATION_MODE_AUTO\",\n safety_state: \"SAFETY_STATE_NORMAL\",\n velocity_override: 100,\n motion_groups: [\n {\n timestamp: \"2025-10-16T09:19:26.634534092Z\",\n sequence_number: 1054764,\n motion_group: \"0@mock-ur5e\",\n controller: \"mock-ur5e\",\n joint_position: [\n 1.487959623336792, -1.8501918315887451, 1.8003005981445312,\n 6.034560203552246, 1.4921919107437134, 1.593459963798523,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n joint_torque: [],\n joint_current: [0, 0, 0, 0, 0, 0],\n flange_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n tcp: \"Flange\",\n tcp_pose: {\n position: [\n 107.6452433732927, -409.0402987746852, 524.2402132330305,\n ],\n orientation: [\n 0.9874434028353319, -0.986571714997442, 1.3336589451098142,\n ],\n },\n payload: \"\",\n coordinate_system: \"\",\n standstill: true,\n },\n ],\n }\n },\n },\n // Add more mock requests here...\n {\n method: \"GET\",\n path: \"/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description\",\n handle() {\n return {\n motion_group_model: \"UniversalRobots_UR5e\",\n mounting: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n tcps: {\n Flange: {\n name: \"Default-Flange\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 0],\n },\n },\n \"complex-tcp-position\": {\n name: \"Complex TCP Position\",\n pose: {\n position: [-200, 300, 150],\n orientation: [\n -0.12139440409113832, -0.06356210998212003,\n -0.2023240068185639,\n ],\n },\n },\n \"offset-150mm-xy\": {\n name: \"-150mm XY Offset\",\n pose: {\n position: [-150, -150, 0],\n orientation: [0, 0, 0],\n },\n },\n \"rotated-90deg-z\": {\n name: \"90° Z Axis Rotation\",\n pose: {\n position: [0, 0, 0],\n orientation: [0, 0, 1.5708],\n },\n },\n },\n payloads: {\n \"FPay-0\": {\n name: \"FPay-0\",\n payload: 0,\n center_of_mass: [0, 0, 0],\n moment_of_inertia: [0, 0, 0],\n },\n },\n cycle_time: 8,\n dh_parameters: [\n {\n alpha: 1.5707963267948966,\n d: 162.25,\n },\n {\n a: -425,\n },\n {\n a: -392.2,\n },\n {\n alpha: 1.5707963267948966,\n d: 133.3,\n },\n {\n alpha: -1.5707963267948966,\n d: 99.7,\n },\n {\n d: 99.6,\n },\n ],\n operation_limits: {\n auto_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n elbow: {\n velocity: 5000,\n },\n flange: {\n velocity: 5000,\n },\n },\n manual_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t1_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n manual_t2_limits: {\n joints: [\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 150,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n {\n position: {\n lower_limit: -6.283185307179586,\n upper_limit: 6.283185307179586,\n },\n velocity: 3.34159255027771,\n acceleration: 40,\n torque: 28,\n },\n ],\n tcp: {\n velocity: 5000,\n },\n },\n },\n serial_number: \"WBVirtualRobot\",\n }\n },\n },\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 }\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 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 } // Mock motion group specification\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: [0, -Math.SQRT1_2, 0, Math.SQRT1_2],\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: [-Math.SQRT1_2, 0, 0, Math.SQRT1_2],\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 } // Mock safety setup\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 1.3492152690887451, -1.5659207105636597,\n 1.6653711795806885, -1.0991662740707397,\n -1.829018235206604, 1.264623761177063,\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 timestamp: new Date().toISOString(),\n sequence_number: 1,\n joint_position: [\n 1.1699999570846558, -1.5700000524520874, 1.3600000143051147,\n 1.0299999713897705, 1.2899999618530273, 1.2799999713897705,\n ],\n joint_limit_reached: {\n limit_reached: [false, false, false, false, false, false],\n },\n standstill: false,\n flange_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n tcp_pose: {\n position: [1.3300010259703043, -409.2680714682808, 531.0203477065281],\n orientation: [\n 1.7564919306270736, -1.7542521568325058, 0.7326972590614671,\n ],\n },\n } satisfies MotionGroupState,\n}\n","import type {\n MotionGroupDescription,\n MotionGroupState,\n RobotControllerState,\n} from \"@wandelbots/nova-api/v2\"\nimport { makeAutoObservable, runInAction } from \"mobx\"\nimport { Vector3 } from \"three\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson } from \"../converters\"\nimport { jointValuesEqual, tcpMotionEqual } from \"./motionStateUpdate\"\nimport type { NovaClient } from \"./NovaClient\"\nimport type { Vector3Simple } from \"./types/vector3\"\n\nconst MOTION_DELTA_THRESHOLD = 0.0001\n\nfunction unwrapRotationVector(\n newRotationVectorApi: Vector3Simple,\n currentRotationVectorApi: Vector3Simple,\n): Vector3Simple {\n const currentRotationVector = new Vector3(\n currentRotationVectorApi[0],\n currentRotationVectorApi[1],\n currentRotationVectorApi[2],\n )\n\n const newRotationVector = new 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 [...newAxis.multiplyScalar(newAngle)] as Vector3Simple\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 [_motionGroupIndex, controllerId] = motionGroupId.split(\"@\") as [\n string,\n string,\n ]\n\n const controller =\n await nova.api.controller.getCurrentRobotControllerState(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 `/controllers/${controllerId}/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 // Get the motion group description for later usage in jogging\n const description = await nova.api.motionGroup.getMotionGroupDescription(\n controllerId,\n motionGroup.motion_group,\n )\n\n return new MotionStreamConnection(\n nova,\n controller,\n motionGroup,\n description,\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: RobotControllerState,\n readonly motionGroup: MotionGroupState,\n readonly description: MotionGroupDescription,\n readonly initialMotionState: MotionGroupState,\n readonly motionStateSocket: AutoReconnectingWebsocket,\n ) {\n this.rapidlyChangingMotionState = initialMotionState\n\n motionStateSocket.addEventListener(\"message\", (event) => {\n const latestMotionState = tryParseJson(event.data)?.result as\n | MotionGroupState\n | undefined\n\n if (!latestMotionState) {\n throw new Error(\n `Failed to get motion state for ${this.motionGroupId}: ${event.data}`,\n )\n }\n\n // handle joint position changes\n if (\n !jointValuesEqual(\n this.rapidlyChangingMotionState.joint_position,\n latestMotionState.joint_position,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState = latestMotionState\n })\n }\n\n // handle tcp pose changes\n if (\n !tcpMotionEqual(\n this.rapidlyChangingMotionState,\n latestMotionState,\n MOTION_DELTA_THRESHOLD,\n )\n ) {\n runInAction(() => {\n if (this.rapidlyChangingMotionState.tcp_pose == null) {\n this.rapidlyChangingMotionState.tcp_pose =\n latestMotionState.tcp_pose\n } else if (\n latestMotionState.tcp_pose?.orientation &&\n latestMotionState.tcp_pose?.position &&\n this.rapidlyChangingMotionState.tcp_pose?.orientation\n ) {\n this.rapidlyChangingMotionState.tcp_pose = {\n position: latestMotionState.tcp_pose.position,\n orientation: unwrapRotationVector(\n latestMotionState.tcp_pose.orientation as Vector3Simple,\n this.rapidlyChangingMotionState.tcp_pose\n .orientation as Vector3Simple,\n ),\n }\n } else {\n console.warn(\n \"Received incomplete tcp_pose, ignoring\",\n latestMotionState.tcp_pose,\n )\n }\n })\n }\n\n // handle standstill changes\n if (\n this.rapidlyChangingMotionState.standstill !==\n latestMotionState.standstill\n ) {\n runInAction(() => {\n this.rapidlyChangingMotionState.standstill =\n latestMotionState.standstill\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 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.map((_, i) => {\n return {\n index: i,\n }\n })\n }\n\n dispose() {\n this.motionStateSocket.close()\n }\n}\n","import type {\n InitializeMovementResponse,\n MotionCommand,\n Pose,\n StartMovementResponse,\n} from \"@wandelbots/nova-api/v2\"\nimport { Vector3 } from \"three/src/math/Vector3.js\"\nimport { when } from \"mobx\"\nimport type { AutoReconnectingWebsocket } from \"../AutoReconnectingWebsocket\"\nimport { tryParseJson, XYZ_TO_VECTOR } from \"../converters\"\nimport type { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport type { NovaClient } from \"./NovaClient\"\nimport type { Vector3Simple } from \"./types/vector3\"\n\nexport type JoggerConnectionOptions = {\n // The mode of the jogger connection - see type description of JoggerMode for details\n mode?: JoggerMode\n\n // Connection timeout in milliseconds to wait for jogging initialization to complete\n timeout?: number\n\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\n // The TCP to use for jogging motions.\n tcp?: string\n\n // The coordinate system in which jogging takes place in\n // coordinateSystem?: string,\n\n // If set to \"tool\", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option\n orientation?: JoggerOrientation\n}\n\n// Three modes are supported:\n// - \"jogging\": Continuous jogging mode, where joint velocities or TCP velocities can be commanded. Opens a single websocket connection to jogging endpoint\n// - \"trajectory\": Incremental jogging mode, where fixed distance motions are planned and executed. Opens a short lived websocket for each motion.\n// - \"off\": No jogging, all websockets are closed.\nexport type JoggerMode = \"jogging\" | \"trajectory\" | \"off\"\n\nexport type JoggerOrientation = \"world\" | \"tool\"\n\nexport class JoggerConnection {\n ENDPOINT_JOGGING = \"/execution/jogging\"\n ENDPOINT_TRAJECTORY = \"/execution/trajectory\"\n DEFAULT_MODE = \"off\" as JoggerMode\n DEFAULT_TCP = \"Flange\"\n // DEFAULT_COORDINATE_SYSTEM = \"world\"\n DEFAULT_INIT_TIMEOUT = 5000\n DEFAULT_ORIENTATION = \"world\" as JoggerOrientation\n\n mode: JoggerMode = \"off\"\n joggingSocket: AutoReconnectingWebsocket | null = null\n trajectorySocket: AutoReconnectingWebsocket | null = null\n timeout: number = this.DEFAULT_INIT_TIMEOUT\n tcp: string\n // coordinateSystem?: string\n orientation: JoggerOrientation\n onError?: (err: unknown) => void\n\n /**\n * Initialize the jogging connection using jogging endpoint or trajectory endpoint depending on the selected mode.\n *\n * @param nova - The Nova client instance\n * @param motionGroupId - The ID of the motion group to connect to\n * @param options - Configuration options for the jogger connection\n * @param options.mode - The jogging mode to initialize:\n * - \"jogging\": Continuous jogging mode with persistent websocket for real-time velocity commands\n * - \"trajectory\": Incremental jogging mode for fixed-distance motions via trajectory planning\n * - \"off\": No jogging enabled, all websockets closed (default)\n * @param options.timeout - Timeout in milliseconds for websocket initialization (default: 5000ms)\n * @param options.tcp - TCP frame to use for motions (default: from motion group)\n * //param options.coordinateSystem - Coordinate system for jogging commands (default: \"world\"). Please note: Currently not implemented\n * @param options.orientation - If set to \"tool\", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option (default: \"world\")\n * @param options.onError - Error handler for websocket errors\n * @returns Promise resolving to initialized JoggerConnection instance\n */\n static async open(\n nova: NovaClient,\n motionGroupId: string,\n options: JoggerConnectionOptions = {},\n ) {\n // Get matching motion stream\n const motionStream = await nova.connectMotionStream(motionGroupId)\n\n // Initialize jogger with options\n const jogger = new JoggerConnection(motionStream, options)\n\n // Initialize the jogging websocket, if necessary (mode is \"jogging\")\n await jogger.setJoggingMode(jogger.mode)\n\n // Return the initialized jogger\n return jogger\n }\n\n constructor(\n readonly motionStream: MotionStreamConnection,\n readonly options: JoggerConnectionOptions | undefined = {},\n ) {\n this.tcp = options?.tcp || motionStream.motionGroup.tcp || this.DEFAULT_TCP\n // this.coordinateSystem = options?.coordinateSystem || this.DEFAULT_COORDINATE_SYSTEM\n this.orientation = options?.orientation || this.DEFAULT_ORIENTATION\n this.timeout = options?.timeout || this.DEFAULT_INIT_TIMEOUT\n this.mode = options?.mode || this.DEFAULT_MODE\n this.onError = options?.onError\n }\n\n // Set a new tcp or other options. If current mode is jogging, will reinitialize the jogging websocket\n async updateOptions(options: Partial<JoggerConnectionOptions>) {\n if (options.tcp) {\n this.tcp = options.tcp\n }\n\n // if (options.coordinateSystem) {\n // this.coordinateSystem = options.coordinateSystem\n // }\n\n if (options.timeout) {\n this.timeout = options.timeout\n }\n\n if (options.mode) {\n this.mode = options.mode\n }\n\n if (options.orientation) {\n this.orientation = options.orientation\n }\n\n if (options.onError) {\n this.onError = options.onError\n }\n\n this.setJoggingMode(this.mode, false)\n }\n\n get motionGroupId() {\n return this.motionStream.motionGroupId\n }\n\n get nova() {\n return this.motionStream.nova\n }\n\n get numJoints() {\n return this.motionStream.joints.length\n }\n\n // get activeJoggingMode() {\n // return this.mode\n // }\n\n // get activeWebsocket() {\n // return this.mode === \"jogging\" ? this.joggingSocket : this.trajectorySocket;\n // }\n\n // Sends stop movement command to robot\n async stop() {\n if (this.joggingSocket) {\n const velocity = new Array(this.numJoints).fill(0)\n this.joggingSocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity,\n })\n }\n\n if (this.trajectorySocket) {\n this.trajectorySocket.sendJson({\n message_type: \"PauseMovementRequest\",\n })\n }\n }\n\n // Dispose the jogger, closing all open websockets\n async dispose() {\n // Collect all initialized sockets\n const sockets = [this.joggingSocket, this.trajectorySocket].filter(\n (s) => s !== null,\n ) as AutoReconnectingWebsocket[]\n\n // Call them to dispose\n sockets.forEach((s) => {\n s.dispose()\n })\n\n // Remove references\n this.joggingSocket = null\n this.trajectorySocket = null\n\n // Return promise that resolves when all sockets are closed\n return Promise.all(sockets.map((s) => s.closed()))\n }\n\n // Activate jogger in one of the supported modes\n // Will iniitialize or close websockets as necessary\n // If mode is unchanged, does nothing (unless skipReinitializeIfSameMode is false)\n async setJoggingMode(mode: JoggerMode, skipReinitializeIfSameMode = true) {\n // If not changing mode, do nothing\n if (this.mode === mode && skipReinitializeIfSameMode) {\n return\n }\n\n // Close any previous websocket connection\n this.dispose()\n\n // Set the new mode\n this.mode = mode\n\n // Mode is \"jogging\" - open jogging websocket\n if (this.mode === \"jogging\") {\n return this.initializeJoggingWebsocket()\n }\n\n // Mode is \"trajectory\" or \"off\" - nothing more to do\n return\n }\n\n // Initializes continuous jogging websocket, called by setJoggingMode(\"jogging\")\n async initializeJoggingWebsocket() {\n // Wait for initialization with timeout\n return new Promise<void>((resolve, reject) => {\n const connectionFailedTimeout = setTimeout(() => {\n reject(\n new Error(\n `Jogging initialization timeout after ${this.timeout} seconds`,\n ),\n )\n }, this.timeout)\n\n this.joggingSocket = this.nova.openReconnectingWebsocket(\n this.ENDPOINT_JOGGING,\n )\n this.joggingSocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data)\n\n if (data?.result?.kind === \"INITIALIZE_RECEIVED\") {\n clearTimeout(connectionFailedTimeout)\n resolve()\n return\n }\n\n if (\n (data && \"error\" in data) ||\n data?.result?.kind === \"MOTION_ERROR\"\n ) {\n clearTimeout(connectionFailedTimeout)\n if (this.onError) {\n this.onError(ev.data)\n } else {\n reject(new Error(ev.data))\n }\n }\n })\n\n this.joggingSocket.sendJson({\n message_type: \"InitializeJoggingRequest\",\n motion_group: this.motionGroupId,\n tcp: this.tcp,\n // response_coordinate_system: this.coordinateSystem,\n })\n })\n }\n\n /**\n * Jogging: Start rotation of a single robot joint at the specified velocity\n */\n async rotateJoints({\n joint,\n direction,\n velocityRadsPerSec,\n }: {\n /** Index of the joint to rotate */\n joint: number\n /** Direction of rotation (\"+\" or \"-\") */\n direction: \"+\" | \"-\"\n /** Speed of the rotation in radians per second */\n velocityRadsPerSec: number\n }) {\n if (!this.joggingSocket || this.mode !== \"jogging\") {\n throw new Error(\n \"Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'\",\n )\n }\n\n const velocity = new Array(this.numJoints).fill(0)\n\n velocity[joint] =\n direction === \"-\" ? -velocityRadsPerSec : velocityRadsPerSec\n\n this.joggingSocket.sendJson({\n message_type: \"JointVelocityRequest\",\n velocity,\n })\n }\n\n /**\n * Jogging: Start the TCP moving along a specified axis at a given velocity\n */\n async translateTCP({\n axis,\n direction,\n velocityMmPerSec,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n direction: \"-\" | \"+\"\n velocityMmPerSec: number\n }) {\n if (!this.joggingSocket || this.mode !== \"jogging\") {\n throw new Error(\n \"Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'\",\n )\n }\n\n const rotation = [0, 0, 0]\n const translation = [0, 0, 0]\n translation[XYZ_TO_VECTOR[axis]] =\n direction === \"-\" ? -velocityMmPerSec : velocityMmPerSec\n\n this.joggingSocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n translation,\n rotation,\n use_tool_coordinate_system: this.orientation === \"tool\",\n })\n }\n\n /**\n * Jogging: Start the TCP rotating around a specified axis at a given velocity\n */\n async rotateTCP({\n axis,\n direction,\n velocityRadsPerSec,\n }: {\n axis: \"x\" | \"y\" | \"z\"\n direction: \"-\" | \"+\"\n velocityRadsPerSec: number\n }) {\n if (!this.joggingSocket || this.mode !== \"jogging\") {\n throw new Error(\n \"Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'\",\n )\n }\n const rotation = [0, 0, 0]\n const translation = [0, 0, 0]\n rotation[XYZ_TO_VECTOR[axis]] =\n direction === \"-\" ? -velocityRadsPerSec : velocityRadsPerSec\n\n this.joggingSocket.sendJson({\n message_type: \"TcpVelocityRequest\",\n translation,\n rotation,\n })\n }\n\n /**\n * Trajectory jogging:\n *\n * Move the robot by a fixed distance in a single cartesian\n * axis, either rotating or translating relative to the TCP.\n * Promise resolves only after the motion has completed.\n */\n async runIncrementalCartesianMotion({\n currentTcpPose,\n currentJoints,\n coordSystemId,\n velocityInRelevantUnits,\n axis,\n direction,\n motion,\n }: {\n currentTcpPose: Pose\n currentJoints: Vector3Simple\n coordSystemId: string\n velocityInRelevantUnits: number\n axis: \"x\" | \"y\" | \"z\"\n direction: \"-\" | \"+\"\n motion:\n | {\n type: \"rotate\"\n distanceRads: number\n }\n | {\n type: \"translate\"\n distanceMm: number\n }\n }) {\n const commands: MotionCommand[] = []\n\n if (this.mode !== \"trajectory\") {\n throw new Error(\n \"Set jogging mode to 'trajectory' to run incremental cartesian motions\",\n )\n }\n\n if (motion.type === \"translate\") {\n if (!currentTcpPose.position) {\n throw new Error(\n \"Current pose has no position, cannot perform translation\",\n )\n }\n\n const targetTcpPosition = [...currentTcpPose.position]\n targetTcpPosition[XYZ_TO_VECTOR[axis]] +=\n motion.distanceMm * (direction === \"-\" ? -1 : 1)\n\n commands.push({\n limits_override: {\n tcp_velocity_limit: velocityInRelevantUnits,\n },\n path: {\n path_definition_name: \"PathLine\",\n target_pose: {\n position: targetTcpPosition,\n orientation: currentTcpPose.orientation,\n },\n },\n })\n } else if (motion.type === \"rotate\") {\n // Concatenate rotations expressed by rotation vectors\n // Equations taken from https://physics.stackexchange.com/a/287819\n\n if (!currentTcpPose.orientation) {\n throw new Error(\n \"Current pose has no orientation, cannot perform rotation\",\n )\n }\n\n // Compute axis and angle of current rotation vector\n const currentRotationVector = new Vector3(\n currentTcpPose.orientation[0],\n currentTcpPose.orientation[1],\n currentTcpPose.orientation[2],\n )\n\n const currentRotationRad = currentRotationVector.length()\n const currentRotationDirection = currentRotationVector.clone().normalize()\n\n // Compute axis and angle of difference rotation vector\n const differenceRotationRad =\n motion.distanceRads * (direction === \"-\" ? -1 : 1)\n\n const differenceRotationDirection = new Vector3(0.0, 0.0, 0.0)\n differenceRotationDirection[axis] = 1.0\n\n // Some abbreviations to make the following equations more readable\n const f1 =\n Math.cos(0.5 * differenceRotationRad) *\n Math.cos(0.5 * currentRotationRad)\n const f2 =\n Math.sin(0.5 * differenceRotationRad) *\n Math.sin(0.5 * currentRotationRad)\n const f3 =\n Math.sin(0.5 * differenceRotationRad) *\n Math.cos(0.5 * currentRotationRad)\n const f4 =\n Math.cos(0.5 * differenceRotationRad) *\n Math.sin(0.5 * currentRotationRad)\n\n const dotProduct = differenceRotationDirection.dot(\n currentRotationDirection,\n )\n\n const crossProduct = differenceRotationDirection\n .clone()\n .cross(currentRotationDirection)\n\n // Compute angle of concatenated rotation\n const newRotationRad = 2.0 * Math.acos(f1 - f2 * dotProduct)\n\n // Compute rotation vector of concatenated rotation\n const f5 = newRotationRad / Math.sin(0.5 * newRotationRad)\n\n const targetTcpOrientation = new Vector3()\n .addScaledVector(crossProduct, f2)\n .addScaledVector(differenceRotationDirection, f3)\n .addScaledVector(currentRotationDirection, f4)\n .multiplyScalar(f5)\n\n commands.push({\n limits_override: {\n tcp_orientation_velocity_limit: velocityInRelevantUnits,\n },\n path: {\n path_definition_name: \"PathLine\",\n target_pose: {\n position: currentTcpPose.position,\n orientation: [...targetTcpOrientation],\n },\n },\n })\n }\n\n // Plan the motion https://portal.wandelbots.io/docs/api/v2/ui/#/operations/planTrajectory\n const description = this.motionStream.description\n if (description.cycle_time === undefined) {\n console.warn(\n \"Current motion group has no cycle time, cannot plan jogging motion\",\n )\n return\n }\n\n const motion_group_setup = {\n motion_group_model: description.motion_group_model,\n cycle_time: description.cycle_time,\n mounting: description.mounting,\n\n // tcp_offset: description.tcp_offset, TODO: implement tcp_offset handling\n // FIXME use proper mode's limits if set\n global: description.operation_limits.auto_limits,\n }\n\n const motionPlanRes = await this.nova.api.trajectoryPlanning.planTrajectory(\n {\n motion_group_setup,\n start_joint_position: currentJoints,\n motion_commands: commands,\n },\n )\n\n const trajectoryData = motionPlanRes.response\n if (!trajectoryData) {\n throw new Error(\n `Failed to plan jogging increment motion ${JSON.stringify(motionPlanRes)}`,\n )\n }\n\n if (this.trajectorySocket) {\n console.warn(\"Trajectory jogging websocket already open; will close\")\n this.trajectorySocket.dispose()\n }\n\n // Execute the planned motion https://portal.wandelbots.io/docs/api/v2/ui/#/operations/executeTrajectory\n this.trajectorySocket = this.nova.openReconnectingWebsocket(\n this.ENDPOINT_TRAJECTORY,\n )\n\n const messageInitializeMovementResponse = (\n result: InitializeMovementResponse | undefined,\n ) => {\n // Handle errorous response\n if (!result || result.add_trajectory_error || result.message) {\n if (this.onError) {\n this.onError(result)\n } else {\n throw new Error(\n result?.add_trajectory_error?.message ||\n result?.message ||\n \"Failed to execute trajectory, unknown error\",\n )\n }\n }\n\n // Handle socket gone\n if (!this.trajectorySocket) {\n throw new Error(\n `Failed to execute trajectory, websocket not available anymore`,\n )\n }\n\n // Trajectory locked, now start movement\n this.trajectorySocket.sendJson({\n message_type: \"StartMovementRequest\",\n direction: \"DIRECTION_FORWARD\",\n })\n }\n\n const waitForMovementToStartAndFinish = async () => {\n // Wait for robot to start moving (standstill becomes false)\n await when(() => !this.motionStream.rapidlyChangingMotionState.standstill)\n\n // Then wait for robot to stop moving (standstill becomes true)\n await when(() => this.motionStream.rapidlyChangingMotionState.standstill)\n\n // Close connection and free robot\n this.trajectorySocket?.dispose()\n this.trajectorySocket = null\n }\n\n const waitForMovementToFinish = async () => {\n // Wait for robot to stop moving (standstill becomes true)\n await when(() => this.motionStream.rapidlyChangingMotionState.standstill)\n\n // Close connection and free robot\n this.trajectorySocket?.dispose()\n this.trajectorySocket = null\n }\n\n const messageStartMovementResponse = async (\n data: StartMovementResponse,\n ) => {\n if (data?.message) {\n if (this.onError) {\n this.onError(data)\n return\n } else {\n throw new Error(\n data.message || \"Failed to execute trajectory, unknown error\",\n )\n }\n }\n\n // Movement started we now wait to verify the robot is moving\n // by observing changes to motion state\n if (this.motionStream.rapidlyChangingMotionState.standstill) {\n await waitForMovementToStartAndFinish()\n } else {\n await waitForMovementToFinish()\n }\n }\n\n this.trajectorySocket.addEventListener(\"message\", (ev: MessageEvent) => {\n const data = tryParseJson(ev.data)\n\n if (!data?.result?.kind) {\n throw new Error(\n `Failed to execute trajectory: Received invalid message ${ev.data}`,\n )\n }\n\n if (data.result.kind === \"INITIALIZE_RECEIVED\") {\n messageInitializeMovementResponse(data.result)\n } else if (data.result.kind === \"START_RECEIVED\") {\n messageStartMovementResponse(data)\n } else {\n throw new Error(\n `Failed to execute trajectory, cannot handle message type \"${data.result.kind}\"`,\n )\n }\n })\n\n // Send initialization/movement request\n this.trajectorySocket.sendJson({\n message_type: \"InitializeMovementRequest\",\n trajectory: {\n message_type: \"TrajectoryData\",\n motion_group: this.motionGroupId,\n data: trajectoryData,\n tcp: this.tcp,\n },\n })\n }\n}\n","/** biome-ignore-all lint/style/noNonNullAssertion: legacy code */\nimport 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 { MockNovaInstance } from \"./mock/MockNovaInstance\"\nimport { NovaCellAPIClient } from \"./NovaCellAPIClient\"\nimport { MotionStreamConnection } from \"./MotionStreamConnection\"\nimport { JoggerConnection, type JoggerConnectionOptions } from \"./JoggerConnection\"\nimport { ConnectedMotionGroup } from \"./ConnectedMotionGroup\"\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\nfunction permissiveInstanceUrlParse(url: string): string {\n if (!url.startsWith(\"http\")) {\n url = `http://${url}`\n }\n\n return new URL(url).toString()\n}\n\n/**\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 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 } else {\n this.config.instanceUrl = permissiveInstanceUrlParse(\n this.config.instanceUrl,\n )\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/v2\"),\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/v2/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 /**\n * Connect to the jogging websocket(s) for a given motion group\n */\n async connectJogger(\n motionGroupId: string,\n options: JoggerConnectionOptions = {},\n ) {\n return await JoggerConnection.open(this, motionGroupId, options)\n }\n\n async connectMotionGroups(\n motionGroupIds: string[],\n ): Promise<ConnectedMotionGroup[]> {\n return Promise.all(\n motionGroupIds.map((motionGroupId) =>\n ConnectedMotionGroup.connect(this, motionGroupId),\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 { Pose } from \"@wandelbots/nova-api/v2\"\n\n/**\n * Convert a Pose object representing a motion group position\n * into a string which represents that pose in Wandelscript.\n */\nexport function poseToWandelscriptString(\n pose: Pick<Pose, \"position\" | \"orientation\">,\n) {\n const position = [\n pose.position?.[0] ?? 0,\n pose.position?.[1] ?? 0,\n pose.position?.[2] ?? 0,\n ]\n\n const orientation = [\n pose.orientation?.[0] ?? 0,\n pose.orientation?.[1] ?? 0,\n pose.orientation?.[2] ?? 0,\n ]\n\n const positionValues = position.map((v) => v.toFixed(1))\n // Rotation needs more precision since it's in radians\n const rotationValues = orientation.map((v) => v.toFixed(4))\n\n return `(${positionValues.concat(rotationValues).join(\", \")})`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA,SAAgB,iBACd,gBACA,gBACA,sBACS;AACT,KAAI,eAAe,WAAW,e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AAO;QACP,GAAG;QACJ;OACD;QACE,OAAO;QACP,GAAG;QACJ;OACD,EACE,GAAG,MACJ;OACF;MACD,kBAAkB;OAChB,aAAa;QACX,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACD,OAAO,EACL,UAAU,KACX;QACD,QAAQ,EACN,UAAU,KACX;QACF;OACD,eAAe;QACb,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACD,kBAAkB;QAChB,QAAQ;SACN;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACD;UACE,UAAU;WACR,aAAa;WACb,aAAa;WACd;UACD,UAAU;UACV,cAAc;UACd,QAAQ;UACT;SACF;QACD,KAAK,EACH,UAAU,KACX;QACF;OACF;MACD,eAAe;MAChB;;IAEJ;GACD;IACE,QAAQ;IACR,MAAM;IACN,SAAS;AACP,YAAO,EACL,aAAa,CACX;MACE,YAAY;MACZ,YAAY;MACZ,MAAM;MACN,sCAAsC;MACtC,eAAe,CACb;OACE,cAAc;OACd,sBAAsB;OACtB,QAAQ;OACR,uBAAuB;OACxB,CACF;MACD,WAAW;MACX,eAAe;MAChB,CACF,EACF;;IAEJ;GACD;IACE,QAAQ;IACR,MAAM;IACN,SAAS;AACP,YAAO;MACL,eAAe;OACb,MAAM;OACN,cAAc;OACd,MAAM;OACP;MACD,MAAM;MACP;;IAEJ;GACD;IACE,QAAQ;IACR,MAAM;IACN,SAAS;AACP,YAAO;MACL,eAAe;OACb;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACD;QACE,OAAO;QACP,OAAO;QACP,GAAG;QACH,GAAG;QACH,4BAA4B;QAC7B;OACF;MACD,yBAAyB;OACvB;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACD;QACE,OAAO;QACP,aAAa;QACb,aAAa;QACb,WAAW;QACZ;OACF;MACF;;IAEJ;GACD;IACE,QAAQ;IACR,MAAM;IACN,SAAS;AACP,YAAO;MACL,iBAAiB,CACf;OACE,cAAc;OACd,UAAU;QACR,uBAAuB;SACrB;UACE,OAAO;UACP,aAAa;UACb,aAAa;UACb,W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