@viamrobotics/test-widgets 0.11.3 → 0.13.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/dist/components/refetch-controller.svelte +5 -2
- package/dist/components/refetch-interval-store.svelte.d.ts +1 -1
- package/dist/components/widgets/arm/arm.svelte +7 -20
- package/dist/components/widgets/arm/joint-position-editor.svelte +8 -3
- package/dist/components/widgets/arm/joint-position-editor.svelte.d.ts +2 -1
- package/dist/components/widgets/arm/joint-position-jogging.svelte +216 -0
- package/dist/components/widgets/arm/joint-position-jogging.svelte.d.ts +13 -0
- package/dist/components/widgets/arm/move-control-mode.d.ts +23 -0
- package/dist/components/widgets/arm/move-control-mode.js +26 -0
- package/dist/components/widgets/arm/move-to-joint-positions-widget.svelte +2 -2
- package/dist/components/widgets/arm/move-to-joint-positions.svelte +11 -9
- package/dist/components/widgets/arm/move-to-joint-positions.svelte.d.ts +2 -1
- package/dist/components/widgets/arm/move-to-position-control.svelte +184 -0
- package/dist/components/widgets/arm/move-to-position-control.svelte.d.ts +7 -0
- package/dist/components/widgets/arm/move-to-position-widget.svelte +5 -33
- package/dist/components/widgets/arm/move-to-position.svelte +8 -2
- package/dist/components/widgets/arm/move-to-position.svelte.d.ts +1 -0
- package/dist/components/widgets/arm/useJogQueue.svelte.d.ts +51 -0
- package/dist/components/widgets/arm/useJogQueue.svelte.js +143 -0
- package/dist/components/widgets/camera/camera.svelte +122 -124
- package/dist/components/widgets/camera/export-screenshot.svelte +12 -8
- package/dist/components/widgets/camera/picture-in-picture-button.svelte +13 -12
- package/dist/components/widgets/do-command/create-do-command-client.svelte.d.ts +2 -3
- package/dist/components/widgets/do-command/create-do-command-client.svelte.js +7 -1
- package/dist/components/widgets/do-command/resource-do-command.svelte +3 -3
- package/dist/components/widgets/vision-service/vision-service.svelte +11 -5
- package/dist/registry.js +1 -1
- package/package.json +2 -2
- package/dist/components/widgets/arm/joint-position-quick-move.svelte +0 -85
- package/dist/components/widgets/arm/joint-position-quick-move.svelte.d.ts +0 -9
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
createResourceClient,
|
|
5
|
-
createResourceMutation,
|
|
6
|
-
createResourceQuery,
|
|
7
|
-
} from '@viamrobotics/svelte-sdk'
|
|
8
|
-
|
|
9
|
-
import Query from '../../query.svelte'
|
|
10
|
-
|
|
11
|
-
import MoveToPosition from './move-to-position.svelte'
|
|
2
|
+
import MoveToPositionControl from './move-to-position-control.svelte'
|
|
12
3
|
|
|
13
4
|
interface Props {
|
|
14
5
|
partID: string
|
|
@@ -16,28 +7,9 @@
|
|
|
16
7
|
}
|
|
17
8
|
|
|
18
9
|
const { partID, resourceName }: Props = $props()
|
|
19
|
-
|
|
20
|
-
const client = createResourceClient(
|
|
21
|
-
ArmClient,
|
|
22
|
-
() => partID,
|
|
23
|
-
() => resourceName
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
const endPositionQuery = createResourceQuery(client, 'getEndPosition', {
|
|
27
|
-
refetchInterval: 500,
|
|
28
|
-
})
|
|
29
|
-
const moveToPosMutation = createResourceMutation(client, 'moveToPosition')
|
|
30
|
-
const moveToPosition = (position: Pose) => {
|
|
31
|
-
moveToPosMutation.mutate([position], {})
|
|
32
|
-
}
|
|
33
10
|
</script>
|
|
34
11
|
|
|
35
|
-
<
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{moveToPosition}
|
|
40
|
-
lastError={moveToPosMutation.error}
|
|
41
|
-
/>
|
|
42
|
-
{/if}
|
|
43
|
-
</Query>
|
|
12
|
+
<MoveToPositionControl
|
|
13
|
+
{partID}
|
|
14
|
+
{resourceName}
|
|
15
|
+
/>
|
|
@@ -10,9 +10,15 @@
|
|
|
10
10
|
endPosition: Pose
|
|
11
11
|
moveToPosition: (position: Pose) => void
|
|
12
12
|
lastError: Error | null
|
|
13
|
+
description?: string
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
endPosition,
|
|
18
|
+
moveToPosition,
|
|
19
|
+
lastError,
|
|
20
|
+
description = 'Pose is with respect to the arm origin and does not take into account the motion service or frame system.',
|
|
21
|
+
}: Props = $props()
|
|
16
22
|
|
|
17
23
|
// svelte-ignore state_referenced_locally
|
|
18
24
|
let desiredPosition = $state({ ...endPosition })
|
|
@@ -41,7 +47,7 @@
|
|
|
41
47
|
desiredPosition = next
|
|
42
48
|
}}
|
|
43
49
|
title="Pose Values"
|
|
44
|
-
description
|
|
50
|
+
{description}
|
|
45
51
|
/>
|
|
46
52
|
|
|
47
53
|
<div class="mb-2 flex flex-col gap-2">
|
|
@@ -3,6 +3,7 @@ interface Props {
|
|
|
3
3
|
endPosition: Pose;
|
|
4
4
|
moveToPosition: (position: Pose) => void;
|
|
5
5
|
lastError: Error | null;
|
|
6
|
+
description?: string;
|
|
6
7
|
}
|
|
7
8
|
declare const MoveToPosition: import("svelte").Component<Props, {}, "">;
|
|
8
9
|
type MoveToPosition = ReturnType<typeof MoveToPosition>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type JogQueueStatus = 'queuing' | 'sending' | 'sent' | 'failed';
|
|
2
|
+
/** The joint's position when an entry starts, and the limits its target is clamped to, in degrees. */
|
|
3
|
+
export interface JogJointRange {
|
|
4
|
+
startDegrees: number;
|
|
5
|
+
minDegrees: number;
|
|
6
|
+
maxDegrees: number;
|
|
7
|
+
}
|
|
8
|
+
export interface JogQueueEntry extends JogJointRange {
|
|
9
|
+
jointIndex: number;
|
|
10
|
+
/** Sum of every queued step in degrees, clamped so the target stays inside the limits. */
|
|
11
|
+
deltaDegrees: number;
|
|
12
|
+
status: JogQueueStatus;
|
|
13
|
+
}
|
|
14
|
+
export interface JogQueueTiming {
|
|
15
|
+
/** Quiet time after the last press or repeat before the queued total is sent. */
|
|
16
|
+
sendDebounceMs: number;
|
|
17
|
+
/** How long a button is held before it starts repeating. */
|
|
18
|
+
holdRepeatDelayMs: number;
|
|
19
|
+
/** Time between repeats while the button stays held. */
|
|
20
|
+
holdRepeatIntervalMs: number;
|
|
21
|
+
/** How long the sent or failed result stays visible. */
|
|
22
|
+
resultDisplayMs: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const DEFAULT_JOG_QUEUE_TIMING: JogQueueTiming;
|
|
25
|
+
interface JogQueueOptions {
|
|
26
|
+
timing?: JogQueueTiming;
|
|
27
|
+
/**
|
|
28
|
+
* Moves every joint in `targetsByJoint` to its target, in degrees. The map
|
|
29
|
+
* holds the joint being sent plus any joint whose earlier move is still in
|
|
30
|
+
* flight or just finished, so a new move never drags those joints back to a
|
|
31
|
+
* stale polled position. Rejects when the move fails.
|
|
32
|
+
*/
|
|
33
|
+
send: (targetsByJoint: ReadonlyMap<number, number>) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** The position the entry moves its joint to, in degrees. */
|
|
36
|
+
export declare const jogTargetDegrees: (entry: JogQueueEntry) => number;
|
|
37
|
+
/**
|
|
38
|
+
* Collects jog presses into one move per joint. Presses within the debounce
|
|
39
|
+
* window, and repeats while a button is held, add to that joint's entry. The
|
|
40
|
+
* total is sent once the joint's input goes quiet. Each joint has its own
|
|
41
|
+
* entry and timers, so jogging a second joint leaves the first joint's badge
|
|
42
|
+
* to run through sending, its result, and clearing on its own.
|
|
43
|
+
*/
|
|
44
|
+
export declare const useJogQueue: ({ send, timing }: JogQueueOptions) => {
|
|
45
|
+
entryFor: (jointIndex: number) => JogQueueEntry | undefined;
|
|
46
|
+
tap: (jointIndex: number, stepDegrees: number, range: JogJointRange) => void;
|
|
47
|
+
beginHold: (jointIndex: number, stepDegrees: number, range: JogJointRange) => void;
|
|
48
|
+
endHold: () => void;
|
|
49
|
+
dispose: () => void;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export const DEFAULT_JOG_QUEUE_TIMING = {
|
|
2
|
+
sendDebounceMs: 300,
|
|
3
|
+
holdRepeatDelayMs: 400,
|
|
4
|
+
holdRepeatIntervalMs: 150,
|
|
5
|
+
resultDisplayMs: 1200,
|
|
6
|
+
};
|
|
7
|
+
/** The position the entry moves its joint to, in degrees. */
|
|
8
|
+
export const jogTargetDegrees = (entry) => entry.startDegrees + entry.deltaDegrees;
|
|
9
|
+
// A step that would cross a joint limit is cut at the limit, so 350° jogged by 15° toward a 360° limit moves the remaining 10°.
|
|
10
|
+
const clampDelta = (range, deltaDegrees) => Math.min(Math.max(range.startDegrees + deltaDegrees, range.minDegrees), range.maxDegrees) -
|
|
11
|
+
range.startDegrees;
|
|
12
|
+
/**
|
|
13
|
+
* Collects jog presses into one move per joint. Presses within the debounce
|
|
14
|
+
* window, and repeats while a button is held, add to that joint's entry. The
|
|
15
|
+
* total is sent once the joint's input goes quiet. Each joint has its own
|
|
16
|
+
* entry and timers, so jogging a second joint leaves the first joint's badge
|
|
17
|
+
* to run through sending, its result, and clearing on its own.
|
|
18
|
+
*/
|
|
19
|
+
export const useJogQueue = ({ send, timing = DEFAULT_JOG_QUEUE_TIMING }) => {
|
|
20
|
+
// $state.raw: the map is replaced wholesale on every change so readers re-run without deep proxies.
|
|
21
|
+
let entries = $state.raw(new Map());
|
|
22
|
+
const debounceTimers = new Map();
|
|
23
|
+
const resultTimers = new Map();
|
|
24
|
+
let holdDelayTimer;
|
|
25
|
+
let holdRepeatTimer;
|
|
26
|
+
let heldJointIndex;
|
|
27
|
+
const setEntry = (jointIndex, entry) => {
|
|
28
|
+
const next = new Map(entries);
|
|
29
|
+
if (entry) {
|
|
30
|
+
next.set(jointIndex, entry);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
next.delete(jointIndex);
|
|
34
|
+
}
|
|
35
|
+
entries = next;
|
|
36
|
+
};
|
|
37
|
+
const clearHoldTimers = () => {
|
|
38
|
+
clearTimeout(holdDelayTimer);
|
|
39
|
+
clearInterval(holdRepeatTimer);
|
|
40
|
+
};
|
|
41
|
+
const committedTargets = () => {
|
|
42
|
+
const targets = new Map();
|
|
43
|
+
for (const entry of entries.values()) {
|
|
44
|
+
if (entry.status === 'sending' || entry.status === 'sent') {
|
|
45
|
+
targets.set(entry.jointIndex, jogTargetDegrees(entry));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return targets;
|
|
49
|
+
};
|
|
50
|
+
const flush = async (jointIndex) => {
|
|
51
|
+
clearTimeout(debounceTimers.get(jointIndex));
|
|
52
|
+
const entry = entries.get(jointIndex);
|
|
53
|
+
if (entry?.status !== 'queuing')
|
|
54
|
+
return;
|
|
55
|
+
if (entry.deltaDegrees === 0) {
|
|
56
|
+
setEntry(jointIndex, undefined);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const sending = { ...entry, status: 'sending' };
|
|
60
|
+
setEntry(jointIndex, sending);
|
|
61
|
+
let status = 'sent';
|
|
62
|
+
try {
|
|
63
|
+
await send(committedTargets());
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
status = 'failed';
|
|
67
|
+
}
|
|
68
|
+
setEntry(jointIndex, { ...sending, status });
|
|
69
|
+
resultTimers.set(jointIndex, setTimeout(() => {
|
|
70
|
+
setEntry(jointIndex, undefined);
|
|
71
|
+
}, timing.resultDisplayMs));
|
|
72
|
+
};
|
|
73
|
+
const add = (jointIndex, stepDegrees, range) => {
|
|
74
|
+
clearTimeout(debounceTimers.get(jointIndex));
|
|
75
|
+
const current = entries.get(jointIndex);
|
|
76
|
+
if (current?.status === 'sending')
|
|
77
|
+
return;
|
|
78
|
+
clearTimeout(resultTimers.get(jointIndex));
|
|
79
|
+
if (current?.status === 'queuing') {
|
|
80
|
+
setEntry(jointIndex, {
|
|
81
|
+
...current,
|
|
82
|
+
deltaDegrees: clampDelta(current, current.deltaDegrees + stepDegrees),
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setEntry(jointIndex, {
|
|
87
|
+
jointIndex,
|
|
88
|
+
...range,
|
|
89
|
+
deltaDegrees: clampDelta(range, stepDegrees),
|
|
90
|
+
status: 'queuing',
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const scheduleSend = (jointIndex) => {
|
|
94
|
+
clearTimeout(debounceTimers.get(jointIndex));
|
|
95
|
+
if (entries.get(jointIndex)?.status !== 'queuing')
|
|
96
|
+
return;
|
|
97
|
+
debounceTimers.set(jointIndex, setTimeout(() => {
|
|
98
|
+
void flush(jointIndex);
|
|
99
|
+
}, timing.sendDebounceMs));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* One discrete press, such as a keyboard or assistive-technology activation.
|
|
103
|
+
* `range` is the joint's current position and limits and is only read when the
|
|
104
|
+
* press starts a new entry.
|
|
105
|
+
*/
|
|
106
|
+
const tap = (jointIndex, stepDegrees, range) => {
|
|
107
|
+
add(jointIndex, stepDegrees, range);
|
|
108
|
+
scheduleSend(jointIndex);
|
|
109
|
+
};
|
|
110
|
+
/** A pointer press. Queues one step now and keeps adding while held. */
|
|
111
|
+
const beginHold = (jointIndex, stepDegrees, range) => {
|
|
112
|
+
clearHoldTimers();
|
|
113
|
+
heldJointIndex = jointIndex;
|
|
114
|
+
add(jointIndex, stepDegrees, range);
|
|
115
|
+
holdDelayTimer = setTimeout(() => {
|
|
116
|
+
holdRepeatTimer = setInterval(() => {
|
|
117
|
+
add(jointIndex, stepDegrees, range);
|
|
118
|
+
}, timing.holdRepeatIntervalMs);
|
|
119
|
+
}, timing.holdRepeatDelayMs);
|
|
120
|
+
};
|
|
121
|
+
/** A pointer release. Stops repeating and schedules the held joint's send. */
|
|
122
|
+
const endHold = () => {
|
|
123
|
+
clearHoldTimers();
|
|
124
|
+
if (heldJointIndex === undefined)
|
|
125
|
+
return;
|
|
126
|
+
scheduleSend(heldJointIndex);
|
|
127
|
+
heldJointIndex = undefined;
|
|
128
|
+
};
|
|
129
|
+
const dispose = () => {
|
|
130
|
+
clearHoldTimers();
|
|
131
|
+
for (const timer of debounceTimers.values())
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
for (const timer of resultTimers.values())
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
entryFor: (jointIndex) => entries.get(jointIndex),
|
|
138
|
+
tap,
|
|
139
|
+
beginHold,
|
|
140
|
+
endHold,
|
|
141
|
+
dispose,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -167,59 +167,10 @@
|
|
|
167
167
|
headingId={getImagesHeadingID}
|
|
168
168
|
/>
|
|
169
169
|
</div>
|
|
170
|
-
<div class="
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
slot="input"
|
|
175
|
-
annotated
|
|
176
|
-
on={waitToStartFeed.current}
|
|
177
|
-
on:change={(event) => {
|
|
178
|
-
waitToStartFeed.current = event.detail
|
|
179
|
-
}}
|
|
180
|
-
/>
|
|
181
|
-
</Label>
|
|
182
|
-
</div>
|
|
183
|
-
{#if isPlaying}
|
|
184
|
-
<div class="flex flex-wrap gap-4 p-4 pb-3">
|
|
185
|
-
<RefetchController
|
|
186
|
-
{refetchInterval}
|
|
187
|
-
allowLive
|
|
188
|
-
queries={[imageQuery, pointcloudQuery]}
|
|
189
|
-
/>
|
|
190
|
-
{#if sourceNames.length > 0 && refetchInterval.current !== RefetchIntervals.LIVE}
|
|
191
|
-
<Label position="left">
|
|
192
|
-
Source
|
|
193
|
-
<Select
|
|
194
|
-
value={selectedSource}
|
|
195
|
-
on:change={onSourceSelect}
|
|
196
|
-
slot="input"
|
|
197
|
-
>
|
|
198
|
-
{#each sourceNames as name (name)}
|
|
199
|
-
<option value={name}>{name}</option>
|
|
200
|
-
{/each}
|
|
201
|
-
</Select>
|
|
202
|
-
</Label>
|
|
203
|
-
{/if}
|
|
204
|
-
{#if panoCoverage}
|
|
205
|
-
<Label>
|
|
206
|
-
{panoToggleLabel}
|
|
207
|
-
<ToggleButtons
|
|
208
|
-
slot="input"
|
|
209
|
-
options={['On', 'Off']}
|
|
210
|
-
selected={displayAs360 ? 'On' : 'Off'}
|
|
211
|
-
on:input={(event) => {
|
|
212
|
-
displayAs360 = event.detail === 'On'
|
|
213
|
-
}}
|
|
214
|
-
/>
|
|
215
|
-
</Label>
|
|
216
|
-
{/if}
|
|
217
|
-
</div>
|
|
218
|
-
{/if}
|
|
219
|
-
<div class="flex h-full w-full flex-wrap gap-4 p-4">
|
|
220
|
-
<div class="min-w-0 grow basis-80">
|
|
221
|
-
{#if isPlaying}
|
|
222
|
-
{#if displayAs360}
|
|
170
|
+
<div class="p-4">
|
|
171
|
+
{#if isPlaying}
|
|
172
|
+
{#if displayAs360}
|
|
173
|
+
<div class="h-80 w-full">
|
|
223
174
|
{#if isLive}
|
|
224
175
|
<!-- renderMode="always" keeps the live VideoTexture advancing each frame -->
|
|
225
176
|
<Canvas renderMode="always">
|
|
@@ -237,84 +188,131 @@
|
|
|
237
188
|
/>
|
|
238
189
|
</Canvas>
|
|
239
190
|
{/if}
|
|
240
|
-
{:else}
|
|
241
|
-
<LiveOrPollingVideo
|
|
242
|
-
{partID}
|
|
243
|
-
{resourceName}
|
|
244
|
-
showResolutionOptions
|
|
245
|
-
videoClass="h-auto max-w-full"
|
|
246
|
-
{isLive}
|
|
247
|
-
data={imageQuery.data}
|
|
248
|
-
error={imageQuery.error}
|
|
249
|
-
isLoading={imageQuery.isLoading}
|
|
250
|
-
refetch={imageQuery.refetch}
|
|
251
|
-
showMousePositionTooltip={mousePostionTooltip === 'On'}
|
|
252
|
-
sourceName={selectedSource}
|
|
253
|
-
/>
|
|
254
|
-
{/if}
|
|
255
|
-
{:else}
|
|
256
|
-
<div class="bg-medium flex h-64 w-full max-w-80 items-center justify-center">
|
|
257
|
-
<Button
|
|
258
|
-
icon="play-circle-outline"
|
|
259
|
-
variant="dark"
|
|
260
|
-
onclick={() => {
|
|
261
|
-
isPlaying = true
|
|
262
|
-
}}
|
|
263
|
-
>
|
|
264
|
-
Start feed
|
|
265
|
-
</Button>
|
|
266
191
|
</div>
|
|
267
|
-
{
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
192
|
+
{:else}
|
|
193
|
+
<LiveOrPollingVideo
|
|
194
|
+
{partID}
|
|
195
|
+
{resourceName}
|
|
196
|
+
showResolutionOptions
|
|
197
|
+
videoClass="h-auto max-w-full"
|
|
198
|
+
{isLive}
|
|
199
|
+
data={imageQuery.data}
|
|
200
|
+
error={imageQuery.error}
|
|
201
|
+
isLoading={imageQuery.isLoading}
|
|
202
|
+
refetch={imageQuery.refetch}
|
|
203
|
+
showMousePositionTooltip={mousePostionTooltip === 'On'}
|
|
273
204
|
sourceName={selectedSource}
|
|
274
|
-
getImage={exportScreenshotQuery.refetch}
|
|
275
205
|
/>
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
206
|
+
{/if}
|
|
207
|
+
{:else}
|
|
208
|
+
<div class="bg-medium flex h-64 w-full items-center justify-center">
|
|
209
|
+
<Button
|
|
210
|
+
icon="play-circle-outline"
|
|
211
|
+
variant="dark"
|
|
212
|
+
onclick={() => {
|
|
213
|
+
isPlaying = true
|
|
214
|
+
}}
|
|
215
|
+
>
|
|
216
|
+
Start feed
|
|
217
|
+
</Button>
|
|
218
|
+
</div>
|
|
219
|
+
{/if}
|
|
220
|
+
|
|
221
|
+
<div class="mt-3 flex flex-wrap items-start gap-2">
|
|
222
|
+
<RefetchController
|
|
223
|
+
{refetchInterval}
|
|
224
|
+
allowLive
|
|
225
|
+
queries={[imageQuery, pointcloudQuery]}
|
|
226
|
+
/>
|
|
227
|
+
<ExportScreenshot
|
|
228
|
+
name={client.current?.name ?? ''}
|
|
229
|
+
sourceName={selectedSource}
|
|
230
|
+
getImage={exportScreenshotQuery.refetch}
|
|
231
|
+
/>
|
|
232
|
+
{#if addImageToDataset}
|
|
233
|
+
<Button
|
|
234
|
+
icon="layers-triple-outline"
|
|
235
|
+
onclick={async () => {
|
|
236
|
+
let imgData
|
|
237
|
+
if (refetchInterval.current === RefetchIntervals.LIVE) {
|
|
238
|
+
const { isSuccess, data } = await imageQuery.refetch()
|
|
239
|
+
if (!isSuccess) return
|
|
240
|
+
imgData = data
|
|
241
|
+
} else {
|
|
242
|
+
imgData = imageQuery.data
|
|
243
|
+
}
|
|
288
244
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
245
|
+
const matchingImage = pickImageForSource(imgData?.images, selectedSource)
|
|
246
|
+
const image = matchingImage?.image
|
|
247
|
+
const mimeType = matchingImage?.mimeType
|
|
292
248
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
249
|
+
if (image) {
|
|
250
|
+
addImageToDataset({
|
|
251
|
+
binaryData: new Uint8Array(image),
|
|
252
|
+
partID,
|
|
253
|
+
componentType: 'camera',
|
|
254
|
+
componentName: resourceName,
|
|
255
|
+
methodName: 'captureAllFromCamera',
|
|
256
|
+
mimeType: mimeType ?? 'image/png',
|
|
257
|
+
dataRequestTimes: [new Date(), new Date()],
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
}}
|
|
261
|
+
>
|
|
262
|
+
Add to dataset
|
|
263
|
+
</Button>
|
|
264
|
+
{/if}
|
|
265
|
+
{#if !isFirefox}
|
|
266
|
+
<PictureInPictureButton
|
|
267
|
+
{resourceName}
|
|
268
|
+
rate={refetchInterval.current}
|
|
269
|
+
/>
|
|
270
|
+
{/if}
|
|
271
|
+
</div>
|
|
272
|
+
<div class="flex flex-col gap-4">
|
|
273
|
+
<div class="flex w-full max-w-80 items-start gap-4">
|
|
274
|
+
{#if sourceNames.length > 0 && refetchInterval.current !== RefetchIntervals.LIVE}
|
|
275
|
+
<Label>
|
|
276
|
+
Source
|
|
277
|
+
<Select
|
|
278
|
+
value={selectedSource}
|
|
279
|
+
on:change={onSourceSelect}
|
|
280
|
+
slot="input"
|
|
281
|
+
>
|
|
282
|
+
{#each sourceNames as name (name)}
|
|
283
|
+
<option value={name}>{name}</option>
|
|
284
|
+
{/each}
|
|
285
|
+
</Select>
|
|
286
|
+
</Label>
|
|
308
287
|
{/if}
|
|
309
|
-
{#if
|
|
310
|
-
<
|
|
311
|
-
{
|
|
312
|
-
|
|
313
|
-
|
|
288
|
+
{#if panoCoverage}
|
|
289
|
+
<Label>
|
|
290
|
+
{panoToggleLabel}
|
|
291
|
+
<ToggleButtons
|
|
292
|
+
slot="input"
|
|
293
|
+
options={['On', 'Off']}
|
|
294
|
+
selected={displayAs360 ? 'On' : 'Off'}
|
|
295
|
+
on:input={(event) => {
|
|
296
|
+
displayAs360 = event.detail === 'On'
|
|
297
|
+
}}
|
|
298
|
+
/>
|
|
299
|
+
</Label>
|
|
314
300
|
{/if}
|
|
301
|
+
</div>
|
|
302
|
+
<div class="flex w-full max-w-80 items-start gap-4">
|
|
315
303
|
<Label>
|
|
316
|
-
|
|
317
|
-
|
|
304
|
+
Start feed automatically
|
|
305
|
+
<ToggleButtons
|
|
306
|
+
slot="input"
|
|
307
|
+
options={['Yes', 'No']}
|
|
308
|
+
selected={waitToStartFeed.current ? 'No' : 'Yes'}
|
|
309
|
+
on:input={(event) => {
|
|
310
|
+
waitToStartFeed.current = event.detail === 'No'
|
|
311
|
+
}}
|
|
312
|
+
/>
|
|
313
|
+
</Label>
|
|
314
|
+
<Label>
|
|
315
|
+
Mouse position tooltip
|
|
318
316
|
<ToggleButtons
|
|
319
317
|
slot="input"
|
|
320
318
|
options={['On', 'Off']}
|
|
@@ -323,7 +321,7 @@
|
|
|
323
321
|
/>
|
|
324
322
|
</Label>
|
|
325
323
|
</div>
|
|
326
|
-
|
|
324
|
+
</div>
|
|
327
325
|
</div>
|
|
328
326
|
</section>
|
|
329
327
|
|
|
@@ -79,11 +79,15 @@
|
|
|
79
79
|
}
|
|
80
80
|
</script>
|
|
81
81
|
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
<div class="flex flex-col items-start gap-1">
|
|
83
|
+
<Button
|
|
84
|
+
icon="camera-outline"
|
|
85
|
+
onclick={handleExport}
|
|
86
|
+
>
|
|
87
|
+
Screenshot
|
|
88
|
+
</Button>
|
|
89
|
+
<ErrorDisplay
|
|
90
|
+
class="max-w-50"
|
|
91
|
+
{lastError}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
})
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<ErrorDisplay
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/>
|
|
24
|
+
<div class="flex flex-col items-start gap-1">
|
|
25
|
+
<Button
|
|
26
|
+
icon="picture-in-picture-top-right"
|
|
27
|
+
onclick={() => pip.toggle(resourceName)}
|
|
28
|
+
progress={pip.readyState === 'loading' ? 'indeterminate' : undefined}
|
|
29
|
+
>
|
|
30
|
+
Picture-in-picture
|
|
31
|
+
</Button>
|
|
32
|
+
<ErrorDisplay
|
|
33
|
+
class="max-w-50"
|
|
34
|
+
lastError={pip.error}
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MLModelClient, ResourceName } from '@viamrobotics/sdk';
|
|
2
|
+
import { type ResourceClientContext } from '@viamrobotics/svelte-sdk';
|
|
2
3
|
import { clientMap } from '../../../client-map';
|
|
3
4
|
type DoCommandable = InstanceType<Exclude<(typeof clientMap)[keyof typeof clientMap], typeof MLModelClient>>;
|
|
4
|
-
export declare const createDoCommandClient: (resource: () => ResourceName, partID: () => string, resourceName: () => string) =>
|
|
5
|
-
current: DoCommandable | undefined;
|
|
6
|
-
};
|
|
5
|
+
export declare const createDoCommandClient: (resource: () => ResourceName, partID: () => string, resourceName: () => string) => ResourceClientContext<DoCommandable>;
|
|
7
6
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MachineConnectionEvent, MLModelClient, ResourceName } from '@viamrobotics/sdk';
|
|
2
|
-
import { useConnectionStatus, useRobotClient } from '@viamrobotics/svelte-sdk';
|
|
2
|
+
import { useConnectionStatus, useRobotClient, } from '@viamrobotics/svelte-sdk';
|
|
3
3
|
import { clientForResource, clientMap } from '../../../client-map';
|
|
4
4
|
export const createDoCommandClient = (resource, partID, resourceName) => {
|
|
5
5
|
const robotClient = useRobotClient(partID);
|
|
@@ -22,5 +22,11 @@ export const createDoCommandClient = (resource, partID, resourceName) => {
|
|
|
22
22
|
get current() {
|
|
23
23
|
return resourceClient;
|
|
24
24
|
},
|
|
25
|
+
get partID() {
|
|
26
|
+
return partID();
|
|
27
|
+
},
|
|
28
|
+
get name() {
|
|
29
|
+
return resourceName();
|
|
30
|
+
},
|
|
25
31
|
};
|
|
26
32
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useResourceStatuses } from '@viamrobotics/svelte-sdk'
|
|
3
3
|
|
|
4
4
|
import DoCommand from './do-command.svelte'
|
|
5
5
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
const { partID, resourceName }: Props = $props()
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const statuses = useResourceStatuses(() => partID)
|
|
14
14
|
const resource = $derived(
|
|
15
|
-
|
|
15
|
+
statuses.current.find((status) => status.name?.name === resourceName)?.name
|
|
16
16
|
)
|
|
17
17
|
</script>
|
|
18
18
|
|