@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.chore-public-names.673.cb7ee37

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 (196) hide show
  1. package/README.md +255 -122
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +7 -3
  4. package/dist/3d.js +20 -20
  5. package/dist/CurrentPoseBar/index.cjs +1 -0
  6. package/dist/CurrentPoseBar/index.d.ts +2 -0
  7. package/dist/CurrentPoseBar/index.js +5 -0
  8. package/dist/JoggingButtons/index.cjs +1 -0
  9. package/dist/JoggingButtons/index.d.ts +3 -0
  10. package/dist/JoggingButtons/index.js +5 -0
  11. package/dist/JoggingGizmo/index.cjs +1 -0
  12. package/dist/JoggingGizmo/index.d.ts +5 -0
  13. package/dist/JoggingGizmo/index.js +6 -0
  14. package/dist/JoggingJointSlider/index.cjs +1 -0
  15. package/dist/JoggingJointSlider/index.d.ts +2 -0
  16. package/dist/JoggingJointSlider/index.js +5 -0
  17. package/dist/SafetyBar/index.cjs +1 -1
  18. package/dist/SafetyBar/index.js +1 -1
  19. package/dist/chunks/ConnectedMotionGroup-D9JJSyXB.js +1822 -0
  20. package/dist/chunks/ConnectedMotionGroup-ir7Vf690.cjs +3 -0
  21. package/dist/chunks/CurrentPoseBar-Cbz4AO36.cjs +1 -0
  22. package/dist/chunks/CurrentPoseBar-CpwvWpEY.js +619 -0
  23. package/dist/chunks/JoggingButtons-i8FdMpCx.js +108 -0
  24. package/dist/chunks/JoggingButtons-paQCBXf4.cjs +1 -0
  25. package/dist/chunks/JoggingGizmoOrientation-CKZeLcMp.js +893 -0
  26. package/dist/chunks/JoggingGizmoOrientation-EPtBeAun.cjs +1 -0
  27. package/dist/chunks/JoggingJointSlider-DQhJOmcc.js +378 -0
  28. package/dist/chunks/JoggingJointSlider-YcEBMgF1.cjs +1 -0
  29. package/dist/chunks/Pose3-Ci1bxEvz.js +1373 -0
  30. package/dist/chunks/Pose3-DwMOSTKO.cjs +1 -0
  31. package/dist/chunks/SafetyBar-Be1c6Vz9.cjs +1 -0
  32. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-WXLP3Yi0.js} +34 -32
  33. package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-7OVHUIUh.js} +84 -134
  34. package/dist/chunks/externalizeComponent-B0n_tR3v.cjs +2 -0
  35. package/dist/chunks/holdSafety-Cbej6-Kc.js +62 -0
  36. package/dist/chunks/holdSafety-TeMXlYQe.cjs +1 -0
  37. package/dist/chunks/joggingColors-BKRoSGQu.js +132 -0
  38. package/dist/chunks/joggingColors-BkPm75Hr.cjs +1 -0
  39. package/dist/chunks/json-3cqBD7UQ.js +18 -0
  40. package/dist/chunks/json-Bd6uGfgP.cjs +1 -0
  41. package/dist/chunks/loadRobotSession-Bt1-Brjp.js +3761 -0
  42. package/dist/chunks/loadRobotSession-DHVuK_pj.cjs +1 -0
  43. package/dist/chunks/novaConnection-BTSIgWd1.cjs +1 -0
  44. package/dist/chunks/novaConnection-J6_ohIQ0.js +14 -0
  45. package/dist/chunks/poseText-BXUaQWnK.cjs +1 -0
  46. package/dist/chunks/poseText-CtdXIeT_.js +41 -0
  47. package/dist/chunks/useSmoothedMotionState-C_Vo0py0.js +202 -0
  48. package/dist/chunks/useSmoothedMotionState-Ce9NjwBu.cjs +1 -0
  49. package/dist/components/AppHeader.d.ts +1 -1
  50. package/dist/components/VelocitySlider.d.ts +6 -1
  51. package/dist/components/currentPoseBar/CurrentPoseBar.d.ts +48 -0
  52. package/dist/components/currentPoseBar/OrientationFormatPopover.d.ts +19 -0
  53. package/dist/components/currentPoseBar/StreamStatus.d.ts +10 -0
  54. package/dist/components/currentPoseBar/orientation.d.ts +34 -0
  55. package/dist/components/currentPoseBar/poseValues.d.ts +15 -0
  56. package/dist/components/jogging/JoggingButtons.d.ts +18 -0
  57. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +8 -2
  58. package/dist/components/jogging/JoggingCartesianTab.d.ts +3 -0
  59. package/dist/components/jogging/JoggingJointTab.d.ts +4 -1
  60. package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
  61. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  62. package/dist/components/jogging/JoggingRefusedError.d.ts +24 -0
  63. package/dist/components/jogging/JoggingStore.d.ts +382 -40
  64. package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +53 -0
  65. package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +26 -0
  66. package/dist/components/jogging/gizmo/RotationHandles.d.ts +7 -0
  67. package/dist/components/jogging/gizmo/RotationScene.d.ts +6 -0
  68. package/dist/components/jogging/gizmo/TranslationHandles.d.ts +6 -0
  69. package/dist/components/jogging/gizmo/TranslationScene.d.ts +6 -0
  70. package/dist/components/jogging/gizmo/arcGrabAreas.d.ts +58 -0
  71. package/dist/components/jogging/gizmo/arcs.d.ts +54 -0
  72. package/dist/components/jogging/gizmo/arrows.d.ts +63 -0
  73. package/dist/components/jogging/gizmo/gizmoShared.d.ts +135 -0
  74. package/dist/components/jogging/gizmo/gizmoView.d.ts +42 -0
  75. package/dist/components/jogging/gizmo/useGizmoTurn.d.ts +11 -0
  76. package/dist/components/jogging/holdSafety.d.ts +82 -0
  77. package/dist/components/jogging/jogError.d.ts +9 -0
  78. package/dist/components/jogging/jogHandle.d.ts +23 -0
  79. package/dist/components/jogging/joggingColors.d.ts +30 -0
  80. package/dist/components/jogging/joggingVelocity.d.ts +21 -0
  81. package/dist/components/jogging/joint/JoggingJointSlider.d.ts +56 -0
  82. package/dist/components/jogging/joint/JointSliderTrack.d.ts +27 -0
  83. package/dist/components/jogging/joint/jointJog.d.ts +55 -0
  84. package/dist/components/jogging/joint/useJointJogHold.d.ts +43 -0
  85. package/dist/components/jogging/useHold.d.ts +42 -0
  86. package/dist/components/jogging/useJogControls.d.ts +44 -0
  87. package/dist/components/robotControl/PanelSelect.d.ts +13 -0
  88. package/dist/components/robotControl/SmallSelect.d.ts +15 -0
  89. package/dist/components/robotControl/poseText.d.ts +43 -0
  90. package/dist/components/robotControl/robotControlTypes.d.ts +36 -0
  91. package/dist/components/robotControl/useCopyText.d.ts +12 -0
  92. package/dist/components/robotControl/useEveryFrame.d.ts +6 -0
  93. package/dist/components/robots/GenericRobot.d.ts +2 -1
  94. package/dist/components/robots/LinearAxis.d.ts +1 -1
  95. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  96. package/dist/components/robots/Robot.d.ts +1 -1
  97. package/dist/components/robots/robotModelLogic.d.ts +11 -9
  98. package/dist/components/utils/converters.d.ts +0 -2
  99. package/dist/components/utils/hooks.d.ts +1 -6
  100. package/dist/components/utils/json.d.ts +4 -0
  101. package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
  102. package/dist/components/utils/useWebGLRenderer.d.ts +32 -0
  103. package/dist/components/utils/webglSupport.d.ts +11 -0
  104. package/dist/core.cjs +1 -1
  105. package/dist/core.d.ts +28 -20
  106. package/dist/core.js +57 -54
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.js +73 -70
  109. package/dist/lib/ConnectedMotionGroup.d.ts +9 -8
  110. package/dist/lib/ControllerStateStream.d.ts +125 -0
  111. package/dist/lib/JoggerConnection.d.ts +172 -27
  112. package/dist/lib/MotionStreamConnection.d.ts +16 -6
  113. package/dist/lib/Pose3.d.ts +22 -0
  114. package/dist/lib/PoseTransformer.d.ts +44 -0
  115. package/dist/lib/TrajectoryExecutionStore.d.ts +260 -0
  116. package/dist/lib/connectionLogger.d.ts +9 -0
  117. package/dist/lib/controllerStateSource.d.ts +38 -0
  118. package/dist/lib/incrementalCartesianMotion.d.ts +40 -0
  119. package/dist/lib/motionGroupModelResources.d.ts +1 -0
  120. package/dist/lib/motionStateUpdate.d.ts +44 -0
  121. package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
  122. package/dist/lib/novaConnection.d.ts +23 -0
  123. package/dist/lib/planErrorTranslation.d.ts +8 -0
  124. package/dist/lib/poseMath.d.ts +51 -0
  125. package/dist/lib/robotSession/RobotActivation.d.ts +90 -0
  126. package/dist/lib/robotSession/RobotDescription.d.ts +84 -0
  127. package/dist/lib/robotSession/RobotLiveState.d.ts +65 -0
  128. package/dist/lib/robotSession/RobotLoadProgress.d.ts +72 -0
  129. package/dist/lib/robotSession/RobotSafety.d.ts +59 -0
  130. package/dist/lib/robotSession/RobotSession.d.ts +117 -0
  131. package/dist/lib/robotSession/RobotTargetPose.d.ts +116 -0
  132. package/dist/lib/robotSession/loadRobotResources.d.ts +46 -0
  133. package/dist/lib/robotSession/loadRobotSession.d.ts +81 -0
  134. package/dist/lib/robotSession/robotPose.d.ts +27 -0
  135. package/dist/lib/rotation.d.ts +12 -0
  136. package/dist/nats.cjs +1 -0
  137. package/dist/nats.d.ts +4 -0
  138. package/dist/nats.js +131 -0
  139. package/dist/session.cjs +1 -0
  140. package/dist/session.d.ts +22 -0
  141. package/dist/session.js +33 -0
  142. package/package.json +68 -66
  143. package/dist/Setup.d.ts +0 -11
  144. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  145. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  146. package/dist/chunks/SafetyBar-DPrv_OQA.cjs +0 -1
  147. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  148. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  149. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  150. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  151. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  152. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
  153. package/dist/components/AdornedTextField.d.ts +0 -7
  154. package/dist/components/CopyableText.d.ts +0 -6
  155. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  156. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  157. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  158. package/dist/components/CycleTimer/index.d.ts +0 -27
  159. package/dist/components/CycleTimer/types.d.ts +0 -49
  160. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  161. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  162. package/dist/components/CycleTimer/utils.d.ts +0 -21
  163. package/dist/components/CycleTimer.d.ts +0 -3
  164. package/dist/components/DataGrid.d.ts +0 -66
  165. package/dist/components/LogPanel.d.ts +0 -38
  166. package/dist/components/LogStore.d.ts +0 -12
  167. package/dist/components/LogViewer.d.ts +0 -46
  168. package/dist/components/ProgramControl.d.ts +0 -55
  169. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  170. package/dist/components/RobotCard.d.ts +0 -98
  171. package/dist/components/RobotListItem.d.ts +0 -34
  172. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  173. package/dist/components/SelectableFab.d.ts +0 -7
  174. package/dist/components/TabBar.d.ts +0 -45
  175. package/dist/components/ThemeSelect.d.ts +0 -6
  176. package/dist/components/Timer/Timer.d.ts +0 -3
  177. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  178. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  179. package/dist/components/Timer/index.d.ts +0 -19
  180. package/dist/components/Timer/types.d.ts +0 -35
  181. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  182. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  183. package/dist/components/Timer/utils.d.ts +0 -17
  184. package/dist/components/Timer.d.ts +0 -3
  185. package/dist/components/TransparentOverlay.d.ts +0 -4
  186. package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
  187. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  188. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  189. package/dist/components/robots/AxisConfig.d.ts +0 -2
  190. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  191. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  192. package/dist/icons/index.d.ts +0 -12
  193. package/dist/lib/novaCompat.d.ts +0 -16
  194. package/dist/themes/createDarkTheme.d.ts +0 -7
  195. package/dist/themes/themeTypes.d.ts +0 -40
  196. package/dist/themes/theming.d.ts +0 -24
@@ -0,0 +1 @@
1
+ "use strict";const I=require("@wandelbots/nova-js"),u=require("mobx"),It=require("./json-Bd6uGfgP.cjs"),O=require("./novaConnection-BTSIgWd1.cjs"),Et=require("axios"),C=require("@wandelbots/nova-js/v2"),T=require("lodash-es"),b=require("./poseText-BXUaQWnK.cjs");function ie(i){switch(i.code){case"locked":return"jogging is locked";case"blocked":return"another client holds the jogging connection";case"disconnected":return"the robot's live state stopped coming";case"safety_state":return`the safety state is ${i.value}`;case"operation_mode":return`the operation mode is ${i.value}`;case"deactivated":return"the robot is not activated"}}class N extends Error{constructor(t){super(`Jogging refused: ${ie(t)}`),this.name="JoggingRefusedError",this.reason=t}}const K={x:0,y:0,z:0,w:1},ne={x:0,y:1,z:2};function D([i,t,e]){return Math.sqrt(i*i+t*t+e*e)}function k([i,t,e],o){return[i*o,t*o,e*o]}function H(i){return k(i,1/(D(i)||1))}function se(i,t){return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]}function tt(i,t){const e=[0,0,0];return e[ne[i]]=t,e}function A([i,t,e],{x:o,y:n,z:s,w:r}){const a=2*(n*e-s*t),d=2*(s*i-o*e),c=2*(o*t-n*i);return[i+r*a+n*c-s*d,t+r*d+s*a-o*c,e+r*c+o*d-n*a]}function wt(i,t){const e=t/2,o=Math.sin(e);return{x:i[0]*o,y:i[1]*o,z:i[2]*o,w:Math.cos(e)}}function et(i,t){return{x:i.x*t.w+i.w*t.x+i.y*t.z-i.z*t.y,y:i.y*t.w+i.w*t.y+i.z*t.x-i.x*t.z,z:i.z*t.w+i.w*t.z+i.x*t.y-i.y*t.x,w:i.w*t.w-i.x*t.x-i.y*t.y-i.z*t.z}}function re(i){const{x:t,y:e,z:o,w:n}=i,s=Math.sqrt(t*t+e*e+o*o+n*n);if(s===0)return K;const r=1/s;return{x:t*r,y:e*r,z:o*r,w:n*r}}function ae({x:i,y:t,z:e,w:o}){return{x:-i,y:-t,z:-e,w:o}}function z(i,t){if(t==="QUATERNION"&&i){const[e=0,o=0,n=0,s=1]=i;return{x:e,y:o,z:n,w:s}}if(t==="ROTATION_VECTOR"&&i){if(i.length<3)throw new Error(`Invalid rotation vector length: ${i.length}. Expected at least 3 values.`);const[e=0,o=0,n=0]=i,s=[e,o,n];return wt(H(s),D(s))}return console.warn(`Unsupported rotation type '${t}'. Only QUATERNION and ROTATION_VECTOR are supported for now.`),K}function jt({x:i,y:t,z:e,w:o}){const n=[i,t,e],s=2*Math.atan2(D(n),Math.abs(o)),r=(o>=0?1:0)-(o<0?1:0);return k(k(H(n),r),s)}function Tt(i){return[(i==null?void 0:i[0])??0,(i==null?void 0:i[1])??0,(i==null?void 0:i[2])??0]}function vt(i){return{position:Tt(i.position),quaternion:i.orientation?z(i.orientation,"ROTATION_VECTOR"):K}}function R(i){return{position:Tt(i.position),quaternion:i.orientation?z(i.orientation,i.orientation_type??"ROTATION_VECTOR"):K}}function L(i,t){const e=A(t.position,i.quaternion);return{position:[i.position[0]+e[0],i.position[1]+e[1],i.position[2]+e[2]],quaternion:re(et(i.quaternion,t.quaternion))}}function Mt(i){const t=ae(i.quaternion);return{position:k(A(i.position,t),-1),quaternion:t}}function ce({currentTcpPose:i,axis:t,direction:e,motion:o,useToolCoordinateSystem:n,coordinateSystemRotation:s}){const r=e==="-"?-1:1;if(o.type==="translate"){if(!i.position)throw new Error("Current pose has no position, cannot perform translation");let h=tt(t,o.distanceMm*r);if(n){if(!i.orientation)throw new Error("Current pose has no orientation, cannot translate relative to tool");h=A(h,z(i.orientation,"ROTATION_VECTOR"))}else s&&(h=A(h,s));const g=[...i.position];return g[0]=(g[0]??0)+h[0],g[1]=(g[1]??0)+h[1],g[2]=(g[2]??0)+h[2],{position:g,orientation:i.orientation}}if(!i.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const a=z(i.orientation,"ROTATION_VECTOR");let d=tt(t,1);!n&&s&&(d=A(d,s));const c=wt(d,o.distanceRads*r),l=n?et(a,c):et(c,a);return{position:i.position,orientation:jt(l)}}function $(i,t,e){return t.length!==i.length?!1:Ct(i,t,e)}function Ot(i,t,e){return t.length!==i.length?!0:Ct(i,t,e)}function Ct(i,t,e){for(let o=0;o<t.length;o++)if(Math.abs((t[o]??0)-(i[o]??0))>e)return!1;return!0}function Rt(i,t,e){if(i===void 0&&t||i&&t===void 0||(i==null?void 0:i.orientation)===void 0||(t==null?void 0:t.orientation)===void 0||(i==null?void 0:i.position)===void 0||(t==null?void 0:t.position)===void 0)return!1;if(i===void 0||t===void 0)return!0;let o=0;return o+=Math.abs(i.orientation[0]-t.orientation[0]),o+=Math.abs(i.orientation[1]-t.orientation[1]),o+=Math.abs(i.orientation[2]-t.orientation[2]),o+=Math.abs(i.position[0]-t.position[0]),o+=Math.abs(i.position[1]-t.position[1]),o+=Math.abs(i.position[2]-t.position[2]),o<=e}function bt(i,t,e){return i.coordinate_system===t.coordinate_system&&i.tcp===t.tcp&&Rt(i.tcp_pose,t.tcp_pose,e)}function at(i,t){const[e=0,o=0,n=0]=t,s=[e,o,n],[r=0,a=0,d=0]=i,c=[r,a,d],l=D(s),h=H(s);let g=D(c),y=H(c);se(y,h)<0&&(g=-g,y=k(y,-1));let m=g-l;return m-=2*Math.PI*Math.floor((m+Math.PI)/(2*Math.PI)),g=l+m,k(y,g)}const le=2e-4;function Pt(i){const{joint_position:t,tcp_pose:e,tcp:o,coordinate_system:n}=i;return{joint_position:t,tcp_pose:e,tcp:o,coordinate_system:n}}function At(i,t){return i.tcp===t.tcp&&i.coordinate_system===t.coordinate_system&&i.tcp_pose===void 0==(t.tcp_pose===void 0)&&$(i.joint_position,t.joint_position,le)}const ht=1e-4;class V{constructor(t,e,o,n,s,r,a="cell",d={}){this.controller=e,this.motionGroup=o,this.description=n,this.initialMotionState=s,this.motionStateSocket=r,this.cellId=a,this.nova=O.createNovaClient(t),this.logger=d.logger??console,this.rapidlyChangingMotionState=s,r.addEventListener("message",c=>{var y;const l=(y=I.tryParseJson(c.data))==null?void 0:y.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${c.data}`);bt(this.rapidlyChangingMotionState,l,ht)||u.runInAction(()=>{var m,S,p;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose:(m=l.tcp_pose)!=null&&m.orientation&&((S=l.tcp_pose)!=null&&S.position)&&((p=this.rapidlyChangingMotionState.tcp_pose)!=null&&p.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:l.tcp_pose.position,orientation:at(l.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:l.tcp_pose})}),Ot(this.rapidlyChangingMotionState.joint_position,l.joint_position,ht)||u.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),l.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==l.tcp&&u.runInAction(()=>{this.rapidlyChangingMotionState.tcp=l.tcp}),this.rapidlyChangingMotionState.standstill!==l.standstill&&u.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill});const h=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,g=l.joint_limit_reached.limit_reached;h.some((m,S)=>m!==g[S])&&u.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=l.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==l.execute&&u.runInAction(()=>{this.rapidlyChangingMotionState.execute=l.execute})}),u.makeAutoObservable(this,{logger:!1,readoutState:u.computed({equals:At,keepAlive:!0})})}static async open(t,e,o={}){var S;const n=O.createNovaClient(t),s=o.cellId??O.cellIdOf(t)??"cell",[r,a]=e.split("@"),d=await n.api.controller.getCurrentRobotControllerState(s,a),c=d==null?void 0:d.motion_groups.find(p=>p.motion_group===e);if(!d||!c)throw new Error(`Controller ${a} or motion group ${e} not found`);const l=n.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${e}/state-stream`),h=await l.firstMessage(),g=(S=I.tryParseJson(h.data))==null?void 0:S.result;if(!g)throw new Error(`Unable to parse initial motion state message ${h.data}`);const y=o.logger??console;y.info("Connected motion state websocket to motion group",{motionGroup:c.motion_group,initialMotionState:g});const m=await n.api.motionGroup.getMotionGroupDescription(s,a,c.motion_group);return new V(n,d,c,m,g,l,s,{logger:y})}get readoutState(){return Pt(this.rapidlyChangingMotionState)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,e)=>({index:e}))}dispose(){this.motionStateSocket.close()}}const gt="Movement request rejected. Another client is currently executing a 'Jogging' motion!",de=1,he=5e3;function ge(i){var e;return(((e=i.times)==null?void 0:e[i.times.length-1])??0)*2e3+he}class Y{constructor(t,e={}){this.motionStream=t,this.options=e,this.DEFAULT_MODE="off",this.DEFAULT_TCP="Flange",this.NO_TCP=void 0,this.DEFAULT_INIT_TIMEOUT=5e3,this.DEFAULT_ORIENTATION="coordsys",this.mode="off",this.joggingSocket=null,this.trajectorySocket=null,this.timeout=this.DEFAULT_INIT_TIMEOUT,this.incrementalMotionInFlight=!1,this.ownsMotionStream=!1,this.tcp=(e==null?void 0:e.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.coordinateSystem=e==null?void 0:e.coordinateSystem,this.orientation=(e==null?void 0:e.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(e==null?void 0:e.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(e==null?void 0:e.mode)||this.DEFAULT_MODE,this.onError=e==null?void 0:e.onError,this.logger=(e==null?void 0:e.logger)??console}static async open(t,e,o={}){const n=await V.open(t,e,{cellId:o.cellId,logger:o.logger}),s=new Y(n,o);s.ownsMotionStream=!0;try{await s.setJoggingMode(s.mode)}catch(r){throw s.dispose(),r}return s}getDefaultTcp(t){var o,n;const e=(n=(o=t.description.dh_parameters)==null?void 0:o[0])==null?void 0:n.type;return t.joints.length<6&&(e===C.JointTypeEnum.RevoluteJoint||e===C.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){return t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),"coordinateSystem"in t&&(this.coordinateSystem=t.coordinateSystem),t.timeout&&(this.timeout=t.timeout),t.mode&&(this.mode=t.mode),t.onError&&(this.onError=t.onError),this.setJoggingMode(this.mode,!1)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get cellId(){return this.motionStream.cellId}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const t=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:t})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const t=this.closeJoggingSockets();return this.ownsMotionStream&&this.motionStream.dispose(),t}closeJoggingSockets(){var e,o;(e=this.endJoggingInit)==null||e.call(this),(o=this.endIncrementalMotion)==null||o.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.closed()))}async setJoggingMode(t,e=!0){if(!(this.mode===t&&e)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,e)=>{const o=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=o;let n=!1;const s=setTimeout(()=>{r(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),r=c=>{n||(n=!0,clearTimeout(s),o.removeEventListener("close",d),this.endJoggingInit===a&&(this.endJoggingInit=void 0),c?e(c):t())},a=()=>r(),d=()=>{o.disposed&&r()};this.endJoggingInit=a,o.addEventListener("close",d),o.addEventListener("message",c=>{var h,g,y;const l=I.tryParseJson(c.data);if(((h=l==null?void 0:l.result)==null?void 0:h.kind)==="INITIALIZE_RECEIVED"){r();return}if(((g=l==null?void 0:l.result)==null?void 0:g.kind)==="MOTION_ERROR")if(this.onBlocked&&((y=l==null?void 0:l.result)!=null&&y.message.includes(gt))){r(),o.dispose(),this.onBlocked();return}else this.onError?(r(),this.onError(c.data)):r(new Error(c.data))}),o.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:e,velocityValue:o,velocityUnit:n}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const s=new Array(this.numJoints).fill(0);s[t]=e==="-"?-o:o,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:s})}async translateTCP({axis:t,direction:e,velocityMmPerSec:o}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:this.velocityAlongAxis(t,e==="-"?-o:o),rotation:[0,0,0],use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:e,velocityRadsPerSec:o}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:[0,0,0],rotation:this.velocityAlongAxis(t,e==="-"?-o:o),use_tool_coordinate_system:this.orientation==="tool"})}get coordinateSystemRotation(){if(!(this.orientation==="tool"||!this.coordinateSystem))return R(this.coordinateSystem).quaternion}velocityAlongAxis(t,e){const o=tt(t,e),n=this.coordinateSystemRotation;return n?A(o,n):o}async runIncrementalCartesianMotion(t){if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(!this.incrementalMotionInFlight){this.incrementalMotionInFlight=!0;try{const e=await this.planIncrementalCartesianMotion(t);e&&await this.executeTrajectory(e,t.refusedReason)}finally{this.incrementalMotionInFlight=!1}}}async planIncrementalCartesianMotion({currentTcpPose:t,currentJoints:e,velocityInRelevantUnits:o,axis:n,direction:s,motion:r}){var S,p,f;const a=[],d=ce({currentTcpPose:t,axis:n,direction:s,motion:r,useToolCoordinateSystem:this.orientation==="tool",coordinateSystemRotation:this.coordinateSystemRotation});a.push({limits_override:r.type==="translate"?{tcp_velocity_limit:o}:{tcp_orientation_velocity_limit:o},path:{path_definition_name:"PathLine",target_pose:{position:d.position,orientation:d.orientation}}});const c=this.motionStream.description;if(c.cycle_time===void 0){this.logger.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const l=this.motionStream.rapidlyChangingMotionState.tcp,h=l?(p=(S=c.tcps)==null?void 0:S[l])==null?void 0:p.pose:void 0,g={motion_group_model:((f=this.options)==null?void 0:f.motionGroupModel)??c.motion_group_model,cycle_time:c.cycle_time,mounting:c.mounting,tcp_offset:h,global:c.operation_limits.auto_limits},y=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:g,start_joint_position:e,motion_commands:a}),m=y.response;if(!m)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(y)}`);if("error_feedback"in m){if(this.onError){this.onError(m);return}throw new Error(`Failed to plan jogging increment motion: ${JSON.stringify(m.error_feedback)}`)}return m}async executeTrajectory(t,e=()=>null){const o=e();if(o)throw new N(o);const n=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);this.trajectorySocket=n;const s=new AbortController;let r,a;try{await new Promise((d,c)=>{let l=!1;const h=()=>{l||(l=!0,d())},g=p=>{if(!l){if(l=!0,this.onError){this.onError(p),d();return}c(p instanceof Error?p:new Error(`Failed to execute trajectory: ${JSON.stringify(p)}`))}},y=()=>{const p=e();return p?(l||(l=!0,c(new N(p))),!0):!1};a=h,this.endIncrementalMotion=h;const m=ge(t);r=setTimeout(()=>{g(new Error(`Jogging motion did not complete within ${m}ms`))},m),n.addEventListener("message",p=>{var v,M;const f=(v=I.tryParseJson(p.data))==null?void 0:v.result;if(!(f!=null&&f.kind)){g(new Error(`Failed to execute trajectory: Received invalid message ${p.data}`));return}if(this.onBlocked&&((M=f.message)!=null&&M.includes(gt))){this.onBlocked(),h();return}if(f.kind==="INITIALIZE_RECEIVED"){if(f.add_trajectory_error||f.message){g(f);return}if(y())return;n.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})}else if(f.kind==="START_RECEIVED"){if(f.message){g(f);return}this.waitForMotionToFinish(t,s.signal).then(h,g)}else f.kind==="PAUSE_RECEIVED"?this.waitUntilStopped(s.signal).then(h,g):f.kind==="MOTION_ERROR"&&f.message?g(f):g(new Error(`Failed to execute trajectory, cannot handle message type "${f.kind}"`))});const S=()=>{y()||n.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:t,tcp:this.tcp}})};if(n.readyState===de)S();else{const p=()=>{n.removeEventListener("open",p),S()};n.addEventListener("open",p)}})}finally{clearTimeout(r),s.abort(),this.endIncrementalMotion===a&&(this.endIncrementalMotion=void 0),n.dispose(),this.trajectorySocket===n&&(this.trajectorySocket=null)}}async waitForMotionToFinish(t,e){const{locations:o}=t,n=(((o==null?void 0:o[0])??0)+((o==null?void 0:o[o.length-1])??0))/2,s=()=>{const r=this.executedTrajectory;return(r==null?void 0:r.state.kind)==="END_OF_TRAJECTORY"&&r.location>=n};await u.when(()=>this.isTrajectoryRunning||s(),{signal:e}),await this.waitUntilStopped(e)}async waitUntilStopped(t){await u.when(()=>!this.isTrajectoryRunning&&this.motionStream.rapidlyChangingMotionState.standstill,{signal:t})}get executedTrajectory(){var e;const t=(e=this.motionStream.rapidlyChangingMotionState.execute)==null?void 0:e.details;return(t==null?void 0:t.kind)==="TRAJECTORY"?t:void 0}get isTrajectoryRunning(){var e;const t=(e=this.executedTrajectory)==null?void 0:e.state.kind;return t==="RUNNING"||t==="WAIT_FOR_IO"}}function ct({position:i,quaternion:t}){return{position:[...i],orientation:jt(t)}}function ut(i){const t=i.lastIndexOf("On");return t>0?i.slice(0,t):i}function kt(i,t){const e=i[t];if(e)return e;const o=ut(t),n=i[o];if(n)return n;const s=Object.keys(i).filter(a=>ut(a)===o);if(s.length!==1)return;const r=s[0];return r?i[r]:void 0}const ue={coordinate_system:"world",name:"world",reference_coordinate_system:"",position:[0,0,0],orientation:[0,0,0],orientation_type:"ROTATION_VECTOR"};function Jt(i){const t=T.keyBy(i.map(n=>({...n,coordinate_system:n.coordinate_system||"world"})),"coordinate_system");t.world??(t.world=ue);const e={},o=n=>{const s=e[n];if(s)return s;const r=kt(t,n);if(!r)throw new Error(`Unknown coordinate system ${n}. Known coordinate systems are: ${Object.keys(t).join(", ")}`);const a=r.reference_coordinate_system||"world";let d;if(a==="world")d=r;else{const c=o(a);d={...r,...ct(L(R(c),R(r))),orientation_type:"ROTATION_VECTOR",reference_coordinate_system:c.reference_coordinate_system}}return e[n]=d,d};return Object.fromEntries(Object.keys(t).map(n=>[n,o(n)]))}function ot(i,t){const e=kt(i,t||"world");if(!e)throw new Error(`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(i).join(", ")}`);return e}function Nt(i,t){return ot(Jt(t),i)}function x(i,t,e){if(i.coordinateSystemId===t)return i;const o=Jt(e),n=ot(o,i.coordinateSystemId||"world"),s=ot(o,t);if(n.coordinate_system===s.coordinate_system)return{...i,coordinateSystemId:s.coordinate_system};const r=L(Mt(R(s)),L(R(n),vt(i.pose)));return{...i,pose:ct(r),coordinateSystemId:s.coordinate_system}}function Dt(i,t,e){return ct(L(L(vt(i),Mt(R(t))),R(e)))}function pt(i,t){const e=i==null?void 0:i[t];if(!e)throw new Error(`Unknown TCP ${t}. Known TCPs are: ${Object.keys(i??{}).join(", ")}`);return{position:e.pose.position??[0,0,0],orientation:e.pose.orientation??[0,0,0],orientation_type:"ROTATION_VECTOR"}}function it({inputPose:i,selectedTcpId:t,selectedCoordinateSystemId:e,tcpOffsetsById:o,coordinateSystems:n}){const s=t&&t!==i.tcpId?{...i,pose:Dt(i.pose,pt(o,i.tcpId),pt(o,t)),tcpId:t}:i;return e?x(s,e,n):s}function Lt(i){var t,e,o,n,s;if(typeof i=="string"){const r=I.tryParseJson(i);return r?Lt(r):i}if(i&&typeof i=="object"){const r=i;return((t=r.error_feedback)==null?void 0:t.error_feedback_name)||((e=r.add_trajectory_error)==null?void 0:e.message)||r.message||((n=(o=r.result)==null?void 0:o.add_trajectory_error)==null?void 0:n.message)||((s=r.result)==null?void 0:s.message)||"Jogging motion failed"}return"Jogging motion failed"}const pe=[{pattern:/^FeedbackSingularity$/,translationKey:"Jogging.StreamStateSection.Error.Singularity.lb"},{pattern:/^FeedbackJointLimitExceeded$/,translationKey:"Jogging.StreamStateSection.Error.JointLimit.lb"},{pattern:/^FeedbackOutOfWorkspace$/,translationKey:"Jogging.StreamStateSection.Error.OutOfWorkspace.lb"},{pattern:/^FeedbackCollision$/,translationKey:"Jogging.StreamStateSection.Error.Collision.lb"},{pattern:/^FeedbackNoSolutionInCurrentConfiguration$/,translationKey:"Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb"},{pattern:/^Feedback\w+$/,translationKey:"Jogging.StreamStateSection.Error.PlanningFailed.lb"}];function me(i){var t;return((t=pe.find(({pattern:e})=>e.test(i)))==null?void 0:t.translationKey)??null}const fe=5,ye=250;function Se(i){var o,n,s,r;const t=[(n=(o=i==null?void 0:i.manual_t1_limits)==null?void 0:o.tcp)==null?void 0:n.velocity,(r=(s=i==null?void 0:i.manual_limits)==null?void 0:s.tcp)==null?void 0:r.velocity].filter(a=>typeof a=="number"&&Number.isFinite(a)&&a>0);return Math.min(ye,...t)/10}const nt=[{id:"0.1",mm:.1,degrees:.05},{id:"1",mm:1,degrees:.5},{id:"5",mm:5,degrees:2.5},{id:"10",mm:10,degrees:5}],_e=[{id:"continuous"},...nt],Ie=["coordsys","tool"],mt="joggingToolStore",ft={code:"locked"},Ee=()=>typeof localStorage>"u"?void 0:localStorage;class F{constructor(t,e,o,n,s,r={}){var d,c,l;this.jogger=t,this.coordSystems=e,this.motionGroupDescription=o,this.tcps=n,this.inverseSolverValue=s,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.jogCoordSystemId="world",this.selectedTcpId="",this.tcpChangeInProgress=!1,this.selectedOrientation="coordsys",this.selectedIncrementId="continuous",this.selectedCartesianMotionType="translate",this.incrementJogInProgress=null,this.lastJogError=null,this.onBeforeActivate=null,this.rotationVelocityDegPerSec=fe,this.minTranslationVelocityMmPerSec=1,this.maxTranslationVelocityMmPerSec=250,this.minRotationVelocityDegPerSec=1,this.maxRotationVelocityDegPerSec=60,this.showCoordSystemSelect=!1,this.showTcpSelect=!0,this.showOrientationSelect=!0,this.showIncrementSelect=!0,this.showTabIcons=!1,this.showVelocitySliderLabel=!0,this.showVelocityLegend=!1,this.showJointsLegend=!1,this.disposers=[],this.inverseSolver=void 0,this.jointType=C.JointTypeEnum.RevoluteJoint,this.jogPress=0,this.stoppedLast=!1,this.runningStep=null,this.disposed=!1,this.endHeldJogWatch=null,this.storage=r.storage??Ee(),this.notMoveableReason=r.notMoveableReason;for(const h of e)if(h.coordinate_system===""){h.coordinate_system="world";break}this.selectedCoordSystemId=((d=e[0])==null?void 0:d.coordinate_system)||"world",this.jogCoordSystemId=this.selectedCoordSystemId,this.selectedTcpId=t.motionStream.rapidlyChangingMotionState.tcp??"",this.tcpChangeInProgress=this.tcps.length>0&&!this.selectedTcpId,this.inverseSolver=s,this.translationVelocityMmPerSec=Se(o==null?void 0:o.operation_limits),this.jointType=((l=(c=o==null?void 0:o.dh_parameters)==null?void 0:c[0])==null?void 0:l.type)??C.JointTypeEnum.RevoluteJoint,u.makeAutoObservable(this,{storage:!1,notMoveableReason:!1,jogPress:!1,stoppedLast:!1,runningStep:!1,endHeldJogWatch:!1},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()};const a=this.jogger.onError;this.jogger.onError=h=>{this.setLastJogError(Lt(h)),a==null||a(h)},this.loadFromLocalStorage(),this.disposers.push(u.autorun(()=>this.saveToLocalStorage())),this.disposers.push(u.autorun(()=>{const h=this.jogger.motionStream.rapidlyChangingMotionState.tcp;h&&h!==this.selectedTcpId&&u.runInAction(()=>{this.selectedTcpId=h,this.tcpChangeInProgress=!1})}))}static async loadFor(t,e={}){const{nova:o,cellId:n}=t,[s,r]=await Promise.all([o.api.controller.listCoordinateSystems(n,t.motionStream.controllerId,"ROTATION_VECTOR"),o.api.motionGroup.getMotionGroupDescription(n,t.motionStream.controllerId,t.motionGroupId)]),a=await o.api.motionGroupModels.getMotionGroupKinematicModel(r.motion_group_model);return F.create(t,{coordinateSystems:s||[],description:r,kinematicModel:a},e)}static create(t,e,o={}){const{coordinateSystems:n,description:s,kinematicModel:r}=e,a=Object.entries(s.tcps||{}).map(([d,c])=>({id:d,readable_name:c.name,position:c.pose.position,orientation:c.pose.orientation}));return new F(t,n,s,a,r.inverse_solver,o)}dispose(){this.disposed=!0;for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return T.countBy(this.coordSystems,t=>t.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){return this.currentTab.id!=="cartesian"?this.activateFor("joint"):this.activateFor(this.activeDiscreteIncrement?"cartesianStep":"cartesian")}async activateFor(t,e){var o;return this.refuseUnlessJoggable(e),this.lastJogError=null,await((o=this.onBeforeActivate)==null?void 0:o.call(this)),this.refuseUnlessJoggable(e),t!=="joint"&&((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&await this.jogger.setOptions({tcp:this.selectedTcpId||void 0,orientation:this.selectedOrientation}),this.jogger.coordinateSystem=this.jogCoordSystem),t==="cartesianStep"?await this.jogger.setJoggingMode("trajectory"):await this.openJoggingWebsocket(),this.jogger}async openJoggingWebsocket(t=!1){this.refuseUnlessJoggable(),t?await this.jogger.setJoggingMode("jogging",!1):await this.jogger.setJoggingMode("jogging");try{this.refuseUnlessJoggable()}catch(e){throw await this.deactivate(),e}}async claimForJogging(){await this.openJoggingWebsocket()}refuseUnlessJoggable(t){const e=this.refusedReason(t);if(e)throw new N(e)}refusedReason(t){var o;if(this.disposed)return{code:"disconnected"};const e=((o=this.notMoveableReason)==null?void 0:o.call(this))??null;if(e)return e;if(this.blocked)return{code:"blocked"};for(const n of this.locks)if(n!==t)return{code:"locked"};return null}async startCartesianJogging(t,e,o){await this.openForHeldJog("cartesian")&&(t==="translate"?await this.jogger.translateTCP({axis:e,direction:o,velocityMmPerSec:this.translationVelocityMmPerSec}):await this.jogger.rotateTCP({axis:e,direction:o,velocityRadsPerSec:this.rotationVelocityRadsPerSec}),this.watchHeldJog())}async startJointJogging(t,e){if(!await this.openForHeldJog("joint"))return;const o=this.jointType===C.JointTypeEnum.PrismaticJoint;await this.jogger.rotateJoints({joint:t,direction:e,velocityUnit:o?"mm/s":"rad/s",velocityValue:o?this.translationVelocityMmPerSec:this.rotationVelocityRadsPerSec}),this.watchHeldJog()}watchHeldJog(){var o;(o=this.endHeldJogWatch)==null||o.call(this);const t=u.reaction(()=>this.refusedReason(),n=>{n&&this.stopJogging().catch(s=>{console.error("Failed to stop jogging:",s)})}),e=()=>{t(),this.endHeldJogWatch===e&&(this.endHeldJogWatch=null)};this.endHeldJogWatch=e}async openForHeldJog(t){const e=++this.jogPress;this.stoppedLast=!1;try{await this.activateFor(t)}catch(o){throw(e===this.jogPress||this.stoppedLast)&&await this.deactivate().catch(()=>{}),o}return e===this.jogPress?!0:(this.stoppedLast&&await this.deactivate(),!1)}async stopJogging(){var e;const t=++this.jogPress;this.stoppedLast=!0,(e=this.endHeldJogWatch)==null||e.call(this),this.runningStep||await this.jogger.stop(),t===this.jogPress&&await this.deactivate()}async runIncrementalCartesianJog(t,e,o,n){this.refuseUnlessJoggable(),await this.withOwnLock(async s=>{const r=this.watchStep(s);try{const a=await this.activateFor("cartesianStep",s),d=a.motionStream.rapidlyChangingMotionState;if(!d.tcp_pose)return;this.setCurrentIncrementJog({axis:e,direction:o}),await a.runIncrementalCartesianMotion({currentTcpPose:d.tcp_pose,currentJoints:d.joint_position,velocityInRelevantUnits:t==="translate"?this.translationVelocityMmPerSec:this.rotationVelocityRadsPerSec,axis:e,direction:o,motion:t==="translate"?{type:"translate",distanceMm:n.mm}:{type:"rotate",distanceRads:I.degreesToRadians(n.degrees)},refusedReason:r.refusedReason})}catch(a){if(r.stoppedByStarter()&&a instanceof N)return;throw a}finally{r.end(),this.setCurrentIncrementJog(null),await this.deactivate()}})}async stopIncrementalJog(t){const e=this.runningStep;e&&(e.stop(t),await e.over)}watchStep(t){let e=null,o=()=>{};const n={stop:(r=ft)=>{e||(e=r,this.jogger.stop().catch(a=>{console.error("Failed to stop the step:",a)}))},over:new Promise(r=>{o=r})};this.runningStep=n;const s=u.reaction(()=>this.refusedReason(t),r=>{r&&n.stop(r)});return{refusedReason:()=>e??this.refusedReason(t),stoppedByStarter:()=>e===ft,end:()=>{s(),this.runningStep===n&&(this.runningStep=null),o()}}}loadFromLocalStorage(){var o;const t=(o=this.storage)==null?void 0:o.getItem(mt),e=t?I.tryParseJson(t):void 0;e&&(this.tabsById[e.selectedTabId]&&(this.selectedTabId=e.selectedTabId),this.coordSystemsById[e.selectedCoordSystemId]&&(this.selectedCoordSystemId=e.selectedCoordSystemId),this.coordSystemsById[e.jogCoordSystemId]&&(this.jogCoordSystemId=e.jogCoordSystemId),this.incrementOptionsById[e.selectedIncrementId]&&(this.selectedIncrementId=e.selectedIncrementId),["translate","rotate"].includes(e.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=e.selectedCartesianMotionType),["coordsys","tool"].includes(e.selectedOrientation)&&(this.selectedOrientation=e.selectedOrientation))}saveToLocalStorage(){var t;(t=this.storage)==null||t.setItem(mt,JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get lastJogErrorTranslationKey(){return this.lastJogError?me(this.lastJogError):null}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,jogCoordSystemId:this.jogCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get canJogCartesian(){return this.inverseSolver!==null}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.canJogCartesian&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return _e}get discreteIncrementOptions(){return nt}get incrementOptionsById(){return T.keyBy(this.incrementOptions,t=>t.id)}get tabsById(){return T.keyBy(this.tabs,t=>t.id)}get currentTab(){return this.tabsById[this.selectedTabId]||this.tabs[0]}get tabIndex(){return this.tabs.indexOf(this.currentTab)}get coordSystemsById(){return T.keyBy(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get jogCoordSystem(){return Nt(this.jogCoordSystemId,this.coordSystems)}get tcpPoseInSelectedCoordSystem(){const{tcp_pose:t,coordinate_system:e}=this.jogger.motionStream.readoutState;return!(t!=null&&t.position)||!t.orientation?t:x({pose:{position:t.position,orientation:t.orientation},coordinateSystemId:e||"world"},this.selectedCoordSystemId,this.coordSystems).pose}get tcpsById(){return T.keyBy(this.tcps,t=>t.id)}tcpPoseIn(t,e){const{tcp_pose:o,tcp:n,coordinate_system:s}=this.jogger.motionStream.readoutState,r=this.tcpsById[n||this.selectedTcpId],a=this.tcpsById[t];if(!(!(o!=null&&o.position)||!o.orientation)&&!(!r||!a))try{return x({pose:Dt(o,r,a),coordinateSystemId:s||"world"},e,this.coordSystems).pose}catch{return}}get activeDiscreteIncrement(){return nt.find(t=>t.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(t){return t?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(t){return t?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(t){return t?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(t,e){const o=this.tabs[e]||this.tabs[0];this.selectedTabId=o.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(e=>{console.error("Failed to change TCP:",e)})}async requestTcpChange(t){var s;if(t===this.selectedTcpId)return;this.refuseUnlessJoggable(),this.tcpChangeInProgress=!0;const e=this.jogger.tcp;let o=!0,n=!1;try{await((s=this.onBeforeActivate)==null?void 0:s.call(this)),o=this.jogger.mode!=="jogging",this.jogger.tcp=t,n=!0,await this.openJoggingWebsocket(!o);let r=await this.waitForTcpConfirmation(t,1e3);o&&await this.jogger.setJoggingMode("off"),r||(r=await this.waitForTcpConfirmation(t,2e3)),u.runInAction(()=>{r?this.selectedTcpId=t:(this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(r){throw n&&o&&await this.jogger.setJoggingMode("off").catch(()=>{}),u.runInAction(()=>{this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),r}finally{u.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,e){return new Promise(o=>{const n=setTimeout(()=>{s(),o(!1)},e),s=u.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(n),o(!0)})})}setSelectedOrientation(t){this.selectedOrientation=t}setMoveRelativeToSelectedTcp(){this.selectedOrientation="tool"}setMoveRelativeToCoordSystem(t){this.selectedOrientation="coordsys",this.jogCoordSystemId=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setLastJogError(t){this.lastJogError=t}setVelocityFromSlider(t,e){!Number.isFinite(t)||t<this.minVelocityInDisplayUnits(e)||t>this.maxVelocityInDisplayUnits(e)||(e?this.rotationVelocityDegPerSec=t:this.translationVelocityMmPerSec=t)}setSelectedCartesianMotionType(t){this.selectedCartesianMotionType=t}lock(t){this.locks.add(t)}unlock(t){this.locks.delete(t)}block(){this.blocked=!0}unblock(){if(this.blocked=!1,this.jogger.mode==="jogging"){try{this.refuseUnlessJoggable()}catch{this.deactivate().catch(t=>{console.error("Failed to stop jogging:",t)});return}this.jogger.initializeJoggingWebsocket().catch(t=>{console.error("Failed to initialize jogging:",t)})}}async withMotionLock(t){return this.withOwnLock(()=>t())}async withOwnLock(t){const e=T.uniqueId();this.lock(e);try{return await t(e)}finally{this.unlock(e)}}}const xt=1e-4,we=new Set(["timestamp","sequence_number","joint_position","joint_torque","joint_current","flange_pose","tcp_pose","flange_velocity","tcp_velocity"]),je=1,yt=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number");class Ft{constructor(t,e,o,n={}){this.source=t,this.motionGroupId=e,this.lastMessageReceivedAt=Date.now(),this.lastInvalidStateMessage=null,this.connectionQuality="good";const s=o.motion_groups.find(r=>r.motion_group===e);if(!s)throw new Error(`Motion group ${e} not found in initial controller state`);this.isVirtual=n.isVirtual??!1,this.onError=n.onError,this.reconnectsOnFocus=(n.reconnectOnFocus??!0)&&typeof window<"u",this.rapidlyChangingMotionState=s,this.lastValidStateMessage={receivedAt:Date.now(),data:o},u.makeAutoObservable(this,{source:!1,lastMessageReceivedAt:!1,connectionQualityInterval:!1,isVirtual:!1,onError:!1,reconnectsOnFocus:!1,readoutState:u.computed({equals:At,keepAlive:!0})},{autoBind:!0}),this.source.addEventListener("message",this.handleMessage),this.connectionQualityInterval=setInterval(this.updateConnectionQuality,500),this.reconnectsOnFocus&&window.addEventListener("focus",this.handleWindowFocus)}get controllerState(){return this.lastValidStateMessage.data}get readoutState(){return Pt(this.rapidlyChangingMotionState)}async nextMotionState(){var o,n;const t=await this.source.nextMessage(),e=(n=(o=this.source.parse(t.data))==null?void 0:o.motion_groups)==null?void 0:n.find(s=>s.motion_group===this.motionGroupId);if(!e)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${t.data}`);return e}setLastInvalidStateMessage(t){this.lastInvalidStateMessage={receivedAt:Date.now(),data:t}}setLastValidStateMessage(t){this.lastValidStateMessage={receivedAt:Date.now(),data:t}}updateRapidlyChangingMotionState(t,e){const o=this.rapidlyChangingMotionState,n=t;for(const s of Object.keys(n))e!=null&&e.has(s)||T.isEqual(o[s],n[s])||(o[s]=n[s]);for(const s of Object.keys(o))e!=null&&e.has(s)||s in n||delete o[s]}setConnectionQuality(t){this.connectionQuality=t}handleWindowFocus(){this.source.reconnect()}updateConnectionQuality(){const t=Date.now()-this.lastMessageReceivedAt,e=this.isVirtual?3e3:1e3,o=this.isVirtual?6e3:3e3;if(t>o){this.source.readyState===je&&this.source.reconnect(),this.setConnectionQuality("critical");return}if(t>e){this.setConnectionQuality("struggling");return}this.setConnectionQuality("good")}dispose(){this.source.removeEventListener("message",this.handleMessage),clearInterval(this.connectionQualityInterval),this.reconnectsOnFocus&&window.removeEventListener("focus",this.handleWindowFocus),this.setConnectionQuality("critical")}handleMessage(t){var c,l;const e=this.source.parse(t.data);if(!(e!=null&&e.motion_groups)){(c=this.onError)==null||c.call(this,{message:I.makeErrorMessage(t.data),url:this.source.url}),this.setLastInvalidStateMessage(t.data);return}this.lastMessageReceivedAt=Date.now();const o=this.lastValidStateMessage.data;(o.safety_state!==e.safety_state||o.operation_mode!==e.operation_mode||o.mode!==e.mode)&&this.setLastValidStateMessage(e);const n=e.motion_groups.find(h=>h.motion_group===this.motionGroupId);if(!n){(l=this.onError)==null||l.call(this,{message:`Motion group ${this.motionGroupId} not found in controller state: ${JSON.stringify(t.data)}`,url:this.source.url}),this.setLastInvalidStateMessage(t.data);return}const s=!$(this.rapidlyChangingMotionState.joint_position,n.joint_position,xt),r=this.rapidlyChangingMotionState.tcp!==n.tcp;if(!s&&!r){this.updateRapidlyChangingMotionState(n,we);return}const a=this.rapidlyChangingMotionState.flange_pose,d=n.flange_pose;if((d==null?void 0:d.orientation)==null||!yt(d.orientation)){const h=d==null?void 0:d.orientation;throw new Error(`Invalid newFlangePose.orientation: expected [number, number, number] (got ${h==null?"null":h.length})`)}if((a==null?void 0:a.orientation)==null||!yt(a.orientation)){const h=a==null?void 0:a.orientation;throw new Error(`Invalid oldFlangePose.orientation: expected [number, number, number] (got ${h==null?"null":h.length})`)}d.orientation=at(d.orientation,a.orientation),this.updateRapidlyChangingMotionState(n)}}const Te=["FeedbackOutOfWorkspace","FeedbackJointLimitExceeded","FeedbackAxisRangeExceeded","FeedbackNoSolutionInCurrentConfiguration"];function $t(i){return i==="FeedbackSingularity"?"Jogging.TargetPose.Error.Singularity.lb":i==="FeedbackCollision"?"Jogging.TargetPose.Error.Collision.lb":Te.includes(i)?"Jogging.TargetPose.Error.NotReachable.lb":"Jogging.TargetPose.Error.PlanningFailed.lb"}function ve(i){return{get url(){return i.url},get readyState(){return i.readyState},addEventListener:(t,e)=>i.addEventListener(t,e),removeEventListener:(t,e)=>i.removeEventListener(t,e),firstMessage:()=>i.firstMessage(),nextMessage:()=>i.nextMessage(),reconnect:()=>i.reconnect(),close:()=>i.close(),parse:t=>{var e;return(e=It.tryParseJson(t))==null?void 0:e.result}}}function Me(i,{controllerId:t,cellId:e,responseRateMs:o}){const n=O.createNovaClient(i),s=e??O.cellIdOf(i)??"cell",r=o===void 0?"":`?response_rate=${o}`;return ve(n.openReconnectingWebsocket(`/cells/${s}/controllers/${t}/state-stream${r}`))}function Vt(i){const t=i.api.opts.axiosInstance;if(!t)throw new Error("Nova API client has no configured HTTP transport");return t}function st(i,t){const e=i.api.opts.baseOptions??{},o={...e,...t};return(e.headers||t.headers)&&(o.headers={...e.headers,...t.headers}),(e.params||t.params)&&(o.params={...e.params,...t.params}),o}async function Oe(i,t,e,o){var s;if(!e)return t;const n=`/experimental/motion-group-models/${encodeURIComponent(t)}/description`;o==null||o(`${n}?serial_number=${encodeURIComponent(e)}`);try{return(await Vt(i).get(n,st(i,{params:{serial_number:e}}))).data.name}catch(r){if(!Et.isAxiosError(r)||((s=r.response)==null?void 0:s.status)!==404)throw r;return t}}async function Ce(i,t,e,o,n){var c;const s=Vt(i),r=`/motion-group-models/${encodeURIComponent(t)}/${o}`,a={};if(e){const l=`/experimental${r}`;n==null||n(`${l}?serial_number=${encodeURIComponent(e)}`);try{return(await s.get(l,st(i,{...a,params:{serial_number:e}}))).data}catch(h){if(!Et.isAxiosError(h)||((c=h.response)==null?void 0:c.status)!==404)throw h}}return n==null||n(r),(await s.get(r,st(i,a))).data}const Gt=["motionGroupDescription","controllerConfiguration","kinematicModel","motionGroupModel","coordinateSystems","controllerState","motionStateStream","controllerStateStream"];class lt extends Error{constructor(t,e,o){super(o),this.stepId=t,this.cause=e,this.name="RobotLoadStepError"}}function W(i){return i instanceof lt}class Ut{constructor(t=null,e=null){this.motionGroupId=null,this.controllerId=null,this.steps=[],this.retryAttempt=0,this.fatalError=null,this.currentStepStartedAt=null,this.motionGroupId=t,this.controllerId=e,this.steps=Gt.map(o=>({id:o,status:"pending",url:null,error:null})),u.makeAutoObservable(this,{},{autoBind:!0})}beginRetry(t){for(const e of this.steps)e.status="pending",e.url=null,e.error=null;this.retryAttempt=t,this.fatalError=null,this.currentStepStartedAt=null}stepById(t){return this.steps.find(e=>e.id===t)}startStep(t,e){const o=this.stepById(t);o&&(o.status="running",o.url=e,o.error=null,this.currentStepStartedAt=Date.now())}updateStepUrl(t,e){const o=this.stepById(t);o&&(o.url=e)}succeedStep(t){const e=this.stepById(t);e&&(e.status="succeeded",this.currentStepStartedAt=null)}failStep(t,e){const o=this.stepById(t);o&&(o.status="failed",o.error=e,this.currentStepStartedAt=null)}failWith(t){this.fatalError=t,this.currentStepStartedAt=null}get totalCount(){return this.steps.length}get succeededCount(){return this.steps.filter(t=>t.status==="succeeded").length}get runningStep(){return this.steps.find(t=>t.status==="running")}get failedStep(){return this.steps.find(t=>t.status==="failed")}get isFailed(){return this.fatalError!==null||this.failedStep!==void 0}get isComplete(){return this.steps.length>0&&this.steps.every(t=>t.status==="succeeded")}}const Re=1e4;async function St(i,t,e){let o;i.catch(()=>{});try{return await Promise.race([i,new Promise((n,s)=>{o=setTimeout(()=>s(new Error(e)),t)})])}finally{clearTimeout(o)}}async function be({nova:i,cellId:t,controllerId:e,motionGroupId:o,progress:n,createStateSource:s,isStale:r=()=>!1,socketTimeoutMs:a=Re}){let d,c,l=!1;function h(){d==null||d.dispose(),c==null||c.close()}async function g(y,m,S){n.startStep(y,m);try{const p=await S();return n.succeedStep(y),p}catch(p){throw n.failStep(y,p),new lt(y,p,I.makeErrorMessage(p))}}try{if(r())return null;const y=`/cells/${t}/controllers/${e}/motion-groups/${o}`,m=`/cells/${t}/controllers/${e}`,S=await g("motionGroupDescription",`${y}/description`,()=>i.api.motionGroup.getMotionGroupDescription(t,e,o));if(r())return null;const{configuration:p}=await g("controllerConfiguration",m,()=>i.api.controller.getRobotController(t,e));if(r())return null;const f={model:S.motion_group_model,serialNumber:S.serial_number},v=f.serialNumber?`?serial_number=${encodeURIComponent(f.serialNumber)}`:"",M=await g("kinematicModel",`/experimental/motion-group-models/${encodeURIComponent(f.model)}/kinematic${v}`,()=>Ce(i,f.model,f.serialNumber,"kinematic",_=>n.updateStepUrl("kinematicModel",_)));if(r())return null;const G=await g("motionGroupModel",`/experimental/motion-group-models/${encodeURIComponent(f.model)}/description${v}`,()=>Oe(i,f.model,f.serialNumber,_=>n.updateStepUrl("motionGroupModel",_)));if(r())return null;const U=await g("coordinateSystems",`${m}/coordinate-systems?orientation_type=ROTATION_VECTOR`,async()=>await i.api.controller.listCoordinateSystems(t,e,"ROTATION_VECTOR")??[]);if(r())return null;const{controllerState:E,motionGroupState:B}=await g("controllerState",`${m}/state`,async()=>{const _=await i.api.controller.getCurrentRobotControllerState(t,e),w=_==null?void 0:_.motion_groups.find(j=>j.motion_group===o);if(!_||!w)throw new Error(`Controller ${e} or motion group ${o} not found`);return{controllerState:_,motionGroupState:w}});if(r())return null;const q=`${y}/state-stream`,{socket:Zt,initialMotionState:Xt}=await g("motionStateStream",q,async()=>{var J;const _=i.openReconnectingWebsocket(q);d=_;const w=await St(_.firstMessage(),a,`No motion state received from ${q} within ${a/1e3}s`),j=(J=It.tryParseJson(w.data))==null?void 0:J.result;if(!j)throw new Error(`Unable to parse initial motion state message ${w.data}`);return{socket:_,initialMotionState:j}});if(r())return null;const{source:te,initialControllerState:ee}=await g("controllerStateStream",`${m}/state`,async()=>{var J;const _=s({cellId:t,controllerId:e});c=_,n.updateStepUrl("controllerStateStream",_.url);const w=await St(_.firstMessage(),a,`No controller state received from ${_.url} within ${a/1e3}s`),j=_.parse(w.data);if(!j)throw new Error(`Unable to parse initial controller state message ${w.data}`);if(!((J=j.motion_groups)!=null&&J.some(oe=>oe.motion_group===o)))throw new Error(`Controller state from ${_.url} does not list motion group ${o} yet`);return{source:_,initialControllerState:j}});return r()?null:(l=!0,{motionGroupDescription:S,controllerConfiguration:p,kinematicModel:M,motionGroupModelName:G,coordinateSystems:U,controllerState:E,motionGroupState:B,initialMotionState:Xt,motionStateSocket:Zt,stateSource:te,initialControllerState:ee,dispose:h})}finally{l||h()}}function rt(i){return i.type==="joint"?{type:"joint",joints:i.joints}:{type:"cartesian",pose:i.tcpPose.pose,coordinateSystemId:i.tcpPose.coordSystemId}}const Q=(i=[0,0,0],t=[0,0,0])=>i.length===t.length&&i.every((e,o)=>e===t[o]);function Pe(i,t){return i.motionGroupId!==t.motionGroupId?!1:i.type==="joint"?t.type==="joint"&&Q(i.joints,t.joints):t.type==="joint"?!1:i.tcpPose.tcpId===t.tcpPose.tcpId&&i.tcpPose.coordSystemId===t.tcpPose.coordSystemId&&Q(i.tcpPose.pose.position,t.tcpPose.pose.position)&&Q(i.tcpPose.pose.orientation,t.tcpPose.pose.orientation)}const P=i=>i??[0,0,0],Z=(i,t)=>i.length===t.length&&i.every((e,o)=>e===t[o]);function Ae(i,t){return i.type==="joint"?t.type==="joint"&&Z(i.joints,t.joints):t.type==="joint"?!1:(i.coordinateSystemId||"world")===(t.coordinateSystemId||"world")&&Z(P(i.pose.position),P(t.pose.position))&&Z(P(i.pose.orientation),P(t.pose.orientation))}function ke(i){return i.type==="joint"?{type:"joint",joints:[...i.joints]}:{type:"cartesian",pose:{position:[...P(i.pose.position)],orientation:[...P(i.pose.orientation)]},coordinateSystemId:i.coordinateSystemId}}class Bt{constructor(t){this.options=t,this.plannedTrajectory=null,this.trajectoryState="idle",this.lastError=null,this.armed=!1,this.plannedFor=null,this.motion=null,this.releaseOnStart=!1,this.disposed=!1,this.disposers=[],this.logger=t.logger??console,u.makeAutoObservable(this,{socket:!1,disposers:!1,logger:!1,options:!1},{autoBind:!0}),this.socket=this.openSocket(),this.disposers.push(u.reaction(()=>this.executionState,e=>{e==="END_OF_TRAJECTORY"&&(this.motion=null,this.reset())}))}get joggingStore(){return this.options.joggingStore}get jogger(){return this.options.joggingStore.jogger}get motionStream(){return this.options.joggingStore.jogger.motionStream}get holdsExecutionSession(){return this.armed}get isPlanOutdated(){return this.plannedFor!==null&&!Object.is(this.plannedFor.velocity,this.velocityFor(this.plannedFor.target))}targetOf(t){return"motionGroupId"in t?t.motionGroupId!==this.jogger.motionGroupId?null:rt(t):t}get executionState(){var t,e;return(e=(t=this.motionStream.rapidlyChangingMotionState.execute)==null?void 0:t.details)==null?void 0:e.state.kind}async planTrajectory(t){var M,G,U;const e=this.targetOf(t);if(!e)throw new Error(`Not planning a pose of motion group "${t.motionGroupId}" for motion group "${this.jogger.motionGroupId}"`);await this.dropPlanIfRefused(),this.armed&&!this.plannedTrajectory&&await this.stopAndReset(),await this.ensureMovementOwnership();const o=this.motionStream.rapidlyChangingMotionState.joint_position??[],{cycle_time:n,mounting:s,motion_group_model:r,tcps:a}=this.motionStream.description,d=this.joggingStore.selectedTcpId,c=d?(M=a==null?void 0:a[d])==null?void 0:M.pose:void 0,l={motion_group_model:((G=this.jogger.options)==null?void 0:G.motionGroupModel)??r,cycle_time:n??0,mounting:s,...c&&{tcp_offset:c}},h=this.velocityFor(e);let g;if(e.type==="cartesian"){let E=e.pose;const B=e.coordinateSystemId||"world";if(B!=="world")try{E=x({pose:{position:E.position??[0,0,0],orientation:E.orientation??[0,0,0]},coordinateSystemId:B},"world",this.joggingStore.coordSystems).pose}catch{return await this.dropPlan(),{ok:!1,errorFeedbackName:"FeedbackUnknown"}}g={limits_override:{tcp_velocity_limit:h},path:{target_pose:E,path_definition_name:"PathCartesianPTP"}}}else g={limits_override:{joint_velocity_limits:Array(o.length).fill(h)},path:{target_joint_position:e.joints,path_definition_name:"PathJointPTP"}};u.runInAction(()=>{this.lastError=null,this.trajectoryState="planning"});let y;try{y=await this.jogger.nova.api.trajectoryPlanning.planTrajectory(this.jogger.cellId,{motion_group_setup:l,start_joint_position:o,motion_commands:[g]})}catch(E){throw await this.dropPlan(),E}const m=y.response;if("error_feedback"in m){const E=((U=m.error_feedback)==null?void 0:U.error_feedback_name)??"FeedbackUnknown";return await this.dropPlan(),{ok:!1,errorFeedbackName:E}}const S=m.joint_positions,p=S[0],f=S[S.length-1];if(!p||!f)throw await this.dropPlan(),new Error("Trajectory returned invalid joint positions");const v={message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.jogger.motionGroupId,tcp:d||void 0,data:m}};return await this.dropPlanIfRefused(),this.socket.sendJson(v),u.runInAction(()=>{this.armed=!0,this.plannedTrajectory={startJoints:p,endJoints:f},this.plannedFor={target:ke(e),velocity:h}}),{ok:!0}}hold(t){if(!this.plannedTrajectory)return!1;if(t){const e=this.targetOf(t);if(!e||!(this.plannedFor&&Ae(e,this.plannedFor.target)))return!1}return this.motion==="starting"?!this.releaseOnStart:this.trajectoryState==="moving"?this.motion==="running":this.trajectoryState!=="planned"||this.motion==="pausing"||this.executionState==="RUNNING"||this.isPlanOutdated||this.refusal()!==null?!1:(this.sendStart(),!0)}async release(){this.motion==="starting"?(this.releaseOnStart=!0,await u.when(()=>this.motion!=="starting")):this.motion==="running"&&this.sendPause(),this.motion==="pausing"&&await this.settlePause()}start(){if(!this.plannedTrajectory)throw new Error("Cannot start trajectory: no planned trajectory exists");if(this.trajectoryState!=="planned")throw new Error(`Cannot start trajectory: expected state "planned", got "${this.trajectoryState}"`);if(this.executionState==="RUNNING")throw new Error("Cannot start trajectory: robot is already running");if(this.motion==="starting")return;const t=this.refusal();if(t)throw new Error(`Cannot start trajectory: ${t}`);this.sendStart()}refusal(){var e,o,n,s;if((o=(e=this.options).isLocked)!=null&&o.call(e))return"the robot is locked";const t=(s=(n=this.options).notMoveableReason)==null?void 0:s.call(n);return t?`the robot may not move (${t.code})`:null}async dropPlanIfRefused(){const t=this.refusal();if(t)throw await this.dropPlan(),new Error(`Cannot plan trajectory: ${t}`)}async pause(){if(this.trajectoryState!=="moving")throw new Error(`Cannot pause trajectory: expected state "moving", got "${this.trajectoryState}"`);this.sendPause(),await this.settlePause()}async stopAndReset(){try{(this.executionState==="RUNNING"||this.trajectoryState==="moving"||this.motion)&&(this.sendPause(),await this.waitUntilStopped())}catch(t){this.logger.warn("Failed to stop trajectory execution cleanly",t)}finally{this.reset(),this.closeSocket(),this.disposed||(this.socket=this.openSocket())}}reset(){this.plannedTrajectory=null,this.plannedFor=null,this.trajectoryState="idle"}async dropPlan(){this.armed?await this.stopAndReset():this.reset()}clearError(){this.lastError=null}dispose(){this.disposed=!0;for(const t of this.disposers)t();this.closeSocket()}velocityFor(t){return t.type==="cartesian"||this.joggingStore.jointType===C.JointTypeEnum.PrismaticJoint?this.joggingStore.translationVelocityMmPerSec:this.joggingStore.rotationVelocityRadsPerSec}async ensureMovementOwnership(){if(this.options.ensureMovementOwnership){await this.options.ensureMovementOwnership();return}this.jogger.mode!=="trajectory"&&(await this.joggingStore.deactivate(),await this.jogger.setJoggingMode("trajectory"))}sendStart(){const t={message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"};this.socket.sendJson(t),this.motion="starting",this.releaseOnStart=!1}sendPause(){if(this.motion==="pausing")return;const t={message_type:"PauseMovementRequest"};this.socket.sendJson(t),this.motion="pausing"}async settlePause(){await this.waitUntilStopped(),u.runInAction(()=>{this.motion==="pausing"&&(this.motion=null,(this.trajectoryState==="moving"||this.trajectoryState==="stopping")&&(this.trajectoryState=this.plannedTrajectory?"planned":"idle"))})}async waitUntilStopped(){await u.when(()=>this.motionStream.rapidlyChangingMotionState.standstill)}handleMessage(t){var o,n;const e=(o=I.tryParseJson(t.data))==null?void 0:o.result;if(e)switch(e.kind){case"INITIALIZE_RECEIVED":e.add_trajectory_error||e.message?(this.lastError=((n=e.add_trajectory_error)==null?void 0:n.message)??e.message??"NOVA refused the trajectory",this.reset()):this.trajectoryState="planned";break;case"START_RECEIVED":this.motion="running",this.trajectoryState="moving",this.releaseOnStart&&(this.releaseOnStart=!1,this.sendPause(),this.settlePause());break;case"PAUSE_RECEIVED":this.trajectoryState==="moving"&&(this.trajectoryState="stopping");break;case"MOTION_ERROR":this.lastError=e.message,this.motion==="starting"&&(this.motion=null),this.reset();break}}openSocket(){const t=this.jogger.nova.openReconnectingWebsocket(`/cells/${this.jogger.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);return t.addEventListener("message",this.handleMessage),t}closeSocket(){this.socket.removeEventListener("message",this.handleMessage),this.socket.dispose(),this.armed=!1,this.motion=null}}const Je=3e4;class dt extends Error{constructor(t,e,o){super(t),this.url=e,this.cause=o,this.name="RobotModeChangeError"}}class Wt{constructor(t,e,o,n,s,r=async()=>{}){this.nova=t,this.ids=e,this.live=o,this.safety=n,this.logger=s,this.releaseControl=r,this.pending=null,this.disposed=!1,u.makeAutoObservable(this,{nova:!1,ids:!1,live:!1,safety:!1,logger:!1,releaseControl:!1,endPending:!1},{autoBind:!0})}get reported(){return this.live.connectionQuality==="critical"?null:this.live.controllerState.mode==="MODE_CONTROL"?"active":"inactive"}get state(){return this.pending??this.reported??"inactive"}async activate(){if(this.refusedAsDisposed())return;if(this.state!=="inactive"){this.logger.warn("Tried to activate while already activating");return}const t=this.safety().activationBlockedReason;if(t){this.logger.warn(`Not enabling control mode for controller "${this.ids.controllerId}" because ${t}`);return}await this.changeMode("activating",()=>this.setMode("ROBOT_SYSTEM_MODE_CONTROL"))}async deactivate(){if(!this.refusedAsDisposed()){if(this.state!=="active"){this.logger.warn("Tried to deactivate while already deactivating");return}await this.changeMode("deactivating",async()=>{await this.releaseControl(),await this.setMode("ROBOT_SYSTEM_MODE_MONITOR")})}}async toggle(){this.state==="inactive"?await this.activate():this.state==="active"&&await this.deactivate()}dispose(){var t;this.disposed=!0,(t=this.endPending)==null||t.call(this)}refusedAsDisposed(){return this.disposed?(this.logger.warn(`Not changing the mode of controller "${this.ids.controllerId}": its session is disposed`),!0):!1}async changeMode(t,e){var a;const o=t==="activating"?"active":"inactive";let n=()=>{},s;const r=()=>{this.endPending===r&&(this.endPending=void 0,n(),clearTimeout(s),this.setPending(null))};(a=this.endPending)==null||a.call(this),this.endPending=r,this.setPending(t),s=setTimeout(r,Je),n=u.when(()=>this.reported===o,r);try{await e()}catch(d){throw r(),d}}setPending(t){this.pending=t}async setMode(t){const{cellId:e,controllerId:o}=this.ids;try{await this.nova.api.controller.setDefaultMode(e,o,t)}catch(n){const s=(typeof n=="object"&&n!==null&&"url"in n&&typeof n.url=="string"?n.url:void 0)??`/cells/${e}/controllers/${o}/mode`;throw new dt(`Failed to set controller "${o}" to ${t}: ${I.makeErrorMessage(n)}`,s,n)}}}const Ne={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class Ht{constructor(t,e,o,n,s){this.motionGroupDescription=t,this.controllerConfiguration=e,this.kinematicModel=o,this.resolvedMotionGroupModel=n,this.coordinateSystems=s,this.dhParameters=(t.dh_parameters??[]).map(r=>({...Ne,...r}))}get isVirtual(){return this.controllerConfiguration.kind==="VirtualController"}get motionGroupModel(){return this.motionGroupDescription.motion_group_model}get serialNumber(){return this.motionGroupDescription.serial_number}get inverseSolver(){return this.kinematicModel.inverse_solver}get jointType(){var t,e;return((e=(t=this.motionGroupDescription.dh_parameters)==null?void 0:t[0])==null?void 0:e.type)??C.JointTypeEnum.RevoluteJoint}get jointLimits(){var t;return((t=this.motionGroupDescription.operation_limits.auto_limits)==null?void 0:t.joints)??[]}get safetyZones(){return this.motionGroupDescription.safety_zones}get safetyLinkColliders(){return this.motionGroupDescription.safety_link_colliders}get safetyToolColliders(){return this.motionGroupDescription.safety_tool_colliders}get kinematicChainOffset(){return this.kinematicModel.kinematic_chain_offset??this.motionGroupDescription.kinematic_chain_offset??null}get flangeOffset(){return this.kinematicModel.flange_offset??this.motionGroupDescription.flange_offset??null}get mounting(){return this.motionGroupDescription.mounting??null}get tcps(){return Object.entries(this.motionGroupDescription.tcps??{}).map(([t,e])=>({id:t,name:e.name}))}get tcpOffsetsById(){return this.motionGroupDescription.tcps??{}}}const _t=i=>Array.isArray(i)&&i.length===3&&i.every(t=>typeof t=="number"),De=.001,Le=.5,xe=.01,X=(i,t,e)=>!!(i&&t&&$([...i],[...t],e));class zt{constructor(t,e,o){this.stream=t,this.description=e,this.jogging=o,u.makeAutoObservable(this,{stream:!1,description:!1,jogging:!1},{autoBind:!0})}get controllerState(){return this.stream.controllerState}get rapidlyChangingMotionState(){return this.stream.rapidlyChangingMotionState}get readoutState(){return this.stream.readoutState}get jointPose(){return this.stream.readoutState.joint_position}get connectionQuality(){return this.stream.connectionQuality}get lastValidStateMessage(){return this.stream.lastValidStateMessage}get lastInvalidStateMessage(){return this.stream.lastInvalidStateMessage}get measuredTcpPoseReference(){return this.tcpPoseReferenceOf(this.rapidlyChangingMotionState)}get displayedTcpPoseReference(){return this.inSelectedFrame(this.measuredTcpPoseReference)}get displayedTcpPose(){return this.readoutState.tcp_pose?this.inSelectedFrame(this.tcpPoseReferenceOf(this.readoutState)).pose:null}isAt(t){if(t.type==="joint")return X(t.joints,this.rapidlyChangingMotionState.joint_position,De);try{const e=it({inputPose:this.measuredTcpPoseReference,selectedTcpId:t.tcpPose.tcpId,selectedCoordinateSystemId:t.tcpPose.coordSystemId,tcpOffsetsById:this.description.tcpOffsetsById,coordinateSystems:this.jogging.coordSystems});return X(t.tcpPose.pose.position,e.pose.position,Le)&&X(t.tcpPose.pose.orientation,e.pose.orientation,xe)}catch{return!1}}nextMotionState(){return this.stream.nextMotionState()}async waitUntilStopped(){let t=await this.stream.nextMotionState(),e=await this.stream.nextMotionState();for(;!$(t.joint_position,e.joint_position,xt);)t=e,e=await this.stream.nextMotionState()}tcpPoseReferenceOf(t){var n,s;const e=(n=t.tcp_pose)==null?void 0:n.position,o=(s=t.tcp_pose)==null?void 0:s.orientation;if(!e||!_t(e))throw new Error(`Invalid current TCP pose position for motion group ${this.stream.motionGroupId}`);if(!o||!_t(o))throw new Error(`Invalid current TCP pose orientation for motion group ${this.stream.motionGroupId}`);return{pose:{position:e,orientation:o},tcpId:t.tcp??"",coordinateSystemId:t.coordinate_system??"world"}}inSelectedFrame(t){return it({inputPose:t,selectedTcpId:this.jogging.selectedTcpId,selectedCoordinateSystemId:this.jogging.selectedCoordSystemId,tcpOffsetsById:this.description.tcpOffsetsById,coordinateSystems:this.jogging.coordSystems})}}const Fe=["SAFETY_STATE_ROBOT_EMERGENCY_STOP","SAFETY_STATE_DEVICE_EMERGENCY_STOP"],$e=["SAFETY_STATE_NORMAL","SAFETY_STATE_REDUCED"],Ve=["SAFETY_STATE_STOP","SAFETY_STATE_STOP_0","SAFETY_STATE_STOP_1","SAFETY_STATE_STOP_2"],Ge=["OPERATION_MODE_AUTO","OPERATION_MODE_MANUAL","OPERATION_MODE_MANUAL_T1","OPERATION_MODE_MANUAL_T2"];class Kt{constructor(t,e){this.state=t,this.activationState=e,u.makeAutoObservable(this,{state:!1,activationState:!1},{autoBind:!0})}get safetyState(){return this.state.controllerState.safety_state}get operationMode(){return this.state.controllerState.operation_mode}get isEstopActive(){return Fe.includes(this.safetyState)}get isMoveableSafetyState(){return $e.includes(this.safetyState)}get isMoveableOperationMode(){return Ge.includes(this.operationMode)}get isActivatableSafetyState(){return this.isMoveableSafetyState||Ve.includes(this.safetyState)}get activationBlockedReason(){return this.isEstopActive?`an emergency stop is active (${this.safetyState})`:this.isActivatableSafetyState?this.isMoveableOperationMode?null:`the operation mode is ${this.operationMode}`:`the safety state is ${this.safetyState}`}get canBeActive(){return this.activationBlockedReason===null}get notMoveableReason(){return this.state.connectionQuality==="critical"?{code:"disconnected"}:this.isMoveableSafetyState?this.isMoveableOperationMode?this.activationState()==="inactive"?{code:"deactivated"}:null:{code:"operation_mode",value:this.operationMode}:{code:"safety_state",value:this.safetyState}}get canBeMoved(){return this.isMoveableSafetyState&&this.isMoveableOperationMode&&this.activationState()==="active"&&this.state.connectionQuality!=="critical"}}const Ue="Jogging.TargetPose.Error.MoveFailed.lb";class Yt{constructor(t,e){this.robot=t,this.logger=e,this.editing=!1,this.draft="",this.confirming=!1,this.staged=null,this.moveStarted=!1,this.disposers=[],u.makeAutoObservable(this,{robot:!1,logger:!1,disposers:!1,onBeforePlan:!1},{autoBind:!0}),this.disposers.push(u.reaction(()=>this.robot.jogging.selectedTabId,()=>{(this.editing||this.staged)&&this.resetToLive()})),this.disposers.push(u.reaction(()=>({trajectoryState:this.robot.trajectory.trajectoryState,executionState:this.robot.trajectory.executionState,isRobotAtStagedPose:this.isRobotAtStagedPose}),({trajectoryState:o,executionState:n,isRobotAtStagedPose:s})=>{if(!this.stagedPose)return;if(o==="moving"){this.moveStarted=!0;return}(n==="END_OF_TRAJECTORY"||this.moveStarted&&s&&o!=="stopping")&&this.resetToLive()})),this.disposers.push(u.reaction(()=>this.robot.trajectory.lastError,o=>{o&&this.staged&&!this.staged.errorKey&&(this.staged={...this.staged,errorKey:Ue,errorMessage:o})})),this.disposers.push(u.reaction(()=>!this.confirming&&this.robot.trajectory.trajectoryState==="planned"&&this.robot.trajectory.isPlanOutdated,o=>{o&&this.stagedPose&&this.plan(this.stagedPose)}))}dispose(){for(const t of this.disposers)t()}get phase(){return this.editing?"editing":this.staged?this.staged.errorKey?"error":"staged":"view"}get isJointTab(){return this.robot.jogging.selectedTabId==="joint"}get liveDisplayString(){if(this.isJointTab)return b.jointsToText(this.robot.state.jointPose);const t=this.robot.state.displayedTcpPose;return t?b.poseToText(t):""}get displayString(){var t;return((t=this.staged)==null?void 0:t.displayString)??this.liveDisplayString}get parsedDraft(){const{state:t,motionGroupId:e}=this.robot;if(this.isJointTab){const s=b.parseJointsText(this.draft,t.jointPose.length);return s?{type:"joint",motionGroupId:e,joints:s}:null}const o=b.parsePoseText(this.draft);if(!o||!t.displayedTcpPose)return null;const n=t.displayedTcpPoseReference;return{type:"cartesian",motionGroupId:e,tcpPose:{pose:{position:o.position,orientation:o.orientation},coordSystemId:n.coordinateSystemId,tcpId:n.tcpId}}}get draftValid(){return this.parsedDraft!==null}beginEdit(){this.draft=this.displayString,this.editing=!0}setDraft(t){this.draft=t}cancelEdit(){this.editing=!1,this.draft=""}async confirmEdit(){const t=this.parsedDraft;t&&await this.plan(t)}async plan(t){var o;if(this.confirming)return;if(this.robot.notMoveableReason()){await this.dropStaged();return}const e=t.type==="joint"?b.jointsToText(t.joints):b.poseToText(t.tcpPose.pose);this.confirming=!0;try{await((o=this.onBeforePlan)==null?void 0:o.call(this));const n=await this.robot.trajectory.planTrajectory(rt(t));u.runInAction(()=>{this.staged={pose:t,displayString:e,errorKey:n.ok?null:$t(n.errorFeedbackName)},this.editing=!1,this.draft=""})}catch(n){this.logger.warn("Failed to plan trajectory to typed pose",n),u.runInAction(()=>{this.staged={pose:t,displayString:e,errorKey:"Jogging.TargetPose.Error.PlanningFailed.lb"},this.editing=!1,this.draft=""})}finally{u.runInAction(()=>{this.confirming=!1})}}holdMove(t){const e=this.stagedPose;return!e||!Pe(e,t)||this.robot.notMoveableReason()?!1:this.robot.trajectory.hold(rt(e))}async releaseMove(){await this.robot.trajectory.release()}async resetToLive(){this.editing=!1,this.draft="",await this.dropStaged()}async dropStaged(){const t=this.staged;this.staged=null,this.moveStarted=!1,t&&(!t.errorKey||this.robot.trajectory.holdsExecutionSession)&&await this.robot.trajectory.stopAndReset()}clear(){this.editing=!1,this.staged=null}get stagedPose(){return!this.staged||this.staged.errorKey?null:this.staged.pose}get isRobotAtStagedPose(){return this.stagedPose?this.robot.state.isAt(this.stagedPose):!1}}const Be={getItem:()=>null,setItem:()=>{}};class qt{constructor(t,e,o,n={}){const s=n.logger??console;this.onError=n.onError??(()=>{}),this.nova=t,this.motionGroupId=e.motionGroupId,this.controllerId=e.controllerId,this.cellId=e.cellId,this.stateSource=o.stateSource,this.motionStateSocket=o.motionStateSocket;const r=new V(t,o.controllerState,o.motionGroupState,o.motionGroupDescription,o.initialMotionState,o.motionStateSocket,e.cellId,{logger:s}),a=new Y(r,{cellId:e.cellId,motionGroupModel:o.motionGroupModelName,logger:s,onError:c=>this.onError({kind:"jog",message:I.makeErrorMessage(c),url:a.motionStream.motionStateSocket.url,cause:c})});this.jogging=F.create(a,{coordinateSystems:o.coordinateSystems,description:o.motionGroupDescription,kinematicModel:o.kinematicModel},{storage:n.storage??Be,notMoveableReason:()=>this.jogRefusedReason}),this.description=new Ht(o.motionGroupDescription,o.controllerConfiguration,o.kinematicModel,o.motionGroupModelName,this.jogging.coordSystems);const d=new Ft(o.stateSource,e.motionGroupId,o.initialControllerState,{isVirtual:this.description.isVirtual,onError:c=>this.onError({kind:"stream",...c})});this.state=new zt(d,this.description,this.jogging),this.activation=new Wt(t,e,this.state,()=>this.safety,s,()=>this.releaseControl()),this.safety=new Kt(this.state,()=>this.activation.state),this.trajectory=new Bt({joggingStore:this.jogging,isLocked:n.isLocked,notMoveableReason:()=>this.jogRefusedReason,ensureMovementOwnership:()=>this.ensureMovementOwnership("trajectory"),logger:s}),this.targetPose=new Yt({motionGroupId:e.motionGroupId,state:this.state,jogging:this.jogging,trajectory:this.trajectory,notMoveableReason:()=>{var c;return this.jogRefusedReason??((c=n.isLocked)!=null&&c.call(n)?{code:"locked"}:null)}},s),this.jogging.onBeforeActivate=async()=>{this.targetPose.staged&&await this.targetPose.resetToLive()},n.autoActivateVirtual&&this.description.isVirtual&&this.activation.state==="inactive"&&this.activation.activate().catch(c=>{this.onError({kind:"mode",message:I.makeErrorMessage(c),url:c instanceof dt?c.url:void 0,cause:c})})}reportError(t){this.onError(t)}get movementOwner(){return this.jogging.jogger.mode}async ensureMovementOwnership(t){if(this.movementOwner!==t){if(t==="jogging"){await this.jogging.claimForJogging();return}await this.jogging.deactivate(),await this.jogging.jogger.setJoggingMode(t)}}get jogRefusedReason(){return this.safety.notMoveableReason??(this.safety.canBeMoved?null:{code:"deactivated"})}async releaseControl(){await this.jogging.stopIncrementalJog({code:"deactivated"}),await this.releasePlannedMove()}async releasePlannedMove(){this.targetPose.staged&&await this.targetPose.resetToLive(),(this.trajectory.plannedTrajectory||this.trajectory.trajectoryState!=="idle"||this.trajectory.holdsExecutionSession)&&await this.trajectory.stopAndReset()}dispose(){this.activation.dispose(),this.targetPose.dispose(),this.state.stream.dispose(),this.trajectory.dispose(),this.stateSource.close(),this.jogging.dispose(),this.motionStateSocket.dispose()}}const We=[1e3,2e3],He=i=>new Promise(t=>setTimeout(t,i));class Qt{constructor(t,e,o,n){this.nova=t,this.motionGroupId=e,this.ids=o,this.options=n,this.state="loading",this.session=null,this.error=null,this.attempt=0,this.disposed=!1,this.progress=new Ut(e,o.controllerId),u.makeAutoObservable(this,{nova:!1,ids:!1,options:!1,attempt:!1,disposed:!1,readyPromise:!1,settle:!1,progress:!1},{autoBind:!0}),this.start()}get ready(){return this.readyPromise}retry(){this.disposed||this.state!=="failed"||this.start()}dispose(){var t;this.disposed||(this.disposed=!0,this.attempt++,(t=this.session)==null||t.dispose(),this.session=null,this.settle.reject(new Error("The robot session load was disposed")))}start(){this.attempt++;const t=this.attempt;this.readyPromise=new Promise((e,o)=>{this.settle={resolve:e,reject:o}}),this.readyPromise.catch(()=>{}),u.runInAction(()=>{this.state="loading",this.error=null}),this.run(t)}isStale(t){return this.disposed||t!==this.attempt}async run(t){var a,d;const{cellId:e,controllerId:o}=this.ids,n=this.options.retryDelaysMs??We,s=this.options.logger??console,r=this.options.stateSource??(c=>Me(this.nova,c));for(let c=0;;c++)try{const l=await be({nova:this.nova,cellId:e,controllerId:o,motionGroupId:this.motionGroupId,progress:this.progress,createStateSource:r,isStale:()=>this.isStale(t),socketTimeoutMs:this.options.socketTimeoutMs});if(!l)return;if(this.isStale(t)){l.dispose();return}let h;try{h=new qt(this.nova,{cellId:e,controllerId:o,motionGroupId:this.motionGroupId},l,this.options)}catch(g){throw l.dispose(),g}if(this.isStale(t)){h.dispose();return}u.runInAction(()=>{this.session=h,this.state="ready"}),this.settle.resolve(h);return}catch(l){if(this.isStale(t))return;const h=W(l)?n[c]:void 0;if(h===void 0){u.runInAction(()=>{W(l)?this.progress.failStep(l.stepId,l.cause):this.progress.failWith(l),this.state="failed",this.error=l}),(d=(a=this.options).onEvent)==null||d.call(a,{type:"loadFailed",motionGroupId:this.motionGroupId,step:W(l)?l.stepId:"unknown",message:I.makeErrorMessage(l),attempts:c+1}),this.settle.reject(l);return}if(s.warn(`Retrying load of robot "${this.motionGroupId}" after: ${I.makeErrorMessage(l)}`),u.runInAction(()=>{this.progress.beginRetry(c+1)}),await He(h),this.isStale(t))return}}}function ze(i,t,e={}){return Ke(O.createNovaClient(i),t,{...e,cellId:e.cellId??O.cellIdOf(i)})}function Ke(i,t,e={}){const o=e.cellId??"cell",n=e.controllerId??t.split("@")[1]??"";return new Qt(i,t,{cellId:o,controllerId:n},e)}exports.ControllerStateStream=Ft;exports.JoggerConnection=Y;exports.JoggingRefusedError=N;exports.JoggingStore=F;exports.MotionStreamConnection=V;exports.ORIENTATION_IDS=Ie;exports.ROBOT_LOAD_STEP_IDS=Gt;exports.RobotActivation=Wt;exports.RobotDescription=Ht;exports.RobotLiveState=zt;exports.RobotLoadProgress=Ut;exports.RobotLoadStepError=lt;exports.RobotModeChangeError=dt;exports.RobotSafety=Kt;exports.RobotSession=qt;exports.RobotSessionLoad=Qt;exports.RobotTargetPose=Yt;exports.TrajectoryExecutionStore=Bt;exports.deriveSelectedTcpPose=it;exports.isRobotLoadStepError=W;exports.jointValuesEqual=$;exports.jointValuesUnchanged=Ot;exports.loadRobotSession=ze;exports.planErrorTranslationKey=$t;exports.poseEqual=Rt;exports.resolveCoordinateSystemInWorld=Nt;exports.tcpMotionEqual=bt;exports.transformPoseToCoordinateSystem=x;exports.unwrapRotationVector=at;
@@ -0,0 +1 @@
1
+ "use strict";const r=require("@wandelbots/nova-js/v2");function s(e){return e instanceof r.Nova?e:typeof e=="string"?new r.Nova({instanceUrl:e}):new r.Nova({instanceUrl:e.config.instanceUrl,accessToken:e.accessToken??e.config.accessToken??void 0})}function a(e){return typeof e=="string"?void 0:e.config.cellId}exports.cellIdOf=a;exports.createNovaClient=s;
@@ -0,0 +1,14 @@
1
+ import { Nova as r } from "@wandelbots/nova-js/v2";
2
+ function a(e) {
3
+ return e instanceof r ? e : typeof e == "string" ? new r({ instanceUrl: e }) : new r({
4
+ instanceUrl: e.config.instanceUrl,
5
+ accessToken: e.accessToken ?? e.config.accessToken ?? void 0
6
+ });
7
+ }
8
+ function f(e) {
9
+ return typeof e == "string" ? void 0 : e.config.cellId;
10
+ }
11
+ export {
12
+ f as a,
13
+ a as c
14
+ };
@@ -0,0 +1 @@
1
+ "use strict";const T=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/,c=(n,t)=>Number.parseFloat(n.toFixed(t));function a(n,t={}){const i=t.positionPrecision??1,r=t.rotationPrecision??4,e=o=>[0,1,2].map(s=>(o==null?void 0:o[s])??0);return`(${[...e(n.position).map(o=>c(o,i)),...e(n.orientation).map(o=>c(o,r))].join(", ")})`}function m(n){return`[${n.map(t=>c(t,4)).join(", ")}]`}function f(n,t,i){let r=n.trim();const e=r.startsWith(t),o=r.endsWith(i);if(e!==o||(e&&(r=r.slice(1,-1)),r.trim()===""))return null;const s=[];for(const u of r.split(",")){const p=u.trim();if(!T.test(p))return null;const l=Number(p);if(!Number.isFinite(l))return null;s.push(l)}return s}function x(n){const t=f(n,"(",")");if((t==null?void 0:t.length)!==6)return null;const[i,r,e,o,s,u]=t;return{position:[i,r,e],orientation:[o,s,u]}}function d(n,t){const i=f(n,"[","]");return(i==null?void 0:i.length)!==t?null:i}exports.jointsToText=m;exports.parseJointsText=d;exports.parsePoseText=x;exports.poseToText=a;
@@ -0,0 +1,41 @@
1
+ const f = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/, c = (n, t) => Number.parseFloat(n.toFixed(t));
2
+ function m(n, t = {}) {
3
+ const i = t.positionPrecision ?? 1, r = t.rotationPrecision ?? 4, e = (o) => [0, 1, 2].map((s) => (o == null ? void 0 : o[s]) ?? 0);
4
+ return `(${[
5
+ ...e(n.position).map((o) => c(o, i)),
6
+ ...e(n.orientation).map((o) => c(o, r))
7
+ ].join(", ")})`;
8
+ }
9
+ function d(n) {
10
+ return `[${n.map((t) => c(t, 4)).join(", ")}]`;
11
+ }
12
+ function l(n, t, i) {
13
+ let r = n.trim();
14
+ const e = r.startsWith(t), o = r.endsWith(i);
15
+ if (e !== o || (e && (r = r.slice(1, -1)), r.trim() === "")) return null;
16
+ const s = [];
17
+ for (const u of r.split(",")) {
18
+ const p = u.trim();
19
+ if (!f.test(p)) return null;
20
+ const a = Number(p);
21
+ if (!Number.isFinite(a)) return null;
22
+ s.push(a);
23
+ }
24
+ return s;
25
+ }
26
+ function x(n) {
27
+ const t = l(n, "(", ")");
28
+ if ((t == null ? void 0 : t.length) !== 6) return null;
29
+ const [i, r, e, o, s, u] = t;
30
+ return { position: [i, r, e], orientation: [o, s, u] };
31
+ }
32
+ function T(n, t) {
33
+ const i = l(n, "[", "]");
34
+ return (i == null ? void 0 : i.length) !== t ? null : i;
35
+ }
36
+ export {
37
+ T as a,
38
+ x as b,
39
+ d as j,
40
+ m as p
41
+ };
@@ -0,0 +1,202 @@
1
+ import { autorun as T, observable as F, runInAction as I } from "mobx";
2
+ import d, { useEffect as C, useState as y, useRef as V } from "react";
3
+ function v(r) {
4
+ C(r, []);
5
+ }
6
+ function R(r) {
7
+ v(() => T(r));
8
+ }
9
+ function U(r) {
10
+ return v(() => {
11
+ let t;
12
+ function e() {
13
+ r(), t = requestAnimationFrame(e);
14
+ }
15
+ return t = requestAnimationFrame(e), () => {
16
+ cancelAnimationFrame(t);
17
+ };
18
+ });
19
+ }
20
+ class A {
21
+ constructor(t = [], e = {}) {
22
+ this.currentValues = [], this.targetValues = [], this.previousTargetValues = [], this.targetUpdateTime = 0, this.animationId = null, this.updateCount = 0, this.velocities = [], this.animate = () => {
23
+ this.update(0.016666666666666666) ? this.animationId = null : this.animationId = requestAnimationFrame(this.animate);
24
+ }, this.options = {
25
+ tension: 120,
26
+ friction: 20,
27
+ threshold: 1e-3,
28
+ onChange: () => {
29
+ },
30
+ onComplete: () => {
31
+ },
32
+ ...e
33
+ }, this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0;
34
+ }
35
+ /**
36
+ * Update interpolation using spring physics
37
+ *
38
+ * Call this method every frame for smooth animation. In React Three Fiber,
39
+ * call from within useFrame callback with the provided delta time.
40
+ *
41
+ * @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)
42
+ * @returns true when interpolation is complete (all values reached their targets)
43
+ */
44
+ update(t = 1 / 60) {
45
+ let e = !1, n = !0;
46
+ this.updateCount++;
47
+ const o = Math.min(t, 1 / 15), u = this.updateCount === 1 ? 0.7 : 1;
48
+ for (let i = 0; i < this.currentValues.length; i++) {
49
+ const c = this.currentValues[i], h = this.targetValues[i], g = this.velocities[i], s = h - c, a = s * this.options.tension * u, m = g * this.options.friction, l = a - m, f = g + l * o, p = c + f * o;
50
+ Math.abs(s) < this.options.threshold && Math.abs(f) < this.options.threshold * 10 ? this.currentValues[i] !== h && (this.currentValues[i] = h, this.velocities[i] = 0, e = !0) : (n = !1, this.currentValues[i] = p, this.velocities[i] = f, e = !0);
51
+ }
52
+ return e && this.options.onChange(this.currentValues), n && this.options.onComplete(this.currentValues), n;
53
+ }
54
+ /**
55
+ * Set new target values for the interpolation to move towards
56
+ *
57
+ * Includes smart blending for very rapid target updates (faster than 120fps)
58
+ * to prevent jarring movements when targets change frequently.
59
+ */
60
+ setTarget(t) {
61
+ const e = performance.now(), n = e - this.targetUpdateTime;
62
+ this.previousTargetValues = [...this.targetValues], this.targetValues = [...t], this.targetUpdateTime = e, this.updateCount = 0;
63
+ const o = this.previousTargetValues.every(
64
+ (u, i) => u === this.currentValues[i]
65
+ );
66
+ if (n < 8 && n > 0 && this.previousTargetValues.length > 0 && !o) {
67
+ const u = Math.min(n / 8, 1);
68
+ for (let i = 0; i < this.targetValues.length; i++) {
69
+ const c = this.previousTargetValues[i] || 0, h = t[i] || 0;
70
+ Math.abs(h - c) > 0.1 && (this.targetValues[i] = c + (h - c) * u);
71
+ }
72
+ }
73
+ for (; this.currentValues.length < t.length; )
74
+ this.currentValues.push(t[this.currentValues.length]), this.velocities.push(0);
75
+ this.currentValues.length > t.length && (this.currentValues = this.currentValues.slice(0, t.length), this.velocities = this.velocities.slice(0, t.length));
76
+ }
77
+ /**
78
+ * Get a copy of all current interpolated values
79
+ */
80
+ getCurrentValues() {
81
+ return [...this.currentValues];
82
+ }
83
+ /**
84
+ * Get a single interpolated value by its array index
85
+ */
86
+ getValue(t) {
87
+ return this.currentValues[t] ?? 0;
88
+ }
89
+ /**
90
+ * Check if automatic interpolation is currently running
91
+ *
92
+ * This only tracks auto-interpolation started with startAutoInterpolation().
93
+ * Manual update() calls are not tracked by this method.
94
+ */
95
+ isInterpolating() {
96
+ return this.animationId !== null;
97
+ }
98
+ /**
99
+ * Stop automatic interpolation if it's running
100
+ *
101
+ * This cancels the internal animation frame loop but does not affect
102
+ * manual update() calls.
103
+ */
104
+ stop() {
105
+ this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null);
106
+ }
107
+ /**
108
+ * Instantly set values without interpolation
109
+ */
110
+ setImmediate(t) {
111
+ this.stop(), this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0, this.options.onChange(this.currentValues);
112
+ }
113
+ /**
114
+ * Update interpolation options
115
+ */
116
+ updateOptions(t) {
117
+ this.options = { ...this.options, ...t };
118
+ }
119
+ /**
120
+ * Start automatic interpolation with an animation loop
121
+ *
122
+ * This begins a requestAnimationFrame loop that calls update() automatically.
123
+ * For React Three Fiber components, prefer using manual update() calls
124
+ * within useFrame hooks instead.
125
+ */
126
+ startAutoInterpolation() {
127
+ this.startInterpolation();
128
+ }
129
+ /**
130
+ * Clean up all resources and stop any running animations
131
+ *
132
+ * This cancels any active animation frames and resets internal state.
133
+ * Call this when the component unmounts or is no longer needed.
134
+ */
135
+ destroy() {
136
+ this.stop();
137
+ }
138
+ startInterpolation() {
139
+ this.animationId === null && this.animate();
140
+ }
141
+ }
142
+ function _(r = [], t = {}) {
143
+ const e = d.useRef(null);
144
+ return e.current || (e.current = new A(r, t)), d.useEffect(() => {
145
+ var n;
146
+ (n = e.current) == null || n.updateOptions(t);
147
+ }, [t]), d.useEffect(() => () => {
148
+ var n;
149
+ (n = e.current) == null || n.destroy();
150
+ }, []), [e.current];
151
+ }
152
+ function j(r, t) {
153
+ const [e] = y(
154
+ () => F({ ...r })
155
+ ), n = V(null), o = V(null), u = V(0);
156
+ function i() {
157
+ o.current !== null && (cancelAnimationFrame(o.current), o.current = null);
158
+ }
159
+ function c() {
160
+ const s = n.current;
161
+ if (!s) return;
162
+ const a = performance.now(), m = (a - u.current) / 1e3;
163
+ u.current = a;
164
+ const l = s.update(m);
165
+ I(() => {
166
+ e.joint_position = s.getCurrentValues();
167
+ }), o.current = l ? null : requestAnimationFrame(c);
168
+ }
169
+ function h() {
170
+ o.current === null && (u.current = performance.now(), o.current = requestAnimationFrame(c));
171
+ }
172
+ function g(s) {
173
+ var m;
174
+ const a = s.joint_position.filter(
175
+ (l) => l !== void 0
176
+ );
177
+ (m = n.current) == null || m.setTarget(a), I(() => {
178
+ const l = s, f = e;
179
+ for (const p of Object.keys(l))
180
+ p !== "joint_position" && f[p] !== l[p] && (f[p] = l[p]);
181
+ }), h();
182
+ }
183
+ return v(() => {
184
+ const s = r.joint_position.filter(
185
+ (a) => a !== void 0
186
+ );
187
+ return n.current = new A(s, t), () => {
188
+ var a;
189
+ i(), (a = n.current) == null || a.destroy();
190
+ };
191
+ }), C(() => {
192
+ var s;
193
+ t && ((s = n.current) == null || s.updateOptions(t));
194
+ }, [t]), C(() => T(() => g(r)), [r]), e;
195
+ }
196
+ export {
197
+ A as V,
198
+ j as a,
199
+ U as b,
200
+ R as c,
201
+ _ as u
202
+ };
@@ -0,0 +1 @@
1
+ "use strict";const V=require("mobx"),u=require("react");function I(r){u.useEffect(r,[])}function v(r){I(()=>V.autorun(r))}function A(r){return I(()=>{let t;function e(){r(),t=requestAnimationFrame(e)}return t=requestAnimationFrame(e),()=>{cancelAnimationFrame(t)}})}class C{constructor(t=[],e={}){this.currentValues=[],this.targetValues=[],this.previousTargetValues=[],this.targetUpdateTime=0,this.animationId=null,this.updateCount=0,this.velocities=[],this.animate=()=>{this.update(.016666666666666666)?this.animationId=null:this.animationId=requestAnimationFrame(this.animate)},this.options={tension:120,friction:20,threshold:.001,onChange:()=>{},onComplete:()=>{},...e},this.currentValues=[...t],this.targetValues=[...t],this.previousTargetValues=[...t],this.velocities=new Array(t.length).fill(0),this.targetUpdateTime=performance.now(),this.updateCount=0}update(t=1/60){let e=!1,n=!0;this.updateCount++;const o=Math.min(t,1/15),c=this.updateCount===1?.7:1;for(let i=0;i<this.currentValues.length;i++){const l=this.currentValues[i],p=this.targetValues[i],d=this.velocities[i],s=p-l,a=s*this.options.tension*c,m=d*this.options.friction,h=a-m,g=d+h*o,f=l+g*o;Math.abs(s)<this.options.threshold&&Math.abs(g)<this.options.threshold*10?this.currentValues[i]!==p&&(this.currentValues[i]=p,this.velocities[i]=0,e=!0):(n=!1,this.currentValues[i]=f,this.velocities[i]=g,e=!0)}return e&&this.options.onChange(this.currentValues),n&&this.options.onComplete(this.currentValues),n}setTarget(t){const e=performance.now(),n=e-this.targetUpdateTime;this.previousTargetValues=[...this.targetValues],this.targetValues=[...t],this.targetUpdateTime=e,this.updateCount=0;const o=this.previousTargetValues.every((c,i)=>c===this.currentValues[i]);if(n<8&&n>0&&this.previousTargetValues.length>0&&!o){const c=Math.min(n/8,1);for(let i=0;i<this.targetValues.length;i++){const l=this.previousTargetValues[i]||0,p=t[i]||0;Math.abs(p-l)>.1&&(this.targetValues[i]=l+(p-l)*c)}}for(;this.currentValues.length<t.length;)this.currentValues.push(t[this.currentValues.length]),this.velocities.push(0);this.currentValues.length>t.length&&(this.currentValues=this.currentValues.slice(0,t.length),this.velocities=this.velocities.slice(0,t.length))}getCurrentValues(){return[...this.currentValues]}getValue(t){return this.currentValues[t]??0}isInterpolating(){return this.animationId!==null}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setImmediate(t){this.stop(),this.currentValues=[...t],this.targetValues=[...t],this.previousTargetValues=[...t],this.velocities=new Array(t.length).fill(0),this.targetUpdateTime=performance.now(),this.updateCount=0,this.options.onChange(this.currentValues)}updateOptions(t){this.options={...this.options,...t}}startAutoInterpolation(){this.startInterpolation()}destroy(){this.stop()}startInterpolation(){this.animationId===null&&this.animate()}}function T(r=[],t={}){const e=u.useRef(null);return e.current||(e.current=new C(r,t)),u.useEffect(()=>{var n;(n=e.current)==null||n.updateOptions(t)},[t]),u.useEffect(()=>()=>{var n;(n=e.current)==null||n.destroy()},[]),[e.current]}function F(r,t){const[e]=u.useState(()=>V.observable({...r})),n=u.useRef(null),o=u.useRef(null),c=u.useRef(0);function i(){o.current!==null&&(cancelAnimationFrame(o.current),o.current=null)}function l(){const s=n.current;if(!s)return;const a=performance.now(),m=(a-c.current)/1e3;c.current=a;const h=s.update(m);V.runInAction(()=>{e.joint_position=s.getCurrentValues()}),o.current=h?null:requestAnimationFrame(l)}function p(){o.current===null&&(c.current=performance.now(),o.current=requestAnimationFrame(l))}function d(s){var m;const a=s.joint_position.filter(h=>h!==void 0);(m=n.current)==null||m.setTarget(a),V.runInAction(()=>{const h=s,g=e;for(const f of Object.keys(h))f!=="joint_position"&&g[f]!==h[f]&&(g[f]=h[f])}),p()}return I(()=>{const s=r.joint_position.filter(a=>a!==void 0);return n.current=new C(s,t),()=>{var a;i(),(a=n.current)==null||a.destroy()}}),u.useEffect(()=>{var s;t&&((s=n.current)==null||s.updateOptions(t))},[t]),u.useEffect(()=>V.autorun(()=>d(r)),[r]),e}exports.ValueInterpolator=C;exports.useAnimationFrame=A;exports.useAutorun=v;exports.useInterpolation=T;exports.useSmoothedMotionState=F;
@@ -1,4 +1,4 @@
1
- import { type SxProps } from "@mui/material/styles";
1
+ import type { SxProps } from "@mui/material/styles";
2
2
  import { type ReactNode } from "react";
3
3
  export type AppItem = {
4
4
  /** Unique identifier for the app */
@@ -11,7 +11,9 @@ type VelocitySliderProps = {
11
11
  useDegree: boolean;
12
12
  store: JoggingStore;
13
13
  };
14
- /** A slider for controlling the movement velocity of a robot */
14
+ /**
15
+ * A slider for controlling the movement velocity of a robot
16
+ */
15
17
  export declare const VelocitySlider: ((props: VelocitySliderProps) => import("react/jsx-runtime").JSX.Element) & {
16
18
  displayName: string;
17
19
  };
@@ -19,5 +21,8 @@ type VelocitySliderLabelProps = {
19
21
  value: string;
20
22
  sx?: SxProps;
21
23
  };
24
+ /**
25
+ * The value next to {@link VelocitySlider}
26
+ */
22
27
  export declare function VelocitySliderLabel({ value, sx }: VelocitySliderLabelProps): import("react/jsx-runtime").JSX.Element;
23
28
  export default VelocitySlider;
@@ -0,0 +1,48 @@
1
+ import type { SxProps, Theme } from "@mui/material/styles";
2
+ import type { JoggingDetailsState, TrajectoryDetailsState } from "@wandelbots/nova-js/v2";
3
+ import type { RobotControlPose, RobotControlSelect } from "../robotControl/robotControlTypes";
4
+ import type { EulerConvention } from "./orientation";
5
+ export type { EulerConvention } from "./orientation";
6
+ /** How the bar shows the orientation of the pose */
7
+ export type OrientationFormat = {
8
+ type: "rotationVector" | "eulerAngles" | "quaternion";
9
+ /** The unit of a rotation vector and of Euler angles */
10
+ angleUnit: "rad" | "deg";
11
+ /** The convention of Euler angles; kept while another type is shown */
12
+ eulerConvention: EulerConvention;
13
+ };
14
+ /**
15
+ * What the robot's motion stream reports: NOVA's
16
+ * `execute.details.state.kind` of a jog or a trajectory
17
+ */
18
+ export type CurrentPoseBarState = JoggingDetailsState["kind"] | TrajectoryDetailsState["kind"];
19
+ /** What the app gives CurrentPoseBar: the pose, its TCP and frame, the state */
20
+ export type CurrentPoseBarProps = {
21
+ /**
22
+ * The TCP's pose relative to the frame, both chosen in the bar: position
23
+ * in mm, orientation as a rotation vector in rad. Read on every frame;
24
+ * null while unknown.
25
+ */
26
+ getCurrentPose: () => RobotControlPose | null;
27
+ /** The TCP whose pose the bar shows; the bar's own, not the panel's */
28
+ tcp?: RobotControlSelect;
29
+ /** The coordinate system the pose is relative to */
30
+ frame?: RobotControlSelect;
31
+ /** The state of the motion stream; none is "Ready" */
32
+ state?: CurrentPoseBarState | null;
33
+ /**
34
+ * An error that outlasts the motion that caused it, e.g. a jog stopped
35
+ * near a collision; shown instead of the state
36
+ */
37
+ error?: string | null;
38
+ /** The orientation format, if the app keeps it; else the bar keeps its own */
39
+ orientationFormat?: OrientationFormat;
40
+ onOrientationFormatChange?: (format: OrientationFormat) => void;
41
+ sx?: SxProps<Theme>;
42
+ };
43
+ /**
44
+ * The bar under the 3D view: the TCP's current pose in a TCP and frame of
45
+ * its own, a button to copy it, the orientation format, and the state of
46
+ * the robot's motion stream
47
+ */
48
+ export declare const CurrentPoseBar: ({ getCurrentPose, tcp, frame, state, error, orientationFormat: appFormat, onOrientationFormatChange, sx, }: CurrentPoseBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { OrientationFormat } from "./CurrentPoseBar";
2
+ type OrientationFormatPopoverProps = {
3
+ /** The bar: the popover opens above it, at its left */
4
+ anchor: HTMLElement | null;
5
+ open: boolean;
6
+ onClose: () => void;
7
+ format: OrientationFormat;
8
+ onChange: (format: OrientationFormat) => void;
9
+ };
10
+ /**
11
+ * Orientation format: how the bar shows the orientation. The angle unit is
12
+ * for a rotation vector and Euler angles; the convention for Euler angles.
13
+ * It renders again only when it opens, closes or shows another format: an
14
+ * open menu measures its place on every render, and the bar renders on every
15
+ * render of the app.
16
+ */
17
+ export declare const OrientationFormatPopover: import("react").MemoExoticComponent<typeof OrientationFormatPopoverContent>;
18
+ declare function OrientationFormatPopoverContent({ anchor, open, onClose, format, onChange, }: OrientationFormatPopoverProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { CurrentPoseBarState } from "./CurrentPoseBar";
2
+ /**
3
+ * The state of the robot's motion stream, as RobotPad's StreamStateSection:
4
+ * an error that outlasts its motion comes first, since the state is normal
5
+ * again as soon as the motion stops
6
+ */
7
+ export declare function StreamStatus({ state, error, }: {
8
+ state: CurrentPoseBarState | null | undefined;
9
+ error: string | null | undefined;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import type { OrientationType } from "@wandelbots/nova-js/v2";
2
+ /** One of NOVA's Euler angle conventions, e.g. `EULER_ANGLES_EXTRINSIC_XYZ` */
3
+ export type EulerConvention = Extract<OrientationType, `EULER_ANGLES_${string}`>;
4
+ /** A quaternion as [x, y, z, w], NOVA's order */
5
+ export type QuaternionTuple = [number, number, number, number];
6
+ type Axis = "X" | "Y" | "Z";
7
+ /** All Euler conventions of NOVA: the intrinsic ones, then the extrinsic ones */
8
+ export declare const EULER_CONVENTIONS: readonly EulerConvention[];
9
+ /**
10
+ * Whether the convention turns about the moving axes (intrinsic) or the fixed
11
+ * ones (extrinsic), and its axes in the order of its angles
12
+ */
13
+ export declare function parseEulerConvention(convention: EulerConvention): {
14
+ intrinsic: boolean;
15
+ axes: [Axis, Axis, Axis];
16
+ };
17
+ /** The quaternion of a rotation vector: its direction is the axis, its length the angle in rad */
18
+ export declare function rotationVectorToQuaternion([x, y, z]: [
19
+ number,
20
+ number,
21
+ number
22
+ ]): QuaternionTuple;
23
+ /**
24
+ * The Euler angles of a rotation in rad, in the order of the convention's
25
+ * axes: intrinsic XYZ turns about X, then the turned Y, then the turned Z;
26
+ * extrinsic XYZ about the fixed X, Y and Z. Each angle is within [-π, π].
27
+ *
28
+ * The method of Bernardes and Viollet (2022), "Quaternion to Euler angles
29
+ * conversion: a direct, general and computationally efficient method", as
30
+ * SciPy uses it. In gimbal lock only the sum or the difference of the first
31
+ * and last angle is known; then the last extrinsic angle is 0.
32
+ */
33
+ export declare function quaternionToEuler(quaternion: QuaternionTuple, convention: EulerConvention): [number, number, number];
34
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { RobotControlPose } from "../robotControl/robotControlTypes";
2
+ import type { OrientationFormat } from "./CurrentPoseBar";
3
+ /** Rotation vector in rad, Figma's default; Euler angles as Figma's, extrinsic XYZ */
4
+ export declare const DEFAULT_ORIENTATION_FORMAT: OrientationFormat;
5
+ /** One value of the bar, e.g. "X" and "-328.2" */
6
+ export type PoseValue = {
7
+ label: string;
8
+ value: string;
9
+ kind: "x" | "y" | "z" | "orientation";
10
+ };
11
+ /**
12
+ * The values the bar shows for a pose: the position to 0.1 mm, then the
13
+ * orientation in the format; a dash for each while the pose is unknown
14
+ */
15
+ export declare function poseValues(pose: RobotControlPose | null, format: OrientationFormat): PoseValue[];
@@ -0,0 +1,18 @@
1
+ import { type JogControlsProps } from "./useJogControls";
2
+ /**
3
+ * Props of {@link JoggingButtons}: the same as those of JoggingGizmo, less
4
+ * what only a 3D drawing needs
5
+ */
6
+ export type JoggingButtonsProps = JogControlsProps;
7
+ /**
8
+ * Jogging by buttons: a row per axis with a minus and a plus button, held to
9
+ * jog. `motion` picks whether they move the robot along the axes (X-, X+) or
10
+ * turn it about them (Rx-, Rx+). The jog stops when the pointer is let go
11
+ * or leaves the button. Only a pointer holds a button: the keyboard reaches
12
+ * it, but does not jog.
13
+ *
14
+ * Unlike JoggingGizmo, the buttons do not turn with the 3D view: X+ is X+ of
15
+ * the jog frame, wherever the camera looks from. They take the same props as
16
+ * the gizmo, so an app wires both the same way.
17
+ */
18
+ export declare const JoggingButtons: (props: JoggingButtonsProps) => import("react/jsx-runtime").JSX.Element;