@viamrobotics/test-widgets 0.15.1 → 0.16.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 +7 -6
- package/dist/components/api-section.svelte.d.ts +4 -3
- 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 +4 -5
- package/dist/components/content-rect.svelte.d.ts +2 -1
- package/dist/components/error.svelte +6 -5
- package/dist/components/error.svelte.d.ts +2 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/is-moving.svelte +4 -2
- package/dist/components/is-moving.svelte.d.ts +2 -1
- package/dist/components/maplibre/index.svelte +5 -6
- package/dist/components/maplibre/index.svelte.d.ts +3 -1
- package/dist/components/mutation-section.svelte +7 -5
- package/dist/components/mutation-section.svelte.d.ts +4 -2
- package/dist/components/pose-editor.svelte +83 -15
- package/dist/components/pose-editor.svelte.d.ts +11 -4
- package/dist/components/queries.svelte +7 -4
- package/dist/components/queries.svelte.d.ts +2 -1
- package/dist/components/query.svelte +4 -3
- package/dist/components/query.svelte.d.ts +2 -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 +19 -0
- package/dist/components/section/index.js +19 -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-errors.svelte +18 -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 +17 -0
- package/dist/components/section/section.svelte.d.ts +8 -0
- package/dist/components/section/use-section-errors.svelte.d.ts +18 -0
- package/dist/components/section/use-section-errors.svelte.js +39 -0
- package/dist/components/section-title.svelte +3 -1
- package/dist/components/section-title.svelte.d.ts +2 -1
- package/dist/components/stop.svelte +31 -14
- package/dist/components/stop.svelte.d.ts +6 -1
- package/dist/components/widgets/arm/arm.svelte +22 -11
- package/dist/components/widgets/arm/get-joint-positions-widget.svelte +1 -1
- 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 +3 -2
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +12 -4
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +14 -6
- package/dist/components/widgets/arm/move-to-position-control.svelte +25 -17
- package/dist/components/widgets/arm/move-to-position.svelte +97 -30
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +3 -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 +5 -4
- package/dist/components/widgets/audio-input/get-properties-widget.svelte +2 -2
- package/dist/components/widgets/audio-output/audio-output.svelte +5 -4
- package/dist/components/widgets/audio-output/get-properties-widget.svelte +2 -2
- package/dist/components/widgets/base/base.svelte +8 -6
- package/dist/components/widgets/base/quick-move.svelte +5 -6
- package/dist/components/widgets/base/set-power.svelte +6 -4
- package/dist/components/widgets/base/set-velocity.svelte +6 -4
- 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/camera/camera.svelte +4 -3
- package/dist/components/widgets/camera/live-or-polling-video.svelte +22 -22
- package/dist/components/widgets/discovery/discovery.svelte +4 -3
- package/dist/components/widgets/encoder/encoder.svelte +5 -3
- package/dist/components/widgets/encoder/get-position-widget.svelte +1 -1
- package/dist/components/widgets/gantry/gantry.svelte +13 -7
- package/dist/components/widgets/gantry/get-position-widget.svelte +1 -1
- package/dist/components/widgets/gantry/quick-move-widget.svelte +1 -1
- package/dist/components/widgets/generic/generic.svelte +4 -1
- package/dist/components/widgets/gripper/gripper.svelte +8 -6
- package/dist/components/widgets/gripper/is-holding-something.svelte +3 -2
- package/dist/components/widgets/input-controller/input-controller.svelte +4 -3
- 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 +9 -5
- package/dist/components/widgets/motion/move.svelte +5 -3
- package/dist/components/widgets/motor/motor.svelte +12 -10
- package/dist/components/widgets/movement-sensor/get-accuracy-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-compass-heading-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-orientation-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/get-position-widget.svelte +2 -2
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +17 -18
- package/dist/components/widgets/power-sensor/get-current-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/get-power-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/get-voltage-widget.svelte +2 -2
- package/dist/components/widgets/power-sensor/power-sensor.svelte +13 -11
- package/dist/components/widgets/sensor/sensor.svelte +4 -3
- package/dist/components/widgets/servo/servo.svelte +9 -4
- package/dist/components/widgets/slam/get-position-widget.svelte +2 -2
- package/dist/components/widgets/slam/move-on-map.svelte +3 -1
- package/dist/components/widgets/slam/slam.svelte +10 -5
- package/dist/components/widgets/switch/position-view.svelte +1 -1
- 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 +17 -4
- package/dist/components/board/pin-section.svelte +0 -28
- package/dist/components/board/pin-section.svelte.d.ts +0 -9
- package/dist/components/section-group.svelte +0 -64
- package/dist/components/section-group.svelte.d.ts +0 -14
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
moveMotionServiceName,
|
|
20
20
|
} from './move-control-mode'
|
|
21
21
|
import MoveToPosition from './move-to-position.svelte'
|
|
22
|
+
import { useArmMotionTracking } from './use-arm-motion-tracking.svelte'
|
|
22
23
|
|
|
23
24
|
interface Props {
|
|
24
25
|
partID: string
|
|
@@ -27,8 +28,6 @@
|
|
|
27
28
|
|
|
28
29
|
const { partID, resourceName }: Props = $props()
|
|
29
30
|
|
|
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
31
|
const FRAME_SYSTEM_REFETCH_INTERVAL_MS = 5000
|
|
33
32
|
|
|
34
33
|
const motionServices = useResourceStatuses(() => partID, 'motion')
|
|
@@ -77,32 +76,31 @@
|
|
|
77
76
|
() => activeMotionServiceName ?? ''
|
|
78
77
|
)
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
const
|
|
79
|
+
const moveMutation = createResourceMutation(motionClient, 'move')
|
|
80
|
+
const moveToPosMutation = createResourceMutation(armClient, 'moveToPosition')
|
|
81
|
+
const lastError = $derived(mode === 'motion' ? moveMutation.error : moveToPosMutation.error)
|
|
82
|
+
|
|
83
|
+
const motionTracking = useArmMotionTracking(armClient, {
|
|
84
|
+
isMovePending: () => moveMutation.isPending || moveToPosMutation.isPending,
|
|
85
|
+
refetchPosition: () => activeQuery.refetch(),
|
|
86
|
+
})
|
|
87
|
+
const refetchInterval = $derived(motionTracking.refetchInterval)
|
|
88
|
+
|
|
82
89
|
const poseQuery = createRobotQuery(
|
|
83
90
|
robotClient,
|
|
84
91
|
'getPose',
|
|
85
|
-
() =>
|
|
86
|
-
() => ({ refetchInterval
|
|
92
|
+
() => [resourceName, 'world', []] satisfies Parameters<RobotClient['getPose']>,
|
|
93
|
+
() => ({ refetchInterval, enabled: mode === 'motion' })
|
|
87
94
|
)
|
|
95
|
+
|
|
88
96
|
const endPositionQuery = createResourceQuery(armClient, 'getEndPosition', () => ({
|
|
89
|
-
refetchInterval
|
|
97
|
+
refetchInterval,
|
|
90
98
|
enabled: mode === 'direct',
|
|
91
99
|
}))
|
|
92
100
|
|
|
93
101
|
const activeQuery = $derived(mode === 'motion' ? poseQuery : endPositionQuery)
|
|
94
102
|
const endPosition = $derived(mode === 'motion' ? poseQuery.data?.pose : endPositionQuery.data)
|
|
95
103
|
|
|
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
104
|
const handleModeInput = (event: CustomEvent<string>) => {
|
|
107
105
|
userChoice = event.detail === 'Motion service' ? 'motion' : 'direct'
|
|
108
106
|
}
|
|
@@ -122,6 +120,15 @@
|
|
|
122
120
|
}
|
|
123
121
|
</script>
|
|
124
122
|
|
|
123
|
+
{#snippet description()}
|
|
124
|
+
{#if mode === 'motion'}
|
|
125
|
+
Pose is in the world frame, as required by the motion service.
|
|
126
|
+
{:else}
|
|
127
|
+
Pose is with respect to the arm origin and does not take into account the motion service or
|
|
128
|
+
frame system.
|
|
129
|
+
{/if}
|
|
130
|
+
{/snippet}
|
|
131
|
+
|
|
125
132
|
<div class="flex flex-col gap-4">
|
|
126
133
|
{#if motionAvailable}
|
|
127
134
|
<Label position="top">
|
|
@@ -185,6 +192,7 @@
|
|
|
185
192
|
{endPosition}
|
|
186
193
|
{moveToPosition}
|
|
187
194
|
{lastError}
|
|
195
|
+
isMoving={motionTracking.isTracking}
|
|
188
196
|
{description}
|
|
189
197
|
/>
|
|
190
198
|
{/if}
|
|
@@ -1,54 +1,104 @@
|
|
|
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
28
|
import ErrorDisplay from '../../error.svelte'
|
|
7
29
|
import PoseEditor from '../../pose-editor.svelte'
|
|
30
|
+
import StatusPill from '../../status-pill.svelte'
|
|
31
|
+
|
|
32
|
+
import { useEditedTargets } from './use-edited-targets.svelte'
|
|
8
33
|
|
|
9
34
|
interface Props {
|
|
10
35
|
endPosition: Pose
|
|
11
36
|
moveToPosition: (position: Pose) => void
|
|
12
37
|
lastError: Error | null
|
|
13
|
-
|
|
38
|
+
isMoving?: boolean
|
|
39
|
+
description?: Snippet
|
|
14
40
|
}
|
|
15
41
|
|
|
16
42
|
const {
|
|
17
43
|
endPosition,
|
|
18
44
|
moveToPosition,
|
|
19
45
|
lastError,
|
|
20
|
-
|
|
46
|
+
isMoving = false,
|
|
47
|
+
description: customDescription,
|
|
21
48
|
}: Props = $props()
|
|
22
49
|
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
const targets = useEditedTargets<PoseKey>(
|
|
51
|
+
(key) => endPosition[key],
|
|
52
|
+
(key) => DRIFT_THRESHOLDS[key]
|
|
53
|
+
)
|
|
25
54
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
const desiredPosition = $derived<Pose>({
|
|
56
|
+
x: targets.target('x'),
|
|
57
|
+
y: targets.target('y'),
|
|
58
|
+
z: targets.target('z'),
|
|
59
|
+
oX: targets.target('oX'),
|
|
60
|
+
oY: targets.target('oY'),
|
|
61
|
+
oZ: targets.target('oZ'),
|
|
62
|
+
theta: targets.target('theta'),
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const handlePoseChange = (next: Pose) => {
|
|
66
|
+
for (const key of POSE_KEYS) {
|
|
67
|
+
if (next[key] !== desiredPosition[key]) {
|
|
68
|
+
targets.edit(key, next[key])
|
|
69
|
+
}
|
|
35
70
|
}
|
|
36
71
|
}
|
|
37
72
|
|
|
38
|
-
const
|
|
39
|
-
|
|
73
|
+
const resetToZero = () => {
|
|
74
|
+
for (const key of POSE_KEYS) {
|
|
75
|
+
targets.edit(key, 0)
|
|
76
|
+
}
|
|
40
77
|
}
|
|
41
78
|
</script>
|
|
42
79
|
|
|
80
|
+
{#snippet poseDescription()}
|
|
81
|
+
Pose is with respect to the arm origin and does not take into account the motion service or frame
|
|
82
|
+
system.
|
|
83
|
+
{/snippet}
|
|
84
|
+
|
|
43
85
|
<div class="flex min-w-0 flex-col gap-4">
|
|
44
86
|
<PoseEditor
|
|
45
87
|
pose={desiredPosition}
|
|
46
|
-
onPoseChange={
|
|
47
|
-
|
|
88
|
+
onPoseChange={handlePoseChange}
|
|
89
|
+
fieldStatus={(key) => ({
|
|
90
|
+
current: endPosition[key],
|
|
91
|
+
isEdited: targets.isEdited(key),
|
|
92
|
+
drift: targets.drift(key),
|
|
93
|
+
isMoving,
|
|
94
|
+
})}
|
|
95
|
+
onFieldReset={(key) => {
|
|
96
|
+
targets.reset(key)
|
|
48
97
|
}}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
98
|
+
description={customDescription ?? poseDescription}
|
|
99
|
+
>
|
|
100
|
+
{#snippet heading()}Pose Values{/snippet}
|
|
101
|
+
</PoseEditor>
|
|
52
102
|
|
|
53
103
|
<div class="mb-2 flex flex-col gap-2">
|
|
54
104
|
<span class="flex flex-row gap-2">
|
|
@@ -64,16 +114,33 @@
|
|
|
64
114
|
</span>
|
|
65
115
|
<div class="flex flex-col gap-2 sm:flex-row">
|
|
66
116
|
<Button onclick={resetToZero}>Zero</Button>
|
|
67
|
-
<Button
|
|
117
|
+
<Button
|
|
118
|
+
onclick={() => {
|
|
119
|
+
targets.resetAll()
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
Current position
|
|
123
|
+
</Button>
|
|
68
124
|
</div>
|
|
69
125
|
</div>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
126
|
+
<div class="mt-auto flex items-center gap-2">
|
|
127
|
+
<Button
|
|
128
|
+
class="w-fit"
|
|
129
|
+
icon="play-circle-outline"
|
|
130
|
+
variant="dark"
|
|
131
|
+
disabled={isMoving}
|
|
132
|
+
onclick={() => moveToPosition(desiredPosition)}
|
|
133
|
+
>
|
|
134
|
+
Execute
|
|
135
|
+
</Button>
|
|
136
|
+
<span role="status">
|
|
137
|
+
{#if isMoving}
|
|
138
|
+
<StatusPill
|
|
139
|
+
isActive
|
|
140
|
+
activeText="Arm is moving"
|
|
141
|
+
/>
|
|
142
|
+
{/if}
|
|
143
|
+
</span>
|
|
144
|
+
</div>
|
|
78
145
|
<ErrorDisplay {lastError} />
|
|
79
146
|
</div>
|
|
@@ -1,9 +1,11 @@
|
|
|
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
|
lastError: Error | null;
|
|
6
|
-
|
|
7
|
+
isMoving?: boolean;
|
|
8
|
+
description?: Snippet;
|
|
7
9
|
}
|
|
8
10
|
declare const MoveToPosition: import("svelte").Component<Props, {}, "">;
|
|
9
11
|
type MoveToPosition = ReturnType<typeof MoveToPosition>;
|
|
@@ -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
|
+
};
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import RefetchController from '../../refetch-controller.svelte'
|
|
12
12
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
13
13
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
14
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
15
|
|
|
15
16
|
import { createAudioCapturer } from './create-audio-capturer.svelte.js'
|
|
16
17
|
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
<div class="flex w-full flex-col divide-y">
|
|
64
65
|
<MutationSection
|
|
65
66
|
title="GetAudio"
|
|
66
|
-
api=
|
|
67
|
+
api={ResourceTriplets.AudioInput}
|
|
67
68
|
description="Capture audio from the device"
|
|
68
69
|
lastError={capture.error}
|
|
69
70
|
>
|
|
@@ -133,13 +134,13 @@
|
|
|
133
134
|
<div class="flex w-full flex-col divide-y @2xl:ml-auto @2xl:max-w-1/2 @4xl:max-w-1/3">
|
|
134
135
|
<ApiSection
|
|
135
136
|
title="GetProperties"
|
|
136
|
-
api=
|
|
137
|
+
api={ResourceTriplets.AudioInput}
|
|
137
138
|
description="Audio input properties"
|
|
138
|
-
class="relative"
|
|
139
|
+
class="relative grow flex-col gap-4"
|
|
139
140
|
>
|
|
140
141
|
<Query
|
|
141
142
|
query={propertiesQuery}
|
|
142
|
-
|
|
143
|
+
class="h-6"
|
|
143
144
|
>
|
|
144
145
|
{#if propertiesQuery.data !== undefined}
|
|
145
146
|
<Properties
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import RefetchController from '../../refetch-controller.svelte'
|
|
12
12
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
13
13
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
14
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
15
|
|
|
15
16
|
import { ExtToCodec, MimeToCodec } from './codec.js'
|
|
16
17
|
import { createAudioPlayer } from './create-audio-player.svelte.js'
|
|
@@ -108,7 +109,7 @@
|
|
|
108
109
|
<div class="flex w-full flex-col divide-y">
|
|
109
110
|
<MutationSection
|
|
110
111
|
title="Play"
|
|
111
|
-
api=
|
|
112
|
+
api={ResourceTriplets.AudioOutput}
|
|
112
113
|
description="Send audio data to the device"
|
|
113
114
|
lastError={playContext.error}
|
|
114
115
|
>
|
|
@@ -180,13 +181,13 @@
|
|
|
180
181
|
<div class="flex w-full flex-col divide-y @2xl:ml-auto @2xl:max-w-1/2 @4xl:max-w-1/3">
|
|
181
182
|
<ApiSection
|
|
182
183
|
title="GetProperties"
|
|
183
|
-
api=
|
|
184
|
+
api={ResourceTriplets.AudioOutput}
|
|
184
185
|
description="Audio output properties"
|
|
185
|
-
class="relative"
|
|
186
|
+
class="relative grow flex-col gap-4"
|
|
186
187
|
>
|
|
187
188
|
<Query
|
|
188
189
|
query={propertiesQuery}
|
|
189
|
-
|
|
190
|
+
class="h-6"
|
|
190
191
|
>
|
|
191
192
|
{#if propertiesQuery.data !== undefined}
|
|
192
193
|
<Properties
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import IsMoving from '../../is-moving.svelte'
|
|
9
9
|
import MutationSection from '../../mutation-section.svelte'
|
|
10
10
|
import StopButton from '../../stop-button.svelte'
|
|
11
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
11
12
|
|
|
12
13
|
import MoveStraight from './move-straight.svelte'
|
|
13
14
|
import QuickMove from './quick-move.svelte'
|
|
@@ -85,8 +86,9 @@
|
|
|
85
86
|
</MutationSection>
|
|
86
87
|
<div class="flex grow flex-col divide-y @4xl:ml-auto @4xl:w-full @4xl:max-w-40">
|
|
87
88
|
<ApiSection
|
|
89
|
+
class="grow flex-col gap-4"
|
|
88
90
|
title="Stop"
|
|
89
|
-
api=
|
|
91
|
+
api={ResourceTriplets.Base}
|
|
90
92
|
>
|
|
91
93
|
<StopButton
|
|
92
94
|
error={stopMutation.error}
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
</ApiSection>
|
|
98
100
|
<IsMoving
|
|
99
101
|
client={BaseClient}
|
|
100
|
-
api=
|
|
102
|
+
api={ResourceTriplets.Base}
|
|
101
103
|
{partID}
|
|
102
104
|
{resourceName}
|
|
103
105
|
/>
|
|
@@ -106,7 +108,7 @@
|
|
|
106
108
|
</div>
|
|
107
109
|
<MutationSection
|
|
108
110
|
title="MoveStraight"
|
|
109
|
-
api=
|
|
111
|
+
api={ResourceTriplets.Base}
|
|
110
112
|
description="Move across a given distance at a given velocity"
|
|
111
113
|
lastError={moveStraightMutation.error}
|
|
112
114
|
>
|
|
@@ -114,7 +116,7 @@
|
|
|
114
116
|
</MutationSection>
|
|
115
117
|
<MutationSection
|
|
116
118
|
title="Spin"
|
|
117
|
-
api=
|
|
119
|
+
api={ResourceTriplets.Base}
|
|
118
120
|
description="Turn to a given angle at a given velocity"
|
|
119
121
|
lastError={spinMutation.error}
|
|
120
122
|
>
|
|
@@ -122,7 +124,7 @@
|
|
|
122
124
|
</MutationSection>
|
|
123
125
|
<MutationSection
|
|
124
126
|
title="SetPower"
|
|
125
|
-
api=
|
|
127
|
+
api={ResourceTriplets.Base}
|
|
126
128
|
description="Move continuously at a given amount of power"
|
|
127
129
|
lastError={setPowerMutation.error}
|
|
128
130
|
>
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
</MutationSection>
|
|
131
133
|
<MutationSection
|
|
132
134
|
title="SetVelocity"
|
|
133
|
-
api=
|
|
135
|
+
api={ResourceTriplets.Base}
|
|
134
136
|
description="Move continually at a given velocity"
|
|
135
137
|
lastError={setVelocityMutation.error}
|
|
136
138
|
>
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { Icon, Label, RangeInput } from '@viamrobotics/prime-core'
|
|
5
5
|
import { onMount } from 'svelte'
|
|
6
|
-
import { twMerge } from 'tailwind-merge'
|
|
7
6
|
|
|
8
7
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
9
8
|
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
const buttonCx =
|
|
54
|
-
'flex gap-2 justify-center items-center w-[60px] border border-light
|
|
53
|
+
'flex gap-2 justify-center items-center w-[60px] border border-light px-2.5 py-3 hover:border-medium hover:bg-medium active:bg-gray-2 h-fit'
|
|
55
54
|
|
|
56
55
|
const keys = {
|
|
57
56
|
W_KEY: 'w',
|
|
@@ -154,7 +153,7 @@
|
|
|
154
153
|
aria-label="left"
|
|
155
154
|
onmouseup={mouseEnd}
|
|
156
155
|
onmouseleave={mouseEnd}
|
|
157
|
-
class={
|
|
156
|
+
class={[buttonCx, pressedKeys.a ? 'bg-gray-2' : 'bg-light']}
|
|
158
157
|
>
|
|
159
158
|
<Icon
|
|
160
159
|
name="undo"
|
|
@@ -171,7 +170,7 @@
|
|
|
171
170
|
aria-label="forwards"
|
|
172
171
|
onmouseup={mouseEnd}
|
|
173
172
|
onmouseleave={mouseEnd}
|
|
174
|
-
class={
|
|
173
|
+
class={[buttonCx, 'flex-col', pressedKeys.w ? 'bg-gray-2' : 'bg-light']}
|
|
175
174
|
>
|
|
176
175
|
<Icon
|
|
177
176
|
name="arrow-up"
|
|
@@ -187,7 +186,7 @@
|
|
|
187
186
|
aria-label="backwards"
|
|
188
187
|
onmouseup={mouseEnd}
|
|
189
188
|
onmouseleave={mouseEnd}
|
|
190
|
-
class={
|
|
189
|
+
class={[buttonCx, 'flex-col', pressedKeys.s ? 'bg-gray-2' : 'bg-light']}
|
|
191
190
|
>
|
|
192
191
|
{#if isKeyboardEnabled}
|
|
193
192
|
<div class="text-gray-6 text-sm font-semibold">S</div>
|
|
@@ -205,7 +204,7 @@
|
|
|
205
204
|
aria-label="right"
|
|
206
205
|
onmouseup={mouseEnd}
|
|
207
206
|
onmouseleave={mouseEnd}
|
|
208
|
-
class={
|
|
207
|
+
class={[buttonCx, pressedKeys.d ? 'bg-gray-2' : 'bg-light']}
|
|
209
208
|
>
|
|
210
209
|
{#if isKeyboardEnabled}
|
|
211
210
|
<div class="text-gray-6 text-sm font-semibold">D</div>
|
|
@@ -17,19 +17,21 @@
|
|
|
17
17
|
|
|
18
18
|
<div class="flex flex-wrap gap-4">
|
|
19
19
|
<Vec3Builder
|
|
20
|
-
title="Linear power"
|
|
21
20
|
titleTooltip="The percentage of max power of the base’s linear propulsion. In the range of –1.0 to 1.0, with 1.0 meaning 100% power."
|
|
22
21
|
xTooltip="+X is right, –X is left"
|
|
23
22
|
yTooltip="+Y is forward, –Y is backward"
|
|
24
23
|
zTooltip="+Z is up, –Z is down"
|
|
25
24
|
bind:vector={linearPower}
|
|
26
|
-
|
|
25
|
+
>
|
|
26
|
+
{#snippet title()}Linear power{/snippet}
|
|
27
|
+
</Vec3Builder>
|
|
27
28
|
<Vec3Builder
|
|
28
|
-
title="Angular power"
|
|
29
29
|
titleTooltip="The percentage of max power of the base’s angular propulsion. In the range of -1.0 to 1.0, with 1.0 meaning 100% power."
|
|
30
30
|
zTooltip="+Z is left, –Z is right"
|
|
31
31
|
bind:vector={angularPower}
|
|
32
|
-
|
|
32
|
+
>
|
|
33
|
+
{#snippet title()}Angular power{/snippet}
|
|
34
|
+
</Vec3Builder>
|
|
33
35
|
</div>
|
|
34
36
|
|
|
35
37
|
<Button
|
|
@@ -17,17 +17,19 @@
|
|
|
17
17
|
|
|
18
18
|
<div class="flex flex-wrap gap-4">
|
|
19
19
|
<Vec3Builder
|
|
20
|
-
title="Linear velocity"
|
|
21
20
|
titleUnits="(mm/s)"
|
|
22
21
|
yTooltip="Only Y is used for a wheeled base, since Viam’s coordinate system considers +Y to be the forward axis."
|
|
23
22
|
bind:vector={linearVelocity}
|
|
24
|
-
|
|
23
|
+
>
|
|
24
|
+
{#snippet title()}Linear velocity{/snippet}
|
|
25
|
+
</Vec3Builder>
|
|
25
26
|
<Vec3Builder
|
|
26
|
-
title="Angular velocity"
|
|
27
27
|
titleUnits="(º/s)"
|
|
28
28
|
zTooltip="Only Z is used for a wheeled base, since Viam’s coordinate system considers +Z to point up and the angular velocity to rotate around the Z axis."
|
|
29
29
|
bind:vector={angularVelocity}
|
|
30
|
-
|
|
30
|
+
>
|
|
31
|
+
{#snippet title()}Angular velocity{/snippet}
|
|
32
|
+
</Vec3Builder>
|
|
31
33
|
</div>
|
|
32
34
|
|
|
33
35
|
<Button
|
|
@@ -5,13 +5,14 @@ I'd be wary of using this elsewhere unless the use case & styling is identitcal
|
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts">
|
|
7
7
|
import type { Vector3 } from '@viamrobotics/sdk'
|
|
8
|
+
import type { Snippet } from 'svelte'
|
|
8
9
|
|
|
9
10
|
import { Icon, Label, NumericInput, Tooltip } from '@viamrobotics/prime-core'
|
|
10
11
|
|
|
11
12
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
12
13
|
|
|
13
14
|
interface Props {
|
|
14
|
-
title:
|
|
15
|
+
title: Snippet
|
|
15
16
|
titleUnits?: string | undefined
|
|
16
17
|
titleTooltip?: string | undefined
|
|
17
18
|
vector: Vector3
|
|
@@ -41,7 +42,7 @@ I'd be wary of using this elsewhere unless the use case & styling is identitcal
|
|
|
41
42
|
class="bg-light flex flex-row place-content-center gap-1 px-2 py-1.5"
|
|
42
43
|
id={builderID}
|
|
43
44
|
>
|
|
44
|
-
{title}
|
|
45
|
+
{@render title()}
|
|
45
46
|
{#if titleUnits}
|
|
46
47
|
<abbr class="text-disabled">{titleUnits}</abbr>
|
|
47
48
|
{/if}
|
|
@@ -16,10 +16,8 @@
|
|
|
16
16
|
const getButtonId = `${id}-get`
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
|
-
<PinSection
|
|
20
|
-
title
|
|
21
|
-
class="h-fit"
|
|
22
|
-
>
|
|
19
|
+
<PinSection class="h-fit">
|
|
20
|
+
{#snippet title()}Read pin{/snippet}
|
|
23
21
|
<section
|
|
24
22
|
class="flex h-full max-h-18.5 w-full flex-col gap-1 p-3 text-xs"
|
|
25
23
|
aria-labelledby={sectionId}
|