@wandelbots/wandelbots-js-react-components 2.54.5-pr.feat-upgrade-safety-bar-to-v2.405.a1124f0 → 2.54.5-pr.feat-upgrade-robot-motions-to-v2.407.98ff8a7
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/RobotCard.d.ts +1 -1
- package/dist/components/RobotCard.d.ts.map +1 -1
- package/dist/components/robots/DHRobot.d.ts.map +1 -1
- package/dist/components/robots/Robot.d.ts +1 -1
- package/dist/components/robots/Robot.d.ts.map +1 -1
- package/dist/components/robots/RobotAnimator.d.ts +2 -2
- package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
- package/dist/components/robots/SupportedRobot.d.ts +3 -3
- package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
- package/dist/components/robots/manufacturerHomePositions.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/lib/ConnectedMotionGroup.d.ts +7 -1
- package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
- package/dist/lib/MotionStreamConnection.d.ts.map +1 -1
- package/dist/lib/motionStateUpdate.d.ts +2 -0
- package/dist/lib/motionStateUpdate.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/RobotCard.tsx +1 -1
- package/src/components/robots/DHRobot.tsx +2 -3
- package/src/components/robots/Robot.tsx +1 -1
- package/src/components/robots/RobotAnimator.test.tsx +7 -22
- package/src/components/robots/RobotAnimator.tsx +8 -13
- package/src/components/robots/SupportedRobot.tsx +3 -6
- package/src/components/robots/manufacturerHomePositions.ts +1 -1
- package/src/lib/ConnectedMotionGroup.ts +22 -4
- package/src/lib/MotionStreamConnection.ts +7 -42
- package/src/lib/motionStateUpdate.ts +41 -0
|
@@ -48,7 +48,13 @@ export declare class ConnectedMotionGroup {
|
|
|
48
48
|
get joints(): {
|
|
49
49
|
index: number;
|
|
50
50
|
}[];
|
|
51
|
-
get dhParameters():
|
|
51
|
+
get dhParameters(): {
|
|
52
|
+
alpha?: number;
|
|
53
|
+
theta?: number;
|
|
54
|
+
a?: number;
|
|
55
|
+
d?: number;
|
|
56
|
+
reverse_rotation_direction?: boolean;
|
|
57
|
+
}[] | undefined;
|
|
52
58
|
get safetyZones(): {
|
|
53
59
|
[key: string]: import("@wandelbots/nova-api/v2").Collider;
|
|
54
60
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectedMotionGroup.d.ts","sourceRoot":"","sources":["../../src/lib/ConnectedMotionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ConnectedMotionGroup.d.ts","sourceRoot":"","sources":["../../src/lib/ConnectedMotionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAEV,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EAEV,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,aAAa,CAAA;IACvB,WAAW,EAAE,aAAa,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAUD;;;GAGG;AACH,qBAAa,oBAAoB;IA8H7B,QAAQ,CAAC,IAAI,EAAE,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,oBAAoB;IACzC,QAAQ,CAAC,WAAW,EAAE,gBAAgB;IACtC,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;IACrD,QAAQ,CAAC,SAAS,EAAE,OAAO;IAC3B,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE;IAC7B,QAAQ,CAAC,WAAW,EAAE,sBAAsB;IAC5C,QAAQ,CAAC,sBAAsB,EAAE,oBAAoB;IACrD,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB;WAtI9C,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE;WAQ1D,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM;IAgG5D,sBAAsB,EAAE,SAAS,GAAG,IAAI,CAAO;IAE/C,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAA;IACpB,eAAe,EAAE,MAAM,CAAK;IAI5B,0BAA0B,EAAE,gBAAgB,CAAA;IAI5C,eAAe,EAAE,oBAAoB,CAAA;IAErC;;;OAGG;IACH,eAAe,EAAE,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,QAAQ,CAC1D;gBAGD,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,oBAAoB,EAChC,WAAW,EAAE,gBAAgB,EAC7B,kBAAkB,EAAE,gBAAgB,EACpC,iBAAiB,EAAE,yBAAyB,EAC5C,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,YAAY,EAAE,EACpB,WAAW,EAAE,sBAAsB,EACnC,sBAAsB,EAAE,oBAAoB,EAC5C,qBAAqB,EAAE,yBAAyB;IAsE3D,IAAI,aAAa,WAEhB;IAED,IAAI,YAAY,WAEf;IAED,IAAI,mBAAmB,WAEtB;IAED,IAAI,sBAAsB,WAGzB;IAED,kEAAkE;IAClE,IAAI,mBAAmB,WAEtB;IAED,IAAI,MAAM;;QAMT;IAGD,IAAI,YAAY;;;;;;oBASf;IAED,IAAI,WAAW;;kBAEd;IAED,oEAAoE;IACpE,IAAI,gBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAU/C;IAED,sEAAsE;IACtE,IAAI,kBAAkB,qBAWrB;IAED;;;OAGG;IACH,IAAI,aAAa,YAOhB;IAED;;;OAGG;IACH,IAAI,qBAAqB,YAOxB;IAED;;OAEG;IACH,IAAI,uBAAuB,YAS1B;IAED;;;OAGG;IACH,IAAI,UAAU,YAMb;IAEK,UAAU;IA2BV,QAAQ;IA2Bd,gBAAgB;IAQhB,OAAO;IAKP,kBAAkB,CAAC,QAAQ,EAAE,MAAM;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MotionStreamConnection.d.ts","sourceRoot":"","sources":["../../src/lib/MotionStreamConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAgB,MAAM,qBAAqB,CAAA;AAC7E,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"MotionStreamConnection.d.ts","sourceRoot":"","sources":["../../src/lib/MotionStreamConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAgB,MAAM,qBAAqB,CAAA;AAC7E,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAW/B;;GAEG;AACH,qBAAa,sBAAsB;IA2D/B,QAAQ,CAAC,IAAI,EAAE,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,oBAAoB;IACzC,QAAQ,CAAC,WAAW,EAAE,gBAAgB;IACtC,QAAQ,CAAC,WAAW,EAAE,sBAAsB;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;WA/D1C,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM;IAuDzD,0BAA0B,EAAE,gBAAgB,CAAA;gBAGjC,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,oBAAoB,EAChC,WAAW,EAAE,gBAAgB,EAC7B,WAAW,EAAE,sBAAsB,EACnC,kBAAkB,EAAE,gBAAgB,EACpC,iBAAiB,EAAE,yBAAyB;IA6EvD,IAAI,aAAa,WAEhB;IAED,IAAI,YAAY,WAEf;IAED,IAAI,sBAAsB,WAGzB;IAED,IAAI,MAAM;;QAMT;IAED,OAAO;CAGR"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { MotionGroupState, Pose } from "@wandelbots/nova-js/v2";
|
|
2
|
+
import type { Vector3Simple } from "./JoggerConnection";
|
|
2
3
|
export declare function jointValuesEqual(oldJointValues: number[], newJointValues: number[], changeDeltaThreshold: number): boolean;
|
|
3
4
|
export declare function poseEqual(oldTcp: Pose | undefined, newTcp: Pose | undefined, changeDeltaThreshold: number): boolean;
|
|
4
5
|
export declare function tcpMotionEqual(oldMotionState: MotionGroupState, newMotionState: MotionGroupState, changeDeltaThreshold: number): boolean;
|
|
6
|
+
export declare function unwrapRotationVector(newRotationVectorApi: Vector3Simple, currentRotationVectorApi: Vector3Simple): Vector3Simple;
|
|
5
7
|
//# sourceMappingURL=motionStateUpdate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionStateUpdate.d.ts","sourceRoot":"","sources":["../../src/lib/motionStateUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"motionStateUpdate.d.ts","sourceRoot":"","sources":["../../src/lib/motionStateUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EAAE,EACxB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAgBT;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE,IAAI,GAAG,SAAS,EACxB,MAAM,EAAE,IAAI,GAAG,SAAS,EACxB,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CA8BT;AAGD,wBAAgB,cAAc,CAC5B,cAAc,EAAE,gBAAgB,EAChC,cAAc,EAAE,gBAAgB,EAChC,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAUT;AAED,wBAAgB,oBAAoB,CAClC,oBAAoB,EAAE,aAAa,EACnC,wBAAwB,EAAE,aAAa,GACtC,aAAa,CAkCf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "2.54.5-pr.feat-upgrade-
|
|
3
|
+
"version": "2.54.5-pr.feat-upgrade-robot-motions-to-v2.407.98ff8a7",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Box, Button, Card, Divider, Typography, useTheme } from "@mui/material"
|
|
2
2
|
import { Bounds } from "@react-three/drei"
|
|
3
3
|
import { Canvas } from "@react-three/fiber"
|
|
4
|
-
import type { ConnectedMotionGroup } from "@wandelbots/nova-js/v1"
|
|
5
4
|
import type { OperationMode, SafetyStateType } from "@wandelbots/nova-js/v2"
|
|
6
5
|
import { observer } from "mobx-react-lite"
|
|
7
6
|
import { useCallback, useEffect, useRef, useState } from "react"
|
|
8
7
|
import { useTranslation } from "react-i18next"
|
|
9
8
|
import type { Group } from "three"
|
|
10
9
|
import { externalizeComponent } from "../externalizeComponent"
|
|
10
|
+
import type { ConnectedMotionGroup } from "../lib/ConnectedMotionGroup"
|
|
11
11
|
import { PresetEnvironment } from "./3d-viewport/PresetEnvironment"
|
|
12
12
|
import type { ProgramState } from "./ProgramControl"
|
|
13
13
|
import { ProgramStateIndicator } from "./ProgramStateIndicator"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Line } from "@react-three/drei"
|
|
2
|
-
import type { DHParameter } from "@wandelbots/nova-js/
|
|
2
|
+
import type { DHParameter } from "@wandelbots/nova-js/v2"
|
|
3
3
|
import React, { useRef } from "react"
|
|
4
4
|
import type * as THREE from "three"
|
|
5
5
|
import { Matrix4, Quaternion, Vector3 } from "three"
|
|
@@ -113,8 +113,7 @@ export function DHRobot({
|
|
|
113
113
|
{dhParameters!.map((param, index) => {
|
|
114
114
|
const { a, b } = getLinePoints(
|
|
115
115
|
param,
|
|
116
|
-
rapidlyChangingMotionState.
|
|
117
|
-
0,
|
|
116
|
+
rapidlyChangingMotionState.joint_position[index] ?? 0,
|
|
118
117
|
)
|
|
119
118
|
const jointName = `dhrobot_J0${index}`
|
|
120
119
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ThreeElements } from "@react-three/fiber"
|
|
2
2
|
|
|
3
|
-
import type { ConnectedMotionGroup } from "@wandelbots/nova-js/v1"
|
|
4
3
|
import type { Group } from "three"
|
|
4
|
+
import type { ConnectedMotionGroup } from "../../lib/ConnectedMotionGroup"
|
|
5
5
|
import { defaultGetModel } from "./robotModelLogic"
|
|
6
6
|
import { SupportedRobot } from "./SupportedRobot"
|
|
7
7
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DHParameter,
|
|
3
|
-
MotionGroupStateResponse,
|
|
4
|
-
} from "@wandelbots/nova-api/v1"
|
|
1
|
+
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-api/v2"
|
|
5
2
|
import { describe, expect, it, vi } from "vitest"
|
|
6
3
|
import RobotAnimator from "./RobotAnimator"
|
|
7
4
|
|
|
@@ -26,12 +23,8 @@ describe("RobotAnimator", () => {
|
|
|
26
23
|
|
|
27
24
|
it("should handle props with different numbers of joints", () => {
|
|
28
25
|
// Test that the component accepts different numbers of DH parameters
|
|
29
|
-
const mockMotionState4Joints:
|
|
30
|
-
|
|
31
|
-
joint_position: {
|
|
32
|
-
joints: [0.1, 0.2, 0.3, 0.4],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
26
|
+
const mockMotionState4Joints: MotionGroupState = {
|
|
27
|
+
joint_position: [0.1, 0.2, 0.3, 0.4],
|
|
35
28
|
} as any
|
|
36
29
|
|
|
37
30
|
const mockDHParameters4Joints: DHParameter[] = [
|
|
@@ -41,12 +34,8 @@ describe("RobotAnimator", () => {
|
|
|
41
34
|
{ theta: 0, reverse_rotation_direction: false },
|
|
42
35
|
]
|
|
43
36
|
|
|
44
|
-
const mockMotionState7Joints:
|
|
45
|
-
|
|
46
|
-
joint_position: {
|
|
47
|
-
joints: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
37
|
+
const mockMotionState7Joints: MotionGroupState = {
|
|
38
|
+
joint_position: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],
|
|
50
39
|
} as any
|
|
51
40
|
|
|
52
41
|
const mockDHParameters7Joints: DHParameter[] = Array(7).fill({
|
|
@@ -63,9 +52,7 @@ describe("RobotAnimator", () => {
|
|
|
63
52
|
}
|
|
64
53
|
// Verify props are correctly typed
|
|
65
54
|
expect(props4.dhParameters).toHaveLength(4)
|
|
66
|
-
expect(
|
|
67
|
-
props4.rapidlyChangingMotionState.state.joint_position.joints,
|
|
68
|
-
).toHaveLength(4)
|
|
55
|
+
expect(props4.rapidlyChangingMotionState.joint_position).toHaveLength(4)
|
|
69
56
|
}).not.toThrow()
|
|
70
57
|
|
|
71
58
|
expect(() => {
|
|
@@ -75,9 +62,7 @@ describe("RobotAnimator", () => {
|
|
|
75
62
|
children: null,
|
|
76
63
|
}
|
|
77
64
|
expect(props7.dhParameters).toHaveLength(7)
|
|
78
|
-
expect(
|
|
79
|
-
props7.rapidlyChangingMotionState.state.joint_position.joints,
|
|
80
|
-
).toHaveLength(7)
|
|
65
|
+
expect(props7.rapidlyChangingMotionState.joint_position).toHaveLength(7)
|
|
81
66
|
}).not.toThrow()
|
|
82
67
|
})
|
|
83
68
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { useFrame, useThree } from "@react-three/fiber"
|
|
2
|
-
import type {
|
|
3
|
-
DHParameter,
|
|
4
|
-
MotionGroupStateResponse,
|
|
5
|
-
} from "@wandelbots/nova-js/v1"
|
|
2
|
+
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2"
|
|
6
3
|
import React, { useEffect, useRef } from "react"
|
|
7
4
|
import type { Group, Object3D } from "three"
|
|
8
5
|
import { useAutorun } from "../utils/hooks"
|
|
@@ -10,7 +7,7 @@ import { ValueInterpolator } from "../utils/interpolation"
|
|
|
10
7
|
import { collectJoints } from "./robotModelLogic"
|
|
11
8
|
|
|
12
9
|
type RobotAnimatorProps = {
|
|
13
|
-
rapidlyChangingMotionState:
|
|
10
|
+
rapidlyChangingMotionState: MotionGroupState
|
|
14
11
|
dhParameters: DHParameter[]
|
|
15
12
|
onRotationChanged?: (joints: Object3D[], jointValues: number[]) => void
|
|
16
13
|
children: React.ReactNode
|
|
@@ -29,10 +26,9 @@ export default function RobotAnimator({
|
|
|
29
26
|
|
|
30
27
|
// Initialize interpolator
|
|
31
28
|
useEffect(() => {
|
|
32
|
-
const initialJointValues =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
29
|
+
const initialJointValues = rapidlyChangingMotionState.joint_position.filter(
|
|
30
|
+
(item) => item !== undefined,
|
|
31
|
+
)
|
|
36
32
|
|
|
37
33
|
interpolatorRef.current = new ValueInterpolator(initialJointValues, {
|
|
38
34
|
tension: 120, // Controls spring stiffness - higher values create faster, more responsive motion
|
|
@@ -91,10 +87,9 @@ export default function RobotAnimator({
|
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
useAutorun(() => {
|
|
94
|
-
const newJointValues =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
90
|
+
const newJointValues = rapidlyChangingMotionState.joint_position.filter(
|
|
91
|
+
(item) => item !== undefined,
|
|
92
|
+
)
|
|
98
93
|
|
|
99
94
|
requestAnimationFrame(() => updateJoints(newJointValues))
|
|
100
95
|
})
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { ThreeElements } from "@react-three/fiber"
|
|
2
|
-
import type {
|
|
3
|
-
DHParameter,
|
|
4
|
-
MotionGroupStateResponse,
|
|
5
|
-
} from "@wandelbots/nova-js/v1"
|
|
2
|
+
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2"
|
|
6
3
|
import { Suspense, useCallback, useEffect, useState } from "react"
|
|
7
4
|
import { DHRobot } from "./DHRobot"
|
|
8
5
|
|
|
@@ -16,12 +13,12 @@ import { applyGhostStyle, removeGhostStyle } from "./ghostStyle"
|
|
|
16
13
|
import { defaultGetModel } from "./robotModelLogic"
|
|
17
14
|
|
|
18
15
|
export type DHRobotProps = {
|
|
19
|
-
rapidlyChangingMotionState:
|
|
16
|
+
rapidlyChangingMotionState: MotionGroupState
|
|
20
17
|
dhParameters: Array<DHParameter>
|
|
21
18
|
} & ThreeElements["group"]
|
|
22
19
|
|
|
23
20
|
export type SupportedRobotProps = {
|
|
24
|
-
rapidlyChangingMotionState:
|
|
21
|
+
rapidlyChangingMotionState: MotionGroupState
|
|
25
22
|
modelFromController: string
|
|
26
23
|
dhParameters: DHParameter[]
|
|
27
24
|
flangeRef?: React.Ref<THREE.Group>
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type AutoReconnectingWebsocket,
|
|
4
4
|
} from "@wandelbots/nova-js"
|
|
5
5
|
import type {
|
|
6
|
+
DHParameter,
|
|
6
7
|
MotionGroupDescription,
|
|
7
8
|
MotionGroupState,
|
|
8
9
|
NovaClient,
|
|
@@ -28,6 +29,14 @@ export type MotionGroupOption = {
|
|
|
28
29
|
selectionId: string
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
const EMPTY_DH_PARAMETER: DHParameter = {
|
|
33
|
+
a: 0,
|
|
34
|
+
d: 0,
|
|
35
|
+
alpha: 0,
|
|
36
|
+
theta: 0,
|
|
37
|
+
reverse_rotation_direction: false,
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
/**
|
|
32
41
|
* Store representing the current state of a connected motion group.
|
|
33
42
|
* API v2 version, not used yet in the components.
|
|
@@ -196,7 +205,7 @@ export class ConnectedMotionGroup {
|
|
|
196
205
|
)
|
|
197
206
|
}
|
|
198
207
|
|
|
199
|
-
// handle
|
|
208
|
+
// handle joint position changes
|
|
200
209
|
if (
|
|
201
210
|
!jointValuesEqual(
|
|
202
211
|
this.rapidlyChangingMotionState.joint_position,
|
|
@@ -205,11 +214,12 @@ export class ConnectedMotionGroup {
|
|
|
205
214
|
)
|
|
206
215
|
) {
|
|
207
216
|
runInAction(() => {
|
|
208
|
-
this.rapidlyChangingMotionState =
|
|
217
|
+
this.rapidlyChangingMotionState.joint_position =
|
|
218
|
+
latestMotionState.joint_position
|
|
209
219
|
})
|
|
210
220
|
}
|
|
211
221
|
|
|
212
|
-
// handle
|
|
222
|
+
// handle tcp pose changes
|
|
213
223
|
if (
|
|
214
224
|
!tcpMotionEqual(
|
|
215
225
|
this.rapidlyChangingMotionState,
|
|
@@ -266,8 +276,16 @@ export class ConnectedMotionGroup {
|
|
|
266
276
|
})
|
|
267
277
|
}
|
|
268
278
|
|
|
279
|
+
// Please note that API v2 omits 0 values
|
|
269
280
|
get dhParameters() {
|
|
270
|
-
|
|
281
|
+
if (this.description.dh_parameters === undefined) {
|
|
282
|
+
return undefined
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return this.description.dh_parameters.map((dh_param) => ({
|
|
286
|
+
...EMPTY_DH_PARAMETER,
|
|
287
|
+
...dh_param,
|
|
288
|
+
}))
|
|
271
289
|
}
|
|
272
290
|
|
|
273
291
|
get safetyZones() {
|
|
@@ -6,51 +6,15 @@ import type {
|
|
|
6
6
|
RobotControllerState,
|
|
7
7
|
} from "@wandelbots/nova-js/v2"
|
|
8
8
|
import { makeAutoObservable, runInAction } from "mobx"
|
|
9
|
-
import { Vector3 } from "three"
|
|
10
9
|
import type { Vector3Simple } from "./JoggerConnection"
|
|
11
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
jointValuesEqual,
|
|
12
|
+
tcpMotionEqual,
|
|
13
|
+
unwrapRotationVector,
|
|
14
|
+
} from "./motionStateUpdate"
|
|
12
15
|
|
|
13
16
|
const MOTION_DELTA_THRESHOLD = 0.0001
|
|
14
17
|
|
|
15
|
-
function unwrapRotationVector(
|
|
16
|
-
newRotationVectorApi: Vector3Simple,
|
|
17
|
-
currentRotationVectorApi: Vector3Simple,
|
|
18
|
-
): Vector3Simple {
|
|
19
|
-
const currentRotationVector = new Vector3(
|
|
20
|
-
currentRotationVectorApi[0],
|
|
21
|
-
currentRotationVectorApi[1],
|
|
22
|
-
currentRotationVectorApi[2],
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
const newRotationVector = new Vector3(
|
|
26
|
-
newRotationVectorApi[0],
|
|
27
|
-
newRotationVectorApi[1],
|
|
28
|
-
newRotationVectorApi[2],
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
const currentAngle = currentRotationVector.length()
|
|
32
|
-
const currentAxis = currentRotationVector.normalize()
|
|
33
|
-
|
|
34
|
-
let newAngle = newRotationVector.length()
|
|
35
|
-
let newAxis = newRotationVector.normalize()
|
|
36
|
-
|
|
37
|
-
// Align rotation axes
|
|
38
|
-
if (newAxis.dot(currentAxis) < 0) {
|
|
39
|
-
newAngle = -newAngle
|
|
40
|
-
newAxis = newAxis.multiplyScalar(-1.0)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Shift rotation angle close to previous one to extend domain of rotation angles beyond [0, pi]
|
|
44
|
-
// - this simplifies interpolation and prevents abruptly changing signs of the rotation angles
|
|
45
|
-
let angleDifference = newAngle - currentAngle
|
|
46
|
-
angleDifference -=
|
|
47
|
-
2.0 * Math.PI * Math.floor((angleDifference + Math.PI) / (2.0 * Math.PI))
|
|
48
|
-
|
|
49
|
-
newAngle = currentAngle + angleDifference
|
|
50
|
-
|
|
51
|
-
return [...newAxis.multiplyScalar(newAngle)] as Vector3Simple
|
|
52
|
-
}
|
|
53
|
-
|
|
54
18
|
/**
|
|
55
19
|
* Store representing the current state of a connected motion group.
|
|
56
20
|
*/
|
|
@@ -142,7 +106,8 @@ export class MotionStreamConnection {
|
|
|
142
106
|
)
|
|
143
107
|
) {
|
|
144
108
|
runInAction(() => {
|
|
145
|
-
this.rapidlyChangingMotionState =
|
|
109
|
+
this.rapidlyChangingMotionState.joint_position =
|
|
110
|
+
latestMotionState.joint_position
|
|
146
111
|
})
|
|
147
112
|
}
|
|
148
113
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { MotionGroupState, Pose } from "@wandelbots/nova-js/v2"
|
|
2
|
+
import type { Vector3Simple } from "./JoggerConnection"
|
|
3
|
+
import { Vector3 } from "three"
|
|
2
4
|
|
|
3
5
|
export function jointValuesEqual(
|
|
4
6
|
oldJointValues: number[],
|
|
@@ -74,3 +76,42 @@ export function tcpMotionEqual(
|
|
|
74
76
|
)
|
|
75
77
|
)
|
|
76
78
|
}
|
|
79
|
+
|
|
80
|
+
export function unwrapRotationVector(
|
|
81
|
+
newRotationVectorApi: Vector3Simple,
|
|
82
|
+
currentRotationVectorApi: Vector3Simple,
|
|
83
|
+
): Vector3Simple {
|
|
84
|
+
const currentRotationVector = new Vector3(
|
|
85
|
+
currentRotationVectorApi[0],
|
|
86
|
+
currentRotationVectorApi[1],
|
|
87
|
+
currentRotationVectorApi[2],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const newRotationVector = new Vector3(
|
|
91
|
+
newRotationVectorApi[0],
|
|
92
|
+
newRotationVectorApi[1],
|
|
93
|
+
newRotationVectorApi[2],
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const currentAngle = currentRotationVector.length()
|
|
97
|
+
const currentAxis = currentRotationVector.normalize()
|
|
98
|
+
|
|
99
|
+
let newAngle = newRotationVector.length()
|
|
100
|
+
let newAxis = newRotationVector.normalize()
|
|
101
|
+
|
|
102
|
+
// Align rotation axes
|
|
103
|
+
if (newAxis.dot(currentAxis) < 0) {
|
|
104
|
+
newAngle = -newAngle
|
|
105
|
+
newAxis = newAxis.multiplyScalar(-1.0)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Shift rotation angle close to previous one to extend domain of rotation angles beyond [0, pi]
|
|
109
|
+
// - this simplifies interpolation and prevents abruptly changing signs of the rotation angles
|
|
110
|
+
let angleDifference = newAngle - currentAngle
|
|
111
|
+
angleDifference -=
|
|
112
|
+
2.0 * Math.PI * Math.floor((angleDifference + Math.PI) / (2.0 * Math.PI))
|
|
113
|
+
|
|
114
|
+
newAngle = currentAngle + angleDifference
|
|
115
|
+
|
|
116
|
+
return [...newAxis.multiplyScalar(newAngle)] as Vector3Simple
|
|
117
|
+
}
|