@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
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
import ApiSection from '../../api-section.svelte'
|
|
10
10
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
11
11
|
import IsMoving from '../../is-moving.svelte'
|
|
12
|
-
import
|
|
12
|
+
import { Section } from '../../section'
|
|
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,41 +71,36 @@
|
|
|
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
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<Query query={jointPositionsQuery}>
|
|
72
|
-
{#if jointPositionsQuery.data}
|
|
73
|
-
<GetJointPositions positions={jointPositionsQuery.data.values} />
|
|
74
|
-
{/if}
|
|
75
|
-
</Query>
|
|
76
|
-
</ApiSection>
|
|
77
|
-
<ApiSection
|
|
78
|
-
title="MoveToJointPositions"
|
|
79
|
-
api="rdk:component:arm"
|
|
74
|
+
class="grow flex-col gap-4"
|
|
75
|
+
method="GetJointPositions"
|
|
76
|
+
api={ResourceTriplets.Arm}
|
|
77
|
+
queries={[jointPositionsQuery]}
|
|
80
78
|
>
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{moveToJointPositions}
|
|
86
|
-
lastError={moveToJointPosMutation.error}
|
|
87
|
-
{jointLimitsDegrees}
|
|
88
|
-
isMoving={isMovingQuery.data ?? false}
|
|
89
|
-
/>
|
|
90
|
-
{/if}
|
|
91
|
-
</Query>
|
|
79
|
+
{#if jointPositionsQuery.data}
|
|
80
|
+
<GetJointPositions positions={jointPositionsQuery.data.values} />
|
|
81
|
+
{/if}
|
|
82
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
92
83
|
</ApiSection>
|
|
93
84
|
<ApiSection
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
class="grow flex-col gap-4"
|
|
86
|
+
method="MoveToJointPositions"
|
|
87
|
+
api={ResourceTriplets.Arm}
|
|
88
|
+
queries={[jointPositionsQuery, kinematicsQuery]}
|
|
89
|
+
mutations={[moveToJointPosMutation]}
|
|
96
90
|
>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
{#if jointPositionsQuery.data}
|
|
92
|
+
<MoveToJointPositions
|
|
93
|
+
positions={jointPositionsQuery.data.values}
|
|
94
|
+
{moveToJointPositions}
|
|
95
|
+
{jointLimitsDegrees}
|
|
96
|
+
isMoving={motionTracking.isTracking}
|
|
97
|
+
/>
|
|
98
|
+
{/if}
|
|
101
99
|
</ApiSection>
|
|
100
|
+
<MoveToPositionControl
|
|
101
|
+
{partID}
|
|
102
|
+
{resourceName}
|
|
103
|
+
/>
|
|
102
104
|
</div>
|
|
103
105
|
|
|
104
106
|
<!-- Control actions sidebar -->
|
|
@@ -106,11 +108,12 @@
|
|
|
106
108
|
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
109
|
>
|
|
108
110
|
<ApiSection
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
class="grow flex-col gap-4"
|
|
112
|
+
method="Stop"
|
|
113
|
+
api={ResourceTriplets.Arm}
|
|
114
|
+
mutations={[stopMutation]}
|
|
111
115
|
>
|
|
112
116
|
<StopButton
|
|
113
|
-
error={stopMutation.error}
|
|
114
117
|
onStop={() => {
|
|
115
118
|
stopMutation.mutate([], {})
|
|
116
119
|
}}
|
|
@@ -118,7 +121,7 @@
|
|
|
118
121
|
</ApiSection>
|
|
119
122
|
<IsMoving
|
|
120
123
|
client={ArmClient}
|
|
121
|
-
api=
|
|
124
|
+
api={ResourceTriplets.Arm}
|
|
122
125
|
{partID}
|
|
123
126
|
{resourceName}
|
|
124
127
|
/>
|
|
@@ -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 GetJointPositions from './get-joint-positions.svelte'
|
|
9
10
|
|
|
@@ -24,13 +25,13 @@
|
|
|
24
25
|
</script>
|
|
25
26
|
|
|
26
27
|
<ApiSection
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
method="GetJointPositions"
|
|
29
|
+
api={ResourceTriplets.Arm}
|
|
30
|
+
queries={[query]}
|
|
31
|
+
class="grow flex-col gap-4"
|
|
30
32
|
>
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</Query>
|
|
33
|
+
{#if query.data}
|
|
34
|
+
<GetJointPositions positions={query.data.values} />
|
|
35
|
+
{/if}
|
|
36
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
36
37
|
</ApiSection>
|
|
@@ -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,9 @@
|
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
9
|
import ApiSection from '../../api-section.svelte'
|
|
10
|
+
import { Section } from '../../section'
|
|
11
|
+
import { useSectionErrors } from '../../section/use-section-errors.svelte'
|
|
12
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
10
13
|
|
|
11
14
|
import ManualMode from './manual-mode.svelte'
|
|
12
15
|
|
|
@@ -35,6 +38,12 @@
|
|
|
35
38
|
|
|
36
39
|
const setManualModeMutation = createResourceMutation(client, 'setManualMode')
|
|
37
40
|
|
|
41
|
+
// The band renders no ApiSection, so it reads the same sources through the errors indicator.
|
|
42
|
+
const bandErrors = useSectionErrors(() => ({
|
|
43
|
+
queries: [propertiesQuery, manualModeQuery],
|
|
44
|
+
mutations: [setManualModeMutation],
|
|
45
|
+
}))
|
|
46
|
+
|
|
38
47
|
const setManualMode = (manualMode: boolean, enabledFor: number) => {
|
|
39
48
|
setManualModeMutation.mutate([manualMode, enabledFor], {})
|
|
40
49
|
}
|
|
@@ -44,27 +53,28 @@
|
|
|
44
53
|
{#if band}
|
|
45
54
|
<section
|
|
46
55
|
aria-label="SetManualMode"
|
|
47
|
-
class="border-b px-4 py-3"
|
|
56
|
+
class="flex items-start justify-between gap-2 border-b px-4 py-3"
|
|
48
57
|
>
|
|
49
58
|
<ManualMode
|
|
50
59
|
title="ManualMode"
|
|
51
60
|
isManualMode={manualModeQuery.data ?? false}
|
|
52
61
|
isPending={setManualModeMutation.isPending}
|
|
53
62
|
{setManualMode}
|
|
54
|
-
lastError={setManualModeMutation.error}
|
|
55
63
|
/>
|
|
64
|
+
<Section.Errors errors={bandErrors.errors} />
|
|
56
65
|
</section>
|
|
57
66
|
{:else}
|
|
58
67
|
<ApiSection
|
|
59
|
-
|
|
60
|
-
api=
|
|
61
|
-
|
|
68
|
+
method="SetManualMode"
|
|
69
|
+
api={ResourceTriplets.Arm}
|
|
70
|
+
queries={[propertiesQuery, manualModeQuery]}
|
|
71
|
+
mutations={[setManualModeMutation]}
|
|
72
|
+
class="grow flex-col gap-4"
|
|
62
73
|
>
|
|
63
74
|
<ManualMode
|
|
64
75
|
isManualMode={manualModeQuery.data ?? false}
|
|
65
76
|
isPending={setManualModeMutation.isPending}
|
|
66
77
|
{setManualMode}
|
|
67
|
-
lastError={setManualModeMutation.error}
|
|
68
78
|
/>
|
|
69
79
|
</ApiSection>
|
|
70
80
|
{/if}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Button, Icon, Label, NumericInput, Tooltip } from '@viamrobotics/prime-core'
|
|
3
3
|
|
|
4
|
-
import ErrorDisplay from '../../error.svelte'
|
|
5
4
|
import StatusPill from '../../status-pill.svelte'
|
|
6
5
|
import { numberValueFromEvent } from '../../../event-handlers'
|
|
7
6
|
|
|
@@ -12,11 +11,10 @@
|
|
|
12
11
|
title?: string
|
|
13
12
|
isManualMode: boolean
|
|
14
13
|
isPending: boolean
|
|
15
|
-
lastError: Error | null
|
|
16
14
|
setManualMode: (manualMode: boolean, enabledFor: number) => void
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
const { title, isManualMode, isPending, setManualMode
|
|
17
|
+
const { title, isManualMode, isPending, setManualMode }: Props = $props()
|
|
20
18
|
|
|
21
19
|
let enabledFor = $state(90)
|
|
22
20
|
let enableAfter = $state(5)
|
|
@@ -147,6 +145,4 @@
|
|
|
147
145
|
Manual mode puts the arm into gravity compensation or servo release mode so the arm can be moved
|
|
148
146
|
by hand.
|
|
149
147
|
</p>
|
|
150
|
-
|
|
151
|
-
<ErrorDisplay {lastError} />
|
|
152
148
|
</div>
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
createResourceQuery,
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import ApiSection from '../../api-section.svelte'
|
|
10
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
10
11
|
|
|
11
12
|
import { getJointPositionLimits, type KinematicsJSON } from './joint-position-limits'
|
|
12
13
|
import MoveToJointPositions from './move-to-joint-positions.svelte'
|
|
14
|
+
import { useArmMotionTracking } from './use-arm-motion-tracking.svelte'
|
|
13
15
|
|
|
14
16
|
interface Props {
|
|
15
17
|
partID: string
|
|
@@ -24,15 +26,21 @@
|
|
|
24
26
|
() => resourceName
|
|
25
27
|
)
|
|
26
28
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
+
const moveToJointPosMutation = createResourceMutation(client, 'moveToJointPositions')
|
|
30
|
+
|
|
31
|
+
const motionTracking = useArmMotionTracking(client, {
|
|
32
|
+
isMovePending: () => moveToJointPosMutation.isPending,
|
|
33
|
+
refetchPosition: () => jointPositionsQuery.refetch(),
|
|
29
34
|
})
|
|
35
|
+
|
|
36
|
+
const jointPositionsQuery = createResourceQuery(client, 'getJointPositions', () => ({
|
|
37
|
+
refetchInterval: motionTracking.refetchInterval,
|
|
38
|
+
}))
|
|
39
|
+
|
|
30
40
|
const kinematicsQuery = createResourceQuery(client, 'getKinematics', {
|
|
31
41
|
refetchInterval: 500,
|
|
32
42
|
})
|
|
33
43
|
|
|
34
|
-
const moveToJointPosMutation = createResourceMutation(client, 'moveToJointPositions')
|
|
35
|
-
|
|
36
44
|
const moveToJointPositions = async (jointPositionsList: number[]) => {
|
|
37
45
|
await moveToJointPosMutation.mutateAsync([jointPositionsList])
|
|
38
46
|
}
|
|
@@ -42,13 +50,19 @@
|
|
|
42
50
|
)
|
|
43
51
|
</script>
|
|
44
52
|
|
|
45
|
-
<
|
|
53
|
+
<ApiSection
|
|
54
|
+
method="MoveToJointPositions"
|
|
55
|
+
api={ResourceTriplets.Arm}
|
|
56
|
+
queries={[jointPositionsQuery, kinematicsQuery]}
|
|
57
|
+
mutations={[moveToJointPosMutation]}
|
|
58
|
+
class="grow flex-col gap-4"
|
|
59
|
+
>
|
|
46
60
|
{#if jointPositionsQuery.data}
|
|
47
61
|
<MoveToJointPositions
|
|
48
62
|
positions={jointPositionsQuery.data.values}
|
|
49
63
|
{moveToJointPositions}
|
|
50
|
-
lastError={moveToJointPosMutation.error}
|
|
51
64
|
{jointLimitsDegrees}
|
|
65
|
+
isMoving={motionTracking.isTracking}
|
|
52
66
|
/>
|
|
53
67
|
{/if}
|
|
54
|
-
</
|
|
68
|
+
</ApiSection>
|
|
@@ -3,37 +3,36 @@
|
|
|
3
3
|
|
|
4
4
|
import AngleUnitToggle from '../../angle-unit-toggle.svelte'
|
|
5
5
|
import CopyButton from '../../copy-button.svelte'
|
|
6
|
-
import ErrorDisplay from '../../error.svelte'
|
|
7
6
|
import PasteButton from '../../paste-button.svelte'
|
|
8
7
|
import { degreesToRadians, formatNumeric, radiansToDegrees } from '../../../format'
|
|
9
8
|
|
|
10
9
|
import JointPositionEditor from './joint-position-editor.svelte'
|
|
11
10
|
import JointPositionJogging from './joint-position-jogging.svelte'
|
|
12
11
|
import { type JointLimit } from './joint-position-limits'
|
|
12
|
+
import { useEditedTargets } from './use-edited-targets.svelte'
|
|
13
13
|
|
|
14
14
|
type ControlMode = 'Jogging' | 'Joint Positions'
|
|
15
15
|
|
|
16
16
|
const CONTROL_MODES: ControlMode[] = ['Jogging', 'Joint Positions']
|
|
17
17
|
|
|
18
|
+
// Tight enough to catch a real move, loose enough to ignore encoder noise.
|
|
19
|
+
const JOINT_DRIFT_DEGREES = 0.5
|
|
20
|
+
|
|
18
21
|
interface Props {
|
|
19
22
|
positions: number[]
|
|
20
23
|
/** Sends the move. Rejects when it fails. */
|
|
21
24
|
moveToJointPositions: (jointPositions: number[]) => Promise<void>
|
|
22
|
-
lastError: Error | null
|
|
23
25
|
jointLimitsDegrees: JointLimit[]
|
|
24
26
|
isMoving?: boolean
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const {
|
|
28
|
-
positions,
|
|
29
|
-
moveToJointPositions,
|
|
30
|
-
lastError,
|
|
31
|
-
jointLimitsDegrees,
|
|
32
|
-
isMoving = false,
|
|
33
|
-
}: Props = $props()
|
|
29
|
+
const { positions, moveToJointPositions, jointLimitsDegrees, isMoving = false }: Props = $props()
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const targets = useEditedTargets<number>(
|
|
32
|
+
(index) => positions[index] ?? 0,
|
|
33
|
+
() => JOINT_DRIFT_DEGREES
|
|
34
|
+
)
|
|
35
|
+
const desiredPositions = $derived(positions.map((_, index) => targets.target(index))) // in degrees
|
|
37
36
|
let useRadians = $state(false)
|
|
38
37
|
let controlMode = $state<ControlMode>('Jogging')
|
|
39
38
|
|
|
@@ -57,10 +56,10 @@
|
|
|
57
56
|
const handlePaste = (data: string): boolean => {
|
|
58
57
|
try {
|
|
59
58
|
const parsed = JSON.parse(data) as number[]
|
|
60
|
-
|
|
59
|
+
for (const [index, pos] of parsed.slice(0, positions.length).entries()) {
|
|
61
60
|
const degrees = useRadians ? radiansToDegrees(pos) : pos
|
|
62
|
-
|
|
63
|
-
}
|
|
61
|
+
targets.edit(index, Math.min(Math.max(degrees, getJointMin(index)), getJointMax(index)))
|
|
62
|
+
}
|
|
64
63
|
} catch {
|
|
65
64
|
return false
|
|
66
65
|
}
|
|
@@ -111,13 +110,12 @@
|
|
|
111
110
|
/>
|
|
112
111
|
{:else}
|
|
113
112
|
<JointPositionEditor
|
|
114
|
-
|
|
113
|
+
{targets}
|
|
115
114
|
{positions}
|
|
116
115
|
{moveToJointPositions}
|
|
117
116
|
{useRadians}
|
|
118
117
|
{jointLimitsDegrees}
|
|
118
|
+
{isMoving}
|
|
119
119
|
/>
|
|
120
120
|
{/if}
|
|
121
|
-
|
|
122
|
-
<ErrorDisplay {lastError} />
|
|
123
121
|
</div>
|