@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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { errorKey } from './error-key';
|
|
2
|
+
export const dedupeErrors = (errors) => {
|
|
3
|
+
const present = errors.filter((error) => error !== null);
|
|
4
|
+
return present.filter((error, index) => present.findIndex((seen) => errorKey(seen) === errorKey(error)) === index);
|
|
5
|
+
};
|
|
6
|
+
const serializeErrors = (errors) => errors.map((error) => errorKey(error)).join('\0\0');
|
|
7
|
+
/**
|
|
8
|
+
* A section's distinct errors across its queries and mutations, and whether its first load is
|
|
9
|
+
* still running.
|
|
10
|
+
*/
|
|
11
|
+
export const useSectionErrors = (getSources) => {
|
|
12
|
+
let held = [];
|
|
13
|
+
const queryErrors = $derived.by(() => {
|
|
14
|
+
const queries = getSources().queries ?? [];
|
|
15
|
+
const next = dedupeErrors(queries.map((query) => query.error));
|
|
16
|
+
if (next.length > 0) {
|
|
17
|
+
if (serializeErrors(next) !== serializeErrors(held)) {
|
|
18
|
+
held = next;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else if (queries.every((query) => query.fetchStatus === 'idle')) {
|
|
22
|
+
held = [];
|
|
23
|
+
}
|
|
24
|
+
return held;
|
|
25
|
+
});
|
|
26
|
+
const errors = $derived.by(() => {
|
|
27
|
+
const mutationErrors = (getSources().mutations ?? []).map((mutation) => mutation.error);
|
|
28
|
+
return dedupeErrors([...queryErrors, ...mutationErrors]);
|
|
29
|
+
});
|
|
30
|
+
const isLoading = $derived(errors.length === 0 && (getSources().queries ?? []).some((query) => query.isLoading));
|
|
31
|
+
return {
|
|
32
|
+
get errors() {
|
|
33
|
+
return errors;
|
|
34
|
+
},
|
|
35
|
+
get isLoading() {
|
|
36
|
+
return isLoading;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
import { Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
5
5
|
|
|
6
|
+
import type { ResourceTriplet } from '../resource-triplet'
|
|
7
|
+
|
|
6
8
|
import { apiDocsHref } from '../api-docs-href'
|
|
7
9
|
|
|
8
10
|
interface Props {
|
|
9
11
|
title: string
|
|
10
12
|
tooltip?: string | undefined
|
|
11
13
|
/** RDK API string, e.g. "rdk:component:camera". Required — SectionTitle is only for headers that map to an API method; the docs link is built from this plus the title. */
|
|
12
|
-
api:
|
|
14
|
+
api: ResourceTriplet
|
|
13
15
|
/** Optional external ID for the <h3>; generated internally if omitted */
|
|
14
16
|
headingId?: string | undefined
|
|
15
17
|
/** Inline content rendered after the title inside the <h3> (e.g. unit labels) */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ResourceTriplet } from '../resource-triplet';
|
|
2
3
|
interface Props {
|
|
3
4
|
title: string;
|
|
4
5
|
tooltip?: string | undefined;
|
|
5
6
|
/** RDK API string, e.g. "rdk:component:camera". Required — SectionTitle is only for headers that map to an API method; the docs link is built from this plus the title. */
|
|
6
|
-
api:
|
|
7
|
+
api: ResourceTriplet;
|
|
7
8
|
/** Optional external ID for the <h3>; generated internally if omitted */
|
|
8
9
|
headingId?: string | undefined;
|
|
9
10
|
/** Inline content rendered after the title inside the <h3> (e.g. unit labels) */
|
|
@@ -13,24 +13,32 @@
|
|
|
13
13
|
Servo,
|
|
14
14
|
ServoClient,
|
|
15
15
|
} from '@viamrobotics/sdk'
|
|
16
|
+
import type { Snippet } from 'svelte'
|
|
16
17
|
|
|
17
18
|
import { createResourceClient, createResourceMutation } from '@viamrobotics/svelte-sdk'
|
|
18
19
|
|
|
20
|
+
import type { ResourceTriplet } from '../resource-triplet'
|
|
21
|
+
|
|
22
|
+
import ApiSection from './api-section.svelte'
|
|
19
23
|
import StopButton from './stop-button.svelte'
|
|
20
24
|
|
|
25
|
+
type Client =
|
|
26
|
+
| typeof ArmClient
|
|
27
|
+
| typeof BaseClient
|
|
28
|
+
| typeof GantryClient
|
|
29
|
+
| typeof GripperClient
|
|
30
|
+
| typeof MotorClient
|
|
31
|
+
| typeof ServoClient
|
|
32
|
+
|
|
21
33
|
interface Props {
|
|
34
|
+
client: Client
|
|
22
35
|
partID: string
|
|
23
36
|
resourceName: string
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| typeof BaseClient
|
|
27
|
-
| typeof GantryClient
|
|
28
|
-
| typeof GripperClient
|
|
29
|
-
| typeof MotorClient
|
|
30
|
-
| typeof ServoClient
|
|
37
|
+
api: ResourceTriplet
|
|
38
|
+
children?: Snippet
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
const { partID, resourceName,
|
|
41
|
+
const { client: clientClass, partID, resourceName, api, children }: Props = $props()
|
|
34
42
|
|
|
35
43
|
const client = $derived(
|
|
36
44
|
createResourceClient<Arm | Base | Gantry | Gripper | Motor | Servo>(
|
|
@@ -43,9 +51,18 @@
|
|
|
43
51
|
const stopMutation = $derived(createResourceMutation(client, 'stop'))
|
|
44
52
|
</script>
|
|
45
53
|
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
<ApiSection
|
|
55
|
+
class="grow flex-col gap-4"
|
|
56
|
+
title="Stop"
|
|
57
|
+
{api}
|
|
58
|
+
>
|
|
59
|
+
<StopButton
|
|
60
|
+
error={stopMutation.error}
|
|
61
|
+
onStop={() => {
|
|
62
|
+
stopMutation.mutate([])
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<!-- snippet for additional actuation info Ex: Motor's IsPowered & GetPosition -->
|
|
67
|
+
{@render children?.()}
|
|
68
|
+
</ApiSection>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ArmClient, BaseClient, GantryClient, GripperClient, MotorClient, ServoClient } from '@viamrobotics/sdk';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ResourceTriplet } from '../resource-triplet';
|
|
4
|
+
type Client = typeof ArmClient | typeof BaseClient | typeof GantryClient | typeof GripperClient | typeof MotorClient | typeof ServoClient;
|
|
2
5
|
interface Props {
|
|
6
|
+
client: Client;
|
|
3
7
|
partID: string;
|
|
4
8
|
resourceName: string;
|
|
5
|
-
|
|
9
|
+
api: ResourceTriplet;
|
|
10
|
+
children?: Snippet;
|
|
6
11
|
}
|
|
7
12
|
declare const Stop: import("svelte").Component<Props, {}, "">;
|
|
8
13
|
type Stop = ReturnType<typeof Stop>;
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
import IsMoving from '../../is-moving.svelte'
|
|
12
12
|
import Query from '../../query.svelte'
|
|
13
13
|
import StopButton from '../../stop-button.svelte'
|
|
14
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
15
|
|
|
15
16
|
import GetJointPositions from './get-joint-positions.svelte'
|
|
16
17
|
import { getJointPositionLimits, type KinematicsJSON } from './joint-position-limits'
|
|
17
18
|
import ManualModeWidget from './manual-mode-widget.svelte'
|
|
18
19
|
import MoveToJointPositions from './move-to-joint-positions.svelte'
|
|
19
20
|
import MoveToPositionControl from './move-to-position-control.svelte'
|
|
21
|
+
import { useArmMotionTracking } from './use-arm-motion-tracking.svelte'
|
|
20
22
|
|
|
21
23
|
interface Props {
|
|
22
24
|
partID: string
|
|
@@ -31,12 +33,17 @@
|
|
|
31
33
|
() => resourceName
|
|
32
34
|
)
|
|
33
35
|
|
|
34
|
-
const options = { refetchInterval: 500 }
|
|
35
|
-
const jointPositionsQuery = createResourceQuery(client, 'getJointPositions', options)
|
|
36
|
-
const kinematicsQuery = createResourceQuery(client, 'getKinematics', options)
|
|
37
|
-
const isMovingQuery = createResourceQuery(client, 'isMoving', options)
|
|
38
|
-
|
|
39
36
|
const moveToJointPosMutation = createResourceMutation(client, 'moveToJointPositions')
|
|
37
|
+
|
|
38
|
+
const motionTracking = useArmMotionTracking(client, {
|
|
39
|
+
isMovePending: () => moveToJointPosMutation.isPending,
|
|
40
|
+
refetchPosition: () => jointPositionsQuery.refetch(),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const jointPositionsQuery = createResourceQuery(client, 'getJointPositions', () => ({
|
|
44
|
+
refetchInterval: motionTracking.refetchInterval,
|
|
45
|
+
}))
|
|
46
|
+
const kinematicsQuery = createResourceQuery(client, 'getKinematics', { refetchInterval: 500 })
|
|
40
47
|
const stopMutation = createResourceMutation(client, 'stop')
|
|
41
48
|
|
|
42
49
|
const moveToJointPositions = async (jointPositionsList: number[]) => {
|
|
@@ -64,8 +71,9 @@
|
|
|
64
71
|
class="flex flex-col gap-4 @2xl:grid @2xl:grow @2xl:grid-cols-2 @2xl:gap-0 @2xl:divide-x @4xl:grid-cols-3"
|
|
65
72
|
>
|
|
66
73
|
<ApiSection
|
|
74
|
+
class="grow flex-col gap-4"
|
|
67
75
|
title="GetJointPositions"
|
|
68
|
-
api=
|
|
76
|
+
api={ResourceTriplets.Arm}
|
|
69
77
|
bottomText="Updates automatically"
|
|
70
78
|
>
|
|
71
79
|
<Query query={jointPositionsQuery}>
|
|
@@ -75,8 +83,9 @@
|
|
|
75
83
|
</Query>
|
|
76
84
|
</ApiSection>
|
|
77
85
|
<ApiSection
|
|
86
|
+
class="grow flex-col gap-4"
|
|
78
87
|
title="MoveToJointPositions"
|
|
79
|
-
api=
|
|
88
|
+
api={ResourceTriplets.Arm}
|
|
80
89
|
>
|
|
81
90
|
<Query query={jointPositionsQuery}>
|
|
82
91
|
{#if jointPositionsQuery.data}
|
|
@@ -85,14 +94,15 @@
|
|
|
85
94
|
{moveToJointPositions}
|
|
86
95
|
lastError={moveToJointPosMutation.error}
|
|
87
96
|
{jointLimitsDegrees}
|
|
88
|
-
isMoving={
|
|
97
|
+
isMoving={motionTracking.isTracking}
|
|
89
98
|
/>
|
|
90
99
|
{/if}
|
|
91
100
|
</Query>
|
|
92
101
|
</ApiSection>
|
|
93
102
|
<ApiSection
|
|
103
|
+
class="grow flex-col gap-4"
|
|
94
104
|
title="MoveToPosition"
|
|
95
|
-
api=
|
|
105
|
+
api={ResourceTriplets.Arm}
|
|
96
106
|
>
|
|
97
107
|
<MoveToPositionControl
|
|
98
108
|
{partID}
|
|
@@ -106,8 +116,9 @@
|
|
|
106
116
|
class="flex flex-row gap-4 @2xl:ml-auto @2xl:w-full @2xl:max-w-40 @2xl:flex-col @2xl:gap-0 @2xl:divide-y"
|
|
107
117
|
>
|
|
108
118
|
<ApiSection
|
|
119
|
+
class="grow flex-col gap-4"
|
|
109
120
|
title="Stop"
|
|
110
|
-
api=
|
|
121
|
+
api={ResourceTriplets.Arm}
|
|
111
122
|
>
|
|
112
123
|
<StopButton
|
|
113
124
|
error={stopMutation.error}
|
|
@@ -118,7 +129,7 @@
|
|
|
118
129
|
</ApiSection>
|
|
119
130
|
<IsMoving
|
|
120
131
|
client={ArmClient}
|
|
121
|
-
api=
|
|
132
|
+
api={ResourceTriplets.Arm}
|
|
122
133
|
{partID}
|
|
123
134
|
{resourceName}
|
|
124
135
|
/>
|
|
@@ -1,45 +1,70 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Button, Icon, Tooltip } from '@viamrobotics/prime-core'
|
|
2
|
+
import { Button, Icon, IconButton, Tooltip } from '@viamrobotics/prime-core'
|
|
3
3
|
|
|
4
|
+
import StatusPill from '../../status-pill.svelte'
|
|
4
5
|
import Table from '../../table.svelte'
|
|
6
|
+
import { degreesToRadians, formatNumeric } from '../../../format'
|
|
7
|
+
|
|
8
|
+
import type { EditedTargets } from './use-edited-targets.svelte'
|
|
5
9
|
|
|
6
10
|
import { type JointLimit } from './joint-position-limits'
|
|
7
11
|
import JointPositionSlider from './joint-position-slider.svelte'
|
|
8
12
|
|
|
9
13
|
interface Props {
|
|
10
|
-
|
|
14
|
+
targets: EditedTargets<number>
|
|
11
15
|
positions: number[]
|
|
12
16
|
jointLimitsDegrees: JointLimit[]
|
|
13
17
|
useRadians: boolean
|
|
14
|
-
/** Sends the move. Rejects when it fails. */
|
|
15
18
|
moveToJointPositions: (jointPositions: number[]) => Promise<void>
|
|
19
|
+
isMoving?: boolean
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const {
|
|
23
|
+
targets,
|
|
20
24
|
positions,
|
|
21
25
|
jointLimitsDegrees,
|
|
22
26
|
useRadians,
|
|
23
27
|
moveToJointPositions,
|
|
28
|
+
isMoving = false,
|
|
24
29
|
}: Props = $props()
|
|
25
30
|
|
|
31
|
+
interface StatusIndicator {
|
|
32
|
+
status: 'info' | 'warn'
|
|
33
|
+
message: string
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
const getSliderMin = (index: number): number => jointLimitsDegrees[index]?.minDegrees ?? -180
|
|
27
37
|
const getSliderMax = (index: number): number => jointLimitsDegrees[index]?.maxDegrees ?? 180
|
|
28
38
|
|
|
39
|
+
const formatAngle = (degrees: number) =>
|
|
40
|
+
useRadians ? `${formatNumeric(degreesToRadians(degrees))} rad` : `${formatNumeric(degrees)}°`
|
|
41
|
+
|
|
42
|
+
const statusIndicator = (index: number): StatusIndicator | undefined => {
|
|
43
|
+
const drift = targets.drift(index)
|
|
44
|
+
if (drift !== undefined) {
|
|
45
|
+
return {
|
|
46
|
+
status: 'warn',
|
|
47
|
+
message: `Arm moved ${formatAngle(drift)} since you edited joint ${index}.`,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (isMoving && targets.isEdited(index)) {
|
|
51
|
+
return { status: 'info', message: 'The arm is moving. Your edit is kept.' }
|
|
52
|
+
}
|
|
53
|
+
return undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
29
56
|
const execute = async () => {
|
|
30
57
|
try {
|
|
31
|
-
await moveToJointPositions(
|
|
58
|
+
await moveToJointPositions(positions.map((_, index) => targets.target(index)))
|
|
32
59
|
} catch {
|
|
33
60
|
// The parent renders the failure from the mutation's error state.
|
|
34
61
|
}
|
|
35
62
|
}
|
|
36
63
|
|
|
37
64
|
const resetToZero = () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const resetToCurrent = () => {
|
|
42
|
-
desiredPositions = [...positions]
|
|
65
|
+
for (const index of positions.keys()) {
|
|
66
|
+
targets.edit(index, 0)
|
|
67
|
+
}
|
|
43
68
|
}
|
|
44
69
|
</script>
|
|
45
70
|
|
|
@@ -51,16 +76,52 @@
|
|
|
51
76
|
</tr>
|
|
52
77
|
</thead>
|
|
53
78
|
<tbody>
|
|
54
|
-
{#each [...
|
|
79
|
+
{#each [...positions.keys()] as index (index)}
|
|
80
|
+
{@const indicator = statusIndicator(index)}
|
|
55
81
|
<tr>
|
|
56
82
|
<th scope="row">{index}</th>
|
|
57
83
|
<th>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
<div class="flex flex-col gap-0.5">
|
|
85
|
+
<div class="flex items-center gap-1">
|
|
86
|
+
<div class="min-w-0 grow">
|
|
87
|
+
<JointPositionSlider
|
|
88
|
+
value={targets.target(index)}
|
|
89
|
+
onValueChange={(degrees) => {
|
|
90
|
+
targets.edit(index, degrees)
|
|
91
|
+
}}
|
|
92
|
+
minDegrees={getSliderMin(index)}
|
|
93
|
+
maxDegrees={getSliderMax(index)}
|
|
94
|
+
{useRadians}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
{#if indicator}
|
|
98
|
+
<Tooltip>
|
|
99
|
+
<Icon
|
|
100
|
+
name={indicator.status === 'warn' ? 'alert' : 'information'}
|
|
101
|
+
cx={indicator.status === 'warn' ? 'text-warning-bright' : 'text-info-dark'}
|
|
102
|
+
/>
|
|
103
|
+
<span slot="description">{indicator.message}</span>
|
|
104
|
+
</Tooltip>
|
|
105
|
+
<!-- The tweakpane slider takes no aria-describedby, so screen readers get the message here. -->
|
|
106
|
+
<span class="sr-only">{indicator.message}</span>
|
|
107
|
+
{/if}
|
|
108
|
+
{#if targets.isEdited(index)}
|
|
109
|
+
<Tooltip>
|
|
110
|
+
<IconButton
|
|
111
|
+
icon="backup-restore"
|
|
112
|
+
label="Reset joint {index} to current"
|
|
113
|
+
onclick={() => {
|
|
114
|
+
targets.reset(index)
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
<span slot="description">Reset joint {index} to its current value</span>
|
|
118
|
+
</Tooltip>
|
|
119
|
+
{/if}
|
|
120
|
+
</div>
|
|
121
|
+
<span class="text-subtle-2 font-roboto-mono text-xs font-normal">
|
|
122
|
+
Current {formatAngle(positions[index] ?? 0)}
|
|
123
|
+
</span>
|
|
124
|
+
</div>
|
|
64
125
|
</th>
|
|
65
126
|
</tr>
|
|
66
127
|
{/each}
|
|
@@ -80,15 +141,32 @@
|
|
|
80
141
|
</span>
|
|
81
142
|
<div class="flex flex-col gap-2 sm:flex-row">
|
|
82
143
|
<Button onclick={resetToZero}>Zero</Button>
|
|
83
|
-
<Button
|
|
144
|
+
<Button
|
|
145
|
+
onclick={() => {
|
|
146
|
+
targets.resetAll()
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
Current position
|
|
150
|
+
</Button>
|
|
84
151
|
</div>
|
|
85
152
|
</div>
|
|
86
153
|
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
154
|
+
<div class="mt-auto flex items-center gap-2">
|
|
155
|
+
<Button
|
|
156
|
+
class="w-fit"
|
|
157
|
+
icon="play-circle-outline"
|
|
158
|
+
variant="dark"
|
|
159
|
+
disabled={isMoving}
|
|
160
|
+
onclick={execute}
|
|
161
|
+
>
|
|
162
|
+
Execute
|
|
163
|
+
</Button>
|
|
164
|
+
<span role="status">
|
|
165
|
+
{#if isMoving}
|
|
166
|
+
<StatusPill
|
|
167
|
+
isActive
|
|
168
|
+
activeText="Arm is moving"
|
|
169
|
+
/>
|
|
170
|
+
{/if}
|
|
171
|
+
</span>
|
|
172
|
+
</div>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { EditedTargets } from './use-edited-targets.svelte';
|
|
1
2
|
import { type JointLimit } from './joint-position-limits';
|
|
2
3
|
interface Props {
|
|
3
|
-
|
|
4
|
+
targets: EditedTargets<number>;
|
|
4
5
|
positions: number[];
|
|
5
6
|
jointLimitsDegrees: JointLimit[];
|
|
6
7
|
useRadians: boolean;
|
|
7
|
-
/** Sends the move. Rejects when it fails. */
|
|
8
8
|
moveToJointPositions: (jointPositions: number[]) => Promise<void>;
|
|
9
|
+
isMoving?: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare const JointPositionEditor: import("svelte").Component<Props, {}, "
|
|
11
|
+
declare const JointPositionEditor: import("svelte").Component<Props, {}, "">;
|
|
11
12
|
type JointPositionEditor = ReturnType<typeof JointPositionEditor>;
|
|
12
13
|
export default JointPositionEditor;
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
value: number
|
|
8
|
+
onValueChange: (degrees: number) => void
|
|
8
9
|
minDegrees: number
|
|
9
10
|
maxDegrees: number
|
|
10
11
|
useRadians: boolean
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const { value, onValueChange, minDegrees, maxDegrees, useRadians }: Props = $props()
|
|
14
15
|
|
|
15
16
|
const min = $derived(useRadians ? degreesToRadians(minDegrees) : minDegrees)
|
|
16
17
|
const max = $derived(useRadians ? degreesToRadians(maxDegrees) : maxDegrees)
|
|
@@ -25,7 +26,10 @@
|
|
|
25
26
|
<Slider
|
|
26
27
|
value={toDisplay(value)}
|
|
27
28
|
on:change={(event) => {
|
|
28
|
-
value
|
|
29
|
+
// The slider also reports changes to `value` from outside, such as a live reading arriving.
|
|
30
|
+
if (event.detail.origin === 'internal') {
|
|
31
|
+
onValueChange(toDegrees(event.detail.value))
|
|
32
|
+
}
|
|
29
33
|
}}
|
|
30
34
|
{min}
|
|
31
35
|
{max}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
value: number;
|
|
3
|
+
onValueChange: (degrees: number) => void;
|
|
3
4
|
minDegrees: number;
|
|
4
5
|
maxDegrees: number;
|
|
5
6
|
useRadians: boolean;
|
|
6
7
|
}
|
|
7
|
-
declare const JointPositionSlider: import("svelte").Component<Props, {}, "
|
|
8
|
+
declare const JointPositionSlider: import("svelte").Component<Props, {}, "">;
|
|
8
9
|
type JointPositionSlider = ReturnType<typeof JointPositionSlider>;
|
|
9
10
|
export default JointPositionSlider;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
9
|
import ApiSection from '../../api-section.svelte'
|
|
10
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
10
11
|
|
|
11
12
|
import ManualMode from './manual-mode.svelte'
|
|
12
13
|
|
|
@@ -57,8 +58,8 @@
|
|
|
57
58
|
{:else}
|
|
58
59
|
<ApiSection
|
|
59
60
|
title="SetManualMode"
|
|
60
|
-
api=
|
|
61
|
-
class="grow"
|
|
61
|
+
api={ResourceTriplets.Arm}
|
|
62
|
+
class="grow flex-col gap-4"
|
|
62
63
|
>
|
|
63
64
|
<ManualMode
|
|
64
65
|
isManualMode={manualModeQuery.data ?? false}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { getJointPositionLimits, type KinematicsJSON } from './joint-position-limits'
|
|
12
12
|
import MoveToJointPositions from './move-to-joint-positions.svelte'
|
|
13
|
+
import { useArmMotionTracking } from './use-arm-motion-tracking.svelte'
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
15
16
|
partID: string
|
|
@@ -24,15 +25,21 @@
|
|
|
24
25
|
() => resourceName
|
|
25
26
|
)
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const moveToJointPosMutation = createResourceMutation(client, 'moveToJointPositions')
|
|
29
|
+
|
|
30
|
+
const motionTracking = useArmMotionTracking(client, {
|
|
31
|
+
isMovePending: () => moveToJointPosMutation.isPending,
|
|
32
|
+
refetchPosition: () => jointPositionsQuery.refetch(),
|
|
29
33
|
})
|
|
34
|
+
|
|
35
|
+
const jointPositionsQuery = createResourceQuery(client, 'getJointPositions', () => ({
|
|
36
|
+
refetchInterval: motionTracking.refetchInterval,
|
|
37
|
+
}))
|
|
38
|
+
|
|
30
39
|
const kinematicsQuery = createResourceQuery(client, 'getKinematics', {
|
|
31
40
|
refetchInterval: 500,
|
|
32
41
|
})
|
|
33
42
|
|
|
34
|
-
const moveToJointPosMutation = createResourceMutation(client, 'moveToJointPositions')
|
|
35
|
-
|
|
36
43
|
const moveToJointPositions = async (jointPositionsList: number[]) => {
|
|
37
44
|
await moveToJointPosMutation.mutateAsync([jointPositionsList])
|
|
38
45
|
}
|
|
@@ -49,6 +56,7 @@
|
|
|
49
56
|
{moveToJointPositions}
|
|
50
57
|
lastError={moveToJointPosMutation.error}
|
|
51
58
|
{jointLimitsDegrees}
|
|
59
|
+
isMoving={motionTracking.isTracking}
|
|
52
60
|
/>
|
|
53
61
|
{/if}
|
|
54
62
|
</Query>
|
|
@@ -10,11 +10,15 @@
|
|
|
10
10
|
import JointPositionEditor from './joint-position-editor.svelte'
|
|
11
11
|
import JointPositionJogging from './joint-position-jogging.svelte'
|
|
12
12
|
import { type JointLimit } from './joint-position-limits'
|
|
13
|
+
import { useEditedTargets } from './use-edited-targets.svelte'
|
|
13
14
|
|
|
14
15
|
type ControlMode = 'Jogging' | 'Joint Positions'
|
|
15
16
|
|
|
16
17
|
const CONTROL_MODES: ControlMode[] = ['Jogging', 'Joint Positions']
|
|
17
18
|
|
|
19
|
+
// Tight enough to catch a real move, loose enough to ignore encoder noise.
|
|
20
|
+
const JOINT_DRIFT_DEGREES = 0.5
|
|
21
|
+
|
|
18
22
|
interface Props {
|
|
19
23
|
positions: number[]
|
|
20
24
|
/** Sends the move. Rejects when it fails. */
|
|
@@ -32,8 +36,11 @@
|
|
|
32
36
|
isMoving = false,
|
|
33
37
|
}: Props = $props()
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const targets = useEditedTargets<number>(
|
|
40
|
+
(index) => positions[index] ?? 0,
|
|
41
|
+
() => JOINT_DRIFT_DEGREES
|
|
42
|
+
)
|
|
43
|
+
const desiredPositions = $derived(positions.map((_, index) => targets.target(index))) // in degrees
|
|
37
44
|
let useRadians = $state(false)
|
|
38
45
|
let controlMode = $state<ControlMode>('Jogging')
|
|
39
46
|
|
|
@@ -57,10 +64,10 @@
|
|
|
57
64
|
const handlePaste = (data: string): boolean => {
|
|
58
65
|
try {
|
|
59
66
|
const parsed = JSON.parse(data) as number[]
|
|
60
|
-
|
|
67
|
+
for (const [index, pos] of parsed.slice(0, positions.length).entries()) {
|
|
61
68
|
const degrees = useRadians ? radiansToDegrees(pos) : pos
|
|
62
|
-
|
|
63
|
-
}
|
|
69
|
+
targets.edit(index, Math.min(Math.max(degrees, getJointMin(index)), getJointMax(index)))
|
|
70
|
+
}
|
|
64
71
|
} catch {
|
|
65
72
|
return false
|
|
66
73
|
}
|
|
@@ -111,11 +118,12 @@
|
|
|
111
118
|
/>
|
|
112
119
|
{:else}
|
|
113
120
|
<JointPositionEditor
|
|
114
|
-
|
|
121
|
+
{targets}
|
|
115
122
|
{positions}
|
|
116
123
|
{moveToJointPositions}
|
|
117
124
|
{useRadians}
|
|
118
125
|
{jointLimitsDegrees}
|
|
126
|
+
{isMoving}
|
|
119
127
|
/>
|
|
120
128
|
{/if}
|
|
121
129
|
|