@wandelbots/wandelbots-js-react-components 2.27.1-pr.feature-update-to-react-19.361.57aba09 → 2.27.1-pr.feature-add-program-control-component.367.8730636

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/Setup.d.ts +1 -1
  3. package/dist/Setup.d.ts.map +1 -1
  4. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +2 -2
  5. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  6. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts +1 -1
  7. package/dist/components/3d-viewport/TrajectoryRenderer.d.ts.map +1 -1
  8. package/dist/components/ProgramControl.d.ts +43 -0
  9. package/dist/components/ProgramControl.d.ts.map +1 -0
  10. package/dist/components/robots/DHRobot.d.ts.map +1 -1
  11. package/dist/components/robots/GenericRobot.d.ts +2 -2
  12. package/dist/components/robots/GenericRobot.d.ts.map +1 -1
  13. package/dist/components/robots/Robot.d.ts +2 -2
  14. package/dist/components/robots/Robot.d.ts.map +1 -1
  15. package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
  16. package/dist/components/robots/SupportedRobot.d.ts +3 -3
  17. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  18. package/dist/externalizeComponent.d.ts +1 -1
  19. package/dist/externalizeComponent.d.ts.map +1 -1
  20. package/dist/index.cjs +47 -39
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +9441 -7734
  25. package/dist/index.js.map +1 -1
  26. package/package.json +32 -33
  27. package/src/Setup.tsx +1 -1
  28. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +2 -2
  29. package/src/components/3d-viewport/TrajectoryRenderer.tsx +1 -1
  30. package/src/components/ProgramControl.tsx +217 -0
  31. package/src/components/jogging/JoggingOptions.tsx +1 -1
  32. package/src/components/robots/DHRobot.tsx +10 -37
  33. package/src/components/robots/GenericRobot.tsx +5 -4
  34. package/src/components/robots/Robot.tsx +2 -2
  35. package/src/components/robots/RobotAnimator.tsx +23 -38
  36. package/src/components/robots/SupportedRobot.tsx +3 -3
  37. package/src/components/utils/converters.ts +1 -1
  38. package/src/externalizeComponent.tsx +1 -1
  39. package/src/i18n/locales/de/translations.json +5 -1
  40. package/src/i18n/locales/en/translations.json +5 -1
  41. package/src/index.ts +1 -1
  42. package/dist/components/robots/RobotAnimator.test.d.ts +0 -2
  43. package/dist/components/robots/RobotAnimator.test.d.ts.map +0 -1
  44. package/dist/components/utils/interpolation.d.ts +0 -159
  45. package/dist/components/utils/interpolation.d.ts.map +0 -1
  46. package/dist/components/utils/interpolation.test.d.ts +0 -2
  47. package/dist/components/utils/interpolation.test.d.ts.map +0 -1
  48. package/dist/test/setup.d.ts +0 -2
  49. package/dist/test/setup.d.ts.map +0 -1
  50. package/src/components/robots/RobotAnimator.test.tsx +0 -113
  51. package/src/components/utils/interpolation.test.ts +0 -1123
  52. package/src/components/utils/interpolation.ts +0 -379
  53. package/src/test/setup.ts +0 -111
@@ -43,5 +43,9 @@
43
43
  "Jogging.CoordinateSystem.hlb": "Koordinatensystem",
44
44
  "Jogging.Cartesian.bt": "Kartesisch",
45
45
  "Jogging.Joints.bt": "Gelenke",
46
- "Jogging.Velocity.bt": "Geschwindigkeit"
46
+ "Jogging.Velocity.bt": "Geschwindigkeit",
47
+ "ProgramControl.Run.bt": "Starten",
48
+ "ProgramControl.Resume.bt": "Fortsetzen",
49
+ "ProgramControl.Pause.bt": "Pausieren",
50
+ "ProgramControl.Stop.bt": "Stoppen"
47
51
  }
@@ -44,5 +44,9 @@
44
44
  "Jogging.CoordinateSystem.hlb": "Coordinate system",
45
45
  "Jogging.Cartesian.bt": "Cartesian",
46
46
  "Jogging.Joints.bt": "Joints",
47
- "Jogging.Velocity.bt": "Velocity"
47
+ "Jogging.Velocity.bt": "Velocity",
48
+ "ProgramControl.Run.bt": "Run",
49
+ "ProgramControl.Resume.bt": "Resume",
50
+ "ProgramControl.Pause.bt": "Pause",
51
+ "ProgramControl.Stop.bt": "Stop"
48
52
  }
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./components/jogging/PoseCartesianValues"
9
9
  export * from "./components/jogging/PoseJointValues"
10
10
  export * from "./components/LoadingCover"
11
11
  export * from "./components/modal/NoMotionGroupModal"
12
+ export * from "./components/ProgramControl"
12
13
  export * from "./components/robots/AxisConfig"
13
14
  export * from "./components/robots/Robot"
14
15
  export { defaultGetModel } from "./components/robots/robotModelLogic"
@@ -16,7 +17,6 @@ export * from "./components/robots/SupportedRobot"
16
17
  export * from "./components/safetyBar/SafetyBar"
17
18
  export * from "./components/SelectableFab"
18
19
  export * from "./components/utils/hooks"
19
- export * from "./components/utils/interpolation"
20
20
  export * from "./components/VelocitySlider"
21
21
  export * from "./components/wandelscript-editor/WandelscriptEditor"
22
22
  export * from "./i18n/config"
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=RobotAnimator.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RobotAnimator.test.d.ts","sourceRoot":"","sources":["../../../src/components/robots/RobotAnimator.test.tsx"],"names":[],"mappings":""}
@@ -1,159 +0,0 @@
1
- /**
2
- * Smooth value interpolation utility using spring physics with tension and friction.
3
- * Designed for React Three Fiber applications with smooth, natural animations.
4
- *
5
- * Features:
6
- * - Spring physics with configurable tension and friction
7
- * - Frame-rate independent using delta timing
8
- * - Handles irregular frame timing and rapid target updates
9
- * - Manual update() calls for useFrame integration (no automatic RAF loop)
10
- * - Direct mutation for performance
11
- *
12
- * @example
13
- * ```tsx
14
- * // Basic spring animation
15
- * const interpolator = new ValueInterpolator([0, 0, 0], {
16
- * tension: 120, // Higher = faster, stiffer spring (default: 120)
17
- * friction: 20, // Higher = more damping, less oscillation (default: 20)
18
- * onChange: (values) => {
19
- * robot.joints.forEach((joint, i) => {
20
- * joint.rotation.y = values[i]
21
- * })
22
- * }
23
- * })
24
- *
25
- * interpolator.setTarget([1.5, -0.8, 2.1])
26
- *
27
- * // React Three Fiber usage
28
- * function MyComponent() {
29
- * const [interpolator] = useInterpolation([0, 0, 0])
30
- *
31
- * useFrame((state, delta) => {
32
- * interpolator.update(delta)
33
- * })
34
- *
35
- * useEffect(() => {
36
- * interpolator.setTarget([1, 2, 3])
37
- * }, [])
38
- *
39
- * return <mesh position={interpolator.getCurrentValues()} />
40
- * }
41
- * ```
42
- */
43
- export interface InterpolationOptions {
44
- /** Spring tension (higher = faster, stiffer spring) - default: 120 */
45
- tension?: number;
46
- /** Spring friction (higher = more damping, less oscillation) - default: 20 */
47
- friction?: number;
48
- /** Minimum threshold to consider interpolation complete - default: 0.001 */
49
- threshold?: number;
50
- /** Callback when values change during interpolation */
51
- onChange?: (values: number[]) => void;
52
- /** Callback when interpolation reaches target values */
53
- onComplete?: (values: number[]) => void;
54
- }
55
- export declare class ValueInterpolator {
56
- private currentValues;
57
- private targetValues;
58
- private previousTargetValues;
59
- private targetUpdateTime;
60
- private animationId;
61
- private options;
62
- private updateCount;
63
- private velocities;
64
- constructor(initialValues?: number[], options?: InterpolationOptions);
65
- /**
66
- * Update interpolation using spring physics
67
- *
68
- * Call this method every frame for smooth animation. In React Three Fiber,
69
- * call from within useFrame callback with the provided delta time.
70
- *
71
- * @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)
72
- * @returns true when interpolation is complete (all values reached their targets)
73
- */
74
- update(delta?: number): boolean;
75
- /**
76
- * Set new target values for the interpolation to move towards
77
- *
78
- * Includes smart blending for very rapid target updates (faster than 120fps)
79
- * to prevent jarring movements when targets change frequently.
80
- */
81
- setTarget(newValues: number[]): void;
82
- /**
83
- * Get a copy of all current interpolated values
84
- */
85
- getCurrentValues(): number[];
86
- /**
87
- * Get a single interpolated value by its array index
88
- */
89
- getValue(index: number): number;
90
- /**
91
- * Check if automatic interpolation is currently running
92
- *
93
- * This only tracks auto-interpolation started with startAutoInterpolation().
94
- * Manual update() calls are not tracked by this method.
95
- */
96
- isInterpolating(): boolean;
97
- /**
98
- * Stop automatic interpolation if it's running
99
- *
100
- * This cancels the internal animation frame loop but does not affect
101
- * manual update() calls.
102
- */
103
- stop(): void;
104
- /**
105
- * Instantly set values without interpolation
106
- */
107
- setImmediate(values: number[]): void;
108
- /**
109
- * Update interpolation options
110
- */
111
- updateOptions(newOptions: Partial<InterpolationOptions>): void;
112
- /**
113
- * Start automatic interpolation with an animation loop
114
- *
115
- * This begins a requestAnimationFrame loop that calls update() automatically.
116
- * For React Three Fiber components, prefer using manual update() calls
117
- * within useFrame hooks instead.
118
- */
119
- startAutoInterpolation(): void;
120
- /**
121
- * Clean up all resources and stop any running animations
122
- *
123
- * This cancels any active animation frames and resets internal state.
124
- * Call this when the component unmounts or is no longer needed.
125
- */
126
- destroy(): void;
127
- private startInterpolation;
128
- private animate;
129
- }
130
- /**
131
- * React hook for using the ValueInterpolator with useFrame
132
- *
133
- * This hook creates a ValueInterpolator that uses spring physics for smooth,
134
- * natural animations. Call interpolator.update(delta) in your useFrame callback.
135
- *
136
- * @example
137
- * ```tsx
138
- * function AnimatedMesh() {
139
- * const [interpolator] = useInterpolation([0, 0, 0], {
140
- * tension: 120, // Higher = faster spring
141
- * friction: 20 // Higher = more damping
142
- * })
143
- * const meshRef = useRef()
144
- *
145
- * useFrame((state, delta) => {
146
- * if (interpolator.update(delta)) {
147
- * // Animation complete
148
- * }
149
- * // Apply current values directly to mesh
150
- * const [x, y, z] = interpolator.getCurrentValues()
151
- * meshRef.current.position.set(x, y, z)
152
- * })
153
- *
154
- * return <mesh ref={meshRef} />
155
- * }
156
- * ```
157
- */
158
- export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator];
159
- //# sourceMappingURL=interpolation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.ts"],"names":[],"mappings":"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,IAAI;IAI9D;;;;;;OAMG;IACH,sBAAsB,IAAI,IAAI;IAI9B;;;;;OAKG;IACH,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,OAAO,CASd;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,GAAE,MAAM,EAAO,EAC5B,OAAO,GAAE,oBAAyB,GACjC,CAAC,iBAAiB,CAAC,CAqBrB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interpolation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interpolation.test.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import "@testing-library/jest-dom";
2
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAA"}
@@ -1,113 +0,0 @@
1
- import type {
2
- DHParameter,
3
- MotionGroupStateResponse,
4
- } from "@wandelbots/nova-api/v1"
5
- import { describe, expect, it, vi } from "vitest"
6
- import RobotAnimator from "./RobotAnimator"
7
-
8
- // Mock the dependencies
9
- vi.mock("./robotModelLogic", () => ({
10
- collectJoints: vi.fn(),
11
- }))
12
-
13
- vi.mock("../utils/interpolation", () => ({
14
- ValueInterpolator: vi.fn().mockImplementation(() => ({
15
- setTarget: vi.fn(),
16
- getCurrentValues: vi.fn(() => []),
17
- destroy: vi.fn(),
18
- })),
19
- }))
20
-
21
- describe("RobotAnimator", () => {
22
- it("should export the component correctly", () => {
23
- expect(RobotAnimator).toBeDefined()
24
- expect(typeof RobotAnimator).toBe("function")
25
- })
26
-
27
- it("should handle props with different numbers of joints", () => {
28
- // Test that the component accepts different numbers of DH parameters
29
- const mockMotionState4Joints: MotionGroupStateResponse = {
30
- state: {
31
- joint_position: {
32
- joints: [0.1, 0.2, 0.3, 0.4],
33
- },
34
- },
35
- } as any
36
-
37
- const mockDHParameters4Joints: DHParameter[] = [
38
- { theta: 0, reverse_rotation_direction: false },
39
- { theta: 0, reverse_rotation_direction: false },
40
- { theta: 0, reverse_rotation_direction: false },
41
- { theta: 0, reverse_rotation_direction: false },
42
- ]
43
-
44
- const mockMotionState7Joints: MotionGroupStateResponse = {
45
- state: {
46
- joint_position: {
47
- joints: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],
48
- },
49
- },
50
- } as any
51
-
52
- const mockDHParameters7Joints: DHParameter[] = Array(7).fill({
53
- theta: 0,
54
- reverse_rotation_direction: false,
55
- })
56
-
57
- // These should not throw TypeScript errors
58
- expect(() => {
59
- const props4 = {
60
- rapidlyChangingMotionState: mockMotionState4Joints,
61
- dhParameters: mockDHParameters4Joints,
62
- children: null,
63
- }
64
- // Verify props are correctly typed
65
- expect(props4.dhParameters).toHaveLength(4)
66
- expect(
67
- props4.rapidlyChangingMotionState.state.joint_position.joints,
68
- ).toHaveLength(4)
69
- }).not.toThrow()
70
-
71
- expect(() => {
72
- const props7 = {
73
- rapidlyChangingMotionState: mockMotionState7Joints,
74
- dhParameters: mockDHParameters7Joints,
75
- children: null,
76
- }
77
- expect(props7.dhParameters).toHaveLength(7)
78
- expect(
79
- props7.rapidlyChangingMotionState.state.joint_position.joints,
80
- ).toHaveLength(7)
81
- }).not.toThrow()
82
- })
83
-
84
- it("should use custom interpolation for smooth value transitions", () => {
85
- // Test the rotation calculation logic
86
- const dhParam1 = { theta: 0.1, reverse_rotation_direction: false }
87
- const dhParam2 = { theta: -0.2, reverse_rotation_direction: true }
88
- const jointValue1 = 0.5
89
- const jointValue2 = 1.0
90
-
91
- // Calculate expected rotations
92
- const expectedRotation1 = 1 * jointValue1 + 0.1 // 0.6
93
- const expectedRotation2 = -1 * jointValue2 + -0.2 // -1.2
94
-
95
- expect(expectedRotation1).toBe(0.6)
96
- expect(expectedRotation2).toBe(-1.2)
97
-
98
- // Test edge cases
99
- const dhParamReverse = { theta: 0, reverse_rotation_direction: true }
100
- const jointValueZero = 0
101
- const expectedRotationReverse = -1 * jointValueZero + 0 // 0
102
-
103
- expect(expectedRotationReverse).toBe(0)
104
-
105
- // Test rotation direction logic
106
- const testValue = 1.5
107
- const normalParam = { theta: 0, reverse_rotation_direction: false }
108
- const reversedParam = { theta: 0, reverse_rotation_direction: true }
109
-
110
- expect(1 * testValue + 0).toBe(1.5) // Normal direction
111
- expect(-1 * testValue + 0).toBe(-1.5) // Reversed direction
112
- })
113
- })