@viamrobotics/motion-tools 1.15.6 → 1.15.8
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/buf/common/v1/common_pb.d.ts +38 -0
- package/dist/buf/common/v1/common_pb.js +64 -0
- package/dist/buf/draw/v1/scene_pb.d.ts +6 -2
- package/dist/buf/draw/v1/scene_pb.js +9 -3
- package/dist/components/Entities/Geometry.svelte +1 -1
- package/dist/components/PCD.svelte +4 -1
- package/dist/components/PCD.svelte.d.ts +1 -0
- package/dist/components/Scene.svelte +0 -1
- package/dist/components/SceneProviders.svelte +0 -2
- package/dist/components/Snapshot.svelte +8 -0
- package/dist/components/hover/LinkedHoveredEntity.svelte +6 -12
- package/dist/components/hover/LinkedHoveredEntity.svelte.d.ts +0 -2
- package/dist/components/overlay/RefreshRate.svelte +7 -6
- package/dist/components/overlay/RefreshRate.svelte.d.ts +1 -1
- package/dist/components/overlay/settings/Settings.svelte +16 -8
- package/dist/components/xr/OriginMarker.svelte +44 -83
- package/dist/components/xr/PointDistance.svelte +8 -14
- package/dist/components/xr/XR.svelte +32 -11
- package/dist/components/xr/frame-configure/Controllers.svelte +6 -0
- package/dist/components/xr/{HandCollider.svelte.d.ts → frame-configure/Controllers.svelte.d.ts} +3 -3
- package/dist/components/xr/{Controllers.svelte → teleop/Controllers.svelte} +4 -19
- package/dist/hooks/use3DModels.svelte.js +1 -1
- package/dist/hooks/useControls.svelte.d.ts +1 -0
- package/dist/hooks/useControls.svelte.js +4 -0
- package/dist/hooks/useGeometries.svelte.js +7 -9
- package/dist/hooks/usePointcloudObjects.svelte.js +7 -6
- package/dist/hooks/usePointclouds.svelte.js +7 -6
- package/dist/hooks/usePose.svelte.js +3 -3
- package/dist/hooks/useSettings.svelte.d.ts +17 -3
- package/dist/hooks/useSettings.svelte.js +27 -7
- package/package.json +2 -2
- package/dist/components/xr/Draggable.svelte +0 -102
- package/dist/components/xr/Draggable.svelte.d.ts +0 -11
- package/dist/components/xr/HandCollider.svelte +0 -20
- package/dist/hooks/useMachineSettings.svelte.d.ts +0 -13
- package/dist/hooks/useMachineSettings.svelte.js +0 -58
- /package/dist/components/xr/{Controllers.svelte.d.ts → teleop/Controllers.svelte.d.ts} +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { World } from '@threlte/rapier'
|
|
2
|
+
import { useThrelte } from '@threlte/core'
|
|
4
3
|
import { useXR, XR, XRButton } from '@threlte/xr'
|
|
5
4
|
import { SvelteMap } from 'svelte/reactivity'
|
|
5
|
+
import { Quaternion } from 'three'
|
|
6
6
|
|
|
7
7
|
import { usePartID } from '../../hooks/usePartID.svelte'
|
|
8
8
|
import { useSettings } from '../../hooks/useSettings.svelte'
|
|
9
9
|
|
|
10
10
|
import CameraFeed from './CameraFeed.svelte'
|
|
11
|
-
import
|
|
11
|
+
import FrameConfigureControllers from './frame-configure/Controllers.svelte'
|
|
12
12
|
import JointLimitsWidget from './JointLimitsWidget.svelte'
|
|
13
13
|
import OriginMarker from './OriginMarker.svelte'
|
|
14
|
+
import TeleopControllers from './teleop/Controllers.svelte'
|
|
15
|
+
import { provideAnchors } from './useAnchors.svelte'
|
|
14
16
|
import { useOrigin } from './useOrigin.svelte'
|
|
15
17
|
import XRToast from './XRToast.svelte'
|
|
16
18
|
|
|
@@ -19,6 +21,7 @@
|
|
|
19
21
|
const { isPresenting } = useXR()
|
|
20
22
|
const settings = useSettings()
|
|
21
23
|
const origin = useOrigin()
|
|
24
|
+
provideAnchors()
|
|
22
25
|
const enableXR = $derived(settings.current.enableXR)
|
|
23
26
|
|
|
24
27
|
const partID = usePartID()
|
|
@@ -44,6 +47,26 @@
|
|
|
44
47
|
const controllerConfig = $derived(settings.current.xrController)
|
|
45
48
|
const leftArmName = $derived(controllerConfig.left.armName)
|
|
46
49
|
const rightArmName = $derived(controllerConfig.right.armName)
|
|
50
|
+
|
|
51
|
+
const { renderer } = useThrelte()
|
|
52
|
+
|
|
53
|
+
// Move into Viam's coordinate system. This basically accomplishes
|
|
54
|
+
// the same thing as setting z up in the Camera component.
|
|
55
|
+
$effect(() => {
|
|
56
|
+
if ($isPresenting) {
|
|
57
|
+
const q = new Quaternion().setFromAxisAngle({ x: 1, y: 0, z: 0 }, -Math.PI / 2)
|
|
58
|
+
|
|
59
|
+
// after the XR session has started and a reference space exists:
|
|
60
|
+
const baseRefSpace = renderer.xr.getReferenceSpace()
|
|
61
|
+
if (baseRefSpace) {
|
|
62
|
+
const rotatedRefSpace = baseRefSpace.getOffsetReferenceSpace(
|
|
63
|
+
new XRRigidTransform({ x: 0, y: 0, z: 0, w: 1 }, { x: q.x, y: q.y, z: q.z, w: q.w })
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
renderer.xr.setReferenceSpace(rotatedRefSpace)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
})
|
|
47
70
|
</script>
|
|
48
71
|
|
|
49
72
|
{#if enableXR}
|
|
@@ -93,15 +116,13 @@
|
|
|
93
116
|
|
|
94
117
|
<XRToast />
|
|
95
118
|
|
|
96
|
-
|
|
97
|
-
<
|
|
119
|
+
{#if settings.current.xrMode === 'arm-teleop'}
|
|
120
|
+
<TeleopControllers />
|
|
121
|
+
{:else if settings.current.xrMode === 'frame-configure'}
|
|
122
|
+
<FrameConfigureControllers />
|
|
123
|
+
{/if}
|
|
98
124
|
|
|
99
|
-
|
|
100
|
-
<T.Group rotation.x={$isPresenting ? -Math.PI / 2 : 0}>
|
|
101
|
-
<OriginMarker />
|
|
102
|
-
</T.Group>
|
|
103
|
-
</T.Group>
|
|
104
|
-
</World>
|
|
125
|
+
<OriginMarker />
|
|
105
126
|
</XR>
|
|
106
127
|
|
|
107
128
|
<XRButton
|
package/dist/components/xr/{HandCollider.svelte.d.ts → frame-configure/Controllers.svelte.d.ts}
RENAMED
|
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
11
11
|
};
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
|
-
declare const
|
|
14
|
+
declare const Controllers: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
15
|
[evt: string]: CustomEvent<any>;
|
|
16
16
|
}, {}, {}, string>;
|
|
17
|
-
type
|
|
18
|
-
export default
|
|
17
|
+
type Controllers = InstanceType<typeof Controllers>;
|
|
18
|
+
export default Controllers;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { RigidBody } from '@threlte/rapier'
|
|
3
2
|
import { Controller } from '@threlte/xr'
|
|
4
3
|
|
|
5
|
-
import { useSettings } from '
|
|
4
|
+
import { useSettings } from '../../../hooks/useSettings.svelte'
|
|
6
5
|
|
|
7
|
-
import ArmTeleop from '
|
|
8
|
-
import HandCollider from './HandCollider.svelte'
|
|
6
|
+
import ArmTeleop from '../ArmTeleop.svelte'
|
|
9
7
|
|
|
10
8
|
const settings = useSettings()
|
|
11
9
|
|
|
@@ -25,21 +23,8 @@
|
|
|
25
23
|
const rightRotationEnabled = $derived(config.right.rotationEnabled)
|
|
26
24
|
</script>
|
|
27
25
|
|
|
28
|
-
<Controller left
|
|
29
|
-
|
|
30
|
-
<RigidBody type="kinematicPosition">
|
|
31
|
-
<HandCollider />
|
|
32
|
-
</RigidBody>
|
|
33
|
-
{/snippet}
|
|
34
|
-
</Controller>
|
|
35
|
-
|
|
36
|
-
<Controller right>
|
|
37
|
-
{#snippet grip()}
|
|
38
|
-
<RigidBody type="kinematicPosition">
|
|
39
|
-
<HandCollider />
|
|
40
|
-
</RigidBody>
|
|
41
|
-
{/snippet}
|
|
42
|
-
</Controller>
|
|
26
|
+
<Controller left />
|
|
27
|
+
<Controller right />
|
|
43
28
|
|
|
44
29
|
<!-- Left Controller Arm Teleop -->
|
|
45
30
|
{#if leftArmName}
|
|
@@ -57,7 +57,7 @@ export const provide3DModels = (partID) => {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
$effect(() => {
|
|
60
|
-
const shouldFetchModels = settings.
|
|
60
|
+
const shouldFetchModels = settings.isLoaded && settings.current.renderArmModels.includes('model');
|
|
61
61
|
if (shouldFetchModels) {
|
|
62
62
|
fetch3DModels();
|
|
63
63
|
}
|
|
@@ -9,6 +9,7 @@ interface CameraControlsContext {
|
|
|
9
9
|
set(current: CameraControlsRef): void;
|
|
10
10
|
setPose(pose: CameraPose, animate?: boolean): void;
|
|
11
11
|
setInitialPose(): void;
|
|
12
|
+
setZoom(zoom: number): void;
|
|
12
13
|
}
|
|
13
14
|
export declare const provideCameraControls: (initialCameraPose: () => CameraPose | undefined) => void;
|
|
14
15
|
export declare const useCameraControls: () => CameraControlsContext;
|
|
@@ -9,6 +9,9 @@ export const provideCameraControls = (initialCameraPose) => {
|
|
|
9
9
|
controls?.setPosition(x, y, z, animate);
|
|
10
10
|
controls?.setLookAt(x, y, z, lookAtX, lookAtY, lookAtZ, animate);
|
|
11
11
|
};
|
|
12
|
+
const setZoom = (zoom) => {
|
|
13
|
+
controls?.zoomTo(zoom);
|
|
14
|
+
};
|
|
12
15
|
const setInitialPose = () => {
|
|
13
16
|
const pose = initialCameraPose();
|
|
14
17
|
setPose(pose ?? { position: [3, 3, 3], lookAt: [0, 0, 0] }, true);
|
|
@@ -28,6 +31,7 @@ export const provideCameraControls = (initialCameraPose) => {
|
|
|
28
31
|
},
|
|
29
32
|
setPose,
|
|
30
33
|
setInitialPose,
|
|
34
|
+
setZoom,
|
|
31
35
|
});
|
|
32
36
|
};
|
|
33
37
|
export const useCameraControls = () => {
|
|
@@ -10,8 +10,8 @@ import { updateGeometryTrait } from '../ecs/traits';
|
|
|
10
10
|
import { createPose } from '../transform';
|
|
11
11
|
import { useEnvironment } from './useEnvironment.svelte';
|
|
12
12
|
import { useLogs } from './useLogs.svelte';
|
|
13
|
-
import { RefreshRates, useMachineSettings } from './useMachineSettings.svelte';
|
|
14
13
|
import { useResourceByName } from './useResourceByName.svelte';
|
|
14
|
+
import { RefreshRates, useSettings } from './useSettings.svelte';
|
|
15
15
|
const key = Symbol('geometries-context');
|
|
16
16
|
const colorUtil = new Color();
|
|
17
17
|
export const provideGeometries = (partID) => {
|
|
@@ -23,18 +23,16 @@ export const provideGeometries = (partID) => {
|
|
|
23
23
|
const cameras = useResourceNames(partID, 'camera');
|
|
24
24
|
const grippers = useResourceNames(partID, 'gripper');
|
|
25
25
|
const gantries = useResourceNames(partID, 'gantry');
|
|
26
|
-
const
|
|
26
|
+
const settings = useSettings();
|
|
27
|
+
const { refreshRates } = $derived(settings.current);
|
|
27
28
|
const armClients = $derived(arms.current.map((arm) => createResourceClient(ArmClient, partID, () => arm.name)));
|
|
28
29
|
const gripperClients = $derived(grippers.current.map((gripper) => createResourceClient(GripperClient, partID, () => gripper.name)));
|
|
29
30
|
const cameraClients = $derived(cameras.current.map((camera) => createResourceClient(CameraClient, partID, () => camera.name)));
|
|
30
31
|
const gantryClients = $derived(gantries.current.map((gantry) => createResourceClient(GantryClient, partID, () => gantry.name)));
|
|
31
|
-
const interval = $derived(refreshRates
|
|
32
|
-
const options = $derived
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
environment.current.viewerMode === 'monitor',
|
|
36
|
-
refetchInterval: interval === RefetchRates.MANUAL ? false : interval,
|
|
37
|
-
};
|
|
32
|
+
const interval = $derived(refreshRates[RefreshRates.poses]);
|
|
33
|
+
const options = $derived({
|
|
34
|
+
enabled: interval !== RefetchRates.OFF && environment.current.viewerMode === 'monitor',
|
|
35
|
+
refetchInterval: interval === RefetchRates.MANUAL ? false : interval,
|
|
38
36
|
});
|
|
39
37
|
const armQueries = $derived(armClients.map((client) => [client.current?.name, createResourceQuery(client, 'getGeometries', () => options)]));
|
|
40
38
|
const gripperQueries = $derived(gripperClients.map((client) => [client.current?.name, createResourceQuery(client, 'getGeometries', () => options)]));
|
|
@@ -9,12 +9,13 @@ import { parsePcdInWorker } from '../lib';
|
|
|
9
9
|
import { createPose } from '../transform';
|
|
10
10
|
import { useEnvironment } from './useEnvironment.svelte';
|
|
11
11
|
import { useLogs } from './useLogs.svelte';
|
|
12
|
-
import { RefreshRates,
|
|
12
|
+
import { RefreshRates, useSettings } from './useSettings.svelte';
|
|
13
13
|
const key = Symbol('pointcloud-object-context');
|
|
14
14
|
export const providePointcloudObjects = (partID) => {
|
|
15
15
|
const world = useWorld();
|
|
16
16
|
const environment = useEnvironment();
|
|
17
|
-
const
|
|
17
|
+
const settings = useSettings();
|
|
18
|
+
const { refreshRates, disabledVisionServices } = $derived(settings.current);
|
|
18
19
|
const services = useResourceNames(partID, 'vision');
|
|
19
20
|
const clients = $derived(services.current.map((service) => createResourceClient(VisionClient, partID, () => service.name)));
|
|
20
21
|
const propQueries = $derived(clients.map((client) => [
|
|
@@ -33,7 +34,7 @@ export const providePointcloudObjects = (partID) => {
|
|
|
33
34
|
fetchedPropQueries &&
|
|
34
35
|
client.current?.name &&
|
|
35
36
|
interval !== RefetchRates.OFF &&
|
|
36
|
-
disabledVisionServices
|
|
37
|
+
disabledVisionServices[client.current?.name] !== true) {
|
|
37
38
|
results.push(client);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -50,13 +51,13 @@ export const providePointcloudObjects = (partID) => {
|
|
|
50
51
|
for (const [name, query] of propQueries) {
|
|
51
52
|
if (name &&
|
|
52
53
|
query.data?.objectPointCloudsSupported === false &&
|
|
53
|
-
disabledVisionServices
|
|
54
|
-
disabledVisionServices
|
|
54
|
+
disabledVisionServices[name] === undefined) {
|
|
55
|
+
disabledVisionServices[name] = true;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
59
|
const logs = useLogs();
|
|
59
|
-
const interval = $derived(refreshRates
|
|
60
|
+
const interval = $derived(refreshRates[RefreshRates.vision]);
|
|
60
61
|
const options = $derived({
|
|
61
62
|
enabled: interval !== RefetchRates.OFF,
|
|
62
63
|
refetchInterval: (interval === RefetchRates.MANUAL ? false : interval),
|
|
@@ -7,13 +7,14 @@ import { traits, useWorld } from '../ecs';
|
|
|
7
7
|
import { parsePcdInWorker } from '../loaders/pcd';
|
|
8
8
|
import { useEnvironment } from './useEnvironment.svelte';
|
|
9
9
|
import { useLogs } from './useLogs.svelte';
|
|
10
|
-
import { RefreshRates,
|
|
10
|
+
import { RefreshRates, useSettings } from './useSettings.svelte';
|
|
11
11
|
const key = Symbol('pointcloud-context');
|
|
12
12
|
export const providePointclouds = (partID) => {
|
|
13
13
|
const environment = useEnvironment();
|
|
14
14
|
const world = useWorld();
|
|
15
15
|
const logs = useLogs();
|
|
16
|
-
const
|
|
16
|
+
const settings = useSettings();
|
|
17
|
+
const { refreshRates, disabledCameras } = $derived(settings.current);
|
|
17
18
|
const cameras = useResourceNames(partID, 'camera');
|
|
18
19
|
const clients = $derived(cameras.current.map((camera) => createResourceClient(CameraClient, partID, () => camera.name)));
|
|
19
20
|
const propQueries = $derived(clients.map((client) => [
|
|
@@ -25,14 +26,14 @@ export const providePointclouds = (partID) => {
|
|
|
25
26
|
}),
|
|
26
27
|
]));
|
|
27
28
|
const fetchedPropQueries = $derived(propQueries.every(([, query]) => query.isPending === false));
|
|
28
|
-
const interval = $derived(refreshRates
|
|
29
|
+
const interval = $derived(refreshRates[RefreshRates.pointclouds]);
|
|
29
30
|
const enabledClients = $derived.by(() => {
|
|
30
31
|
const results = [];
|
|
31
32
|
for (const client of clients) {
|
|
32
33
|
if (fetchedPropQueries &&
|
|
33
34
|
client.current?.name &&
|
|
34
35
|
interval !== RefetchRates.OFF &&
|
|
35
|
-
disabledCameras
|
|
36
|
+
disabledCameras[client.current?.name] !== true) {
|
|
36
37
|
results.push(client);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -47,8 +48,8 @@ export const providePointclouds = (partID) => {
|
|
|
47
48
|
*/
|
|
48
49
|
$effect(() => {
|
|
49
50
|
for (const [name, query] of propQueries) {
|
|
50
|
-
if (name && query.data?.supportsPcd === false && disabledCameras
|
|
51
|
-
disabledCameras
|
|
51
|
+
if (name && query.data?.supportsPcd === false && disabledCameras[name] === undefined) {
|
|
52
|
+
disabledCameras[name] = true;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
});
|
|
@@ -6,15 +6,15 @@ import { RefetchRates } from '../components/overlay/RefreshRate.svelte';
|
|
|
6
6
|
import { useEnvironment } from './useEnvironment.svelte';
|
|
7
7
|
import { useFrames } from './useFrames.svelte';
|
|
8
8
|
import { useLogs } from './useLogs.svelte';
|
|
9
|
-
import { RefreshRates, useMachineSettings } from './useMachineSettings.svelte';
|
|
10
9
|
import { usePartID } from './usePartID.svelte';
|
|
11
10
|
import { useRefetchPoses } from './useRefetchPoses';
|
|
12
11
|
import { useResourceByName } from './useResourceByName.svelte';
|
|
12
|
+
import { RefreshRates, useSettings } from './useSettings.svelte';
|
|
13
13
|
const originFrameComponentTypes = new Set(['arm', 'gantry', 'gripper', 'base']);
|
|
14
14
|
export const usePose = (name, parent) => {
|
|
15
15
|
const environment = useEnvironment();
|
|
16
16
|
const logs = useLogs();
|
|
17
|
-
const
|
|
17
|
+
const settings = useSettings();
|
|
18
18
|
const partID = usePartID();
|
|
19
19
|
const robotClient = useRobotClient(() => partID.current);
|
|
20
20
|
const currentName = $derived(name());
|
|
@@ -25,7 +25,7 @@ export const usePose = (name, parent) => {
|
|
|
25
25
|
const parentResource = $derived(currentParent ? resourceByName.current[currentParent] : undefined);
|
|
26
26
|
const frames = useFrames();
|
|
27
27
|
let pose = $state();
|
|
28
|
-
const interval = $derived(refreshRates
|
|
28
|
+
const interval = $derived(settings.current.refreshRates[RefreshRates.poses]);
|
|
29
29
|
const resolvedParent = $derived(originFrameComponentTypes.has(parentResource?.subtype ?? '') ? `${parent()}_origin` : parent());
|
|
30
30
|
const resolvedName = $derived(originFrameComponentTypes.has(resource?.subtype ?? '') ? `${currentName}_origin` : currentName);
|
|
31
31
|
const query = createRobotQuery(robotClient, 'getPose', () => [resolvedName, resolvedParent ?? 'world', []], () => ({
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export interface Settings {
|
|
2
|
-
isLoaded: boolean;
|
|
3
2
|
cameraMode: 'orthographic' | 'perspective';
|
|
3
|
+
interactionMode: 'navigate' | 'measure' | 'lasso';
|
|
4
|
+
refreshRates: {
|
|
5
|
+
poses: number;
|
|
6
|
+
pointclouds: number;
|
|
7
|
+
vision: number;
|
|
8
|
+
};
|
|
9
|
+
disabledCameras: Record<string, boolean>;
|
|
10
|
+
disabledVisionServices: Record<string, boolean>;
|
|
4
11
|
transforming: boolean;
|
|
5
12
|
snapping: boolean;
|
|
6
13
|
transformMode: 'translate' | 'rotate' | 'scale';
|
|
@@ -12,19 +19,19 @@ export interface Settings {
|
|
|
12
19
|
pointColor: string;
|
|
13
20
|
lineWidth: number;
|
|
14
21
|
lineDotSize: number;
|
|
15
|
-
interactionMode: 'navigate' | 'measure' | 'lasso';
|
|
16
22
|
enableMeasureAxisX: boolean;
|
|
17
23
|
enableMeasureAxisY: boolean;
|
|
18
24
|
enableMeasureAxisZ: boolean;
|
|
19
25
|
enableLabels: boolean;
|
|
20
26
|
enableKeybindings: boolean;
|
|
21
27
|
enableQueryDevtools: boolean;
|
|
22
|
-
enableXR: boolean;
|
|
23
28
|
enableArmPositionsWidget: boolean;
|
|
24
29
|
openCameraWidgets: Record<string, string[]>;
|
|
25
30
|
renderStats: boolean;
|
|
26
31
|
renderArmModels: 'colliders' | 'colliders+model' | 'model';
|
|
27
32
|
renderSubEntityHoverDetail: boolean;
|
|
33
|
+
enableXR: boolean;
|
|
34
|
+
xrMode: 'frame-configure' | 'arm-teleop';
|
|
28
35
|
xrController: {
|
|
29
36
|
left: {
|
|
30
37
|
armName?: string;
|
|
@@ -42,7 +49,14 @@ export interface Settings {
|
|
|
42
49
|
}
|
|
43
50
|
interface Context {
|
|
44
51
|
current: Settings;
|
|
52
|
+
isLoaded: boolean;
|
|
53
|
+
merge(value: Settings): void;
|
|
45
54
|
}
|
|
55
|
+
export declare const RefreshRates: {
|
|
56
|
+
readonly poses: "poses";
|
|
57
|
+
readonly pointclouds: "pointclouds";
|
|
58
|
+
readonly vision: "vision";
|
|
59
|
+
};
|
|
46
60
|
export declare const provideSettings: () => Context;
|
|
47
61
|
export declare const useSettings: () => Context;
|
|
48
62
|
export {};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { get, set } from 'idb-keyval';
|
|
2
2
|
import { getContext, setContext } from 'svelte';
|
|
3
3
|
const key = Symbol('dashboard-context');
|
|
4
|
+
export const RefreshRates = {
|
|
5
|
+
poses: 'poses',
|
|
6
|
+
pointclouds: 'pointclouds',
|
|
7
|
+
vision: 'vision',
|
|
8
|
+
};
|
|
4
9
|
const defaults = () => ({
|
|
5
|
-
isLoaded: false,
|
|
6
10
|
cameraMode: 'perspective',
|
|
11
|
+
refreshRates: {
|
|
12
|
+
poses: 1000,
|
|
13
|
+
pointclouds: 5000,
|
|
14
|
+
vision: 1000,
|
|
15
|
+
},
|
|
16
|
+
disabledCameras: {},
|
|
17
|
+
disabledVisionServices: {},
|
|
7
18
|
transforming: false,
|
|
8
19
|
snapping: false,
|
|
9
20
|
transformMode: 'translate',
|
|
@@ -22,12 +33,13 @@ const defaults = () => ({
|
|
|
22
33
|
enableLabels: false,
|
|
23
34
|
enableKeybindings: true,
|
|
24
35
|
enableQueryDevtools: false,
|
|
25
|
-
enableXR: false,
|
|
26
36
|
enableArmPositionsWidget: false,
|
|
27
37
|
openCameraWidgets: {},
|
|
28
38
|
renderStats: false,
|
|
29
39
|
renderArmModels: 'colliders+model',
|
|
30
40
|
renderSubEntityHoverDetail: false,
|
|
41
|
+
enableXR: false,
|
|
42
|
+
xrMode: 'frame-configure',
|
|
31
43
|
xrController: {
|
|
32
44
|
left: {
|
|
33
45
|
scaleFactor: 1,
|
|
@@ -40,17 +52,19 @@ const defaults = () => ({
|
|
|
40
52
|
},
|
|
41
53
|
});
|
|
42
54
|
export const provideSettings = () => {
|
|
55
|
+
let isLoaded = $state(false);
|
|
43
56
|
let settings = $state(defaults());
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
get('motion-tools-settings')
|
|
58
|
+
.then((response) => {
|
|
46
59
|
if (response) {
|
|
47
60
|
settings = { ...settings, ...response };
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
})
|
|
63
|
+
.finally(() => {
|
|
64
|
+
isLoaded = true;
|
|
51
65
|
});
|
|
52
66
|
$effect(() => {
|
|
53
|
-
if (
|
|
67
|
+
if (isLoaded) {
|
|
54
68
|
set('motion-tools-settings', $state.snapshot(settings));
|
|
55
69
|
}
|
|
56
70
|
});
|
|
@@ -61,6 +75,12 @@ export const provideSettings = () => {
|
|
|
61
75
|
set current(value) {
|
|
62
76
|
settings = value;
|
|
63
77
|
},
|
|
78
|
+
get isLoaded() {
|
|
79
|
+
return isLoaded;
|
|
80
|
+
},
|
|
81
|
+
merge(value) {
|
|
82
|
+
settings = { ...settings, ...value };
|
|
83
|
+
},
|
|
64
84
|
};
|
|
65
85
|
setContext(key, context);
|
|
66
86
|
return context;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.8",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"@neodrag/svelte": "^2.3.3",
|
|
137
137
|
"@tanstack/svelte-query-devtools": "^6.0.2",
|
|
138
138
|
"earcut": "^3.0.2",
|
|
139
|
-
"
|
|
139
|
+
"filtrex": "^3.1.0",
|
|
140
140
|
"koota": "0.6.5",
|
|
141
141
|
"lodash-es": "4.17.23",
|
|
142
142
|
"three-mesh-bvh": "^0.9.8",
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
|
|
4
|
-
import { RigidBody as RigidBodyType } from '@dimforge/rapier3d-compat'
|
|
5
|
-
import { T, useTask } from '@threlte/core'
|
|
6
|
-
import { useGamepad } from '@threlte/extras'
|
|
7
|
-
import { AutoColliders, RigidBody } from '@threlte/rapier'
|
|
8
|
-
import { useController } from '@threlte/xr'
|
|
9
|
-
import { Group, Vector3 } from 'three'
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
children: Snippet
|
|
13
|
-
onPointerEnter?: () => void
|
|
14
|
-
onPointerLeave?: () => void
|
|
15
|
-
onPointerDown?: () => void
|
|
16
|
-
onPointerUp?: () => void
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let { onPointerEnter, onPointerLeave, onPointerDown, onPointerUp, children }: Props = $props()
|
|
20
|
-
|
|
21
|
-
let hovering = $state(false)
|
|
22
|
-
|
|
23
|
-
let dragging = $state(false)
|
|
24
|
-
let rigidBody: RigidBodyType | undefined = $state()
|
|
25
|
-
|
|
26
|
-
const group = new Group()
|
|
27
|
-
const vec3 = new Vector3()
|
|
28
|
-
const offset = new Vector3()
|
|
29
|
-
const position = new Vector3()
|
|
30
|
-
|
|
31
|
-
const left = useController('left')
|
|
32
|
-
const right = useController('right')
|
|
33
|
-
const leftPad = useGamepad({ xr: true, hand: 'left' })
|
|
34
|
-
const rightPad = useGamepad({ xr: true, hand: 'right' })
|
|
35
|
-
|
|
36
|
-
leftPad.trigger.on('down', () => {
|
|
37
|
-
if (!$left) return
|
|
38
|
-
|
|
39
|
-
dragging = true
|
|
40
|
-
group.getWorldPosition(vec3)
|
|
41
|
-
offset.copy($left.grip.position).sub(vec3)
|
|
42
|
-
onPointerDown?.()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
leftPad.trigger.on('up', () => {
|
|
46
|
-
dragging = false
|
|
47
|
-
onPointerUp?.()
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
rightPad.trigger.on('down', () => {
|
|
51
|
-
if (!$right) return
|
|
52
|
-
|
|
53
|
-
dragging = true
|
|
54
|
-
group.getWorldPosition(vec3)
|
|
55
|
-
offset.copy($right.grip.position).sub(vec3)
|
|
56
|
-
onPointerDown?.()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
rightPad.trigger.on('up', () => {
|
|
60
|
-
dragging = true
|
|
61
|
-
onPointerUp?.()
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
const onsensorenter = () => {
|
|
65
|
-
hovering = true
|
|
66
|
-
onPointerEnter?.()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const onsensorexit = () => {
|
|
70
|
-
hovering = false
|
|
71
|
-
onPointerLeave?.()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const { start, stop } = useTask(
|
|
75
|
-
() => {
|
|
76
|
-
if (!$left || !rigidBody) return
|
|
77
|
-
|
|
78
|
-
position.copy($left.grip.position).sub(offset)
|
|
79
|
-
|
|
80
|
-
rigidBody.setNextKinematicTranslation({ x: position.x, y: position.y, z: position.z })
|
|
81
|
-
},
|
|
82
|
-
{ autoStart: false }
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
$effect(() => (hovering && dragging ? start() : stop()))
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<T is={group}>
|
|
89
|
-
<RigidBody
|
|
90
|
-
bind:rigidBody
|
|
91
|
-
type="kinematicPosition"
|
|
92
|
-
>
|
|
93
|
-
<AutoColliders
|
|
94
|
-
sensor
|
|
95
|
-
shape="convexHull"
|
|
96
|
-
{onsensorenter}
|
|
97
|
-
{onsensorexit}
|
|
98
|
-
>
|
|
99
|
-
{@render children?.()}
|
|
100
|
-
</AutoColliders>
|
|
101
|
-
</RigidBody>
|
|
102
|
-
</T>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
interface Props {
|
|
3
|
-
children: Snippet;
|
|
4
|
-
onPointerEnter?: () => void;
|
|
5
|
-
onPointerLeave?: () => void;
|
|
6
|
-
onPointerDown?: () => void;
|
|
7
|
-
onPointerUp?: () => void;
|
|
8
|
-
}
|
|
9
|
-
declare const Draggable: import("svelte").Component<Props, {}, "">;
|
|
10
|
-
type Draggable = ReturnType<typeof Draggable>;
|
|
11
|
-
export default Draggable;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Group } from 'three'
|
|
3
|
-
|
|
4
|
-
import { useParent, useTask } from '@threlte/core'
|
|
5
|
-
import { Collider, useRigidBody } from '@threlte/rapier'
|
|
6
|
-
|
|
7
|
-
const parent = useParent()
|
|
8
|
-
const rb = useRigidBody()
|
|
9
|
-
|
|
10
|
-
useTask(() => {
|
|
11
|
-
const { position } = $parent as Group
|
|
12
|
-
rb?.setNextKinematicTranslation({ x: position.x, y: position.y, z: position.z })
|
|
13
|
-
})
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<Collider
|
|
17
|
-
sensor
|
|
18
|
-
shape="ball"
|
|
19
|
-
args={[0.1]}
|
|
20
|
-
/>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SvelteMap } from 'svelte/reactivity';
|
|
2
|
-
export declare const RefreshRates: {
|
|
3
|
-
readonly poses: "poses";
|
|
4
|
-
readonly pointclouds: "pointclouds";
|
|
5
|
-
};
|
|
6
|
-
type Context = {
|
|
7
|
-
refreshRates: SvelteMap<string, number>;
|
|
8
|
-
disabledCameras: SvelteMap<string, boolean>;
|
|
9
|
-
disabledVisionServices: SvelteMap<string, boolean>;
|
|
10
|
-
};
|
|
11
|
-
export declare const provideMachineSettings: () => void;
|
|
12
|
-
export declare const useMachineSettings: () => Context;
|
|
13
|
-
export {};
|