Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silent-frames-render.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@viamrobotics/motion-tools': patch
---

Fetch geometries from generic components
22 changes: 21 additions & 1 deletion src/lib/hooks/useGeometries.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ArmClient, BaseClient, CameraClient, GantryClient, GripperClient } from '@viamrobotics/sdk'
import {
ArmClient,
BaseClient,
CameraClient,
GantryClient,
GenericComponentClient,
GripperClient,
} from '@viamrobotics/sdk'
import {
createResourceClient,
createResourceQuery,
Expand Down Expand Up @@ -37,6 +44,7 @@ export const provideGeometries = (partID: () => string) => {
const cameras = useResourceNames(partID, 'camera')
const grippers = useResourceNames(partID, 'gripper')
const gantries = useResourceNames(partID, 'gantry')
const generics = useResourceNames(partID, 'generic')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any issues with this and generic services?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, but is this a shortcoming of the svelte sdk that i can't filter by anything other than subtype?


const settings = useSettings()
const { refreshRates } = $derived(settings.current)
Expand All @@ -58,6 +66,11 @@ export const provideGeometries = (partID: () => string) => {
const gantryClients = $derived(
gantries.current.map((gantry) => createResourceClient(GantryClient, partID, () => gantry.name))
)
const genericClients = $derived(
generics.current
.filter((generic) => generic.type === 'component')
.map((generic) => createResourceClient(GenericComponentClient, partID, () => generic.name))
)

const interval = $derived(refreshRates[RefreshRates.poses])

Expand Down Expand Up @@ -96,13 +109,20 @@ export const provideGeometries = (partID: () => string) => {
[client.current?.name, createResourceQuery(client, 'getGeometries', () => options)] as const
)
)
const genericQueries = $derived(
genericClients.map(
(client) =>
[client.current?.name, createResourceQuery(client, 'getGeometries', () => options)] as const
)
)

const queries = $derived([
...armQueries,
...baseQueries,
...gripperQueries,
...cameraQueries,
...gantryQueries,
...genericQueries,
])

$effect(() => {
Expand Down
Loading