mujoco-react 10.8.0 → 10.9.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/index.d.ts +2 -0
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/GenericIK.ts +24 -2
package/dist/index.d.ts
CHANGED
|
@@ -311,6 +311,8 @@ interface GenericIKOptions {
|
|
|
311
311
|
epsilon: number;
|
|
312
312
|
posWeight: number;
|
|
313
313
|
rotWeight: number;
|
|
314
|
+
/** Per-iteration |Δq| cap in radians; bounds near-singular DLS steps. */
|
|
315
|
+
maxStepRad: number;
|
|
314
316
|
jointLimits?: ReadonlyArray<readonly [number, number] | null | undefined>;
|
|
315
317
|
}
|
|
316
318
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3829,7 +3829,8 @@ var DEFAULTS = {
|
|
|
3829
3829
|
tolerance: 1e-3,
|
|
3830
3830
|
epsilon: 1e-6,
|
|
3831
3831
|
posWeight: 1,
|
|
3832
|
-
rotWeight: 0.3
|
|
3832
|
+
rotWeight: 0.3,
|
|
3833
|
+
maxStepRad: 0.5
|
|
3833
3834
|
};
|
|
3834
3835
|
function resolveOptions(opts) {
|
|
3835
3836
|
return {
|
|
@@ -3839,6 +3840,7 @@ function resolveOptions(opts) {
|
|
|
3839
3840
|
epsilon: opts?.epsilon ?? DEFAULTS.epsilon,
|
|
3840
3841
|
posWeight: opts?.posWeight ?? DEFAULTS.posWeight,
|
|
3841
3842
|
rotWeight: opts?.rotWeight ?? DEFAULTS.rotWeight,
|
|
3843
|
+
maxStepRad: opts?.maxStepRad ?? DEFAULTS.maxStepRad,
|
|
3842
3844
|
jointLimits: opts?.jointLimits
|
|
3843
3845
|
};
|
|
3844
3846
|
}
|
|
@@ -3949,7 +3951,20 @@ var GenericIK = class {
|
|
|
3949
3951
|
}
|
|
3950
3952
|
dq[j] = sum;
|
|
3951
3953
|
}
|
|
3952
|
-
for (let i = 0; i < n; i++)
|
|
3954
|
+
for (let i = 0; i < n; i++) {
|
|
3955
|
+
let step = dq[i];
|
|
3956
|
+
if (step > o.maxStepRad) step = o.maxStepRad;
|
|
3957
|
+
else if (step < -o.maxStepRad) step = -o.maxStepRad;
|
|
3958
|
+
let next = q[i] + step;
|
|
3959
|
+
const limits = o.jointLimits?.[i];
|
|
3960
|
+
if (limits) {
|
|
3961
|
+
const low = Math.min(limits[0], limits[1]);
|
|
3962
|
+
const high = Math.max(limits[0], limits[1]);
|
|
3963
|
+
if (next < low) next = low;
|
|
3964
|
+
else if (next > high) next = high;
|
|
3965
|
+
}
|
|
3966
|
+
q[i] = next;
|
|
3967
|
+
}
|
|
3953
3968
|
}
|
|
3954
3969
|
data.qpos.set(savedQpos);
|
|
3955
3970
|
this.mujoco.mj_forward(model, data);
|