@viamrobotics/motion-tools 1.1.3 → 1.1.4
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/color.js +3 -3
- package/dist/components/SceneProviders.svelte +0 -2
- package/dist/components/Tree/Settings.svelte +0 -19
- package/dist/hooks/usePose.svelte.d.ts +4 -0
- package/dist/hooks/usePose.svelte.js +4 -6
- package/package.json +5 -6
- package/dist/hooks/useMotionClient.svelte.d.ts +0 -8
- package/dist/hooks/useMotionClient.svelte.js +0 -32
package/dist/color.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Color } from 'three';
|
|
2
2
|
import twColors from 'tailwindcss/colors';
|
|
3
|
-
import { isNumber } from 'lodash-es';
|
|
4
3
|
import { ResourceName } from '@viamrobotics/sdk';
|
|
5
4
|
// Step 3: linear sRGB → sRGB
|
|
6
5
|
const linearToSrgb = (x) => {
|
|
@@ -104,7 +103,7 @@ export const isRGB = (color) => {
|
|
|
104
103
|
!('b' in color)) {
|
|
105
104
|
return false;
|
|
106
105
|
}
|
|
107
|
-
return
|
|
106
|
+
return typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number';
|
|
108
107
|
};
|
|
109
108
|
export const parseRGB = (color, defaultColor = { r: 0, g: 0, b: 0 }) => {
|
|
110
109
|
if (!isRGB(color))
|
|
@@ -112,8 +111,9 @@ export const parseRGB = (color, defaultColor = { r: 0, g: 0, b: 0 }) => {
|
|
|
112
111
|
return new Color().setRGB(color.r > 1 ? color.r / 255 : color.r, color.g > 1 ? color.g / 255 : color.g, color.b > 1 ? color.b / 255 : color.b);
|
|
113
112
|
};
|
|
114
113
|
export const parseOpacity = (opacity, defaultOpacity = 1) => {
|
|
115
|
-
if (
|
|
114
|
+
if (typeof opacity !== 'number') {
|
|
116
115
|
return defaultOpacity;
|
|
116
|
+
}
|
|
117
117
|
return opacity > 1 ? opacity / 100 : opacity;
|
|
118
118
|
};
|
|
119
119
|
const isColor = (color) => {
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
provideTransformControls,
|
|
14
14
|
type CameraPose,
|
|
15
15
|
} from '../hooks/useControls.svelte'
|
|
16
|
-
import { provideMotionClient } from '../hooks/useMotionClient.svelte'
|
|
17
16
|
import { provideLogs } from '../hooks/useLogs.svelte'
|
|
18
17
|
import { provideOrigin } from './xr/useOrigin.svelte'
|
|
19
18
|
import { provideWorldStates } from '../hooks/useWorldState.svelte'
|
|
@@ -45,7 +44,6 @@
|
|
|
45
44
|
provideGeometries(() => partID.current)
|
|
46
45
|
provide3DModels(() => partID.current)
|
|
47
46
|
providePointclouds(() => partID.current)
|
|
48
|
-
provideMotionClient(() => partID.current)
|
|
49
47
|
provideArmClient(() => partID.current)
|
|
50
48
|
provideWorldStates()
|
|
51
49
|
provideFramelessComponents()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Select, Switch, Input } from '@viamrobotics/prime-core'
|
|
3
3
|
import RefreshRate from '../RefreshRate.svelte'
|
|
4
|
-
import { useMotionClient } from '../../hooks/useMotionClient.svelte'
|
|
5
4
|
import Drawer from './Drawer.svelte'
|
|
6
5
|
import { useSettings } from '../../hooks/useSettings.svelte'
|
|
7
6
|
import { useResourceNames } from '@viamrobotics/svelte-sdk'
|
|
@@ -19,10 +18,8 @@
|
|
|
19
18
|
const cameras = useResourceNames(() => partID.current, 'camera')
|
|
20
19
|
const settings = useSettings()
|
|
21
20
|
const { disabledCameras } = useMachineSettings()
|
|
22
|
-
const motionClient = useMotionClient()
|
|
23
21
|
const geometries = useGeometries()
|
|
24
22
|
const pointclouds = usePointClouds()
|
|
25
|
-
|
|
26
23
|
const { refetchPoses } = useRefetchPoses()
|
|
27
24
|
|
|
28
25
|
// Invalidate the renderer for any settings change
|
|
@@ -76,22 +73,6 @@
|
|
|
76
73
|
{/each}
|
|
77
74
|
</div>
|
|
78
75
|
|
|
79
|
-
<label class="flex flex-col gap-1">
|
|
80
|
-
Motion client
|
|
81
|
-
<Select
|
|
82
|
-
onchange={(event: InputEvent) => {
|
|
83
|
-
if (event.target instanceof HTMLSelectElement) {
|
|
84
|
-
motionClient.set(event.target.value)
|
|
85
|
-
}
|
|
86
|
-
}}
|
|
87
|
-
value={motionClient.current}
|
|
88
|
-
>
|
|
89
|
-
{#each motionClient.names as name (name)}
|
|
90
|
-
<option>{name}</option>
|
|
91
|
-
{/each}
|
|
92
|
-
</Select>
|
|
93
|
-
</label>
|
|
94
|
-
|
|
95
76
|
<h3 class="pt-2 text-sm"><strong>Pointclouds</strong></h3>
|
|
96
77
|
<div class="flex flex-col gap-2.5">
|
|
97
78
|
<label class="flex items-center justify-between gap-2">
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRobotQuery, useRobotClient } from '@viamrobotics/svelte-sdk';
|
|
2
2
|
import { usePartID } from './usePartID.svelte';
|
|
3
|
-
import {
|
|
3
|
+
import { commonApi, Pose } from '@viamrobotics/sdk';
|
|
4
4
|
import { RefreshRates, useMachineSettings } from './useMachineSettings.svelte';
|
|
5
|
-
import { useMotionClient } from './useMotionClient.svelte';
|
|
6
5
|
import { useEnvironment } from './useEnvironment.svelte';
|
|
7
6
|
import { observe } from '@threlte/core';
|
|
8
7
|
import { untrack } from 'svelte';
|
|
@@ -16,7 +15,7 @@ export const usePose = (name, parent) => {
|
|
|
16
15
|
const logs = useLogs();
|
|
17
16
|
const { refreshRates } = useMachineSettings();
|
|
18
17
|
const partID = usePartID();
|
|
19
|
-
const
|
|
18
|
+
const robotClient = useRobotClient(() => partID.current);
|
|
20
19
|
const currentName = $derived(name());
|
|
21
20
|
const currentParent = $derived(parent());
|
|
22
21
|
const resourceByName = useResourceByName();
|
|
@@ -25,7 +24,6 @@ export const usePose = (name, parent) => {
|
|
|
25
24
|
const parentResource = $derived(currentParent ? resourceByName.current[currentParent] : undefined);
|
|
26
25
|
const frames = useFrames();
|
|
27
26
|
let pose = $state(undefined);
|
|
28
|
-
const client = createResourceClient(MotionClient, () => partID.current, () => motionClient.current ?? '');
|
|
29
27
|
const interval = $derived(refreshRates.get(RefreshRates.poses));
|
|
30
28
|
const resolvedParent = $derived(parentResource?.subtype === 'arm' || parentResource?.subtype === 'gantry'
|
|
31
29
|
? `${parent()}_origin`
|
|
@@ -33,7 +31,7 @@ export const usePose = (name, parent) => {
|
|
|
33
31
|
const resolvedName = $derived(resource?.subtype === 'arm' || resource?.subtype === 'gantry'
|
|
34
32
|
? `${currentName}_origin`
|
|
35
33
|
: currentName);
|
|
36
|
-
const query =
|
|
34
|
+
const query = createRobotQuery(robotClient, 'getPose', () => [resolvedName, resolvedParent ?? 'world', []], () => ({
|
|
37
35
|
enabled: interval !== RefetchRates.OFF && environment.current.viewerMode === 'monitor',
|
|
38
36
|
refetchInterval: interval === RefetchRates.MANUAL ? false : interval,
|
|
39
37
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@testing-library/jest-dom": "6.8.0",
|
|
26
26
|
"@testing-library/svelte": "5.2.8",
|
|
27
27
|
"@testing-library/user-event": "^14.6.1",
|
|
28
|
-
"@thi.ng/paths": "5.2.21",
|
|
29
28
|
"@threlte/core": "8.3.0",
|
|
30
29
|
"@threlte/extras": "9.7.0",
|
|
31
30
|
"@threlte/rapier": "3.2.0",
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
"@typescript-eslint/eslint-plugin": "8.42.0",
|
|
37
36
|
"@typescript-eslint/parser": "8.42.0",
|
|
38
37
|
"@viamrobotics/prime-core": "0.1.5",
|
|
39
|
-
"@viamrobotics/sdk": "0.
|
|
38
|
+
"@viamrobotics/sdk": "0.58.0",
|
|
40
39
|
"@viamrobotics/svelte-sdk": "1.0.1",
|
|
41
40
|
"@vitejs/plugin-basic-ssl": "2.1.0",
|
|
42
41
|
"@vitest/coverage-v8": "^3.2.4",
|
|
@@ -49,8 +48,6 @@
|
|
|
49
48
|
"globals": "16.3.0",
|
|
50
49
|
"idb-keyval": "6.2.2",
|
|
51
50
|
"jsdom": "26.1.0",
|
|
52
|
-
"koota": "^0.5.3",
|
|
53
|
-
"lodash-es": "4.17.21",
|
|
54
51
|
"lucide-svelte": "0.542.0",
|
|
55
52
|
"prettier": "3.6.2",
|
|
56
53
|
"prettier-plugin-svelte": "3.4.0",
|
|
@@ -62,7 +59,6 @@
|
|
|
62
59
|
"svelte-virtuallists": "1.4.2",
|
|
63
60
|
"tailwindcss": "4.1.13",
|
|
64
61
|
"three": "0.182.0",
|
|
65
|
-
"three-mesh-bvh": "^0.9.1",
|
|
66
62
|
"threlte-uikit": "1.2.1",
|
|
67
63
|
"tsx": "4.20.5",
|
|
68
64
|
"type-fest": "^5.0.1",
|
|
@@ -84,6 +80,7 @@
|
|
|
84
80
|
"@viamrobotics/svelte-sdk": ">=0.1",
|
|
85
81
|
"@zag-js/svelte": ">=1",
|
|
86
82
|
"@zag-js/tree-view": ">=1",
|
|
83
|
+
"camera-controls": ">=3",
|
|
87
84
|
"idb-keyval": ">=6",
|
|
88
85
|
"lucide-svelte": ">=0.511",
|
|
89
86
|
"runed": ">=0.28",
|
|
@@ -122,6 +119,8 @@
|
|
|
122
119
|
"@bufbuild/protobuf": "1.10.1",
|
|
123
120
|
"@neodrag/svelte": "^2.3.3",
|
|
124
121
|
"@tanstack/svelte-query-devtools": "^6.0.2",
|
|
122
|
+
"koota": "^0.5.3",
|
|
123
|
+
"lodash-es": "4.17.21",
|
|
125
124
|
"uuid-tool": "^2.0.3"
|
|
126
125
|
},
|
|
127
126
|
"scripts": {
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useResourceNames } from '@viamrobotics/svelte-sdk';
|
|
2
|
-
import { getContext, setContext } from 'svelte';
|
|
3
|
-
const key = Symbol('motion-client-context');
|
|
4
|
-
export const provideMotionClient = (partID) => {
|
|
5
|
-
const motionResources = useResourceNames(partID, 'motion');
|
|
6
|
-
const motionNames = $derived(motionResources.current.map((resource) => resource.name));
|
|
7
|
-
let current = $state();
|
|
8
|
-
$effect.pre(() => {
|
|
9
|
-
if (current) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (motionNames.includes('builtin')) {
|
|
13
|
-
current = 'builtin';
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
current = motionNames[0];
|
|
17
|
-
});
|
|
18
|
-
setContext(key, {
|
|
19
|
-
get names() {
|
|
20
|
-
return motionNames;
|
|
21
|
-
},
|
|
22
|
-
get current() {
|
|
23
|
-
return current;
|
|
24
|
-
},
|
|
25
|
-
set(value) {
|
|
26
|
-
current = value;
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
export const useMotionClient = () => {
|
|
31
|
-
return getContext(key);
|
|
32
|
-
};
|