@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,197 @@
1
+ import { IconButton, Slider, Typography } from "@mui/material"
2
+ import Stack from "@mui/material/Stack"
3
+ import { observer, useLocalObservable } from "mobx-react-lite"
4
+ import { I18nextProvider, useTranslation } from "react-i18next"
5
+ import { ChevronLeft, ChevronRight } from "@mui/icons-material"
6
+ import { useAnimationFrame } from "../utils/hooks"
7
+ import { useState } from "react"
8
+ import i18n from '../../i18n/config';
9
+
10
+ type JoggingJointRotationControlProps = {
11
+ startJogging: (direction: "-" | "+") => void
12
+ stopJogging: () => void
13
+ lowerLimitDegs?: number
14
+ upperLimitDegs?: number
15
+ getValueDegs: () => number|undefined
16
+
17
+ disabled?: boolean
18
+ } & React.ComponentProps<typeof Stack>
19
+
20
+ export const JoggingJointRotationControl = observer(
21
+ ({
22
+ startJogging,
23
+ stopJogging,
24
+ lowerLimitDegs,
25
+ upperLimitDegs,
26
+ getValueDegs,
27
+ disabled,
28
+ ...rest
29
+ }: JoggingJointRotationControlProps) => {
30
+ const { t } = useTranslation()
31
+ const [currentValue, setCurrentValue] = useState<number|undefined>()
32
+
33
+ const state = useLocalObservable(() => ({
34
+ activeJoggingDir: null as "-" | "+" | null,
35
+
36
+ startJogging(dir: "-" | "+") {
37
+ this.activeJoggingDir = dir
38
+ startJogging(dir)
39
+ },
40
+
41
+ stopJogging() {
42
+ this.activeJoggingDir = null
43
+ stopJogging()
44
+ },
45
+ }))
46
+
47
+ useAnimationFrame(() => {
48
+ setCurrentValue(getValueDegs())
49
+ })
50
+
51
+ function onPointerDownMinus(ev: React.PointerEvent) {
52
+ // Stop right click from triggering jog
53
+ if (ev.button === 0) state.startJogging("-")
54
+ }
55
+
56
+ function onPointerDownPlus(ev: React.PointerEvent) {
57
+ if (ev.button === 0) state.startJogging("+")
58
+ }
59
+
60
+ function formatDegrees(value: number | undefined, precision = 1) {
61
+ if (value === undefined || isNaN(value)) return ""
62
+
63
+ const output = t("General.degree.variable", {
64
+ amount: value.toFixed(precision),
65
+ })
66
+
67
+ if (value > 0 && precision === 0) {
68
+ return `+${output}`
69
+ } else {
70
+ return output
71
+ }
72
+ }
73
+
74
+ return (
75
+ <I18nextProvider i18n={i18n}>
76
+ <Stack
77
+ height="64px"
78
+ width="100%"
79
+ maxWidth="300px"
80
+ direction="row"
81
+ {...rest}
82
+ >
83
+ <IconButton
84
+ onPointerDown={onPointerDownMinus}
85
+ onPointerUp={state.stopJogging}
86
+ onPointerOut={state.stopJogging}
87
+ disabled={disabled}
88
+ sx={{
89
+ width: "52px",
90
+ color: "white",
91
+ alignContent: "center",
92
+ borderRadius: "16px 0px 0px 16px",
93
+ backgroundColor:
94
+ state.activeJoggingDir === "-" ? "#495975 !important" : "#38445A",
95
+ "& svg": {
96
+ width: "42px",
97
+ height: "42px",
98
+ },
99
+ }}
100
+ >
101
+ <ChevronLeft />
102
+ </IconButton>
103
+
104
+ <Stack
105
+ flexGrow={1}
106
+ alignItems="center"
107
+ justifyContent="center"
108
+ sx={{
109
+ borderStyle: "solid",
110
+ borderLeftWidth: 0,
111
+ borderRightWidth: 0,
112
+ borderTopWidth: "4px",
113
+ borderBottomWidth: "4px",
114
+ backgroundColor: "#38445A",
115
+ borderColor: "#38445A",
116
+ paddingLeft: "20px",
117
+ paddingRight: "20px",
118
+ zIndex: 1,
119
+ }}
120
+ >
121
+ <Typography
122
+ sx={{
123
+ fontSize: "15px",
124
+ position: "relative",
125
+ top: "5px",
126
+ }}
127
+ >
128
+ {formatDegrees(currentValue)}
129
+ </Typography>
130
+
131
+ <Slider
132
+ disabled
133
+ aria-label="Joint position"
134
+ min={lowerLimitDegs}
135
+ max={upperLimitDegs}
136
+ value={currentValue}
137
+ track={false}
138
+ sx={{
139
+ "& .MuiSlider-mark": {
140
+ display: "none",
141
+ },
142
+ "& .MuiSlider-thumb": {
143
+ width: "5px",
144
+ height: "10px",
145
+ borderRadius: "2px",
146
+ },
147
+ "& .MuiSlider-markLabel": {
148
+ top: "20px",
149
+ fontSize: "12px",
150
+ },
151
+ "& .MuiSlider-rail": {
152
+ backgroundColor: "#1F283A",
153
+ opacity: 1,
154
+ },
155
+ }}
156
+ marks={
157
+ lowerLimitDegs !== undefined &&
158
+ upperLimitDegs !== undefined && [
159
+ {
160
+ value: lowerLimitDegs,
161
+ label: formatDegrees(lowerLimitDegs, 0),
162
+ },
163
+ {
164
+ value: upperLimitDegs,
165
+ label: formatDegrees(upperLimitDegs, 0),
166
+ },
167
+ ]
168
+ }
169
+ />
170
+ </Stack>
171
+
172
+ <IconButton
173
+ onPointerDown={onPointerDownPlus}
174
+ onPointerUp={state.stopJogging}
175
+ onPointerOut={state.stopJogging}
176
+ disabled={disabled}
177
+ sx={{
178
+ width: "52px",
179
+ color: "white",
180
+ alignContent: "center",
181
+ fontSize: "37px",
182
+ borderRadius: "0px 16px 16px 0px",
183
+ backgroundColor:
184
+ state.activeJoggingDir === "+" ? "#495975 !important" : "#38445A",
185
+ "& svg": {
186
+ width: "42px",
187
+ height: "42px",
188
+ },
189
+ }}
190
+ >
191
+ <ChevronRight />
192
+ </IconButton>
193
+ </Stack>
194
+ </I18nextProvider>
195
+ )
196
+ },
197
+ )
@@ -0,0 +1,93 @@
1
+ import { Stack, Typography } from "@mui/material"
2
+ import { observer } from "mobx-react-lite"
3
+ import { radiansToDegrees } from "@wandelbots/wandelbots-js"
4
+ import type { JoggingStore } from "./JoggingStore"
5
+ import { JoggingVelocitySlider } from "./JoggingVelocitySlider"
6
+ import { JoggingJointRotationControl } from "./JoggingJointRotationControl"
7
+ import { JoggingJointValues } from "./JoggingJointValues"
8
+
9
+ export const JoggingJointTab = observer(
10
+ ({ store }: { store: JoggingStore; }) => {
11
+ async function startJointJogging(opts: {
12
+ joint: number
13
+ direction: "-" | "+"
14
+ }) {
15
+ await store.jogger.startJointRotation({
16
+ joint: opts.joint,
17
+ direction: opts.direction,
18
+ velocityRadsPerSec: store.rotationVelocityRadsPerSec,
19
+ })
20
+ }
21
+
22
+ async function stopJointJogging() {
23
+ await store.jogger.stop()
24
+ }
25
+
26
+ return (
27
+ <Stack>
28
+ <JoggingJointValues store={store} />
29
+ <Stack>
30
+ {store.jogger.motionStream.joints.map((joint) => {
31
+ const jointLimits =
32
+ store.motionGroupSpec.mechanical_joint_limits?.[
33
+ joint.index
34
+ ]
35
+ const lowerLimitDegs =
36
+ jointLimits?.lower_limit !== undefined
37
+ ? radiansToDegrees(jointLimits.lower_limit)
38
+ : undefined
39
+ const upperLimitDegs =
40
+ jointLimits?.upper_limit !== undefined
41
+ ? radiansToDegrees(jointLimits.upper_limit)
42
+ : undefined
43
+
44
+ return (
45
+ <Stack
46
+ direction="row"
47
+ alignItems="center"
48
+ gap={2}
49
+ key={`joint-${joint.index}`}
50
+ marginTop="0.8rem"
51
+ >
52
+ <Typography
53
+ sx={{
54
+ flexGrow: 1,
55
+ textAlign: "right",
56
+ }}
57
+ >{`J${joint.index + 1}`}</Typography>
58
+ <JoggingJointRotationControl
59
+ key={joint.index}
60
+ disabled={store.isLocked}
61
+ lowerLimitDegs={lowerLimitDegs}
62
+ upperLimitDegs={upperLimitDegs}
63
+ getValueDegs={() => {
64
+ const value =
65
+ store.jogger.motionStream.rapidlyChangingMotionState.state
66
+ .joint_position.joints[joint.index]
67
+ return value !== undefined
68
+ ? radiansToDegrees(value)
69
+ : undefined
70
+ }}
71
+ startJogging={(direction: "-" | "+") =>
72
+ startJointJogging({
73
+ joint: joint.index,
74
+ direction,
75
+ })
76
+ }
77
+ stopJogging={stopJointJogging}
78
+ />
79
+ {/* Just to balance out the right side */}
80
+ <Typography
81
+ sx={{
82
+ flexGrow: 1,
83
+ }}
84
+ />
85
+ </Stack>
86
+ )
87
+ })}
88
+ </Stack>
89
+ <JoggingVelocitySlider store={store} />
90
+ </Stack>
91
+ )
92
+ },
93
+ )
@@ -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 { useTranslation } from "react-i18next"
5
+ import { JoggingStore } from "./JoggingStore"
6
+ import { useAnimationFrame } from "../utils/hooks"
7
+
8
+ export const JoggingJointValues = observer(({ store }: { store: JoggingStore }) => {
9
+ const valueHolderRef = useRef<HTMLPreElement>(null)
10
+ const { t } = useTranslation()
11
+
12
+ function getCurrentValueString() {
13
+ const { joints } =
14
+ store.jogger.motionStream.rapidlyChangingMotionState.state.joint_position
15
+ return `{${joints.map((j) => parseFloat(j.toFixed(4))).join(", ")}}`
16
+ }
17
+
18
+ useAnimationFrame(() => {
19
+ if (!valueHolderRef.current) return
20
+ valueHolderRef.current.textContent = getCurrentValueString()
21
+ })
22
+
23
+ return (
24
+ <Stack alignItems="center" marginTop="0.8rem">
25
+ <Typography
26
+ sx={{
27
+ fontSize: "12px",
28
+ marginTop: "0.8rem",
29
+ }}
30
+ >
31
+ {t("Jogging.Joints.JointValues.lb")}
32
+ </Typography>
33
+ <Typography
34
+ component="pre"
35
+ ref={valueHolderRef}
36
+ sx={{
37
+ fontSize: "14px",
38
+ opacity: 0.6,
39
+ }}
40
+ >
41
+ {getCurrentValueString()}
42
+ </Typography>
43
+ </Stack>
44
+ )
45
+ })
@@ -0,0 +1,96 @@
1
+ import { Stack, MenuItem, InputLabel, Select } from "@mui/material"
2
+ import { observer } from "mobx-react-lite"
3
+ import type { IncrementOptionId, JoggingStore } from "./JoggingStore"
4
+ import { useTranslation } from "react-i18next"
5
+ import { useThemeColors } from "../../themes/wbTheme"
6
+ import { ThemeSelect } from "../ThemeSelect"
7
+
8
+ export const JoggingOptions = observer(({ store }: { store: JoggingStore }) => {
9
+ const { t } = useTranslation()
10
+ const colors = useThemeColors()
11
+
12
+ return (
13
+ <Stack
14
+ direction={"row"}
15
+ alignItems={"center"}
16
+ spacing={1}
17
+ sx={{
18
+ padding: "16px",
19
+ "& label": {
20
+ color: colors.textSubtle,
21
+ fontSize: "12px",
22
+ marginBottom: "4px",
23
+ },
24
+ }}
25
+ >
26
+ {/* Coordinate system */}
27
+ <Stack width="33%">
28
+ <InputLabel id="jogging-coord-select">{"Coordinate Sys."}</InputLabel>
29
+ <ThemeSelect
30
+ kind="filled"
31
+ labelId="jogging-coord-select"
32
+ value={store.selectedCoordSystemId}
33
+ displayEmpty={true}
34
+ onChange={(event) => {
35
+ store.setSelectedCoordSystemId(event.target.value as string)
36
+ }}
37
+ disabled={store.isLocked}
38
+ >
39
+ {store.coordSystems.map((cs) => (
40
+ <MenuItem key={cs.coordinate_system} value={cs.coordinate_system}>
41
+ {cs.name || cs.coordinate_system}
42
+ </MenuItem>
43
+ ))}
44
+ </ThemeSelect>
45
+ </Stack>
46
+
47
+ {/* TCP selection */}
48
+ <Stack width="33%">
49
+ <InputLabel id="jogging-tcp-select">TCP</InputLabel>
50
+ <ThemeSelect
51
+ kind="filled"
52
+ labelId="jogging-tcp-select"
53
+ value={store.selectedTcpId}
54
+ onChange={(event) => {
55
+ store.setSelectedTcpId(event.target.value as string)
56
+ }}
57
+ disabled={store.isLocked}
58
+ >
59
+ {store.tcps.map((tcp) => (
60
+ <MenuItem key={tcp.id} value={tcp.id}>
61
+ {tcp.id}
62
+ </MenuItem>
63
+ ))}
64
+ </ThemeSelect>
65
+ </Stack>
66
+
67
+ {/* Increment selection */}
68
+ <Stack width="33%">
69
+ <InputLabel id="jogging-increment-select">{"Increment"}</InputLabel>
70
+ <ThemeSelect
71
+ kind="filled"
72
+ labelId="jogging-increment-select"
73
+ value={store.selectedIncrementId}
74
+ onChange={(event) => {
75
+ store.setSelectedIncrementId(
76
+ event.target.value as IncrementOptionId,
77
+ )
78
+ }}
79
+ disabled={store.isLocked}
80
+ >
81
+ <MenuItem key="continuous" value="continuous">
82
+ {t("Jogging.Increment.Continuous.dd")}
83
+ </MenuItem>
84
+
85
+ {store.discreteIncrementOptions.map((inc) => (
86
+ <MenuItem key={inc.id} value={inc.id}>
87
+ {store.currentMotionType === "translate"
88
+ ? `${inc.mm}mm`
89
+ : `${inc.degrees}°`}
90
+ </MenuItem>
91
+ ))}
92
+ </ThemeSelect>
93
+ </Stack>
94
+ </Stack>
95
+ )
96
+ })
@@ -0,0 +1,26 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { JoggingPanel } from "./JoggingPanel";
3
+ import { useArgs } from "@storybook/preview-api";
4
+ import { NovaClient } from "@wandelbots/wandelbots-js";
5
+
6
+ const meta: Meta<typeof JoggingPanel> = {
7
+ component: JoggingPanel,
8
+
9
+ args: {
10
+ motionGroupId: "0@mock-ur5e"
11
+ },
12
+ render: function Component(args) {
13
+ const [, setArgs] = useArgs();
14
+ return <JoggingPanel
15
+ {...args}
16
+ nova={new NovaClient({
17
+ instanceUrl: "https://mock",
18
+ mock: true
19
+ })}
20
+ />;
21
+ },
22
+ };
23
+ export default meta;
24
+
25
+ export const Default: StoryObj<typeof JoggingPanel> = {
26
+ };
@@ -0,0 +1,148 @@
1
+ import { Paper, Stack, Tab, Tabs } from "@mui/material"
2
+ import { observer, useLocalObservable } from "mobx-react-lite"
3
+ import { useEffect } from "react"
4
+ import { JoggingCartesianTab } from "./JoggingCartesianTab"
5
+ import { JoggingJointTab } from "./JoggingJointTab"
6
+ import { JoggingStore } from "./JoggingStore"
7
+ import { LoadingCover } from "../LoadingCover"
8
+ import { runInAction } from "mobx"
9
+ import { NovaClient } from "@wandelbots/wandelbots-js"
10
+
11
+ export type JoggingPanelProps = {
12
+ nova: NovaClient
13
+ motionGroupId: string
14
+ }
15
+
16
+ export const JoggingPanel = observer((props: JoggingPanelProps) => {
17
+ const { nova } = props
18
+
19
+ const state = useLocalObservable(() => ({
20
+ joggingStore: null as JoggingStore | null,
21
+ loadingError: null as unknown | null,
22
+ }))
23
+
24
+ async function init() {
25
+ try {
26
+ const jogger = await nova.connectJogger(props.motionGroupId)
27
+ const joggingStore = await JoggingStore.loadFor(jogger)
28
+ runInAction(() => {
29
+ state.joggingStore = joggingStore
30
+ })
31
+ } catch (err) {
32
+ state.loadingError = err
33
+ }
34
+ }
35
+
36
+ useEffect(() => {
37
+ init()
38
+ return () => {
39
+ state.joggingStore?.dispose()
40
+ }
41
+ }, [])
42
+
43
+ // Set correct jogging mode on jogger based on user selections
44
+ useEffect(() => {
45
+ if (!state.joggingStore) return
46
+
47
+ const {
48
+ currentTab,
49
+ selectedTcpId,
50
+ selectedCoordSystemId,
51
+ selectedDiscreteIncrement,
52
+ } = state.joggingStore
53
+
54
+ if (currentTab.id !== "cartesian" && currentTab.id !== "joint") return
55
+
56
+ const cartesianJoggingOpts = {
57
+ tcpId: selectedTcpId,
58
+ coordSystemId: selectedCoordSystemId,
59
+ }
60
+
61
+ if (selectedDiscreteIncrement && currentTab.id === "cartesian") {
62
+ state.joggingStore.jogger.setJoggingMode("increment", cartesianJoggingOpts)
63
+ } else {
64
+ state.joggingStore.jogger.setJoggingMode(currentTab.id, cartesianJoggingOpts)
65
+ }
66
+ }, [
67
+ state.joggingStore?.currentTab,
68
+ state.joggingStore?.selectedTcpId,
69
+ state.joggingStore?.selectedCoordSystemId,
70
+ state.joggingStore?.selectedDiscreteIncrement,
71
+ ])
72
+
73
+ useEffect(() => {
74
+
75
+ // Set the robot to default control mode (JoZi says is important for physical robot jogging)
76
+ async function init() {
77
+ if (!state.joggingStore) return
78
+
79
+ try {
80
+ await nova.api.controller.setDefaultMode(
81
+ state.joggingStore.jogger.motionStream.controllerId,
82
+ "MODE_CONTROL",
83
+ )
84
+ } catch (err) {
85
+ console.error(err)
86
+ }
87
+ }
88
+
89
+ init()
90
+ }, [state.joggingStore?.jogger.motionStream.controllerId])
91
+
92
+ if (!state.joggingStore) {
93
+ return (
94
+ <JoggingPanelOuter>
95
+ <LoadingCover message="Loading jogging" error={state.loadingError} />
96
+ </JoggingPanelOuter>
97
+ )
98
+ }
99
+
100
+ const { joggingStore: store } = state
101
+
102
+ return (
103
+ <JoggingPanelOuter>
104
+ <Stack flexGrow={1}>
105
+ {/* Tab selection */}
106
+ <Tabs value={store.tabIndex} onChange={store.onTabChange}>
107
+ {store.tabs.map((tab) => (
108
+ <Tab
109
+ key={tab.id}
110
+ label={tab.label}
111
+ id={`jogging-tab-${tab.id}`}
112
+ aria-controls={`jogging-tab-${tab.id}`}
113
+ />
114
+ ))}
115
+ </Tabs>
116
+
117
+ {/* Current tab content */}
118
+ <Stack flexGrow={1}>
119
+ {store.currentTab.id === "cartesian" && (
120
+ <JoggingCartesianTab store={store} />
121
+ )}
122
+ {store.currentTab.id === "joint" && (
123
+ <JoggingJointTab store={store} />
124
+ )}
125
+ </Stack>
126
+ </Stack>
127
+ </JoggingPanelOuter>
128
+ )
129
+ })
130
+
131
+ function JoggingPanelOuter({ children }: { children: React.ReactNode }) {
132
+ return (
133
+ <Stack
134
+ sx={{
135
+ maxWidth: "460px",
136
+ minWidth: "350px",
137
+ overflowY: "auto",
138
+ position: "relative",
139
+ }}
140
+ >
141
+ <Paper sx={{
142
+ minHeight: "90vh"
143
+ }}>
144
+ {children}
145
+ </Paper>
146
+ </Stack>
147
+ )
148
+ }