@viamrobotics/test-widgets 0.15.1 → 0.17.0
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.
- package/README.md +15 -1
- package/dist/api-docs-href.d.ts +2 -2
- package/dist/api-docs-href.js +0 -1
- package/dist/components/api-section.svelte +58 -49
- package/dist/components/api-section.svelte.d.ts +24 -10
- package/dist/components/boundary.svelte +51 -0
- package/dist/components/boundary.svelte.d.ts +5 -0
- package/dist/components/connection-status.svelte +57 -61
- package/dist/components/connection-status.svelte.d.ts +5 -5
- package/dist/components/content-rect.svelte +10 -5
- package/dist/components/content-rect.svelte.d.ts +3 -1
- package/dist/components/error.svelte +15 -5
- package/dist/components/error.svelte.d.ts +8 -1
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +4 -3
- package/dist/components/is-moving.svelte +29 -35
- package/dist/components/is-moving.svelte.d.ts +6 -6
- package/dist/components/maplibre/index.svelte +5 -6
- package/dist/components/maplibre/index.svelte.d.ts +3 -1
- package/dist/components/pose-editor.svelte +83 -15
- package/dist/components/pose-editor.svelte.d.ts +11 -4
- package/dist/components/progress.svelte +1 -0
- package/dist/components/queries.svelte +14 -4
- package/dist/components/queries.svelte.d.ts +6 -1
- package/dist/components/query.svelte +11 -3
- package/dist/components/query.svelte.d.ts +6 -1
- package/dist/components/section/error-key.d.ts +2 -0
- package/dist/components/section/error-key.js +2 -0
- package/dist/components/section/index.d.ts +21 -0
- package/dist/components/section/index.js +21 -0
- package/dist/components/section/section-body.svelte +36 -0
- package/dist/components/section/section-body.svelte.d.ts +13 -0
- package/dist/components/section/section-error-reporter.d.ts +8 -0
- package/dist/components/section/section-error-reporter.js +7 -0
- package/dist/components/section/section-error.svelte +36 -0
- package/dist/components/section/section-error.svelte.d.ts +9 -0
- package/dist/components/section/section-errors.svelte +145 -0
- package/dist/components/section/section-errors.svelte.d.ts +6 -0
- package/dist/components/section/section-heading.svelte +21 -0
- package/dist/components/section/section-heading.svelte.d.ts +9 -0
- package/dist/components/section/section-loading.d.ts +4 -0
- package/dist/components/section/section-loading.js +10 -0
- package/dist/components/section/section-method.svelte +29 -0
- package/dist/components/section/section-method.svelte.d.ts +9 -0
- package/dist/components/section/section-placeholder.svelte +29 -0
- package/dist/components/section/section-placeholder.svelte.d.ts +7 -0
- package/dist/components/section/section-text.svelte +17 -0
- package/dist/components/section/section-text.svelte.d.ts +8 -0
- package/dist/components/section/section-tooltip.svelte +25 -0
- package/dist/components/section/section-tooltip.svelte.d.ts +7 -0
- package/dist/components/section/section.svelte +23 -0
- package/dist/components/section/section.svelte.d.ts +11 -0
- package/dist/components/section/use-section-errors.svelte.d.ts +19 -0
- package/dist/components/section/use-section-errors.svelte.js +49 -0
- package/dist/components/stop-button.svelte +1 -5
- package/dist/components/stop-button.svelte.d.ts +0 -1
- package/dist/components/stop.svelte +31 -14
- package/dist/components/stop.svelte.d.ts +6 -1
- package/dist/components/widgets/arm/arm.svelte +43 -40
- package/dist/components/widgets/arm/get-joint-positions-widget.svelte +10 -9
- package/dist/components/widgets/arm/joint-position-editor.svelte +105 -27
- package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +4 -3
- package/dist/components/widgets/arm/joint-position-slider.svelte +6 -2
- package/dist/components/widgets/arm/joint-position-slider.svelte.d.ts +2 -1
- package/dist/components/widgets/arm/manual-mode-widget.svelte +16 -6
- package/dist/components/widgets/arm/manual-mode.svelte +1 -5
- package/dist/components/widgets/arm/manual-mode.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +22 -8
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +15 -17
- package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/move-to-position-control.svelte +45 -33
- package/dist/components/widgets/arm/move-to-position.svelte +97 -34
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -2
- package/dist/components/widgets/arm/quick-move-widget.svelte +10 -4
- package/dist/components/widgets/arm/quick-move.svelte +1 -4
- package/dist/components/widgets/arm/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.d.ts +16 -0
- package/dist/components/widgets/arm/use-arm-motion-tracking.svelte.js +37 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.d.ts +9 -0
- package/dist/components/widgets/arm/use-edited-targets.svelte.js +24 -0
- package/dist/components/widgets/audio-input/audio-input.svelte +80 -77
- package/dist/components/widgets/audio-input/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/audio-output/audio-output.svelte +87 -84
- package/dist/components/widgets/audio-output/get-properties-widget.svelte +16 -16
- package/dist/components/widgets/base/base.svelte +78 -43
- package/dist/components/widgets/base/move-straight-widget.svelte +16 -4
- package/dist/components/widgets/base/quick-move-widget.svelte +25 -9
- package/dist/components/widgets/base/quick-move.svelte +5 -6
- package/dist/components/widgets/base/set-power-widget.svelte +20 -8
- package/dist/components/widgets/base/set-power.svelte +6 -4
- package/dist/components/widgets/base/set-velocity-widget.svelte +20 -8
- package/dist/components/widgets/base/set-velocity.svelte +6 -4
- package/dist/components/widgets/base/spin-widget.svelte +20 -8
- package/dist/components/widgets/base/vec3-builder.svelte +3 -2
- package/dist/components/widgets/base/vec3-builder.svelte.d.ts +2 -1
- package/dist/components/widgets/board/analog-read.svelte +2 -4
- package/dist/components/widgets/board/analog-write.svelte +2 -4
- package/dist/components/widgets/board/gpio-read.svelte +2 -1
- package/dist/components/widgets/board/gpio-write.svelte +2 -1
- package/dist/components/widgets/board/pin-section.svelte +5 -6
- package/dist/components/widgets/board/pin-section.svelte.d.ts +3 -2
- package/dist/components/widgets/board/read-write-pins.svelte +2 -2
- package/dist/components/widgets/button/push.svelte +2 -2
- package/dist/components/widgets/camera/camera.svelte +17 -24
- package/dist/components/widgets/camera/live-or-polling-video.svelte +33 -30
- package/dist/components/widgets/custom-control/__tests__/__fixtures__/with-sibling.svelte +10 -0
- package/dist/components/widgets/custom-control/control-frame.svelte +60 -0
- package/dist/components/widgets/custom-control/control-frame.svelte.d.ts +10 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.d.ts +19 -0
- package/dist/components/widgets/custom-control/create-control-host.svelte.js +26 -0
- package/dist/components/widgets/custom-control/custom-control.d.ts +35 -0
- package/dist/components/widgets/custom-control/custom-control.js +85 -0
- package/dist/components/widgets/custom-control/custom-control.svelte +45 -0
- package/dist/components/widgets/custom-control/custom-control.svelte.d.ts +14 -0
- package/dist/components/widgets/discovery/discovery.svelte +13 -17
- package/dist/components/widgets/encoder/encoder.svelte +25 -21
- package/dist/components/widgets/encoder/get-position-widget.svelte +19 -16
- package/dist/components/widgets/gantry/gantry.svelte +58 -76
- package/dist/components/widgets/gantry/get-position-widget.svelte +15 -14
- package/dist/components/widgets/gantry/home.svelte +21 -10
- package/dist/components/widgets/gantry/move-to-position-widget.svelte +2 -1
- package/dist/components/widgets/gantry/move-to-position.svelte +1 -4
- package/dist/components/widgets/gantry/move-to-position.svelte.d.ts +0 -1
- package/dist/components/widgets/gantry/quick-move-widget.svelte +3 -2
- package/dist/components/widgets/gantry/quick-move.svelte +1 -5
- package/dist/components/widgets/gantry/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/generic/generic.svelte +11 -6
- package/dist/components/widgets/gripper/grab-widget.svelte +26 -0
- package/dist/components/widgets/gripper/grab-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/grab.svelte +3 -19
- package/dist/components/widgets/gripper/grab.svelte.d.ts +1 -2
- package/dist/components/widgets/gripper/gripper.svelte +18 -18
- package/dist/components/widgets/gripper/is-holding-something.svelte +21 -21
- package/dist/components/widgets/gripper/open-widget.svelte +26 -0
- package/dist/components/widgets/gripper/open-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/open.svelte +3 -19
- package/dist/components/widgets/gripper/open.svelte.d.ts +1 -2
- package/dist/components/widgets/input-controller/input-controller.svelte +10 -16
- package/dist/components/widgets/input-controller/webgamepad.svelte +2 -2
- package/dist/components/widgets/ml-model-service/ml-model-service.svelte +1 -1
- package/dist/components/widgets/motion/frame-select.svelte +4 -2
- package/dist/components/widgets/motion/frame-select.svelte.d.ts +2 -1
- package/dist/components/widgets/motion/motion.svelte +27 -31
- package/dist/components/widgets/motion/move-widget.svelte +32 -12
- package/dist/components/widgets/motion/move-widget.svelte.d.ts +6 -0
- package/dist/components/widgets/motion/move.svelte +6 -16
- package/dist/components/widgets/motion/move.svelte.d.ts +0 -1
- package/dist/components/widgets/motor/go-for-view.svelte +16 -8
- package/dist/components/widgets/motor/go-to-view.svelte +12 -4
- package/dist/components/widgets/motor/motor.svelte +100 -64
- package/dist/components/widgets/motor/quick-move-widget.svelte +16 -8
- package/dist/components/widgets/motor/set-power-widget.svelte +12 -4
- package/dist/components/widgets/motor/set-rpm-widget.svelte +12 -4
- package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/get-position-widget.svelte +8 -11
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +64 -66
- package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +2 -1
- package/dist/components/widgets/power-sensor/get-current-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-power-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +8 -11
- package/dist/components/widgets/power-sensor/power-sensor.svelte +35 -45
- package/dist/components/widgets/sensor/sensor.svelte +8 -12
- package/dist/components/widgets/servo/move-widget.svelte +2 -1
- package/dist/components/widgets/servo/move.svelte +1 -4
- package/dist/components/widgets/servo/move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/quick-move-widget.svelte +2 -1
- package/dist/components/widgets/servo/quick-move.svelte +1 -5
- package/dist/components/widgets/servo/quick-move.svelte.d.ts +0 -1
- package/dist/components/widgets/servo/servo.svelte +53 -37
- package/dist/components/widgets/slam/get-position-widget.svelte +8 -11
- package/dist/components/widgets/slam/move-on-map.svelte +9 -6
- package/dist/components/widgets/slam/move-on-map.svelte.d.ts +2 -1
- package/dist/components/widgets/slam/slam.svelte +65 -75
- package/dist/components/widgets/switch/position-view.svelte +1 -1
- package/dist/components/widgets/switch/position.svelte +2 -2
- package/dist/components/widgets/switch/switch.svelte +1 -1
- package/dist/components/widgets/vision-service/detection-row.svelte +4 -2
- package/dist/components/widgets/vision-service/detection-row.svelte.d.ts +2 -1
- package/dist/components/widgets/vision-service/fonts/public-sans.json +1 -0
- package/dist/components/widgets/vision-service/fonts/public-sans.png +0 -0
- package/dist/components/widgets/vision-service/image.svelte +4 -4
- package/dist/components/widgets/vision-service/legend.svelte +4 -4
- package/dist/components/widgets/vision-service/public-sans-font.d.ts +5 -0
- package/dist/components/widgets/vision-service/public-sans-font.js +14 -0
- package/dist/components/widgets/vision-service/vision-service.svelte +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/package.json +19 -5
- package/dist/components/board/pin-section.svelte +0 -28
- package/dist/components/board/pin-section.svelte.d.ts +0 -9
- package/dist/components/mutation-section.svelte +0 -73
- package/dist/components/mutation-section.svelte.d.ts +0 -16
- package/dist/components/mutation-view.svelte +0 -29
- package/dist/components/mutation-view.svelte.d.ts +0 -10
- package/dist/components/section-group.svelte +0 -64
- package/dist/components/section-group.svelte.d.ts +0 -14
- package/dist/components/section-title.svelte +0 -63
- package/dist/components/section-title.svelte.d.ts +0 -14
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
useRobotClient,
|
|
11
11
|
} from '@viamrobotics/svelte-sdk'
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import ApiSection from '../../api-section.svelte'
|
|
14
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
15
|
|
|
15
16
|
import {
|
|
16
17
|
canPlanMotion,
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
moveMotionServiceName,
|
|
20
21
|
} from './move-control-mode'
|
|
21
22
|
import MoveToPosition from './move-to-position.svelte'
|
|
23
|
+
import { useArmMotionTracking } from './use-arm-motion-tracking.svelte'
|
|
22
24
|
|
|
23
25
|
interface Props {
|
|
24
26
|
partID: string
|
|
@@ -27,8 +29,6 @@
|
|
|
27
29
|
|
|
28
30
|
const { partID, resourceName }: Props = $props()
|
|
29
31
|
|
|
30
|
-
// Both modes read the live pose back at this rate, so `Current position` is never stale.
|
|
31
|
-
const POSE_REFETCH_INTERVAL_MS = 500
|
|
32
32
|
const FRAME_SYSTEM_REFETCH_INTERVAL_MS = 5000
|
|
33
33
|
|
|
34
34
|
const motionServices = useResourceStatuses(() => partID, 'motion')
|
|
@@ -77,32 +77,31 @@
|
|
|
77
77
|
() => activeMotionServiceName ?? ''
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
const
|
|
80
|
+
const moveMutation = createResourceMutation(motionClient, 'move')
|
|
81
|
+
const moveToPosMutation = createResourceMutation(armClient, 'moveToPosition')
|
|
82
|
+
const activeMutation = $derived(mode === 'motion' ? moveMutation : moveToPosMutation)
|
|
83
|
+
|
|
84
|
+
const motionTracking = useArmMotionTracking(armClient, {
|
|
85
|
+
isMovePending: () => moveMutation.isPending || moveToPosMutation.isPending,
|
|
86
|
+
refetchPosition: () => activeQuery.refetch(),
|
|
87
|
+
})
|
|
88
|
+
const refetchInterval = $derived(motionTracking.refetchInterval)
|
|
89
|
+
|
|
82
90
|
const poseQuery = createRobotQuery(
|
|
83
91
|
robotClient,
|
|
84
92
|
'getPose',
|
|
85
|
-
() =>
|
|
86
|
-
() => ({ refetchInterval
|
|
93
|
+
() => [resourceName, 'world', []] satisfies Parameters<RobotClient['getPose']>,
|
|
94
|
+
() => ({ refetchInterval, enabled: mode === 'motion' })
|
|
87
95
|
)
|
|
96
|
+
|
|
88
97
|
const endPositionQuery = createResourceQuery(armClient, 'getEndPosition', () => ({
|
|
89
|
-
refetchInterval
|
|
98
|
+
refetchInterval,
|
|
90
99
|
enabled: mode === 'direct',
|
|
91
100
|
}))
|
|
92
101
|
|
|
93
102
|
const activeQuery = $derived(mode === 'motion' ? poseQuery : endPositionQuery)
|
|
94
103
|
const endPosition = $derived(mode === 'motion' ? poseQuery.data?.pose : endPositionQuery.data)
|
|
95
104
|
|
|
96
|
-
const moveMutation = createResourceMutation(motionClient, 'move')
|
|
97
|
-
const moveToPosMutation = createResourceMutation(armClient, 'moveToPosition')
|
|
98
|
-
const lastError = $derived(mode === 'motion' ? moveMutation.error : moveToPosMutation.error)
|
|
99
|
-
|
|
100
|
-
const description = $derived(
|
|
101
|
-
mode === 'motion'
|
|
102
|
-
? 'Pose is in the world frame, as required by the motion service.'
|
|
103
|
-
: 'Pose is with respect to the arm origin and does not take into account the motion service or frame system.'
|
|
104
|
-
)
|
|
105
|
-
|
|
106
105
|
const handleModeInput = (event: CustomEvent<string>) => {
|
|
107
106
|
userChoice = event.detail === 'Motion service' ? 'motion' : 'direct'
|
|
108
107
|
}
|
|
@@ -122,7 +121,22 @@
|
|
|
122
121
|
}
|
|
123
122
|
</script>
|
|
124
123
|
|
|
125
|
-
|
|
124
|
+
{#snippet description()}
|
|
125
|
+
{#if mode === 'motion'}
|
|
126
|
+
Pose is in the world frame, as required by the motion service.
|
|
127
|
+
{:else}
|
|
128
|
+
Pose is with respect to the arm origin and does not take into account the motion service or
|
|
129
|
+
frame system.
|
|
130
|
+
{/if}
|
|
131
|
+
{/snippet}
|
|
132
|
+
|
|
133
|
+
<ApiSection
|
|
134
|
+
method="MoveToPosition"
|
|
135
|
+
api={ResourceTriplets.Arm}
|
|
136
|
+
queries={[frameSystemQuery, activeQuery]}
|
|
137
|
+
mutations={[activeMutation]}
|
|
138
|
+
class="grow flex-col gap-4"
|
|
139
|
+
>
|
|
126
140
|
{#if motionAvailable}
|
|
127
141
|
<Label position="top">
|
|
128
142
|
<span class="flex items-center gap-1 text-xs">
|
|
@@ -177,17 +191,15 @@
|
|
|
177
191
|
{/snippet}
|
|
178
192
|
</Banner>
|
|
179
193
|
{/if}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{#
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
</Queries>
|
|
193
|
-
</div>
|
|
194
|
+
<!-- Re-seed the editor on a mode change: the two modes report the pose in different frames. -->
|
|
195
|
+
{#key mode}
|
|
196
|
+
{#if endPosition}
|
|
197
|
+
<MoveToPosition
|
|
198
|
+
{endPosition}
|
|
199
|
+
{moveToPosition}
|
|
200
|
+
isMoving={motionTracking.isTracking}
|
|
201
|
+
{description}
|
|
202
|
+
/>
|
|
203
|
+
{/if}
|
|
204
|
+
{/key}
|
|
205
|
+
</ApiSection>
|
|
@@ -1,54 +1,101 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script
|
|
2
|
+
lang="ts"
|
|
3
|
+
module
|
|
4
|
+
>
|
|
2
5
|
import type { Pose } from '@viamrobotics/sdk'
|
|
3
6
|
|
|
7
|
+
type PoseKey = keyof Pose
|
|
8
|
+
|
|
9
|
+
const POSE_KEYS: PoseKey[] = ['x', 'y', 'z', 'oX', 'oY', 'oZ', 'theta']
|
|
10
|
+
|
|
11
|
+
// Tight enough to catch a real move, loose enough to ignore encoder noise. Theta is in degrees.
|
|
12
|
+
const DRIFT_THRESHOLDS: Record<PoseKey, number> = {
|
|
13
|
+
x: 1,
|
|
14
|
+
y: 1,
|
|
15
|
+
z: 1,
|
|
16
|
+
oX: 0.01,
|
|
17
|
+
oY: 0.01,
|
|
18
|
+
oZ: 0.01,
|
|
19
|
+
theta: 0.5,
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import type { Snippet } from 'svelte'
|
|
25
|
+
|
|
4
26
|
import { Button, Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
5
27
|
|
|
6
|
-
import ErrorDisplay from '../../error.svelte'
|
|
7
28
|
import PoseEditor from '../../pose-editor.svelte'
|
|
29
|
+
import StatusPill from '../../status-pill.svelte'
|
|
30
|
+
|
|
31
|
+
import { useEditedTargets } from './use-edited-targets.svelte'
|
|
8
32
|
|
|
9
33
|
interface Props {
|
|
10
34
|
endPosition: Pose
|
|
11
35
|
moveToPosition: (position: Pose) => void
|
|
12
|
-
|
|
13
|
-
description?:
|
|
36
|
+
isMoving?: boolean
|
|
37
|
+
description?: Snippet
|
|
14
38
|
}
|
|
15
39
|
|
|
16
40
|
const {
|
|
17
41
|
endPosition,
|
|
18
42
|
moveToPosition,
|
|
19
|
-
|
|
20
|
-
description
|
|
43
|
+
isMoving = false,
|
|
44
|
+
description: customDescription,
|
|
21
45
|
}: Props = $props()
|
|
22
46
|
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
const targets = useEditedTargets<PoseKey>(
|
|
48
|
+
(key) => endPosition[key],
|
|
49
|
+
(key) => DRIFT_THRESHOLDS[key]
|
|
50
|
+
)
|
|
25
51
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
const desiredPosition = $derived<Pose>({
|
|
53
|
+
x: targets.target('x'),
|
|
54
|
+
y: targets.target('y'),
|
|
55
|
+
z: targets.target('z'),
|
|
56
|
+
oX: targets.target('oX'),
|
|
57
|
+
oY: targets.target('oY'),
|
|
58
|
+
oZ: targets.target('oZ'),
|
|
59
|
+
theta: targets.target('theta'),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const handlePoseChange = (next: Pose) => {
|
|
63
|
+
for (const key of POSE_KEYS) {
|
|
64
|
+
if (next[key] !== desiredPosition[key]) {
|
|
65
|
+
targets.edit(key, next[key])
|
|
66
|
+
}
|
|
35
67
|
}
|
|
36
68
|
}
|
|
37
69
|
|
|
38
|
-
const
|
|
39
|
-
|
|
70
|
+
const resetToZero = () => {
|
|
71
|
+
for (const key of POSE_KEYS) {
|
|
72
|
+
targets.edit(key, 0)
|
|
73
|
+
}
|
|
40
74
|
}
|
|
41
75
|
</script>
|
|
42
76
|
|
|
77
|
+
{#snippet poseDescription()}
|
|
78
|
+
Pose is with respect to the arm origin and does not take into account the motion service or frame
|
|
79
|
+
system.
|
|
80
|
+
{/snippet}
|
|
81
|
+
|
|
43
82
|
<div class="flex min-w-0 flex-col gap-4">
|
|
44
83
|
<PoseEditor
|
|
45
84
|
pose={desiredPosition}
|
|
46
|
-
onPoseChange={
|
|
47
|
-
|
|
85
|
+
onPoseChange={handlePoseChange}
|
|
86
|
+
fieldStatus={(key) => ({
|
|
87
|
+
current: endPosition[key],
|
|
88
|
+
isEdited: targets.isEdited(key),
|
|
89
|
+
drift: targets.drift(key),
|
|
90
|
+
isMoving,
|
|
91
|
+
})}
|
|
92
|
+
onFieldReset={(key) => {
|
|
93
|
+
targets.reset(key)
|
|
48
94
|
}}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
95
|
+
description={customDescription ?? poseDescription}
|
|
96
|
+
>
|
|
97
|
+
{#snippet heading()}Pose Values{/snippet}
|
|
98
|
+
</PoseEditor>
|
|
52
99
|
|
|
53
100
|
<div class="mb-2 flex flex-col gap-2">
|
|
54
101
|
<span class="flex flex-row gap-2">
|
|
@@ -64,16 +111,32 @@
|
|
|
64
111
|
</span>
|
|
65
112
|
<div class="flex flex-col gap-2 sm:flex-row">
|
|
66
113
|
<Button onclick={resetToZero}>Zero</Button>
|
|
67
|
-
<Button
|
|
114
|
+
<Button
|
|
115
|
+
onclick={() => {
|
|
116
|
+
targets.resetAll()
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
Current position
|
|
120
|
+
</Button>
|
|
68
121
|
</div>
|
|
69
122
|
</div>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
123
|
+
<div class="mt-auto flex items-center gap-2">
|
|
124
|
+
<Button
|
|
125
|
+
class="w-fit"
|
|
126
|
+
icon="play-circle-outline"
|
|
127
|
+
variant="dark"
|
|
128
|
+
disabled={isMoving}
|
|
129
|
+
onclick={() => moveToPosition(desiredPosition)}
|
|
130
|
+
>
|
|
131
|
+
Execute
|
|
132
|
+
</Button>
|
|
133
|
+
<span role="status">
|
|
134
|
+
{#if isMoving}
|
|
135
|
+
<StatusPill
|
|
136
|
+
isActive
|
|
137
|
+
activeText="Arm is moving"
|
|
138
|
+
/>
|
|
139
|
+
{/if}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
79
142
|
</div>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Pose } from '@viamrobotics/sdk';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
2
3
|
interface Props {
|
|
3
4
|
endPosition: Pose;
|
|
4
5
|
moveToPosition: (position: Pose) => void;
|
|
5
|
-
|
|
6
|
-
description?:
|
|
6
|
+
isMoving?: boolean;
|
|
7
|
+
description?: Snippet;
|
|
7
8
|
}
|
|
8
9
|
declare const MoveToPosition: import("svelte").Component<Props, {}, "">;
|
|
9
10
|
type MoveToPosition = ReturnType<typeof MoveToPosition>;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
createResourceQuery,
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import ApiSection from '../../api-section.svelte'
|
|
10
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
10
11
|
|
|
11
12
|
import QuickMove from './quick-move.svelte'
|
|
12
13
|
|
|
@@ -34,12 +35,17 @@
|
|
|
34
35
|
}
|
|
35
36
|
</script>
|
|
36
37
|
|
|
37
|
-
<
|
|
38
|
+
<ApiSection
|
|
39
|
+
method="MoveToJointPositions"
|
|
40
|
+
api={ResourceTriplets.Arm}
|
|
41
|
+
queries={[jointPositionsQuery]}
|
|
42
|
+
mutations={[quickMoveToJointPosMutation]}
|
|
43
|
+
class="grow flex-col gap-4"
|
|
44
|
+
>
|
|
38
45
|
{#if jointPositionsQuery.data}
|
|
39
46
|
<QuickMove
|
|
40
47
|
positions={jointPositionsQuery.data.values}
|
|
41
48
|
moveToJointPositions={quickMoveToJointPositions}
|
|
42
|
-
lastError={quickMoveToJointPosMutation.error}
|
|
43
49
|
/>
|
|
44
50
|
{/if}
|
|
45
|
-
</
|
|
51
|
+
</ApiSection>
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Button } from '@viamrobotics/prime-core'
|
|
3
3
|
|
|
4
|
-
import ErrorDisplay from '../../error.svelte'
|
|
5
4
|
import Table from '../../table.svelte'
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
7
|
positions: number[]
|
|
9
8
|
moveToJointPositions: (jointPositions: number[]) => void
|
|
10
|
-
lastError: Error | null
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
const { positions, moveToJointPositions
|
|
11
|
+
const { positions, moveToJointPositions }: Props = $props()
|
|
14
12
|
|
|
15
13
|
const quickMove = (index: number, increment: number) => {
|
|
16
14
|
const clonedPositions = positions.map((position, positionIndex) =>
|
|
@@ -59,4 +57,3 @@
|
|
|
59
57
|
{/each}
|
|
60
58
|
</tbody>
|
|
61
59
|
</Table>
|
|
62
|
-
<ErrorDisplay {lastError} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArmClient } from '@viamrobotics/sdk';
|
|
2
|
+
import { type ResourceClientContext } from '@viamrobotics/svelte-sdk';
|
|
3
|
+
interface ArmMotionTrackingOptions {
|
|
4
|
+
/** A move this widget sent is still in flight. */
|
|
5
|
+
isMovePending: () => boolean;
|
|
6
|
+
/** Re-reads the arm's position. Called once each time the arm stops. */
|
|
7
|
+
refetchPosition: () => Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** Allows an editor to track the arm's live position. */
|
|
10
|
+
export declare const useArmMotionTracking: (client: ResourceClientContext<ArmClient>, { isMovePending, refetchPosition }: ArmMotionTrackingOptions) => {
|
|
11
|
+
/** The arm is moving or has just stopped, so the editor follows the live position. */
|
|
12
|
+
readonly isTracking: boolean;
|
|
13
|
+
/** How often to poll the arm's position. Faster while tracking. */
|
|
14
|
+
readonly refetchInterval: 500 | 250;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createResourceQuery } from '@viamrobotics/svelte-sdk';
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
const IDLE_REFETCH_INTERVAL_MS = 500;
|
|
4
|
+
const MOVING_REFETCH_INTERVAL_MS = 250;
|
|
5
|
+
/** Allows an editor to track the arm's live position. */
|
|
6
|
+
export const useArmMotionTracking = (client, { isMovePending, refetchPosition }) => {
|
|
7
|
+
const isMovingQuery = createResourceQuery(client, 'isMoving', {
|
|
8
|
+
refetchInterval: IDLE_REFETCH_INTERVAL_MS,
|
|
9
|
+
});
|
|
10
|
+
const isMoving = $derived(isMovingQuery.data === true || isMovePending());
|
|
11
|
+
let isSettling = $state(false);
|
|
12
|
+
let wasMoving = false;
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (isMoving) {
|
|
15
|
+
wasMoving = true;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!wasMoving)
|
|
19
|
+
return;
|
|
20
|
+
wasMoving = false;
|
|
21
|
+
isSettling = true;
|
|
22
|
+
void untrack(refetchPosition).finally(() => {
|
|
23
|
+
isSettling = false;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
const isTracking = $derived(isMoving || isSettling);
|
|
27
|
+
return {
|
|
28
|
+
/** The arm is moving or has just stopped, so the editor follows the live position. */
|
|
29
|
+
get isTracking() {
|
|
30
|
+
return isTracking;
|
|
31
|
+
},
|
|
32
|
+
/** How often to poll the arm's position. Faster while tracking. */
|
|
33
|
+
get refetchInterval() {
|
|
34
|
+
return isTracking ? MOVING_REFETCH_INTERVAL_MS : IDLE_REFETCH_INTERVAL_MS;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface EditedTargets<TKey> {
|
|
2
|
+
target: (key: TKey) => number;
|
|
3
|
+
isEdited: (key: TKey) => boolean;
|
|
4
|
+
drift: (key: TKey) => number | undefined;
|
|
5
|
+
edit: (key: TKey, value: number) => void;
|
|
6
|
+
reset: (key: TKey) => void;
|
|
7
|
+
resetAll: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useEditedTargets: <TKey>(readLive: (key: TKey) => number, driftThreshold: (key: TKey) => number) => EditedTargets<TKey>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
+
export const useEditedTargets = (readLive, driftThreshold) => {
|
|
3
|
+
const edits = new SvelteMap();
|
|
4
|
+
return {
|
|
5
|
+
target: (key) => edits.get(key)?.value ?? readLive(key),
|
|
6
|
+
isEdited: (key) => edits.has(key),
|
|
7
|
+
drift: (key) => {
|
|
8
|
+
const edit = edits.get(key);
|
|
9
|
+
if (!edit)
|
|
10
|
+
return undefined;
|
|
11
|
+
const distance = Math.abs(readLive(key) - edit.baseline);
|
|
12
|
+
return distance > driftThreshold(key) ? distance : undefined;
|
|
13
|
+
},
|
|
14
|
+
edit: (key, value) => {
|
|
15
|
+
edits.set(key, { value, baseline: readLive(key) });
|
|
16
|
+
},
|
|
17
|
+
reset: (key) => {
|
|
18
|
+
edits.delete(key);
|
|
19
|
+
},
|
|
20
|
+
resetAll: () => {
|
|
21
|
+
edits.clear();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
import ApiSection from '../../api-section.svelte'
|
|
7
7
|
import Properties from '../../audio-properties.svelte'
|
|
8
8
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
9
|
-
import MutationSection from '../../mutation-section.svelte'
|
|
10
|
-
import Query from '../../query.svelte'
|
|
11
9
|
import RefetchController from '../../refetch-controller.svelte'
|
|
12
10
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
11
|
+
import { Section } from '../../section'
|
|
13
12
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
13
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
14
|
|
|
15
15
|
import { createAudioCapturer } from './create-audio-capturer.svelte.js'
|
|
16
16
|
|
|
@@ -61,94 +61,97 @@
|
|
|
61
61
|
<div class="@container">
|
|
62
62
|
<div class="flex flex-col divide-y @2xl:flex-row @2xl:divide-x @2xl:divide-y-0">
|
|
63
63
|
<div class="flex w-full flex-col divide-y">
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
api=
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
<ApiSection
|
|
65
|
+
method="GetAudio"
|
|
66
|
+
api={ResourceTriplets.AudioInput}
|
|
67
|
+
mutations={[capture]}
|
|
68
|
+
class="flex-row flex-wrap gap-2"
|
|
69
69
|
>
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
{#snippet subheading()}
|
|
71
|
+
<Section.Text>Capture audio from the device</Section.Text>
|
|
72
|
+
{/snippet}
|
|
73
|
+
<div class="flex grow flex-wrap justify-between gap-2">
|
|
74
|
+
<div class="flex flex-col gap-2">
|
|
75
|
+
<Label cx="gap-1 text-xs">
|
|
76
|
+
Codec
|
|
77
|
+
<Select
|
|
78
|
+
slot="input"
|
|
79
|
+
value={selectedCodec}
|
|
80
|
+
on:change={(e) => {
|
|
81
|
+
captureCodec = (e.target as HTMLSelectElement).value
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
{#each availableCodecs as codec (codec)}
|
|
85
|
+
<option value={codec}>{codec}</option>
|
|
86
|
+
{/each}
|
|
87
|
+
</Select>
|
|
88
|
+
</Label>
|
|
89
|
+
<Label cx="gap-1 text-xs">
|
|
90
|
+
Duration (seconds, 0 = stream until stopped)
|
|
91
|
+
<NumericInput
|
|
92
|
+
slot="input"
|
|
93
|
+
value={captureDuration}
|
|
94
|
+
on:change={(e) => {
|
|
95
|
+
captureDuration = numberValueFromEvent(e) ?? 3
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
</Label>
|
|
99
|
+
</div>
|
|
96
100
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<p class="font-roboto-mono text-subtle-1 text-xs">
|
|
100
|
-
{(capture.totalBytes / 1024).toFixed(1)} kB captured
|
|
101
|
-
</p>
|
|
102
|
-
<Button
|
|
103
|
-
icon="stop-circle-outline"
|
|
104
|
-
onclick={capture.stop}
|
|
105
|
-
>
|
|
106
|
-
Stop
|
|
107
|
-
</Button>
|
|
108
|
-
{:else}
|
|
109
|
-
{#if capture.downloadUrl}
|
|
101
|
+
<div class="mt-auto flex flex-col items-start gap-2">
|
|
102
|
+
{#if capture.status === 'recording'}
|
|
110
103
|
<p class="font-roboto-mono text-subtle-1 text-xs">
|
|
111
104
|
{(capture.totalBytes / 1024).toFixed(1)} kB captured
|
|
112
105
|
</p>
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
rel="external"
|
|
106
|
+
<Button
|
|
107
|
+
icon="stop-circle-outline"
|
|
108
|
+
onclick={capture.stop}
|
|
117
109
|
>
|
|
118
|
-
|
|
119
|
-
</
|
|
110
|
+
Stop
|
|
111
|
+
</Button>
|
|
112
|
+
{:else}
|
|
113
|
+
{#if capture.downloadUrl}
|
|
114
|
+
<p class="font-roboto-mono text-subtle-1 text-xs">
|
|
115
|
+
{(capture.totalBytes / 1024).toFixed(1)} kB captured
|
|
116
|
+
</p>
|
|
117
|
+
<a
|
|
118
|
+
href={capture.downloadUrl}
|
|
119
|
+
download="audio-capture.{selectedCodec}"
|
|
120
|
+
rel="external"
|
|
121
|
+
>
|
|
122
|
+
<Button icon="download">Download</Button>
|
|
123
|
+
</a>
|
|
124
|
+
{/if}
|
|
125
|
+
<Button
|
|
126
|
+
icon="play-circle-outline"
|
|
127
|
+
onclick={() => capture.start(selectedCodec, captureDuration)}
|
|
128
|
+
disabled={!client.current}
|
|
129
|
+
>
|
|
130
|
+
{capture.status === 'done' ? 'Capture Again' : 'Start Capture'}
|
|
131
|
+
</Button>
|
|
120
132
|
{/if}
|
|
121
|
-
|
|
122
|
-
icon="play-circle-outline"
|
|
123
|
-
onclick={() => capture.start(selectedCodec, captureDuration)}
|
|
124
|
-
disabled={!client.current}
|
|
125
|
-
>
|
|
126
|
-
{capture.status === 'done' ? 'Capture Again' : 'Start Capture'}
|
|
127
|
-
</Button>
|
|
128
|
-
{/if}
|
|
133
|
+
</div>
|
|
129
134
|
</div>
|
|
130
|
-
</
|
|
135
|
+
</ApiSection>
|
|
131
136
|
</div>
|
|
132
137
|
|
|
133
138
|
<div class="flex w-full flex-col divide-y @2xl:ml-auto @2xl:max-w-1/2 @4xl:max-w-1/3">
|
|
134
139
|
<ApiSection
|
|
135
|
-
|
|
136
|
-
api=
|
|
137
|
-
|
|
138
|
-
class="relative"
|
|
140
|
+
method="GetProperties"
|
|
141
|
+
api={ResourceTriplets.AudioInput}
|
|
142
|
+
queries={[propertiesQuery]}
|
|
143
|
+
class="relative grow flex-col gap-4"
|
|
139
144
|
>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{/if}
|
|
151
|
-
</Query>
|
|
145
|
+
{#snippet subheading()}
|
|
146
|
+
<Section.Text>Audio input properties</Section.Text>
|
|
147
|
+
{/snippet}
|
|
148
|
+
{#if propertiesQuery.data !== undefined}
|
|
149
|
+
<Properties
|
|
150
|
+
supportedCodecs={propertiesQuery.data.supportedCodecs}
|
|
151
|
+
sampleRateHz={propertiesQuery.data.sampleRateHz}
|
|
152
|
+
numChannels={propertiesQuery.data.numChannels}
|
|
153
|
+
/>
|
|
154
|
+
{/if}
|
|
152
155
|
</ApiSection>
|
|
153
156
|
</div>
|
|
154
157
|
</div>
|