@viamrobotics/test-widgets 0.17.3 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/boundary.svelte +6 -1
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +8 -1
- package/dist/components/maplibre/index.svelte +3 -2
- package/dist/components/section/section-error.svelte +52 -8
- package/dist/components/section/section-error.svelte.d.ts +2 -0
- package/dist/components/section/section-errors.svelte +10 -2
- package/dist/components/widgets/arm/arm.svelte +5 -14
- package/dist/components/widgets/arm/stop-widget.svelte +20 -0
- package/dist/components/widgets/arm/stop-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/base/base.svelte +32 -150
- package/dist/components/widgets/base/stop-widget.svelte +20 -0
- package/dist/components/widgets/base/stop-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/camera/camera.svelte +28 -10
- package/dist/components/widgets/camera/export-screenshot.svelte +12 -20
- package/dist/components/widgets/camera/export-screenshot.svelte.d.ts +2 -0
- package/dist/components/widgets/camera/live-or-polling-video.svelte +13 -12
- package/dist/components/widgets/camera/picture-in-picture-button.svelte +7 -15
- package/dist/components/widgets/custom-control/custom-control.svelte +2 -2
- package/dist/components/widgets/do-command/do-command.svelte +6 -6
- package/dist/components/widgets/gantry/move-to-position-widget.svelte +12 -8
- package/dist/components/widgets/gantry/quick-move-widget.svelte +29 -15
- package/dist/components/widgets/gripper/grab-widget.svelte +10 -3
- package/dist/components/widgets/gripper/gripper.svelte +15 -54
- package/dist/components/widgets/gripper/is-holding-something-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/gripper/open-grab-control.svelte +60 -0
- package/dist/components/widgets/gripper/open-grab-control.svelte.d.ts +9 -0
- package/dist/components/widgets/gripper/open-widget.svelte +10 -3
- package/dist/components/widgets/gripper/stop-widget.svelte +20 -0
- package/dist/components/widgets/gripper/stop-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/ml-model-service/metadata-widget.svelte +52 -0
- package/dist/components/widgets/ml-model-service/metadata-widget.svelte.d.ts +13 -0
- package/dist/components/widgets/ml-model-service/ml-model-service.svelte +9 -22
- package/dist/components/widgets/movement-sensor/movement-sensor.svelte +102 -125
- package/dist/components/widgets/operations-and-sessions/operations-and-sessions.svelte +11 -7
- package/dist/components/widgets/servo/get-position-widget.svelte +42 -0
- package/dist/components/widgets/servo/get-position-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/servo/move-widget.svelte +10 -5
- package/dist/components/widgets/servo/quick-move-widget.svelte +28 -10
- package/dist/components/widgets/servo/servo.svelte +22 -111
- package/dist/components/widgets/servo/stop-widget.svelte +20 -0
- package/dist/components/widgets/servo/stop-widget.svelte.d.ts +7 -0
- package/dist/components/widgets/switch/position-view.svelte +8 -5
- package/dist/components/widgets/switch/position.svelte +1 -5
- package/dist/components/widgets/switch/position.svelte.d.ts +0 -1
- package/dist/components/widgets/switch/switch.svelte +18 -17
- package/dist/components/widgets/vision-service/vision-service.svelte +12 -7
- package/dist/registry.d.ts +2 -2
- package/dist/registry.js +15 -5
- package/package.json +13 -13
- package/dist/components/content-rect.svelte +0 -26
- package/dist/components/content-rect.svelte.d.ts +0 -11
- package/dist/components/error.svelte +0 -71
- package/dist/components/error.svelte.d.ts +0 -15
- package/dist/components/queries.svelte +0 -97
- package/dist/components/queries.svelte.d.ts +0 -17
- package/dist/components/query.svelte +0 -29
- package/dist/components/query.svelte.d.ts +0 -15
- package/dist/components/widgets/gripper/is-holding-something.svelte.d.ts +0 -7
- /package/dist/components/widgets/gripper/{is-holding-something.svelte → is-holding-something-widget.svelte} +0 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { MLModelClient } from '@viamrobotics/sdk'
|
|
3
3
|
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
4
4
|
|
|
5
5
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
6
|
-
import Queries from '../../queries.svelte'
|
|
7
6
|
import RefetchController from '../../refetch-controller.svelte'
|
|
8
7
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
9
8
|
|
|
10
|
-
import
|
|
9
|
+
import MetadataWidget from './metadata-widget.svelte'
|
|
11
10
|
|
|
12
11
|
interface Props {
|
|
13
12
|
partID: string
|
|
@@ -29,16 +28,9 @@
|
|
|
29
28
|
() => resourceName
|
|
30
29
|
)
|
|
31
30
|
|
|
31
|
+
// Never polls. It observes the Metadata widget's cache entry so manual refresh reaches it.
|
|
32
32
|
// @ts-expect-error No resource overlap
|
|
33
|
-
const metadataQuery = createResourceQuery(client, 'metadata',
|
|
34
|
-
// Lower bound of 1Hz for getProperties, higher frequencies are wasteful.
|
|
35
|
-
refetchInterval:
|
|
36
|
-
refetchInterval.current === false
|
|
37
|
-
? false
|
|
38
|
-
: (Math.max(refetchInterval.current, 1000) as number | false),
|
|
39
|
-
}))
|
|
40
|
-
|
|
41
|
-
const metadata = $derived((metadataQuery.data as unknown as { metadata: Metadata })?.metadata)
|
|
33
|
+
const metadataQuery = createResourceQuery(client, 'metadata', { refetchInterval: false })
|
|
42
34
|
</script>
|
|
43
35
|
|
|
44
36
|
<ConnectionStatus {partID}>
|
|
@@ -51,15 +43,10 @@
|
|
|
51
43
|
/>
|
|
52
44
|
</div>
|
|
53
45
|
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<div class="p-4">
|
|
60
|
-
<ResultsTable {metadata} />
|
|
61
|
-
</div>
|
|
62
|
-
{/if}
|
|
63
|
-
</Queries>
|
|
46
|
+
<MetadataWidget
|
|
47
|
+
{partID}
|
|
48
|
+
{resourceName}
|
|
49
|
+
refetchInterval={refetchInterval.current}
|
|
50
|
+
/>
|
|
64
51
|
{/snippet}
|
|
65
52
|
</ConnectionStatus>
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
5
5
|
import { slide } from 'svelte/transition'
|
|
6
6
|
|
|
7
|
+
import ApiSection from '../../api-section.svelte'
|
|
7
8
|
import ConnectionStatus from '../../connection-status.svelte'
|
|
8
|
-
import Query from '../../query.svelte'
|
|
9
9
|
import ReadingsList from '../../readings-list.svelte'
|
|
10
10
|
import RefetchController from '../../refetch-controller.svelte'
|
|
11
11
|
import { createRefetchIntervalStore } from '../../refetch-interval-store.svelte'
|
|
12
|
-
import { Section } from '../../section'
|
|
12
|
+
import { Section, useSectionErrors } from '../../section'
|
|
13
13
|
import { ResourceTriplets } from '../../../resource-triplet'
|
|
14
14
|
|
|
15
15
|
import Accuracy from './accuracy.svelte'
|
|
@@ -85,180 +85,157 @@
|
|
|
85
85
|
enabled: showFullReadings,
|
|
86
86
|
refetchInterval: refetchInterval.current,
|
|
87
87
|
}))
|
|
88
|
+
|
|
89
|
+
const propertiesErrors = useSectionErrors(() => ({ queries: [propertiesQuery] }))
|
|
90
|
+
const readingsErrors = useSectionErrors(() => ({ queries: [readingsQuery] }))
|
|
88
91
|
</script>
|
|
89
92
|
|
|
90
93
|
<ConnectionStatus {partID}>
|
|
91
94
|
{#snippet connected()}
|
|
92
|
-
<div class="p-4">
|
|
95
|
+
<div class="flex items-center gap-2 p-4">
|
|
93
96
|
<RefetchController
|
|
94
97
|
{refetchInterval}
|
|
95
98
|
queries={[propertiesQuery, positionQuery]}
|
|
96
99
|
/>
|
|
100
|
+
<Section.Errors errors={propertiesErrors.errors} />
|
|
97
101
|
</div>
|
|
98
102
|
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
method="GetPosition"
|
|
111
|
-
api={ResourceTriplets.MovementSensor}
|
|
112
|
-
/>
|
|
113
|
-
</Section.Heading>
|
|
114
|
-
<Query
|
|
115
|
-
query={positionQuery}
|
|
116
|
-
class="h-6"
|
|
103
|
+
<Section.Body isLoading={propertiesErrors.isLoading}>
|
|
104
|
+
{#if propertiesQuery.data !== undefined}
|
|
105
|
+
<div class="@container">
|
|
106
|
+
<div class="flex flex-wrap text-xs @4xl:flex-nowrap">
|
|
107
|
+
<div class="flex w-full flex-col @4xl:w-1/4">
|
|
108
|
+
{#if propertiesQuery.data.positionSupported}
|
|
109
|
+
<ApiSection
|
|
110
|
+
method="GetPosition"
|
|
111
|
+
api={ResourceTriplets.MovementSensor}
|
|
112
|
+
queries={[positionQuery]}
|
|
113
|
+
class="flex-col gap-2"
|
|
117
114
|
>
|
|
118
115
|
{#if positionQuery.data !== undefined}
|
|
119
116
|
<Position data={positionQuery.data} />
|
|
120
117
|
{/if}
|
|
121
|
-
</
|
|
122
|
-
|
|
123
|
-
{/if}
|
|
118
|
+
</ApiSection>
|
|
119
|
+
{/if}
|
|
124
120
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/>
|
|
132
|
-
<span class="text-subtle-2 text-xs font-normal">(º)</span>
|
|
133
|
-
</Section.Heading>
|
|
134
|
-
<Query
|
|
135
|
-
query={orientationQuery}
|
|
136
|
-
class="h-6"
|
|
121
|
+
{#if propertiesQuery.data.orientationSupported}
|
|
122
|
+
<ApiSection
|
|
123
|
+
method="GetOrientation"
|
|
124
|
+
api={ResourceTriplets.MovementSensor}
|
|
125
|
+
queries={[orientationQuery]}
|
|
126
|
+
class="flex-col gap-2"
|
|
137
127
|
>
|
|
128
|
+
{#snippet subheading()}
|
|
129
|
+
<span class="text-subtle-2 text-xs font-normal">(º)</span>
|
|
130
|
+
{/snippet}
|
|
138
131
|
{#if orientationQuery.data !== undefined}
|
|
139
132
|
<Orientation data={orientationQuery.data} />
|
|
140
133
|
{/if}
|
|
141
|
-
</
|
|
142
|
-
|
|
143
|
-
{/if}
|
|
134
|
+
</ApiSection>
|
|
135
|
+
{/if}
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/>
|
|
152
|
-
<span class="text-subtle-2 text-xs font-normal">(º)</span>
|
|
153
|
-
</Section.Heading>
|
|
154
|
-
<Query
|
|
155
|
-
query={compassHeadingQuery}
|
|
156
|
-
class="h-6"
|
|
137
|
+
{#if propertiesQuery.data.compassHeadingSupported}
|
|
138
|
+
<ApiSection
|
|
139
|
+
method="GetCompassHeading"
|
|
140
|
+
api={ResourceTriplets.MovementSensor}
|
|
141
|
+
queries={[compassHeadingQuery]}
|
|
142
|
+
class="flex-col gap-2"
|
|
157
143
|
>
|
|
144
|
+
{#snippet subheading()}
|
|
145
|
+
<span class="text-subtle-2 text-xs font-normal">(º)</span>
|
|
146
|
+
{/snippet}
|
|
158
147
|
{#if compassHeadingQuery.data !== undefined}
|
|
159
148
|
<CompassHeading data={compassHeadingQuery.data} />
|
|
160
149
|
{/if}
|
|
161
|
-
</
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
</div>
|
|
150
|
+
</ApiSection>
|
|
151
|
+
{/if}
|
|
152
|
+
</div>
|
|
165
153
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
/>
|
|
174
|
-
<span class="text-subtle-2 text-xs font-normal">(º/s)</span>
|
|
175
|
-
</Section.Heading>
|
|
176
|
-
<Query
|
|
177
|
-
query={angularVelocityQuery}
|
|
178
|
-
class="h-6"
|
|
154
|
+
<div class="flex w-full flex-col @4xl:w-1/4">
|
|
155
|
+
{#if propertiesQuery.data.angularVelocitySupported}
|
|
156
|
+
<ApiSection
|
|
157
|
+
method="GetAngularVelocity"
|
|
158
|
+
api={ResourceTriplets.MovementSensor}
|
|
159
|
+
queries={[angularVelocityQuery]}
|
|
160
|
+
class="flex-col gap-2"
|
|
179
161
|
>
|
|
162
|
+
{#snippet subheading()}
|
|
163
|
+
<span class="text-subtle-2 text-xs font-normal">(º/s)</span>
|
|
164
|
+
{/snippet}
|
|
180
165
|
{#if angularVelocityQuery.data !== undefined}
|
|
181
166
|
<Vector3 data={angularVelocityQuery.data} />
|
|
182
167
|
{/if}
|
|
183
|
-
</
|
|
184
|
-
|
|
185
|
-
{/if}
|
|
168
|
+
</ApiSection>
|
|
169
|
+
{/if}
|
|
186
170
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/>
|
|
194
|
-
<span class="text-subtle-2 text-xs font-normal">(m/s)</span>
|
|
195
|
-
</Section.Heading>
|
|
196
|
-
<Query
|
|
197
|
-
query={linearVelocityQuery}
|
|
198
|
-
class="h-6"
|
|
171
|
+
{#if propertiesQuery.data.linearVelocitySupported}
|
|
172
|
+
<ApiSection
|
|
173
|
+
method="GetLinearVelocity"
|
|
174
|
+
api={ResourceTriplets.MovementSensor}
|
|
175
|
+
queries={[linearVelocityQuery]}
|
|
176
|
+
class="flex-col gap-2"
|
|
199
177
|
>
|
|
178
|
+
{#snippet subheading()}
|
|
179
|
+
<span class="text-subtle-2 text-xs font-normal">(m/s)</span>
|
|
180
|
+
{/snippet}
|
|
200
181
|
{#if linearVelocityQuery.data !== undefined}
|
|
201
182
|
<Vector3 data={linearVelocityQuery.data} />
|
|
202
183
|
{/if}
|
|
203
|
-
</
|
|
204
|
-
|
|
205
|
-
{/if}
|
|
184
|
+
</ApiSection>
|
|
185
|
+
{/if}
|
|
206
186
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
/>
|
|
214
|
-
<span class="text-subtle-2 text-xs font-normal">(m/s<sup>2</sup>)</span>
|
|
215
|
-
</Section.Heading>
|
|
216
|
-
<Query
|
|
217
|
-
query={linearAccelerationQuery}
|
|
218
|
-
class="h-6"
|
|
187
|
+
{#if propertiesQuery.data.linearAccelerationSupported}
|
|
188
|
+
<ApiSection
|
|
189
|
+
method="GetLinearAcceleration"
|
|
190
|
+
api={ResourceTriplets.MovementSensor}
|
|
191
|
+
queries={[linearAccelerationQuery]}
|
|
192
|
+
class="flex-col gap-2"
|
|
219
193
|
>
|
|
194
|
+
{#snippet subheading()}
|
|
195
|
+
<span class="text-subtle-2 text-xs font-normal">(m/s<sup>2</sup>)</span>
|
|
196
|
+
{/snippet}
|
|
220
197
|
{#if linearAccelerationQuery.data !== undefined}
|
|
221
198
|
<Vector3 data={linearAccelerationQuery.data} />
|
|
222
199
|
{/if}
|
|
223
|
-
</
|
|
224
|
-
|
|
225
|
-
{/if}
|
|
200
|
+
</ApiSection>
|
|
201
|
+
{/if}
|
|
226
202
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
/>
|
|
233
|
-
</Section.Heading>
|
|
234
|
-
<Query
|
|
235
|
-
query={accuracyQuery}
|
|
236
|
-
class="h-6"
|
|
203
|
+
<ApiSection
|
|
204
|
+
method="GetAccuracy"
|
|
205
|
+
api={ResourceTriplets.MovementSensor}
|
|
206
|
+
queries={[accuracyQuery]}
|
|
207
|
+
class="flex-col gap-2"
|
|
237
208
|
>
|
|
238
209
|
{#if accuracyQuery.data !== undefined}
|
|
239
210
|
<Accuracy data={accuracyQuery.data} />
|
|
240
211
|
{/if}
|
|
241
|
-
</
|
|
212
|
+
</ApiSection>
|
|
242
213
|
</div>
|
|
243
|
-
</div>
|
|
244
214
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
215
|
+
{#if propertiesQuery.data.positionSupported}
|
|
216
|
+
<Map
|
|
217
|
+
coordinate={positionQuery.data?.coordinate}
|
|
218
|
+
rotation={orientationQuery.data?.oZ}
|
|
219
|
+
/>
|
|
220
|
+
{/if}
|
|
221
|
+
</div>
|
|
251
222
|
</div>
|
|
252
|
-
|
|
253
|
-
</
|
|
223
|
+
{/if}
|
|
224
|
+
</Section.Body>
|
|
254
225
|
|
|
255
|
-
<
|
|
226
|
+
<Section
|
|
227
|
+
errorReporter={readingsErrors}
|
|
228
|
+
class="flex-col gap-4"
|
|
229
|
+
>
|
|
256
230
|
<div class="flex flex-col gap-0.5">
|
|
257
231
|
<Section.Heading>
|
|
258
232
|
<Section.Method
|
|
259
233
|
method="GetReadings"
|
|
260
234
|
api={ResourceTriplets.MovementSensor}
|
|
261
235
|
/>
|
|
236
|
+
{#snippet aside()}
|
|
237
|
+
<Section.Errors errors={readingsErrors.errors} />
|
|
238
|
+
{/snippet}
|
|
262
239
|
</Section.Heading>
|
|
263
240
|
<p class="text-subtle-2 text-xs">Get all the measurements and data from the sensor</p>
|
|
264
241
|
</div>
|
|
@@ -270,13 +247,13 @@
|
|
|
270
247
|
|
|
271
248
|
{#if showFullReadings}
|
|
272
249
|
<div transition:slide={{ duration: 150 }}>
|
|
273
|
-
<
|
|
250
|
+
<Section.Body isLoading={readingsErrors.isLoading}>
|
|
274
251
|
{#if readingsQuery.data !== undefined}
|
|
275
252
|
<ReadingsList data={readingsQuery.data} />
|
|
276
253
|
{/if}
|
|
277
|
-
</
|
|
254
|
+
</Section.Body>
|
|
278
255
|
</div>
|
|
279
256
|
{/if}
|
|
280
|
-
</
|
|
257
|
+
</Section>
|
|
281
258
|
{/snippet}
|
|
282
259
|
</ConnectionStatus>
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import { createRobotMutation, createRobotQuery, useRobotClient } from '@viamrobotics/svelte-sdk'
|
|
4
4
|
import { slide } from 'svelte/transition'
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import { Section } from '../../section'
|
|
6
|
+
import { Section, useSectionErrors } from '../../section'
|
|
8
7
|
|
|
9
8
|
import OperationsTable from './operations-table.svelte'
|
|
10
9
|
import RttPill from './rtt-pill.svelte'
|
|
@@ -29,6 +28,11 @@
|
|
|
29
28
|
enabled: !isCollapsed,
|
|
30
29
|
}))
|
|
31
30
|
|
|
31
|
+
const sectionErrors = useSectionErrors(() => ({
|
|
32
|
+
queries: [operationsQuery, sessionsQuery],
|
|
33
|
+
mutations: [cancelOperationMutation],
|
|
34
|
+
}))
|
|
35
|
+
|
|
32
36
|
let rtt = $state(0)
|
|
33
37
|
let then = Date.now()
|
|
34
38
|
|
|
@@ -54,9 +58,9 @@
|
|
|
54
58
|
class="fixed bottom-0 z-10 w-full bg-white"
|
|
55
59
|
aria-labelledby={headingID}
|
|
56
60
|
>
|
|
57
|
-
<header>
|
|
61
|
+
<header class="border-light bg-extralight flex h-8 items-center border-y">
|
|
58
62
|
<button
|
|
59
|
-
class="group
|
|
63
|
+
class="group flex grow items-center gap-2 self-stretch px-2"
|
|
60
64
|
aria-controls={collapseID}
|
|
61
65
|
aria-label={`${isCollapsed ? 'Expand' : 'Collapse'} Operations and Sessions`}
|
|
62
66
|
aria-expanded={!isCollapsed}
|
|
@@ -78,6 +82,9 @@
|
|
|
78
82
|
<RttPill {rtt} />
|
|
79
83
|
{/if}
|
|
80
84
|
</button>
|
|
85
|
+
<div class="px-2">
|
|
86
|
+
<Section.Errors errors={sectionErrors.errors} />
|
|
87
|
+
</div>
|
|
81
88
|
</header>
|
|
82
89
|
|
|
83
90
|
{#if !isCollapsed}
|
|
@@ -98,8 +105,6 @@
|
|
|
98
105
|
{cancelOperation}
|
|
99
106
|
/>
|
|
100
107
|
{/if}
|
|
101
|
-
<ErrorDisplay lastError={operationsQuery.error} />
|
|
102
|
-
<Section.Error error={cancelOperationMutation.error} />
|
|
103
108
|
</div>
|
|
104
109
|
<div class="flex h-max flex-col gap-2">
|
|
105
110
|
<span class="text-default text-sm font-semibold">Sessions</span>
|
|
@@ -109,7 +114,6 @@
|
|
|
109
114
|
ourSessionId={client.current?.sessionId}
|
|
110
115
|
/>
|
|
111
116
|
{/if}
|
|
112
|
-
<ErrorDisplay lastError={sessionsQuery.error} />
|
|
113
117
|
</div>
|
|
114
118
|
</div>
|
|
115
119
|
{/if}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ServoClient } from '@viamrobotics/sdk'
|
|
3
|
+
import { createResourceClient, createResourceQuery } from '@viamrobotics/svelte-sdk'
|
|
4
|
+
|
|
5
|
+
import ApiSection from '../../api-section.svelte'
|
|
6
|
+
import { Section } from '../../section'
|
|
7
|
+
import { formatNumeric } from '../../../format'
|
|
8
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
partID: string
|
|
12
|
+
resourceName: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { partID, resourceName }: Props = $props()
|
|
16
|
+
|
|
17
|
+
const client = createResourceClient(
|
|
18
|
+
ServoClient,
|
|
19
|
+
() => partID,
|
|
20
|
+
() => resourceName
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const positionQuery = createResourceQuery(client, 'getPosition', {
|
|
24
|
+
refetchInterval: 500,
|
|
25
|
+
})
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<ApiSection
|
|
29
|
+
class="grow flex-col gap-4"
|
|
30
|
+
method="GetPosition"
|
|
31
|
+
api={ResourceTriplets.Servo}
|
|
32
|
+
queries={[positionQuery]}
|
|
33
|
+
>
|
|
34
|
+
{#if positionQuery.data !== undefined}
|
|
35
|
+
<!-- span required to get unit closer to position reading -->
|
|
36
|
+
<span class="flex flex-row gap-1">
|
|
37
|
+
<span class="font-roboto-mono font-normal">{formatNumeric(positionQuery.data)}</span>
|
|
38
|
+
<abbr class="text-subtle-2">º</abbr>
|
|
39
|
+
</span>
|
|
40
|
+
{/if}
|
|
41
|
+
<Section.Text class="mt-auto">Updates automatically</Section.Text>
|
|
42
|
+
</ApiSection>
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
createResourceQuery,
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
9
|
+
import ApiSection from '../../api-section.svelte'
|
|
10
|
+
import { ResourceTriplets } from '../../../resource-triplet'
|
|
11
11
|
|
|
12
12
|
import Move from './move.svelte'
|
|
13
13
|
|
|
@@ -34,12 +34,17 @@
|
|
|
34
34
|
}
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
|
-
<
|
|
37
|
+
<ApiSection
|
|
38
|
+
class="grow flex-col gap-4"
|
|
39
|
+
method="Move"
|
|
40
|
+
api={ResourceTriplets.Servo}
|
|
41
|
+
queries={[positionQuery]}
|
|
42
|
+
mutations={[moveMutation]}
|
|
43
|
+
>
|
|
38
44
|
{#if positionQuery.data !== undefined}
|
|
39
45
|
<Move
|
|
40
46
|
currentPosition={positionQuery.data}
|
|
41
47
|
{moveTo}
|
|
42
48
|
/>
|
|
43
49
|
{/if}
|
|
44
|
-
</
|
|
45
|
-
<Section.Error error={moveMutation.error} />
|
|
50
|
+
</ApiSection>
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
createResourceQuery,
|
|
7
7
|
} from '@viamrobotics/svelte-sdk'
|
|
8
8
|
|
|
9
|
-
import Query from '../../query.svelte'
|
|
10
9
|
import { Section } from '../../section'
|
|
10
|
+
import { useSectionErrors } from '../../section/use-section-errors.svelte'
|
|
11
11
|
|
|
12
12
|
import QuickMove from './quick-move.svelte'
|
|
13
13
|
|
|
@@ -29,17 +29,35 @@
|
|
|
29
29
|
})
|
|
30
30
|
const quickMoveMutation = createResourceMutation(client, 'move')
|
|
31
31
|
|
|
32
|
+
const quickMoveErrors = useSectionErrors(() => ({
|
|
33
|
+
queries: [positionQuery],
|
|
34
|
+
mutations: [quickMoveMutation],
|
|
35
|
+
}))
|
|
36
|
+
|
|
32
37
|
const quickMoveTo = (angle: number) => {
|
|
33
38
|
quickMoveMutation.mutate([angle], {})
|
|
34
39
|
}
|
|
35
40
|
</script>
|
|
36
41
|
|
|
37
|
-
<
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<Section.
|
|
42
|
+
<Section
|
|
43
|
+
errorReporter={quickMoveErrors}
|
|
44
|
+
class="grow flex-col gap-4"
|
|
45
|
+
>
|
|
46
|
+
<div class="flex flex-col gap-0.5">
|
|
47
|
+
<Section.Heading>
|
|
48
|
+
Quick move
|
|
49
|
+
{#snippet aside()}
|
|
50
|
+
<Section.Errors errors={quickMoveErrors.errors} />
|
|
51
|
+
{/snippet}
|
|
52
|
+
</Section.Heading>
|
|
53
|
+
</div>
|
|
54
|
+
<Section.Body isLoading={quickMoveErrors.isLoading}>
|
|
55
|
+
{#if positionQuery.data !== undefined}
|
|
56
|
+
<QuickMove
|
|
57
|
+
currentPosition={positionQuery.data}
|
|
58
|
+
moveTo={quickMoveTo}
|
|
59
|
+
/>
|
|
60
|
+
{/if}
|
|
61
|
+
<Section.Text class="mt-auto">Press a button to execute</Section.Text>
|
|
62
|
+
</Section.Body>
|
|
63
|
+
</Section>
|