@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `doCommand` that asks a resource for its custom control artifact.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Transitional delivery path. A module declares its control per model in
|
|
5
|
+
* `meta.json` (`models[].custom_control`); serving the bytes over `doCommand` exists only until the
|
|
6
|
+
* machine or registry can serve the declared file. Do not build new integrations on it. Module
|
|
7
|
+
* authors keep their manifests and drop the handler when delivery moves.
|
|
8
|
+
*/
|
|
9
|
+
export const CUSTOM_CONTROL_COMMAND = 'get-custom-control';
|
|
10
|
+
// The policy the host injects into every custom control artifact before rendering it.
|
|
11
|
+
export const CUSTOM_CONTROL_CSP = [
|
|
12
|
+
"default-src 'none'",
|
|
13
|
+
"script-src 'unsafe-inline'",
|
|
14
|
+
"style-src 'unsafe-inline'",
|
|
15
|
+
'img-src data: blob:',
|
|
16
|
+
'media-src blob:',
|
|
17
|
+
'font-src data:',
|
|
18
|
+
"connect-src 'none'",
|
|
19
|
+
"base-uri 'none'",
|
|
20
|
+
"form-action 'none'",
|
|
21
|
+
].join('; ');
|
|
22
|
+
const CSP_META = `<meta http-equiv="Content-Security-Policy" content="${CUSTOM_CONTROL_CSP}">`;
|
|
23
|
+
// The artifact is untrusted, so the injection point has to be where the browser's parser sees a
|
|
24
|
+
// real tag. A DOM parser is off the table (it would have to serialize the artifact back), so this
|
|
25
|
+
// is a regex anchored at the start of the document that matches only tags written plainly enough
|
|
26
|
+
// that the browser cannot read them differently:
|
|
27
|
+
// - Only whitespace, comments, and a doctype may precede the tags. An unanchored `<head>` could sit
|
|
28
|
+
// inside a comment, script, or attribute value, where the meta would be inert text.
|
|
29
|
+
// - A comment must end at its first `-->` and may not use the early endings (`<!-->`, `--!>`) the
|
|
30
|
+
// browser also honors, since a tag after an early ending is real to the browser and not to us.
|
|
31
|
+
// - Whitespace is the five HTML characters, not JS `\s`, which also matches U+00A0 and friends.
|
|
32
|
+
// - A quoted attribute value may not contain `<` or `>`, so the first `>` always ends the tag.
|
|
33
|
+
// Anything stranger fails the match, and the meta then goes in a fresh head at the start.
|
|
34
|
+
const SPACE = String.raw `[\t\n\f\r ]`;
|
|
35
|
+
const COMMENT = String.raw `<!--(?!-?>)(?:(?!--!?>)[\s\S])*-->`;
|
|
36
|
+
const SKIPPED = String.raw `(?:${SPACE}|${COMMENT})*`;
|
|
37
|
+
const VALUE = String.raw `"[^"<>]*"|'[^'<>]*'|[^\t\n\f\r "'<>=\x60]+`;
|
|
38
|
+
const ATTRIBUTE = String.raw `${SPACE}+[^\t\n\f\r "'<>/=]+(?:${SPACE}*=${SPACE}*(?:${VALUE}))?`;
|
|
39
|
+
const openingTag = (name) => String.raw `<${name}(?:${ATTRIBUTE})*${SPACE}*>`;
|
|
40
|
+
const DOCUMENT_START = new RegExp(String.raw `^(${SKIPPED}(?:<!doctype[^>]*>${SKIPPED})?)(${openingTag('html')})?(${SKIPPED})(${openingTag('head')})?`, 'i');
|
|
41
|
+
/**
|
|
42
|
+
* Asks a resource for its custom control artifact over `doCommand` and validates the reply.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated Bound to the transitional `doCommand` delivery path ({@link CUSTOM_CONTROL_COMMAND}).
|
|
45
|
+
* The `CustomControlArtifact` it returns is the shape every delivery path will produce; the
|
|
46
|
+
* function is replaced when the machine or registry can serve the manifest-declared file.
|
|
47
|
+
*/
|
|
48
|
+
export const loadCustomControl = async (client) => {
|
|
49
|
+
const reply = await client.doCommand({ command: CUSTOM_CONTROL_COMMAND });
|
|
50
|
+
assertArtifact(reply);
|
|
51
|
+
const artifact = { html: reply.html };
|
|
52
|
+
if (reply.revision !== undefined)
|
|
53
|
+
artifact.revision = reply.revision;
|
|
54
|
+
if (reply.path !== undefined)
|
|
55
|
+
artifact.path = reply.path;
|
|
56
|
+
return artifact;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Returns the artifact with the host's Content Security Policy injected as the first child of
|
|
60
|
+
* `<head>`, creating the head when the artifact has none, so the policy applies before any other
|
|
61
|
+
* element parses. An artifact whose head already opens with this exact meta is returned unchanged.
|
|
62
|
+
*/
|
|
63
|
+
export const prepareArtifact = (html) => {
|
|
64
|
+
const [, beforeTags = '', htmlTag = '', between = '', headTag = ''] = DOCUMENT_START.exec(html) ?? [];
|
|
65
|
+
if (headTag) {
|
|
66
|
+
const headEnd = beforeTags.length + htmlTag.length + between.length + headTag.length;
|
|
67
|
+
return html.startsWith(CSP_META, headEnd) ? html : insertAt(html, headEnd, CSP_META);
|
|
68
|
+
}
|
|
69
|
+
return insertAt(html, beforeTags.length + htmlTag.length, `<head>${CSP_META}</head>`);
|
|
70
|
+
};
|
|
71
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
72
|
+
const assertArtifact = (value) => {
|
|
73
|
+
if (!isRecord(value))
|
|
74
|
+
throw new Error('Invalid custom control reply: expected an object');
|
|
75
|
+
if (typeof value.html !== 'string' || value.html.trim() === '') {
|
|
76
|
+
throw new Error('Invalid custom control reply: "html" must be a non-blank string');
|
|
77
|
+
}
|
|
78
|
+
if (value.revision !== undefined && typeof value.revision !== 'string') {
|
|
79
|
+
throw new Error('Invalid custom control reply: "revision" must be a string when present');
|
|
80
|
+
}
|
|
81
|
+
if (value.path !== undefined && typeof value.path !== 'string') {
|
|
82
|
+
throw new Error('Invalid custom control reply: "path" must be a string when present');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const insertAt = (html, index, inserted) => html.slice(0, index) + inserted + html.slice(index);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import ErrorDisplay from '../../error.svelte'
|
|
5
|
+
|
|
6
|
+
import ControlFrame from './control-frame.svelte'
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
partID: string
|
|
10
|
+
resourceName: string
|
|
11
|
+
html: string
|
|
12
|
+
loading?: Snippet
|
|
13
|
+
error?: Snippet<[{ failure: Error; reset: () => void }]>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { partID, resourceName, html, loading, error }: Props = $props()
|
|
17
|
+
|
|
18
|
+
const toError = (thrown: unknown) =>
|
|
19
|
+
thrown instanceof Error ? thrown : new Error(String(thrown))
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
{#key html}
|
|
23
|
+
<svelte:boundary>
|
|
24
|
+
<ControlFrame
|
|
25
|
+
{partID}
|
|
26
|
+
{resourceName}
|
|
27
|
+
{html}
|
|
28
|
+
{loading}
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
{#snippet failed(thrown, reset)}
|
|
32
|
+
{@const failure = toError(thrown)}
|
|
33
|
+
<div
|
|
34
|
+
role="alert"
|
|
35
|
+
class="bg-extralight flex min-h-40 w-full items-center justify-center p-4"
|
|
36
|
+
>
|
|
37
|
+
{#if error}
|
|
38
|
+
{@render error({ failure, reset })}
|
|
39
|
+
{:else}
|
|
40
|
+
<ErrorDisplay lastError={failure} />
|
|
41
|
+
{/if}
|
|
42
|
+
</div>
|
|
43
|
+
{/snippet}
|
|
44
|
+
</svelte:boundary>
|
|
45
|
+
{/key}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
partID: string;
|
|
4
|
+
resourceName: string;
|
|
5
|
+
html: string;
|
|
6
|
+
loading?: Snippet;
|
|
7
|
+
error?: Snippet<[{
|
|
8
|
+
failure: Error;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
}]>;
|
|
11
|
+
}
|
|
12
|
+
declare const CustomControl: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type CustomControl = ReturnType<typeof CustomControl>;
|
|
14
|
+
export default CustomControl;
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
import ApiSection from '../../api-section.svelte'
|
|
11
11
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
12
|
-
import Query from '../../query.svelte'
|
|
13
12
|
import RefetchController from '../../refetch-controller.svelte'
|
|
14
13
|
import {
|
|
15
14
|
createRefetchIntervalStore,
|
|
16
15
|
RefetchIntervals,
|
|
17
16
|
} from '../../refetch-interval-store.svelte'
|
|
17
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
18
18
|
|
|
19
19
|
import type { ComponentPreviews, ComponentPreviewSnippet } from './component-preview'
|
|
20
20
|
|
|
@@ -134,23 +134,19 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
|
|
136
136
|
<ApiSection
|
|
137
|
-
|
|
138
|
-
api=
|
|
139
|
-
|
|
137
|
+
method="DiscoverResources"
|
|
138
|
+
api={ResourceTriplets.Discovery}
|
|
139
|
+
queries={[discoveryQuery]}
|
|
140
|
+
class="relative grow flex-col gap-4"
|
|
140
141
|
>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
{componentPreview}
|
|
150
|
-
{onAddComponent}
|
|
151
|
-
/>
|
|
152
|
-
{/if}
|
|
153
|
-
</Query>
|
|
142
|
+
{#if discoveryQuery.data !== undefined}
|
|
143
|
+
<ResourcesList
|
|
144
|
+
data={discoveryQuery.data}
|
|
145
|
+
{previews}
|
|
146
|
+
{componentPreview}
|
|
147
|
+
{onAddComponent}
|
|
148
|
+
/>
|
|
149
|
+
{/if}
|
|
154
150
|
</ApiSection>
|
|
155
151
|
{/snippet}
|
|
156
152
|
</ConnectionStatus>
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import ApiSection from '../../api-section.svelte'
|
|
11
11
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
12
|
-
import ErrorDisplay from '../../error.svelte'
|
|
13
|
-
import Queries from '../../queries.svelte'
|
|
14
12
|
import RefetchController from '../../refetch-controller.svelte'
|
|
15
13
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
14
|
+
import { Section } from '../../section'
|
|
15
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
16
16
|
|
|
17
17
|
import { getEncoderPositionArgs } from './encoder-position-type'
|
|
18
18
|
import Position from './position.svelte'
|
|
@@ -64,29 +64,34 @@
|
|
|
64
64
|
<div class="@container">
|
|
65
65
|
<div class="grid w-full grid-cols-1 divide-y @lg:grid-cols-2 @lg:divide-x @lg:divide-y-0">
|
|
66
66
|
<ApiSection
|
|
67
|
-
|
|
68
|
-
api=
|
|
69
|
-
|
|
70
|
-
class="gap-3"
|
|
67
|
+
method="GetPosition"
|
|
68
|
+
api={ResourceTriplets.Encoder}
|
|
69
|
+
queries={[propertiesQuery, positionQuery]}
|
|
70
|
+
class="grow flex-col gap-3"
|
|
71
71
|
>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
{#snippet tooltip()}
|
|
73
|
+
Relative encoders return ticks since last zeroing. Absolute encoders return degrees.
|
|
74
|
+
{/snippet}
|
|
75
|
+
{#if positionQuery.data !== undefined}
|
|
76
|
+
{@const [position, encoderPositionType] = positionQuery.data}
|
|
77
|
+
<div class="font-roboto-mono flex flex-col gap-2 text-sm">
|
|
78
|
+
<Position
|
|
79
|
+
{position}
|
|
80
|
+
{encoderPositionType}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
{/if}
|
|
83
84
|
</ApiSection>
|
|
84
85
|
|
|
85
86
|
<ApiSection
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
class="grow flex-col gap-4"
|
|
88
|
+
method="ResetPosition"
|
|
89
|
+
api={ResourceTriplets.Encoder}
|
|
90
|
+
mutations={[resetMutation]}
|
|
89
91
|
>
|
|
92
|
+
{#snippet subheading()}
|
|
93
|
+
<Section.Text>Set the current position as the new zero position</Section.Text>
|
|
94
|
+
{/snippet}
|
|
90
95
|
<Button
|
|
91
96
|
icon="play-circle-outline"
|
|
92
97
|
class="w-fit"
|
|
@@ -96,7 +101,6 @@
|
|
|
96
101
|
>
|
|
97
102
|
Execute
|
|
98
103
|
</Button>
|
|
99
|
-
<ErrorDisplay lastError={resetMutation.error} />
|
|
100
104
|
</ApiSection>
|
|
101
105
|
</div>
|
|
102
106
|
</div>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
4
4
|
|
|
5
5
|
import ApiSection from '../../api-section.svelte'
|
|
6
|
-
import
|
|
6
|
+
import { Section } from '../../section'
|
|
7
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
7
8
|
|
|
8
9
|
import { getEncoderPositionArgs } from './encoder-position-type'
|
|
9
10
|
import Position from './position.svelte'
|
|
@@ -35,20 +36,22 @@
|
|
|
35
36
|
</script>
|
|
36
37
|
|
|
37
38
|
<ApiSection
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class="grow"
|
|
39
|
+
method="GetPosition"
|
|
40
|
+
api={ResourceTriplets.Encoder}
|
|
41
|
+
queries={[propertiesQuery, positionQuery]}
|
|
42
|
+
class="grow flex-col gap-4"
|
|
42
43
|
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
{#snippet tooltip()}
|
|
45
|
+
Relative encoders return ticks since last zeroing. Absolute encoders return degrees.
|
|
46
|
+
{/snippet}
|
|
47
|
+
{#if positionQuery.data !== undefined}
|
|
48
|
+
{@const [position, encoderPositionType] = positionQuery.data}
|
|
49
|
+
<div class="font-roboto-mono flex flex-col gap-2 text-sm">
|
|
50
|
+
<Position
|
|
51
|
+
{position}
|
|
52
|
+
{encoderPositionType}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
54
57
|
</ApiSection>
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
createResourceQuery,
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
|
-
import { apiDocsHref } from '../../../api-docs-href'
|
|
10
9
|
import ApiSection from '../../api-section.svelte'
|
|
11
10
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
12
11
|
import IsMoving from '../../is-moving.svelte'
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import { Section } from '../../section'
|
|
13
|
+
import { useSectionErrors } from '../../section/use-section-errors.svelte'
|
|
15
14
|
import StopButton from '../../stop-button.svelte'
|
|
15
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
16
16
|
|
|
17
17
|
import Home from './home.svelte'
|
|
18
18
|
import MoveToPosition from './move-to-position.svelte'
|
|
@@ -40,7 +40,10 @@
|
|
|
40
40
|
const quickMoveMutation = createResourceMutation(client, 'moveToPosition')
|
|
41
41
|
const stopMutation = createResourceMutation(client, 'stop')
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const quickMoveErrors = useSectionErrors(() => ({
|
|
44
|
+
queries: [positionQuery],
|
|
45
|
+
mutations: [quickMoveMutation],
|
|
46
|
+
}))
|
|
44
47
|
</script>
|
|
45
48
|
|
|
46
49
|
<ConnectionStatus {partID}>
|
|
@@ -50,100 +53,79 @@
|
|
|
50
53
|
<div class="@container grow">
|
|
51
54
|
<div class="flex flex-col divide-y @2xl:flex-row @2xl:divide-x @2xl:divide-y-0">
|
|
52
55
|
<ApiSection
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
class="grow flex-col gap-4"
|
|
57
|
+
method="GetPosition"
|
|
58
|
+
api={ResourceTriplets.Gantry}
|
|
59
|
+
queries={[positionQuery, lengthsQuery]}
|
|
55
60
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
>
|
|
66
|
-
GetPosition
|
|
67
|
-
</a>
|
|
68
|
-
and
|
|
69
|
-
<a
|
|
70
|
-
href={apiDocsHref('rdk:component:gantry', 'getLengths')}
|
|
71
|
-
target="_blank"
|
|
72
|
-
rel="noopener noreferrer external"
|
|
73
|
-
class="decoration-gray-5 hover:decoration-default text-default font-mono font-semibold underline underline-offset-3"
|
|
74
|
-
>
|
|
75
|
-
GetLengths
|
|
76
|
-
</a>
|
|
77
|
-
</h3>
|
|
78
|
-
<Queries queries={[positionQuery, lengthsQuery]}>
|
|
79
|
-
{@const positions = positionQuery.data}
|
|
80
|
-
{@const lengths = lengthsQuery.data ?? []}
|
|
81
|
-
{#if positions !== undefined}
|
|
82
|
-
<PositionAndLengths
|
|
83
|
-
{positions}
|
|
84
|
-
{lengths}
|
|
85
|
-
/>
|
|
86
|
-
{/if}
|
|
87
|
-
</Queries>
|
|
61
|
+
{@const positions = positionQuery.data}
|
|
62
|
+
{@const lengths = lengthsQuery.data ?? []}
|
|
63
|
+
{#if positions !== undefined}
|
|
64
|
+
<PositionAndLengths
|
|
65
|
+
{positions}
|
|
66
|
+
{lengths}
|
|
67
|
+
/>
|
|
68
|
+
{/if}
|
|
69
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
88
70
|
</ApiSection>
|
|
89
71
|
<ApiSection
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
class="grow flex-col gap-4"
|
|
73
|
+
method="MoveToPosition"
|
|
74
|
+
api={ResourceTriplets.Gantry}
|
|
75
|
+
queries={[positionQuery]}
|
|
76
|
+
mutations={[moveMutation]}
|
|
92
77
|
>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/>
|
|
103
|
-
{/if}
|
|
104
|
-
</Query>
|
|
78
|
+
{@const positions = positionQuery.data}
|
|
79
|
+
{#if positions !== undefined}
|
|
80
|
+
<MoveToPosition
|
|
81
|
+
{positions}
|
|
82
|
+
moveTo={(newPos: number[], speeds: number[]) => {
|
|
83
|
+
moveMutation.mutate([newPos, speeds], {})
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
{/if}
|
|
105
87
|
</ApiSection>
|
|
106
88
|
<div class="flex grow flex-col divide-y">
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
<Section
|
|
90
|
+
errorReporter={quickMoveErrors}
|
|
91
|
+
class="grow flex-col gap-4"
|
|
110
92
|
>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
<div class="flex flex-col gap-0.5">
|
|
94
|
+
<Section.Heading>
|
|
95
|
+
Quick move
|
|
96
|
+
{#snippet aside()}
|
|
97
|
+
<Section.Errors errors={quickMoveErrors.errors} />
|
|
98
|
+
{/snippet}
|
|
99
|
+
</Section.Heading>
|
|
100
|
+
</div>
|
|
101
|
+
<Section.Body isLoading={quickMoveErrors.isLoading}>
|
|
115
102
|
{@const positions = positionQuery.data}
|
|
116
103
|
{#if positions !== undefined}
|
|
117
104
|
<QuickMove
|
|
118
105
|
{positions}
|
|
119
|
-
lastError={quickMoveMutation.error}
|
|
120
106
|
moveTo={(newPos: number[], speeds: number[]) => {
|
|
121
107
|
quickMoveMutation.mutate([newPos, speeds], {})
|
|
122
108
|
}}
|
|
123
109
|
/>
|
|
124
110
|
{/if}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<Home
|
|
133
|
-
{partID}
|
|
134
|
-
{resourceName}
|
|
135
|
-
/>
|
|
136
|
-
</ApiSection>
|
|
111
|
+
<Section.Text class="mt-auto">Press a button to execute</Section.Text>
|
|
112
|
+
</Section.Body>
|
|
113
|
+
</Section>
|
|
114
|
+
<Home
|
|
115
|
+
{partID}
|
|
116
|
+
{resourceName}
|
|
117
|
+
/>
|
|
137
118
|
</div>
|
|
138
119
|
</div>
|
|
139
120
|
</div>
|
|
140
121
|
<div class="flex flex-col divide-y @4xl:ml-auto @4xl:w-full @4xl:max-w-40">
|
|
141
122
|
<ApiSection
|
|
142
|
-
|
|
143
|
-
|
|
123
|
+
class="grow flex-col gap-4"
|
|
124
|
+
method="Stop"
|
|
125
|
+
api={ResourceTriplets.Gantry}
|
|
126
|
+
mutations={[stopMutation]}
|
|
144
127
|
>
|
|
145
128
|
<StopButton
|
|
146
|
-
error={stopMutation.error}
|
|
147
129
|
onStop={() => {
|
|
148
130
|
stopMutation.mutate([])
|
|
149
131
|
}}
|
|
@@ -151,7 +133,7 @@
|
|
|
151
133
|
</ApiSection>
|
|
152
134
|
<IsMoving
|
|
153
135
|
client={GantryClient}
|
|
154
|
-
api=
|
|
136
|
+
api={ResourceTriplets.Gantry}
|
|
155
137
|
{partID}
|
|
156
138
|
{resourceName}
|
|
157
139
|
/>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
4
4
|
|
|
5
5
|
import ApiSection from '../../api-section.svelte'
|
|
6
|
-
import
|
|
6
|
+
import { Section } from '../../section'
|
|
7
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
7
8
|
|
|
8
9
|
import PositionAndLengths from './position-and-lengths.svelte'
|
|
9
10
|
|
|
@@ -26,18 +27,18 @@
|
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
29
|
<ApiSection
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class="grow"
|
|
30
|
+
method="GetPosition"
|
|
31
|
+
api={ResourceTriplets.Gantry}
|
|
32
|
+
class="grow flex-col gap-4"
|
|
33
|
+
queries={[positionQuery, lengthsQuery]}
|
|
32
34
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</Queries>
|
|
35
|
+
{@const positions = positionQuery.data}
|
|
36
|
+
{@const lengths = lengthsQuery.data ?? []}
|
|
37
|
+
{#if positions !== undefined}
|
|
38
|
+
<PositionAndLengths
|
|
39
|
+
{positions}
|
|
40
|
+
{lengths}
|
|
41
|
+
/>
|
|
42
|
+
{/if}
|
|
43
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
43
44
|
</ApiSection>
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { GantryClient } from '@viamrobotics/sdk'
|
|
4
4
|
import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import ApiSection from '../../api-section.svelte'
|
|
7
|
+
import { Section } from '../../section'
|
|
8
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
7
9
|
|
|
8
10
|
interface Props {
|
|
9
11
|
partID: string
|
|
@@ -21,13 +23,22 @@
|
|
|
21
23
|
const homeMutation = createResourceMutation(client, 'home')
|
|
22
24
|
</script>
|
|
23
25
|
|
|
24
|
-
<
|
|
25
|
-
class="
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}}
|
|
26
|
+
<ApiSection
|
|
27
|
+
class="grow flex-col gap-4"
|
|
28
|
+
method="Home"
|
|
29
|
+
api={ResourceTriplets.Gantry}
|
|
30
|
+
mutations={[homeMutation]}
|
|
30
31
|
>
|
|
31
|
-
|
|
32
|
-
</
|
|
33
|
-
|
|
32
|
+
{#snippet subheading()}
|
|
33
|
+
<Section.Text>Run the homing sequence</Section.Text>
|
|
34
|
+
{/snippet}
|
|
35
|
+
<Button
|
|
36
|
+
class="w-fit"
|
|
37
|
+
icon="play-circle-outline"
|
|
38
|
+
onclick={() => {
|
|
39
|
+
homeMutation.mutate([], {})
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
Execute
|
|
43
|
+
</Button>
|
|
44
|
+
</ApiSection>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
9
|
import Query from '../../query.svelte'
|
|
10
|
+
import { Section } from '../../section'
|
|
10
11
|
|
|
11
12
|
import MoveToPosition from './move-to-position.svelte'
|
|
12
13
|
|
|
@@ -34,10 +35,10 @@
|
|
|
34
35
|
{#if positions !== undefined}
|
|
35
36
|
<MoveToPosition
|
|
36
37
|
{positions}
|
|
37
|
-
lastError={moveMutation.error}
|
|
38
38
|
moveTo={(newPos: number[], speeds: number[]) => {
|
|
39
39
|
moveMutation.mutate([newPos, speeds], {})
|
|
40
40
|
}}
|
|
41
41
|
/>
|
|
42
42
|
{/if}
|
|
43
43
|
</Query>
|
|
44
|
+
<Section.Error error={moveMutation.error} />
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { Button, Icon, NumericInput, Tooltip } from '@viamrobotics/prime-core'
|
|
3
3
|
import { isEqual, zip } from 'lodash-es'
|
|
4
4
|
|
|
5
|
-
import ErrorDisplay from '../../error.svelte'
|
|
6
5
|
import Table from '../../table.svelte'
|
|
7
6
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
8
7
|
|
|
@@ -11,10 +10,9 @@
|
|
|
11
10
|
interface Props {
|
|
12
11
|
positions: number[]
|
|
13
12
|
moveTo: (newPos: number[], speeds: number[]) => void
|
|
14
|
-
lastError: Error | null
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
const { positions, moveTo
|
|
15
|
+
const { positions, moveTo }: Props = $props()
|
|
18
16
|
|
|
19
17
|
let desiredSpeeds: number[] = $state([])
|
|
20
18
|
|
|
@@ -122,5 +120,4 @@
|
|
|
122
120
|
>
|
|
123
121
|
Execute
|
|
124
122
|
</Button>
|
|
125
|
-
<ErrorDisplay {lastError} />
|
|
126
123
|
</div>
|