@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
@@ -1,21 +1,68 @@
1
1
  import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
2
- import { type Pose } from "@wandelbots/nova-js/v2";
2
+ import { type CoordinateSystem, type Pose } from "@wandelbots/nova-js/v2";
3
+ import { type JoggingRefusedReason } from "../components/jogging/JoggingRefusedError";
4
+ import type { ConnectionLogger } from "./connectionLogger";
5
+ import { type IncrementalMotion } from "./incrementalCartesianMotion";
3
6
  import { MotionStreamConnection } from "./MotionStreamConnection";
4
- import type { AnyNovaClient } from "./novaCompat";
7
+ import type { NovaConnection } from "./novaConnection";
8
+ export type { IncrementalMotion } from "./incrementalCartesianMotion";
5
9
  export type Vector3Simple = [number, number, number];
10
+ /** A step jog: see `JoggerConnection.runIncrementalCartesianMotion` */
11
+ export type IncrementalCartesianMotionRequest = {
12
+ currentTcpPose: Pose;
13
+ currentJoints: Vector3Simple;
14
+ /**
15
+ * @deprecated Not used: a step follows the jogger's `orientation` and
16
+ * `coordinateSystem`
17
+ */
18
+ coordSystemId?: string;
19
+ velocityInRelevantUnits: number;
20
+ axis: "x" | "y" | "z";
21
+ direction: "-" | "+";
22
+ motion: IncrementalMotion;
23
+ /**
24
+ * Why the robot may not move now, or null when it may. The step asks right
25
+ * before it sends its trajectory to NOVA and right before it starts it:
26
+ * with a reason it sends nothing more and rejects with a
27
+ * `JoggingRefusedError`, also with `onError`, since the robot did not
28
+ * move. Planning the step and NOVA's answer to its trajectory take a round
29
+ * trip each, and NOVA switches a controller to control mode by itself for
30
+ * a movement request. The jogging store gives it.
31
+ */
32
+ refusedReason?: () => JoggingRefusedReason | null;
33
+ };
6
34
  export type JoggerConnectionOptions = {
7
35
  mode?: JoggerMode;
8
36
  timeout?: number;
9
37
  /**
10
- * When an error message is received from the jogging websocket, it
11
- * will be passed here. If this handler is not provided, the error will
12
- * instead be thrown as an unhandled error.
38
+ * Gets the errors of the jogging websocket and of step jogs (a refused
39
+ * or failed plan, a refused trajectory, a motion that does not end). Without
40
+ * it, the initialization of the jogging websocket and the step jog reject
41
+ * with the error.
13
42
  */
14
43
  onError?: (err: unknown) => void;
15
44
  tcp?: string;
45
+ /**
46
+ * The coordinate system whose axes cartesian jogging moves along, unless in
47
+ * tool orientation. Its pose has to be relative to world (a coordinate
48
+ * system that refers to another one has to be resolved first). Defaults to
49
+ * world.
50
+ */
51
+ coordinateSystem?: CoordinateSystem;
16
52
  orientation?: JoggerOrientation;
17
53
  /** Cell id on the Nova instance. Defaults to "cell". */
18
54
  cellId?: string;
55
+ /**
56
+ * Model name sent to the planner for incremental motions. Defaults to the
57
+ * model in the motion group description; pass the resolved name for a robot
58
+ * whose data lives in a custom copy.
59
+ */
60
+ motionGroupModel?: string;
61
+ /**
62
+ * Where the jogger logs, and the motion stream that `open()` opens.
63
+ * Defaults to the console.
64
+ */
65
+ logger?: ConnectionLogger;
19
66
  };
20
67
  export type JoggerMode = "jogging" | "trajectory" | "off";
21
68
  export type JoggerOrientation = "coordsys" | "tool";
@@ -32,13 +79,34 @@ export declare class JoggerConnection {
32
79
  trajectorySocket: AutoReconnectingWebsocket | null;
33
80
  timeout: number;
34
81
  tcp: string | undefined;
82
+ /** See {@link JoggerConnectionOptions.coordinateSystem}. Applies to the next jog command. */
83
+ coordinateSystem: CoordinateSystem | undefined;
35
84
  orientation: JoggerOrientation;
36
85
  onError?: (err: unknown) => void;
37
86
  onBlocked?: () => void;
87
+ private readonly logger;
88
+ /**
89
+ * Set from planning an incremental jog until the robot has come to a
90
+ * standstill again. Jogs requested in between are dropped: their trajectory
91
+ * would be planned from a joint position the robot has already left, and the
92
+ * controller refuses that with "Motion group is not at expected location on
93
+ * trajectory. Please move to the trajectory!".
94
+ */
95
+ private incrementalMotionInFlight;
96
+ /** Ends an incremental jog that still waits for the robot */
97
+ private endIncrementalMotion?;
98
+ /**
99
+ * Whether the jogger opened its motion stream itself (in `open()`): then
100
+ * `dispose()` closes it too. A motion stream given to the constructor
101
+ * belongs to the caller.
102
+ */
103
+ private ownsMotionStream;
104
+ /** Ends a jogging initialization that still waits for NOVA */
105
+ private endJoggingInit?;
38
106
  /**
39
107
  * Initialize the jogging connection using jogging endpoint or trajectory endpoint depending on the selected mode.
40
108
  *
41
- * @param nova - The Nova client instance
109
+ * @param connection - The base URL of a NOVA instance, or a NOVA client of the app (see `NovaConnection`)
42
110
  * @param motionGroupId - The ID of the motion group to connect to
43
111
  * @param options - Configuration options for the jogger connection
44
112
  * @param options.mode - The jogging mode to initialize:
@@ -47,22 +115,40 @@ export declare class JoggerConnection {
47
115
  * - "off": No jogging enabled, all websockets closed (default)
48
116
  * @param options.timeout - Timeout in milliseconds for websocket initialization (default: 5000ms)
49
117
  * @param options.tcp - TCP frame to use for motions (default: from motion group)
50
- * //param options.coordinateSystem - Coordinate system for jogging commands (default: "world"). Please note: Currently not implemented
118
+ * @param options.coordinateSystem - Coordinate system whose axes cartesian jogging moves along, relative to world (default: world)
51
119
  * @param options.orientation - If set to "tool", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option (default: "coordsys")
52
- * @param options.onError - Error handler for websocket errors
53
- * @returns Promise resolving to initialized JoggerConnection instance
120
+ * @param options.onError - Error handler for websocket errors and step jogs
121
+ * @param options.motionGroupModel - Model name for planning step jogs (default: from the motion group description)
122
+ * @param options.logger - Where the jogger and its motion stream log (default: the console)
123
+ * @returns Promise resolving to initialized JoggerConnection instance. Its
124
+ * `dispose()` also closes the motion stream that this function opens.
54
125
  */
55
- static open(nova: AnyNovaClient, motionGroupId: string, options?: JoggerConnectionOptions): Promise<JoggerConnection>;
126
+ static open(connection: NovaConnection, motionGroupId: string, options?: JoggerConnectionOptions): Promise<JoggerConnection>;
56
127
  constructor(motionStream: MotionStreamConnection, options?: JoggerConnectionOptions | undefined);
57
128
  getDefaultTcp(motionStream: MotionStreamConnection): string | undefined;
58
129
  setOptions(options: Partial<JoggerConnectionOptions>): Promise<void>;
59
130
  get motionGroupId(): string;
60
- get nova(): import("@wandelbots/nova-js/v2").Nova;
61
131
  get cellId(): string;
62
132
  get numJoints(): number;
63
133
  stop(): Promise<void>;
134
+ /**
135
+ * Dispose the jogger, closing all open websockets: the jogging websockets,
136
+ * and the motion stream if the jogger opened it (in `open()`). A motion
137
+ * stream given to the constructor stays open: its caller closes it.
138
+ */
64
139
  dispose(): Promise<void[]>;
140
+ /** Closes the jogging and trajectory websockets */
141
+ private closeJoggingSockets;
65
142
  setJoggingMode(mode: JoggerMode, skipReinitializeIfSameMode?: boolean): Promise<void>;
143
+ /**
144
+ * Opens the continuous jogging websocket and initializes it; called by
145
+ * `setJoggingMode("jogging")`. The promise settles once:
146
+ * - it resolves when NOVA confirms the initialization (INITIALIZE_RECEIVED),
147
+ * when the jogger closes the websocket before that (`setJoggingMode`,
148
+ * `dispose`), or when an error message goes to `onBlocked` or `onError`;
149
+ * - it rejects on an error message without such a handler, and when NOVA
150
+ * does not confirm the initialization within `timeout` milliseconds.
151
+ */
66
152
  initializeJoggingWebsocket(): Promise<void>;
67
153
  /**
68
154
  * Jogging: Start rotation of a single robot joint at the specified velocity
@@ -92,27 +178,86 @@ export declare class JoggerConnection {
92
178
  direction: "-" | "+";
93
179
  velocityRadsPerSec: number;
94
180
  }): Promise<void>;
181
+ /**
182
+ * Rotation from {@link JoggerConnection.coordinateSystem} into world,
183
+ * while jogging along its axes. Undefined when jogging along world or tool
184
+ * axes.
185
+ */
186
+ private get coordinateSystemRotation();
187
+ /**
188
+ * Velocity vector along one axis of the jogging frame. The API takes TCP
189
+ * velocities in either the tool frame or world, so an axis of
190
+ * {@link JoggerConnection.coordinateSystem} is rotated into world here.
191
+ */
192
+ private velocityAlongAxis;
95
193
  /**
96
194
  * Trajectory jogging:
97
195
  *
98
196
  * Move the robot by a fixed distance in a single cartesian
99
197
  * axis, either rotating or translating relative to the TCP.
100
- * Promise resolves only after the motion has completed.
198
+ * The axis is one of the tool in tool orientation, else one of
199
+ * {@link JoggerConnection.coordinateSystem} (default: world).
200
+ *
201
+ * Promise resolves only after the motion has completed: once NOVA reports
202
+ * the trajectory at its end, or no longer as running (`stop()`), and the
203
+ * robot stands still, or after a watchdog of twice the planned duration
204
+ * plus 5 s, which also ends a step that never starts. A step requested
205
+ * while another one runs is dropped (resolves at once). Every error (a
206
+ * refused or failed plan, a refused trajectory, an error of the
207
+ * controller, the watchdog) goes to `onError`, or without it rejects the
208
+ * promise. A step that the robot may no longer make (see
209
+ * {@link IncrementalCartesianMotionRequest.refusedReason}) rejects with a
210
+ * `JoggingRefusedError`.
101
211
  */
102
- runIncrementalCartesianMotion({ currentTcpPose, currentJoints, velocityInRelevantUnits, axis, direction, motion, }: {
103
- currentTcpPose: Pose;
104
- currentJoints: Vector3Simple;
105
- coordSystemId: string;
106
- velocityInRelevantUnits: number;
107
- axis: "x" | "y" | "z";
108
- direction: "-" | "+";
109
- motion: {
110
- type: "rotate";
111
- distanceRads: number;
112
- } | {
113
- type: "translate";
114
- distanceMm: number;
115
- };
116
- }): Promise<void>;
212
+ runIncrementalCartesianMotion(request: IncrementalCartesianMotionRequest): Promise<void>;
213
+ /**
214
+ * Plan the trajectory for a single incremental jog. Returns undefined when
215
+ * no trajectory could be produced; the reason (a planner rejection such as a
216
+ * singularity, or a motion group without a cycle time) is reported through
217
+ * {@link JoggerConnection.onError} or logged.
218
+ */
219
+ private planIncrementalCartesianMotion;
220
+ /**
221
+ * Execute a planned trajectory https://portal.wandelbots.io/docs/api/v2/ui/#/operations/executeTrajectory
222
+ * and resolve once the robot has run it to its end and stands still again
223
+ * (see {@link JoggerConnection.waitForMotionToFinish}), so that the caller
224
+ * -- and with it the jogging UI's motion lock -- stays blocked for the
225
+ * whole motion. It also resolves when the jogger closes the websocket
226
+ * (`setJoggingMode`, `dispose`).
227
+ *
228
+ * Each call owns its own websocket. Sharing
229
+ * {@link JoggerConnection.trajectorySocket} across motions meant a finishing
230
+ * motion closed the socket of a later one.
231
+ *
232
+ * `refusedReason` is asked right before the trajectory and its start go to
233
+ * NOVA, see {@link IncrementalCartesianMotionRequest.refusedReason}
234
+ */
235
+ private executeTrajectory;
236
+ /**
237
+ * Resolve once the robot has finished executing a trajectory.
238
+ *
239
+ * What says so is the execution state in the motion stream (`execute`),
240
+ * which NOVA gives to follow a movement. `standstill` alone does not: it
241
+ * says that NOVA treats the measured joint velocities as 0, which is so
242
+ * before the robot picks up speed and can be so for the whole of a slow
243
+ * motion. A step that took `standstill` as its end closed its websocket,
244
+ * and with it stopped the robot, soon after the start of a 5° turn at
245
+ * 1 °/s.
246
+ *
247
+ * So the step is over when NOVA has run the trajectory to its end, or no
248
+ * longer runs it after it did (NOVA executes nothing any more), and the
249
+ * robot stands still. A step that never starts does not get here: the
250
+ * watchdog of `executeTrajectory` ends it with an error.
251
+ */
252
+ private waitForMotionToFinish;
253
+ /**
254
+ * Resolve once NOVA no longer runs a trajectory and the robot stands
255
+ * still: at the end of the trajectory, or after a pause
256
+ */
257
+ private waitUntilStopped;
258
+ /** The trajectory that NOVA executes now, as the motion stream reports it */
259
+ private get executedTrajectory();
260
+ /** Whether NOVA moves the robot along a trajectory, or is about to */
261
+ private get isTrajectoryRunning();
117
262
  }
118
263
  export default JoggerConnection;
@@ -1,12 +1,16 @@
1
1
  import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
2
- import type { MotionGroupDescription, MotionGroupState, Nova, RobotControllerState } from "@wandelbots/nova-js/v2";
3
- import { type AnyNovaClient } from "./novaCompat";
2
+ import type { MotionGroupDescription, MotionGroupState, RobotControllerState } from "@wandelbots/nova-js/v2";
3
+ import type { ConnectionLogger } from "./connectionLogger";
4
+ import { type MotionStateReadout } from "./motionStateUpdate";
5
+ import { type NovaConnection } from "./novaConnection";
4
6
  /**
5
7
  * Store representing the current state of a connected motion group.
6
8
  */
7
9
  export type MotionStreamConnectionOptions = {
8
10
  /** Cell id on the Nova instance. Defaults to "cell". */
9
11
  cellId?: string;
12
+ /** Where the stream logs. Defaults to the console. */
13
+ logger?: ConnectionLogger;
10
14
  };
11
15
  export declare class MotionStreamConnection {
12
16
  readonly controller: RobotControllerState;
@@ -15,11 +19,17 @@ export declare class MotionStreamConnection {
15
19
  readonly initialMotionState: MotionGroupState;
16
20
  readonly motionStateSocket: AutoReconnectingWebsocket;
17
21
  readonly cellId: string;
18
- static open(novaClient: AnyNovaClient, motionGroupId: string, options?: MotionStreamConnectionOptions): Promise<MotionStreamConnection>;
22
+ static open(connection: NovaConnection, motionGroupId: string, options?: MotionStreamConnectionOptions): Promise<MotionStreamConnection>;
19
23
  rapidlyChangingMotionState: MotionGroupState;
20
- /** Normalized instance-level Nova client (see `asNovaInstance`) */
21
- readonly nova: Nova;
22
- constructor(nova: AnyNovaClient, controller: RobotControllerState, motionGroup: MotionGroupState, description: MotionGroupDescription, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, cellId?: string);
24
+ private readonly logger;
25
+ constructor(connection: NovaConnection, controller: RobotControllerState, motionGroup: MotionGroupState, description: MotionGroupDescription, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, cellId?: string, options?: Pick<MotionStreamConnectionOptions, "logger">);
26
+ /**
27
+ * What pose readouts show (joints, TCP pose): it holds the previous reading
28
+ * while the joints only jitter (less than 0.0002 rad), and while the TCP and
29
+ * the coordinate system stay. Kept alive, so it also holds for untracked
30
+ * reads, e.g. from requestAnimationFrame.
31
+ */
32
+ get readoutState(): MotionStateReadout;
23
33
  get motionGroupId(): string;
24
34
  get controllerId(): string;
25
35
  get joints(): {
@@ -0,0 +1,22 @@
1
+ import type { CoordinateSystem, Pose, RobotTcp } from "@wandelbots/nova-js/v2";
2
+ import { Quaternion, Vector3 } from "three";
3
+ /**
4
+ * Partial port of Pose math for use on the frontend, allowing
5
+ * us to avoid a network roundtrip for fast animation stuff
6
+ * See https://code.wabo.run/robotics/wb-robotix/-/blob/develop/src/math/core/include/wb/math/space/Pose.h
7
+ *
8
+ * Ported from RobotPad (src/util/Pose3.ts), only what the jogger and the
9
+ * jogging store use.
10
+ */
11
+ export declare class Pose3 {
12
+ readonly position: Vector3;
13
+ readonly quaternion: Quaternion;
14
+ static fromPose(apiPose: Pose): Pose3;
15
+ /** A TCP's offset from the flange */
16
+ static fromRobotTcp(robotTcp: Pick<RobotTcp, "position" | "orientation" | "orientation_type">): Pose3;
17
+ static fromCoordinateSystem(coordinateSystem: CoordinateSystem): Pose3;
18
+ constructor(position: Vector3, quaternion: Quaternion);
19
+ inverse(): Pose3;
20
+ multiply(other: Pose3): Pose3;
21
+ get orientation(): Vector3;
22
+ }
@@ -0,0 +1,44 @@
1
+ import type { CoordinateSystem, MotionGroupDescription, Pose, RobotTcp } from "@wandelbots/nova-js/v2";
2
+ /** A pose and the coordinate system that it is relative to */
3
+ export type ReferencedPose = {
4
+ pose: Required<Pose>;
5
+ coordinateSystemId: string;
6
+ };
7
+ /** A pose of a TCP, and the coordinate system that it is relative to */
8
+ export type TcpReferencedPose = ReferencedPose & {
9
+ tcpId: string;
10
+ };
11
+ /**
12
+ * A coordinate system's pose relative to world, following its chain of
13
+ * reference coordinate systems. Throws for an unknown id.
14
+ */
15
+ export declare function resolveCoordinateSystemInWorld(coordinateSystemId: string, coordinateSystems: CoordinateSystem[]): CoordinateSystem;
16
+ /**
17
+ * The pose expressed in another coordinate system. Coordinate systems that
18
+ * refer to others are resolved through `coordinateSystems`; an empty id is
19
+ * world. Throws for an unknown id. What else the pose carries, such as its
20
+ * TCP, stays.
21
+ */
22
+ export declare function transformPoseToCoordinateSystem<T extends ReferencedPose>(inputPose: T, targetCoordinateSystemId: string, coordinateSystems: CoordinateSystem[]): T;
23
+ /** A TCP's offset from the flange, as `RobotTcp` has it */
24
+ export type TcpOffset = Pick<RobotTcp, "position" | "orientation" | "orientation_type">;
25
+ /**
26
+ * The pose of one TCP as the pose of another TCP of the same flange, both
27
+ * relative to the same coordinate system: back to the flange, then out to
28
+ * the other TCP
29
+ */
30
+ export declare function transformPoseToTcp(pose: Pose, poseTcp: TcpOffset, targetTcp: TcpOffset): Required<Pose>;
31
+ /**
32
+ * A TCP's pose as the pose of the selected TCP, in the selected coordinate
33
+ * system: e.g. the pose that NOVA reports as the one the user chose to see.
34
+ * Without a selection the pose stays as it is. Throws for an unknown TCP or
35
+ * coordinate system.
36
+ */
37
+ export declare function deriveSelectedTcpPose({ inputPose, selectedTcpId, selectedCoordinateSystemId, tcpOffsetsById, coordinateSystems, }: {
38
+ inputPose: TcpReferencedPose;
39
+ selectedTcpId?: string;
40
+ selectedCoordinateSystemId?: string;
41
+ /** The motion group's TCPs, as its description lists them */
42
+ tcpOffsetsById: MotionGroupDescription["tcps"];
43
+ coordinateSystems: CoordinateSystem[];
44
+ }): TcpReferencedPose;
@@ -0,0 +1,260 @@
1
+ import { type Pose } from "@wandelbots/nova-js/v2";
2
+ import type { JoggingStore } from "../components/jogging/JoggingStore";
3
+ import type { ConnectionLogger } from "./connectionLogger";
4
+ import { type RobotPose } from "./robotSession/robotPose";
5
+ import type { RobotNotMoveableReason } from "./robotSession/RobotSafety";
6
+ /** Where {@link TrajectoryExecutionStore.planTrajectory} moves the robot to */
7
+ export type TrajectoryTarget = {
8
+ type: "cartesian";
9
+ /**
10
+ * The pose of the jogging store's selected TCP, in the coordinate
11
+ * system `coordinateSystemId`
12
+ */
13
+ pose: Pose;
14
+ /**
15
+ * A coordinate system of the jogging store's `coordSystems`, also one
16
+ * that refers to another. Defaults to world.
17
+ */
18
+ coordinateSystemId?: string;
19
+ } | {
20
+ type: "joint";
21
+ /** The position of each joint (rad, or mm for a prismatic joint) */
22
+ joints: number[];
23
+ };
24
+ /**
25
+ * Outcome of a planTrajectory call. Planner rejections (unreachable pose,
26
+ * singularity, joint limit, ...) are an expected user-facing result rather
27
+ * than an exception, so they are returned as a value carrying the backend's
28
+ * error_feedback_name (e.g. "FeedbackOutOfWorkspace") for the caller to
29
+ * translate into a friendly message, see `planErrorTranslationKey`.
30
+ */
31
+ export type PlanTrajectoryResult = {
32
+ ok: true;
33
+ } | {
34
+ ok: false;
35
+ errorFeedbackName: string;
36
+ };
37
+ /** The first and the last joint positions of the planned trajectory */
38
+ export type PlannedTrajectory = {
39
+ startJoints: number[];
40
+ endJoints: number[];
41
+ };
42
+ /**
43
+ * - "idle": no trajectory
44
+ * - "planning": a trajectory is planned or waits for NOVA to accept it
45
+ * - "planned": NOVA accepted the trajectory, `hold` or `start` moves the robot
46
+ * - "moving": the robot moves along the trajectory
47
+ * - "stopping": the robot decelerates after a pause
48
+ */
49
+ export type TrajectoryState = "idle" | "planning" | "planned" | "moving" | "stopping";
50
+ /** See {@link TrajectoryExecutionStore} */
51
+ export type TrajectoryExecutionStoreOptions = {
52
+ /**
53
+ * The jogging store of the motion group: its jogger's connection, the
54
+ * selected TCP, the coordinate systems and the velocities
55
+ */
56
+ joggingStore: JoggingStore;
57
+ /**
58
+ * Whether the app locks the robot. `planTrajectory`, `start` and `hold`
59
+ * refuse then. Defaults to never locked.
60
+ */
61
+ isLocked?: () => boolean;
62
+ /**
63
+ * Why the robot may not move now, or null when it may. `planTrajectory`,
64
+ * `start` and `hold` refuse while there is a reason: NOVA switches a
65
+ * controller to control mode by itself for a movement request, the
66
+ * trajectory as its start, and holds it there while it holds the
67
+ * trajectory. Defaults to a robot that may always move; a robot session
68
+ * gives the reason that its jogging follows.
69
+ */
70
+ notMoveableReason?: () => RobotNotMoveableReason | null;
71
+ /**
72
+ * Called before each plan: ends every other motion of the app that holds
73
+ * the controller's execution session. Defaults to ending continuous jogging
74
+ * and putting the jogger into its "trajectory" mode.
75
+ */
76
+ ensureMovementOwnership?: () => Promise<void>;
77
+ /** Where the store logs. Defaults to the console. */
78
+ logger?: ConnectionLogger;
79
+ };
80
+ /**
81
+ * Moves the robot to a target ("Move to"): plans a trajectory to it, keeps it
82
+ * initialized on an execution websocket of the controller, and starts and
83
+ * pauses the motion along it. Without a UI: an app shows `trajectoryState`,
84
+ * `plannedTrajectory` and `lastError` and calls the actions. For a button
85
+ * that moves the robot while it is held, these are `hold` and `release`:
86
+ * they see to it that the robot stops after a release, whatever the order
87
+ * of NOVA's messages.
88
+ *
89
+ * A planned trajectory holds the controller's execution session, also after
90
+ * the robot arrived, until `stopAndReset`. So an app calls that before
91
+ * jogging again (e.g. from the jogging store's `onBeforeActivate`).
92
+ */
93
+ export declare class TrajectoryExecutionStore {
94
+ private readonly options;
95
+ /** The trajectory that `hold` and `start` move along, from the last plan */
96
+ plannedTrajectory: PlannedTrajectory | null;
97
+ /** See {@link TrajectoryState} */
98
+ trajectoryState: TrajectoryState;
99
+ /** The message of the last motion error. `clearError` removes it. */
100
+ lastError: string | null;
101
+ private socket;
102
+ /**
103
+ * NOVA got a trajectory on the execution websocket and the websocket is
104
+ * still open: it may hold the trajectory, whatever became of the plan here
105
+ */
106
+ private armed;
107
+ /**
108
+ * What the planned trajectory was planned for: where it goes, as
109
+ * `planTrajectory` got it, and its velocity limit
110
+ */
111
+ private plannedFor;
112
+ /**
113
+ * What NOVA was asked to do on the execution websocket, whatever became of
114
+ * the plan here: a start is on its way ("starting"), NOVA confirmed it
115
+ * ("running"), a pause followed ("pausing"), or nothing moves (null)
116
+ */
117
+ private motion;
118
+ /** The hold ended while "starting": pause once NOVA confirms the start */
119
+ private releaseOnStart;
120
+ /** Set by `dispose`: no execution websocket opens any more */
121
+ private disposed;
122
+ private readonly disposers;
123
+ private readonly logger;
124
+ private get joggingStore();
125
+ private get jogger();
126
+ private get motionStream();
127
+ /**
128
+ * Whether NOVA may still hold a trajectory of this store, and with it the
129
+ * controller's execution session, which blocks jogging and keeps the
130
+ * controller in control mode: from a plan that NOVA got until
131
+ * `stopAndReset`. Also after `reset`, after the robot arrived and after a
132
+ * failed move, which only drop the plan here.
133
+ */
134
+ get holdsExecutionSession(): boolean;
135
+ /**
136
+ * Whether the planned trajectory was planned with another velocity than
137
+ * the jogging store has now: the velocity is part of the trajectory, and
138
+ * the store's slider stays live. `hold` does not start such a trajectory;
139
+ * plan the target again to move at the velocity that shows.
140
+ */
141
+ get isPlanOutdated(): boolean;
142
+ /** The target of a pose of this motion group; null for another's */
143
+ private targetOf;
144
+ /** The execution state that the motion stream reports, e.g. "RUNNING" */
145
+ get executionState(): "PAUSED_BY_USER" | "PAUSED_NEAR_COLLISION" | "PAUSED_NEAR_JOINT_LIMIT" | "PAUSED_NEAR_SINGULARITY" | "PAUSED_ON_IO" | "RUNNING" | "END_OF_TRAJECTORY" | "WAIT_FOR_IO" | undefined;
146
+ /**
147
+ * Plans a trajectory from the current joints to the target and initializes
148
+ * it on the execution websocket. The store is "planned" once NOVA accepted
149
+ * it. Returns a planner rejection as a value; throws while the app locks
150
+ * the robot or the robot may not move (see
151
+ * `TrajectoryExecutionStoreOptions`), also when that came to be while the
152
+ * planner worked, and when the planner cannot be reached. A target that
153
+ * cannot be planned leaves no trajectory, also not the one before it on
154
+ * the controller.
155
+ *
156
+ * `to` is a target, or a pose as an app saves it (`RobotPose`): its joints,
157
+ * or its TCP pose in its coordinate system, planned for the selected TCP.
158
+ * Throws for a pose of another motion group, and plans nothing then.
159
+ */
160
+ planTrajectory(to: TrajectoryTarget | RobotPose): Promise<PlanTrajectoryResult>;
161
+ /**
162
+ * The Move to button is held: starts the motion along the planned
163
+ * trajectory, or goes on with a paused one. Returns whether the robot moves
164
+ * for this hold: not without a trajectory that NOVA accepted, not while
165
+ * the move before it still stops, not along a trajectory that was
166
+ * planned with another velocity than now
167
+ * ({@link TrajectoryExecutionStore.isPlanOutdated}), and not while the
168
+ * robot may not move or the app locks it (see
169
+ * `TrajectoryExecutionStoreOptions`). Safe to repeat while held.
170
+ * {@link TrajectoryExecutionStore.release} ends the hold.
171
+ *
172
+ * `to` is where the button says it moves to, as `planTrajectory` got it:
173
+ * the robot does not move along a trajectory that was planned for another
174
+ * target, e.g. while the plan for the shown one is still to come or
175
+ * failed, nor for a pose of another motion group. Without it, the hold
176
+ * starts whatever is planned.
177
+ */
178
+ hold(to?: TrajectoryTarget | RobotPose): boolean;
179
+ /**
180
+ * The Move to button was let go: pauses the motion. Whatever the motion
181
+ * stream shows by then, and also when the plan is gone here: only NOVA's
182
+ * own word that the trajectory ended makes a pause needless. A release
183
+ * before NOVA confirmed the start pauses as soon as it does, however late.
184
+ * Resolves once the robot stands still; the trajectory stays planned, so
185
+ * `hold` goes on from there. Does nothing when nothing moves, and is safe
186
+ * to repeat.
187
+ */
188
+ release(): Promise<void>;
189
+ /**
190
+ * Starts the motion along the planned trajectory. For a button that is
191
+ * held, use {@link TrajectoryExecutionStore.hold}. Throws when nothing can
192
+ * start, and while the robot may not move or the app locks it (see
193
+ * `TrajectoryExecutionStoreOptions`).
194
+ */
195
+ start(): void;
196
+ /**
197
+ * Why the store sends the robot no trajectory and no start now, or null:
198
+ * the app locks the robot, or the robot may not move
199
+ */
200
+ private refusal;
201
+ /**
202
+ * Drops the plan and throws while the store sends the robot no
203
+ * trajectory, see {@link TrajectoryExecutionStore.planTrajectory}
204
+ */
205
+ private dropPlanIfRefused;
206
+ /**
207
+ * Pauses the motion. Resolves once the robot stands still; the trajectory
208
+ * stays planned, so `start` goes on from there. For a button that was let
209
+ * go, use {@link TrajectoryExecutionStore.release}.
210
+ */
211
+ pause(): Promise<void>;
212
+ /**
213
+ * Stops a moving robot, drops the trajectory and hands the controller's
214
+ * execution session back: closes the execution websocket and opens a new
215
+ * one for the next plan
216
+ */
217
+ stopAndReset(): Promise<void>;
218
+ /**
219
+ * Drops the planned trajectory here, without telling NOVA: it keeps the
220
+ * trajectory and the execution session, see
221
+ * {@link TrajectoryExecutionStore.holdsExecutionSession}
222
+ */
223
+ reset(): void;
224
+ /**
225
+ * Drops the plan because its next target cannot be planned. The trajectory
226
+ * before it is still armed on the controller, so the execution session goes
227
+ * back as well: with no plan here, nothing else would ask for that.
228
+ */
229
+ private dropPlan;
230
+ /** Removes {@link TrajectoryExecutionStore.lastError} */
231
+ clearError(): void;
232
+ /**
233
+ * Closes the execution websocket and stops following the motion stream.
234
+ * No execution websocket opens afterwards.
235
+ */
236
+ dispose(): void;
237
+ /**
238
+ * The velocity limit of a trajectory to a target: the jogging store's
239
+ * translation velocity (mm/s) for a pose, and for joints the velocity
240
+ * they are jogged with, which is its rotation velocity (rad/s), or its
241
+ * translation velocity (mm/s) for linear axes
242
+ */
243
+ private velocityFor;
244
+ /** Ends continuous jogging, unless the app has its own way */
245
+ private ensureMovementOwnership;
246
+ private sendStart;
247
+ /** Sends the pause of the move, once */
248
+ private sendPause;
249
+ /**
250
+ * After a pause: once the robot stands still, the trajectory is planned
251
+ * again. Not when the robot was started again meanwhile: that move has a
252
+ * pause of its own to wait for.
253
+ */
254
+ private settlePause;
255
+ /** Resolves once the motion stream reports that the robot stands still */
256
+ private waitUntilStopped;
257
+ private handleMessage;
258
+ private openSocket;
259
+ private closeSocket;
260
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Where the library's NOVA connections log: the console by default, or an
3
+ * app's own logger (e.g. one that sends the lines to its backend)
4
+ */
5
+ export type ConnectionLogger = {
6
+ info: (message: string, data?: unknown) => void;
7
+ debug: (message: string, data?: unknown) => void;
8
+ warn: (message: string, data?: unknown) => void;
9
+ };