@wandelbots/wandelbots-js-react-components 1.3.0 → 1.3.2

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 (168) hide show
  1. package/README.md +0 -29
  2. package/package.json +60 -43
  3. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +44 -0
  4. package/src/components/3d-viewport/PresetEnvironment.tsx +78 -0
  5. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +54 -0
  6. package/src/components/LoadingButton.stories.tsx +61 -0
  7. package/src/components/LoadingButton.tsx +19 -0
  8. package/src/components/LoadingCover.tsx +75 -0
  9. package/src/components/ThemeSelect.tsx +49 -0
  10. package/src/components/VelocitySlider.stories.tsx +32 -0
  11. package/src/components/VelocitySlider.tsx +52 -0
  12. package/src/components/jogging/JoggingCartesianAxisControl.stories.tsx +41 -0
  13. package/src/components/jogging/JoggingCartesianAxisControl.tsx +127 -0
  14. package/src/components/jogging/JoggingCartesianTab.tsx +265 -0
  15. package/src/components/jogging/JoggingCartesianValues.tsx +45 -0
  16. package/src/components/jogging/JoggingFreedriveTab.tsx +9 -0
  17. package/src/components/jogging/JoggingJointLimitDetector.tsx +51 -0
  18. package/src/components/jogging/JoggingJointRotationControl.stories.tsx +38 -0
  19. package/src/components/jogging/JoggingJointRotationControl.tsx +197 -0
  20. package/src/components/jogging/JoggingJointTab.tsx +93 -0
  21. package/src/components/jogging/JoggingJointValues.tsx +45 -0
  22. package/src/components/jogging/JoggingOptions.tsx +96 -0
  23. package/src/components/jogging/JoggingPanel.stories.tsx +26 -0
  24. package/src/components/jogging/JoggingPanel.tsx +148 -0
  25. package/src/components/jogging/JoggingStore.tsx +294 -0
  26. package/src/components/jogging/JoggingVelocitySlider.tsx +56 -0
  27. package/src/components/robots/ABB_1200_07_7.tsx +123 -0
  28. package/src/components/robots/AxisConfig.ts +3 -0
  29. package/src/components/robots/DHRobot.tsx +129 -0
  30. package/src/components/robots/FANUC_ARC_Mate_100iD.tsx +187 -0
  31. package/src/components/robots/FANUC_ARC_Mate_120iD.tsx +187 -0
  32. package/src/components/robots/FANUC_CRX10iA.tsx +167 -0
  33. package/src/components/robots/FANUC_CRX25iA.tsx +167 -0
  34. package/src/components/robots/FANUC_CRX25iAL.tsx +178 -0
  35. package/src/components/robots/KUKA_KR210_R2700.tsx +291 -0
  36. package/src/components/robots/KUKA_KR270_R2700.tsx +244 -0
  37. package/src/components/robots/RobotAnimator.tsx +83 -0
  38. package/src/components/robots/SupportedRobot.tsx +131 -0
  39. package/src/components/robots/UniversalRobots_UR10.tsx +112 -0
  40. package/src/components/robots/UniversalRobots_UR10e.tsx +275 -0
  41. package/src/components/robots/UniversalRobots_UR3.tsx +112 -0
  42. package/src/components/robots/UniversalRobots_UR3e.tsx +112 -0
  43. package/src/components/robots/UniversalRobots_UR5.tsx +111 -0
  44. package/src/components/robots/UniversalRobots_UR5e.tsx +280 -0
  45. package/src/components/robots/Yaskawa_AR1440.tsx +152 -0
  46. package/src/components/robots/Yaskawa_AR1730.tsx +165 -0
  47. package/src/components/robots/Yaskawa_AR2010.tsx +159 -0
  48. package/src/components/robots/Yaskawa_AR3120.tsx +160 -0
  49. package/src/components/robots/Yaskawa_AR900.tsx +121 -0
  50. package/src/components/utils/converters.ts +23 -0
  51. package/src/components/utils/errorHandling.ts +30 -0
  52. package/src/components/utils/hooks.tsx +54 -0
  53. package/src/components/utils/robotTreeQuery.ts +27 -0
  54. package/src/components/wandelscript-editor/WandelscriptEditor.stories.tsx +45 -0
  55. package/src/components/wandelscript-editor/WandelscriptEditor.tsx +114 -0
  56. package/src/components/wandelscript-editor/wandelscript.tmLanguage.ts +62 -0
  57. package/src/declarations.d.ts +10 -0
  58. package/src/i18n/config.ts +27 -0
  59. package/src/i18n/locales/de/translations.json +12 -0
  60. package/src/i18n/locales/en/translations.json +12 -0
  61. package/src/icons/arrowForwardFilled.tsx +7 -0
  62. package/src/icons/axis-x.svg +3 -0
  63. package/src/icons/axis-y.svg +3 -0
  64. package/src/icons/axis-z.svg +3 -0
  65. package/src/icons/expandFilled.tsx +11 -0
  66. package/src/icons/home.tsx +12 -0
  67. package/src/icons/infoOutlined.tsx +10 -0
  68. package/src/icons/jogging.svg +3 -0
  69. package/src/icons/robot.svg +3 -0
  70. package/src/icons/robot.tsx +14 -0
  71. package/src/icons/rotation.svg +4 -0
  72. package/src/icons/wbLogo.tsx +21 -0
  73. package/src/index.ts +7 -0
  74. package/src/themes/color.tsx +74 -0
  75. package/src/themes/theme.ts +150 -0
  76. package/src/themes/wbTheme.stories.tsx +64 -0
  77. package/src/themes/wbTheme.ts +186 -0
  78. package/dist/cjs/components/3d-viewport/SafetyZonesRenderer.d.ts +0 -2
  79. package/dist/cjs/index.js +0 -5875
  80. package/dist/cjs/types/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -10
  81. package/dist/cjs/types/components/3d-viewport/PresetEnvironment.d.ts +0 -6
  82. package/dist/cjs/types/components/3d-viewport/SafetyZonesRenderer.d.ts +0 -6
  83. package/dist/cjs/types/components/robots/ABB_1200_07_7.d.ts +0 -2
  84. package/dist/cjs/types/components/robots/AxisConfig.d.ts +0 -2
  85. package/dist/cjs/types/components/robots/DHRobot.d.ts +0 -2
  86. package/dist/cjs/types/components/robots/FANUC_ARC_Mate_100iD.d.ts +0 -2
  87. package/dist/cjs/types/components/robots/FANUC_ARC_Mate_120iD.d.ts +0 -2
  88. package/dist/cjs/types/components/robots/FANUC_CRX10iA.d.ts +0 -2
  89. package/dist/cjs/types/components/robots/FANUC_CRX25iA.d.ts +0 -2
  90. package/dist/cjs/types/components/robots/FANUC_CRX25iAL.d.ts +0 -2
  91. package/dist/cjs/types/components/robots/KUKA_KR210_R2700.d.ts +0 -2
  92. package/dist/cjs/types/components/robots/KUKA_KR270_R2700.d.ts +0 -2
  93. package/dist/cjs/types/components/robots/RobotAnimator.d.ts +0 -11
  94. package/dist/cjs/types/components/robots/SupportedRobot.d.ts +0 -14
  95. package/dist/cjs/types/components/robots/UniversalRobots_UR10.d.ts +0 -2
  96. package/dist/cjs/types/components/robots/UniversalRobots_UR10e.d.ts +0 -2
  97. package/dist/cjs/types/components/robots/UniversalRobots_UR3.d.ts +0 -2
  98. package/dist/cjs/types/components/robots/UniversalRobots_UR3e.d.ts +0 -2
  99. package/dist/cjs/types/components/robots/UniversalRobots_UR5.d.ts +0 -2
  100. package/dist/cjs/types/components/robots/UniversalRobots_UR5e.d.ts +0 -2
  101. package/dist/cjs/types/components/robots/Yaskawa_AR1440.d.ts +0 -2
  102. package/dist/cjs/types/components/robots/Yaskawa_AR1730.d.ts +0 -2
  103. package/dist/cjs/types/components/robots/Yaskawa_AR2010.d.ts +0 -2
  104. package/dist/cjs/types/components/robots/Yaskawa_AR3120.d.ts +0 -2
  105. package/dist/cjs/types/components/robots/Yaskawa_AR900.d.ts +0 -2
  106. package/dist/cjs/types/components/utils/hooks.d.ts +0 -21
  107. package/dist/cjs/types/components/utils/robotTreeQuery.d.ts +0 -5
  108. package/dist/cjs/types/components/wandelscript-editor/WandelscriptEditor.d.ts +0 -12
  109. package/dist/cjs/types/components/wandelscript-editor/WandelscriptEditor.stories.d.ts +0 -5
  110. package/dist/cjs/types/components/wandelscript-editor/wandelscript.tmLanguage.d.ts +0 -44
  111. package/dist/cjs/types/icons/arrowForwardFilled.d.ts +0 -1
  112. package/dist/cjs/types/icons/expandFilled.d.ts +0 -1
  113. package/dist/cjs/types/icons/home.d.ts +0 -1
  114. package/dist/cjs/types/icons/infoOutlined.d.ts +0 -1
  115. package/dist/cjs/types/icons/robot.d.ts +0 -1
  116. package/dist/cjs/types/icons/wbLogo.d.ts +0 -6
  117. package/dist/cjs/types/index.d.ts +0 -4
  118. package/dist/cjs/types/themes/color.d.ts +0 -9
  119. package/dist/cjs/types/themes/theme.d.ts +0 -143
  120. package/dist/cjs/types/themes/wbTheme.d.ts +0 -1
  121. package/dist/cjs/types/themes/wbTheme.stories.d.ts +0 -6
  122. package/dist/esm/components/3d-viewport/SafetyZonesRenderer.d.ts +0 -2
  123. package/dist/esm/index.js +0 -5852
  124. package/dist/esm/types/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -10
  125. package/dist/esm/types/components/3d-viewport/PresetEnvironment.d.ts +0 -6
  126. package/dist/esm/types/components/3d-viewport/SafetyZonesRenderer.d.ts +0 -6
  127. package/dist/esm/types/components/robots/ABB_1200_07_7.d.ts +0 -2
  128. package/dist/esm/types/components/robots/AxisConfig.d.ts +0 -2
  129. package/dist/esm/types/components/robots/DHRobot.d.ts +0 -2
  130. package/dist/esm/types/components/robots/FANUC_ARC_Mate_100iD.d.ts +0 -2
  131. package/dist/esm/types/components/robots/FANUC_ARC_Mate_120iD.d.ts +0 -2
  132. package/dist/esm/types/components/robots/FANUC_CRX10iA.d.ts +0 -2
  133. package/dist/esm/types/components/robots/FANUC_CRX25iA.d.ts +0 -2
  134. package/dist/esm/types/components/robots/FANUC_CRX25iAL.d.ts +0 -2
  135. package/dist/esm/types/components/robots/KUKA_KR210_R2700.d.ts +0 -2
  136. package/dist/esm/types/components/robots/KUKA_KR270_R2700.d.ts +0 -2
  137. package/dist/esm/types/components/robots/RobotAnimator.d.ts +0 -11
  138. package/dist/esm/types/components/robots/SupportedRobot.d.ts +0 -14
  139. package/dist/esm/types/components/robots/UniversalRobots_UR10.d.ts +0 -2
  140. package/dist/esm/types/components/robots/UniversalRobots_UR10e.d.ts +0 -2
  141. package/dist/esm/types/components/robots/UniversalRobots_UR3.d.ts +0 -2
  142. package/dist/esm/types/components/robots/UniversalRobots_UR3e.d.ts +0 -2
  143. package/dist/esm/types/components/robots/UniversalRobots_UR5.d.ts +0 -2
  144. package/dist/esm/types/components/robots/UniversalRobots_UR5e.d.ts +0 -2
  145. package/dist/esm/types/components/robots/Yaskawa_AR1440.d.ts +0 -2
  146. package/dist/esm/types/components/robots/Yaskawa_AR1730.d.ts +0 -2
  147. package/dist/esm/types/components/robots/Yaskawa_AR2010.d.ts +0 -2
  148. package/dist/esm/types/components/robots/Yaskawa_AR3120.d.ts +0 -2
  149. package/dist/esm/types/components/robots/Yaskawa_AR900.d.ts +0 -2
  150. package/dist/esm/types/components/utils/hooks.d.ts +0 -21
  151. package/dist/esm/types/components/utils/robotTreeQuery.d.ts +0 -5
  152. package/dist/esm/types/components/wandelscript-editor/WandelscriptEditor.d.ts +0 -12
  153. package/dist/esm/types/components/wandelscript-editor/WandelscriptEditor.stories.d.ts +0 -5
  154. package/dist/esm/types/components/wandelscript-editor/wandelscript.tmLanguage.d.ts +0 -44
  155. package/dist/esm/types/icons/arrowForwardFilled.d.ts +0 -1
  156. package/dist/esm/types/icons/expandFilled.d.ts +0 -1
  157. package/dist/esm/types/icons/home.d.ts +0 -1
  158. package/dist/esm/types/icons/index.d.ts +0 -6
  159. package/dist/esm/types/icons/infoOutlined.d.ts +0 -1
  160. package/dist/esm/types/icons/robot.d.ts +0 -1
  161. package/dist/esm/types/icons/wbLogo.d.ts +0 -6
  162. package/dist/esm/types/index.d.ts +0 -4
  163. package/dist/esm/types/themes/color.d.ts +0 -9
  164. package/dist/esm/types/themes/theme.d.ts +0 -143
  165. package/dist/esm/types/themes/wbTheme.d.ts +0 -1
  166. package/dist/esm/types/themes/wbTheme.stories.d.ts +0 -6
  167. package/dist/index.d.ts +0 -33
  168. /package/{dist/cjs/types/icons/index.d.ts → src/icons/index.ts} +0 -0
@@ -0,0 +1,41 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { JoggingCartesianAxisControl } from "./JoggingCartesianAxisControl";
3
+ import { useRef, useState } from "react";
4
+ import { useAnimationFrame } from "../utils/hooks";
5
+ import { useArgs } from "@storybook/preview-api";
6
+
7
+ const meta: Meta<typeof JoggingCartesianAxisControl> = {
8
+ component: JoggingCartesianAxisControl,
9
+
10
+ args: {
11
+ color: "#F14D42",
12
+ label: "X",
13
+ disabled: false,
14
+ },
15
+ render: function Component(args) {
16
+ const [, setArgs] = useArgs();
17
+
18
+ const joggingDirRef = useRef<"+" | "-" | null>(null);
19
+ const joggingValueRef = useRef(0);
20
+
21
+ useAnimationFrame(() => {
22
+ if (joggingDirRef.current === "+") {
23
+ joggingValueRef.current += 1;
24
+ } else if (joggingDirRef.current === "-") {
25
+ joggingValueRef.current -= 1;
26
+ }
27
+ })
28
+
29
+ return <JoggingCartesianAxisControl
30
+ {...args}
31
+ startJogging={(direction) => joggingDirRef.current = direction}
32
+ stopJogging={() => joggingDirRef.current = null}
33
+ getDisplayedValue={() => joggingValueRef.current.toString()}
34
+ />;
35
+ },
36
+
37
+ };
38
+ export default meta;
39
+
40
+ export const Default: StoryObj<typeof JoggingCartesianAxisControl> = {
41
+ };
@@ -0,0 +1,127 @@
1
+ import { Button, Typography } from "@mui/material"
2
+ import Stack from "@mui/material/Stack"
3
+ import { observer } from "mobx-react-lite"
4
+ import { useRef, type ReactNode } from "react"
5
+ import { useAnimationFrame } from "../utils/hooks"
6
+
7
+ type JoggingCartesianAxisControlProps = {
8
+ color?: string
9
+ label: ReactNode
10
+ getDisplayedValue: () => string
11
+ startJogging: (direction: "-" | "+") => void
12
+ stopJogging: () => void
13
+ disabled?: boolean
14
+ } & React.ComponentProps<typeof Stack>
15
+
16
+ export const JoggingCartesianAxisControl = observer(
17
+ ({
18
+ color,
19
+ label,
20
+ getDisplayedValue,
21
+ startJogging,
22
+ stopJogging,
23
+ disabled,
24
+ ...rest
25
+ }: JoggingCartesianAxisControlProps) => {
26
+ useAnimationFrame(() => {
27
+ const displayValue = getDisplayedValue()
28
+ const element = valueContainerRef.current
29
+ if (!element) return
30
+
31
+ element.textContent = displayValue
32
+ })
33
+
34
+ const valueContainerRef = useRef<HTMLParagraphElement>(null)
35
+
36
+ color = color || "#F14D42"
37
+
38
+ function onPointerDownMinus(ev: React.PointerEvent) {
39
+ // Stop right click from triggering jog
40
+ if (ev.button === 0) startJogging("-")
41
+ }
42
+
43
+ function onPointerDownPlus(ev: React.PointerEvent) {
44
+ if (ev.button === 0) startJogging("+")
45
+ }
46
+
47
+ return (
48
+ <Stack height="72px" direction="row" {...rest}>
49
+ <Button
50
+ onPointerDown={onPointerDownMinus}
51
+ onPointerUp={stopJogging}
52
+ onPointerOut={stopJogging}
53
+ disabled={disabled}
54
+ sx={{
55
+ width: "105px",
56
+ backgroundColor: color,
57
+ color: "white",
58
+ alignContent: "center",
59
+ fontSize: "37px",
60
+ borderRadius: "16px 0px 0px 16px",
61
+
62
+ ":hover": {
63
+ color: "white",
64
+ backgroundColor: color,
65
+ },
66
+ }}
67
+ >
68
+ {"-"}
69
+ </Button>
70
+
71
+ <Stack
72
+ spacing="6px"
73
+ sx={{
74
+ width: "184px",
75
+ backgroundColor: color,
76
+ alignItems: "center",
77
+ justifyContent: "center",
78
+ opacity: "0.9",
79
+ }}
80
+ >
81
+ <Stack
82
+ height="22px"
83
+ direction="row"
84
+ alignItems="center"
85
+ justifyItems="center"
86
+ spacing={1}
87
+ sx={{ userSelect: "none" }}
88
+ >
89
+ {label}
90
+ </Stack>
91
+ <Typography
92
+ height="22px"
93
+ sx={{
94
+ fontSize: "15px",
95
+ color: "white",
96
+ }}
97
+ ref={valueContainerRef}
98
+ >
99
+ {getDisplayedValue()}
100
+ </Typography>
101
+ </Stack>
102
+
103
+ <Button
104
+ onPointerDown={onPointerDownPlus}
105
+ onPointerUp={stopJogging}
106
+ onPointerOut={stopJogging}
107
+ disabled={disabled}
108
+ sx={{
109
+ width: "105px",
110
+ backgroundColor: color,
111
+ color: "white",
112
+ alignContent: "center",
113
+ fontSize: "37px",
114
+ borderRadius: "0px 16px 16px 0px",
115
+
116
+ ":hover": {
117
+ color: "white",
118
+ backgroundColor: color,
119
+ },
120
+ }}
121
+ >
122
+ {"+"}
123
+ </Button>
124
+ </Stack>
125
+ )
126
+ },
127
+ )
@@ -0,0 +1,265 @@
1
+ import {
2
+ ToggleButtonGroup,
3
+ ToggleButton,
4
+ Stack,
5
+ Typography,
6
+ } from "@mui/material"
7
+ import { observer } from "mobx-react-lite"
8
+ import { JoggingCartesianAxisControl } from "./JoggingCartesianAxisControl"
9
+ import { radiansToDegrees } from "@wandelbots/wandelbots-js"
10
+ import { useTranslation } from "react-i18next"
11
+ import RotationIcon from "../../icons/rotation.svg"
12
+ import XAxisIcon from "../../icons/axis-x.svg"
13
+ import YAxisIcon from "../../icons/axis-y.svg"
14
+ import ZAxisIcon from "../../icons/axis-z.svg"
15
+ import type { JoggingStore, DiscreteIncrementOption } from "./JoggingStore"
16
+ import { JoggingOptions } from "./JoggingOptions"
17
+ import { JoggingVelocitySlider } from "./JoggingVelocitySlider"
18
+ import { useReaction } from "../utils/hooks"
19
+ import { JoggingCartesianValues } from "./JoggingCartesianValues"
20
+ import { JoggingJointLimitDetector } from "./JoggingJointLimitDetector"
21
+
22
+ type JoggingCartesianOpts = {
23
+ axis: "x" | "y" | "z"
24
+ motionType: "translate" | "rotate"
25
+ direction: "-" | "+"
26
+ }
27
+
28
+ export const JoggingCartesianTab = observer(
29
+ ({ store }: { store: JoggingStore }) => {
30
+ const { t } = useTranslation()
31
+
32
+ function onMotionTypeChange(
33
+ _event: React.MouseEvent<HTMLElement>,
34
+ newMotionType: string,
35
+ ) {
36
+ if (newMotionType === "translate" || newMotionType === "rotate")
37
+ store.setSelectedCartesianMotionType(newMotionType)
38
+ }
39
+
40
+ useReaction(
41
+ () => [store.selectedCoordSystemId, store.selectedTcpId],
42
+ () => {
43
+ store.jogger.motionStream.motionStateSocket.changeUrl(
44
+ store.jogger.nova.makeWebsocketURL(`/motion-groups/${store.jogger.motionGroupId}/state-stream?tcp=${store.selectedTcpId}&response_coordinate_system=${store.selectedCoordSystemId}`)
45
+ )
46
+ },
47
+ { fireImmediately: true } as any,
48
+ )
49
+
50
+ async function runIncrementalCartesianJog(
51
+ opts: JoggingCartesianOpts,
52
+ increment: DiscreteIncrementOption,
53
+ ) {
54
+ const tcpPose = store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose
55
+ const jointPosition =
56
+ store.jogger.motionStream.rapidlyChangingMotionState.state.joint_position
57
+ if (!tcpPose) return
58
+
59
+ // await robotPad.withMotionLock(async () => {
60
+ // await jogger.runIncrementalCartesianMotion({
61
+ // currentTcpPose: tcpPose,
62
+ // currentJoints: jointPosition,
63
+ // coordSystemId: store.selectedCoordSystemId,
64
+ // velocityInRelevantUnits: store.velocityInCurrentUnits,
65
+ // axis: opts.axis,
66
+ // direction: opts.direction,
67
+ // motion:
68
+ // store.selectedCartesianMotionType === "translate"
69
+ // ? {
70
+ // type: "translate",
71
+ // distanceMm: increment.mm,
72
+ // }
73
+ // : {
74
+ // type: "rotate",
75
+ // distanceRads: degreesToRadians(increment.degrees),
76
+ // },
77
+ // })
78
+ // })
79
+ }
80
+
81
+ async function startCartesianJogging(opts: JoggingCartesianOpts) {
82
+ if (store.isLocked) return
83
+
84
+ if (store.selectedDiscreteIncrement) {
85
+ return runIncrementalCartesianJog(opts, store.selectedDiscreteIncrement)
86
+ }
87
+
88
+ if (opts.motionType === "translate") {
89
+ await store.jogger.startTCPTranslation({
90
+ axis: opts.axis,
91
+ direction: opts.direction,
92
+ velocityMmPerSec: store.translationVelocityMmPerSec,
93
+ })
94
+ } else {
95
+ await store.jogger.startTCPRotation({
96
+ axis: opts.axis,
97
+ direction: opts.direction,
98
+ velocityRadsPerSec: store.rotationVelocityRadsPerSec,
99
+ })
100
+
101
+ }
102
+ }
103
+
104
+ async function stopJogging() {
105
+ if (store.isLocked) return
106
+
107
+ if (store.selectedDiscreteIncrement) {
108
+ return
109
+ }
110
+
111
+ await store.jogger.stop()
112
+ }
113
+
114
+ const axisList = [
115
+ {
116
+ id: "x",
117
+ color: "#F14D42",
118
+ icon: <XAxisIcon />,
119
+ },
120
+ {
121
+ id: "y",
122
+ color: "#42A705",
123
+ icon: <YAxisIcon />,
124
+ },
125
+ {
126
+ id: "z",
127
+ color: "#0075FF",
128
+ icon: <ZAxisIcon />,
129
+ },
130
+ ] as const
131
+
132
+ function formatMM(value: number) {
133
+ return t("General.mm.variable", { amount: value.toFixed(1) })
134
+ }
135
+
136
+ function formatDegrees(value: number) {
137
+ return t("General.degree.variable", {
138
+ amount: radiansToDegrees(value).toFixed(1),
139
+ })
140
+ }
141
+
142
+ return (
143
+ <Stack>
144
+ {/* Jogging options */}
145
+ <JoggingOptions store={store} />
146
+
147
+ {/* Show Wandelscript string for the current coords */}
148
+ <JoggingCartesianValues store={store} />
149
+
150
+ {/* Translate or rotate toggle */}
151
+ <Stack alignItems="center" marginTop="1rem">
152
+ <ToggleButtonGroup
153
+ value={store.selectedCartesianMotionType}
154
+ onChange={onMotionTypeChange}
155
+ exclusive
156
+ aria-label={t("Jogging.Cartesian.MotionType.lb")}
157
+ sx={{
158
+ "& > button": {
159
+ borderRadius: "8px",
160
+ textTransform: "none",
161
+ padding: "4px 30px",
162
+ },
163
+ }}
164
+ >
165
+ <ToggleButton value="translate">
166
+ {t("Jogging.Cartesian.Translation.bt")}
167
+ </ToggleButton>
168
+ <ToggleButton value="rotate">
169
+ {t("Jogging.Cartesian.Rotation.bt")}
170
+ </ToggleButton>
171
+ </ToggleButtonGroup>
172
+ </Stack>
173
+
174
+ <Stack width="80%" maxWidth="296px" margin="auto">
175
+ {/* Cartesian translate jogging */}
176
+ {store.selectedCartesianMotionType === "translate" &&
177
+ axisList.map((axis) => (
178
+ <JoggingCartesianAxisControl
179
+ key={axis.id}
180
+ color={axis.color}
181
+ disabled={store.isLocked}
182
+ sx={{
183
+ marginTop: "12px",
184
+ }}
185
+ label={
186
+ <>
187
+ {axis.icon}
188
+ <Typography
189
+ sx={{
190
+ fontSize: "24px",
191
+ color: "white",
192
+ }}
193
+ >
194
+ {axis.id.toUpperCase()}
195
+ </Typography>
196
+ </>
197
+ }
198
+ getDisplayedValue={() =>
199
+ formatMM(
200
+ store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose?.position[
201
+ axis.id
202
+ ] || 0,
203
+ )
204
+ }
205
+ startJogging={(direction: "-" | "+") =>
206
+ startCartesianJogging({
207
+ axis: axis.id,
208
+ motionType: "translate",
209
+ direction,
210
+ })
211
+ }
212
+ stopJogging={stopJogging}
213
+ />
214
+ ))}
215
+
216
+ {/* Cartesian rotate jogging */}
217
+ {store.selectedCartesianMotionType === "rotate" &&
218
+ axisList.map((axis) => (
219
+ <JoggingCartesianAxisControl
220
+ key={axis.id}
221
+ color={axis.color}
222
+ disabled={store.isLocked}
223
+ sx={{
224
+ marginTop: "12px",
225
+ }}
226
+ label={
227
+ <>
228
+ <RotationIcon />
229
+ <Typography
230
+ sx={{
231
+ fontSize: "24px",
232
+ color: "white",
233
+ }}
234
+ >
235
+ {axis.id.toUpperCase()}
236
+ </Typography>
237
+ </>
238
+ }
239
+ getDisplayedValue={() =>
240
+ formatDegrees(
241
+ store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose
242
+ ?.orientation?.[axis.id] || 0,
243
+ )
244
+ }
245
+ startJogging={(direction: "-" | "+") =>
246
+ startCartesianJogging({
247
+ axis: axis.id,
248
+ motionType: "rotate",
249
+ direction,
250
+ })
251
+ }
252
+ stopJogging={stopJogging}
253
+ />
254
+ ))}
255
+ </Stack>
256
+
257
+ {/* Velocity slider */}
258
+ <JoggingVelocitySlider store={store} />
259
+
260
+ {/* Show message if joint limits reached */}
261
+ <JoggingJointLimitDetector store={store} />
262
+ </Stack>
263
+ )
264
+ },
265
+ )
@@ -0,0 +1,45 @@
1
+ import { observer } from "mobx-react-lite"
2
+ import { Stack, Typography } from "@mui/material"
3
+ import { useRef } from "react"
4
+ import { poseToWandelscriptString } from "@wandelbots/wandelbots-js"
5
+ import { useAnimationFrame } from "../utils/hooks"
6
+ import { JoggingStore } from "./JoggingStore"
7
+
8
+ export const JoggingCartesianValues = observer(({ store }: { store: JoggingStore }) => {
9
+ const poseStringRef = useRef<HTMLPreElement>(null)
10
+
11
+ function getCurrentPoseString() {
12
+ const tcpPose = store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose
13
+ if (!tcpPose) return ""
14
+ return poseToWandelscriptString(tcpPose)
15
+ }
16
+
17
+ useAnimationFrame(() => {
18
+ if (!poseStringRef.current) {
19
+ return
20
+ }
21
+
22
+ poseStringRef.current.textContent = getCurrentPoseString()
23
+ })
24
+
25
+ return (
26
+ <Stack alignItems="center" marginTop="0.8rem">
27
+ <Typography
28
+ sx={{
29
+ fontSize: "12px",
30
+ marginTop: "0.8rem",
31
+ }}
32
+ >
33
+ {store.selectedTcpId} - {store.selectedCoordSystem?.name}
34
+ </Typography>
35
+ <Typography
36
+ component="pre"
37
+ ref={poseStringRef}
38
+ sx={{
39
+ fontSize: "14px",
40
+ opacity: 0.6,
41
+ }}
42
+ ></Typography>
43
+ </Stack>
44
+ )
45
+ })
@@ -0,0 +1,9 @@
1
+ import { Stack } from "@mui/material"
2
+
3
+ export const JoggingFreedriveTab = () => {
4
+ return (
5
+ <Stack height={"300px"} alignItems={"center"} justifyContent={"center"}>
6
+ {"TODO: JoggingFreedriveTab"}
7
+ </Stack>
8
+ )
9
+ }
@@ -0,0 +1,51 @@
1
+ import { Typography } from "@mui/material"
2
+ import { useTranslation } from "react-i18next"
3
+ import { useState } from "react"
4
+ import { isEqual } from "lodash-es"
5
+ import { MotionStreamConnection } from "@wandelbots/wandelbots-js"
6
+ import { useAnimationFrame } from "../utils/hooks"
7
+ import { JoggingStore } from "./JoggingStore"
8
+
9
+ /**
10
+ * Monitors the active robot motion state and displays a message if
11
+ * any joint limits are reached.
12
+ */
13
+ export const JoggingJointLimitDetector = ({ store }: { store: JoggingStore }) => {
14
+ const { t } = useTranslation()
15
+
16
+ const [jointLimitsReached, setJointLimitsReached] = useState(
17
+ store.jogger.motionStream.rapidlyChangingMotionState.state.joint_limit_reached
18
+ .limit_reached,
19
+ )
20
+
21
+ useAnimationFrame(() => {
22
+ const newLimitsReached =
23
+ store.jogger.motionStream.rapidlyChangingMotionState.state.joint_limit_reached
24
+ .limit_reached
25
+
26
+ if (!isEqual(jointLimitsReached, newLimitsReached)) {
27
+ setJointLimitsReached(newLimitsReached)
28
+ }
29
+ })
30
+
31
+ const jointLimitReachedIndices: number[] = []
32
+ jointLimitsReached.forEach((limitReached, index) => {
33
+ if (limitReached) jointLimitReachedIndices.push(index)
34
+ })
35
+
36
+ if (!jointLimitReachedIndices.length) return null
37
+
38
+ return (
39
+ <Typography
40
+ color="error"
41
+ sx={{
42
+ padding: "1rem",
43
+ textAlign: "center",
44
+ }}
45
+ >
46
+ {t("Jogging.JointLimitsReached.lb", {
47
+ jointNumbers: jointLimitReachedIndices.map((i) => i + 1).join(", "),
48
+ })}
49
+ </Typography>
50
+ )
51
+ }
@@ -0,0 +1,38 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { JoggingJointRotationControl } from "./JoggingJointRotationControl";
3
+ import { useRef } from "react";
4
+ import { useAnimationFrame } from "../utils/hooks";
5
+
6
+ const meta: Meta<typeof JoggingJointRotationControl> = {
7
+ component: JoggingJointRotationControl,
8
+
9
+ args: {
10
+ lowerLimitDegs: -360,
11
+ upperLimitDegs: 360,
12
+ disabled: false,
13
+ },
14
+ render: function Component(args) {
15
+ const joggingDirRef = useRef<"+" | "-" | null>(null);
16
+ const joggingValueRef = useRef(0);
17
+
18
+ useAnimationFrame(() => {
19
+ if (joggingDirRef.current === "+") {
20
+ joggingValueRef.current += 1;
21
+ } else if (joggingDirRef.current === "-") {
22
+ joggingValueRef.current -= 1;
23
+ }
24
+ })
25
+
26
+ return <JoggingJointRotationControl
27
+ {...args}
28
+ startJogging={(direction) => joggingDirRef.current = direction}
29
+ stopJogging={() => joggingDirRef.current = null}
30
+ getValueDegs={() => joggingValueRef.current}
31
+ />;
32
+ },
33
+
34
+ };
35
+ export default meta;
36
+
37
+ export const Default: StoryObj<typeof JoggingJointRotationControl> = {
38
+ };