@pollen-robotics/reachy-mini-sdk 1.8.0 → 1.8.1
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/APP_CREATION_GUIDE.md +1795 -0
- package/README.md +2 -5
- package/dist/animation/distance.d.ts +87 -0
- package/dist/animation/distance.d.ts.map +1 -0
- package/dist/animation/distance.js +140 -0
- package/dist/animation/distance.js.map +1 -0
- package/dist/animation/index.d.ts +34 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +33 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/pose.d.ts +40 -0
- package/dist/animation/pose.d.ts.map +1 -0
- package/dist/animation/pose.js +15 -0
- package/dist/animation/pose.js.map +1 -0
- package/dist/animation/presets.d.ts +85 -0
- package/dist/animation/presets.d.ts.map +1 -0
- package/dist/animation/presets.js +82 -0
- package/dist/animation/presets.js.map +1 -0
- package/dist/animation/safe-return.d.ts +90 -0
- package/dist/animation/safe-return.d.ts.map +1 -0
- package/dist/animation/safe-return.js +123 -0
- package/dist/animation/safe-return.js.map +1 -0
- package/dist/lib/reachy-mini.d.ts +99 -0
- package/dist/lib/reachy-mini.d.ts.map +1 -1
- package/dist/lib/reachy-mini.js +314 -9
- package/dist/lib/reachy-mini.js.map +1 -1
- package/dist/lib/types.d.ts +27 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/host/README.md +14 -12
- package/host/dist/ReachyHost.d.ts +2 -1
- package/host/dist/ReachyHost.d.ts.map +1 -1
- package/host/dist/chunks/index-lMs2sCXG.js +439 -0
- package/host/dist/chunks/{mountHost-D7cgkU9Q.js → mountHost-DjE5zE9R.js} +11142 -11014
- package/host/dist/chunks/{reachy-mini-B1hlBmDQ.js → reachy-mini-GHNS4GSp.js} +494 -307
- package/host/dist/components/PickerView.d.ts.map +1 -1
- package/host/dist/components/PostOAuthSplash.d.ts +25 -0
- package/host/dist/components/PostOAuthSplash.d.ts.map +1 -0
- package/host/dist/components/ReachyHostShell.d.ts.map +1 -1
- package/host/dist/components/TopBar.d.ts +8 -1
- package/host/dist/components/TopBar.d.ts.map +1 -1
- package/host/dist/components/WelcomeBackOverlay.d.ts.map +1 -1
- package/host/dist/embed/index.d.ts +3 -2
- package/host/dist/embed/index.d.ts.map +1 -1
- package/host/dist/entry/auto.js +2 -2
- package/host/dist/entry/embed.js +2 -2
- package/host/dist/hooks/useHostBridge.d.ts +6 -0
- package/host/dist/hooks/useHostBridge.d.ts.map +1 -1
- package/host/dist/hooks/useSdk.d.ts.map +1 -1
- package/host/dist/index.js +3 -3
- package/host/dist/lib/protocol.d.ts +17 -3
- package/host/dist/lib/protocol.d.ts.map +1 -1
- package/host/dist/lib/settings.d.ts +3 -2
- package/host/dist/lib/settings.d.ts.map +1 -1
- package/host/dist/mountHost.d.ts.map +1 -1
- package/host/dist/ui/design/IdentityChipBar.d.ts +46 -0
- package/host/dist/ui/design/IdentityChipBar.d.ts.map +1 -0
- package/host/dist/ui/design/LinkQualityBars.d.ts +32 -0
- package/host/dist/ui/design/LinkQualityBars.d.ts.map +1 -0
- package/host/dist/ui/design/MetaPill.d.ts +41 -0
- package/host/dist/ui/design/MetaPill.d.ts.map +1 -0
- package/host/dist/ui/design/TransportChip.d.ts +39 -0
- package/host/dist/ui/design/TransportChip.d.ts.map +1 -0
- package/package.json +7 -4
- package/CHANGELOG.md +0 -188
- package/host/APP_AUTHOR_GUIDE.md +0 -646
- package/host/SPEC.md +0 -618
- package/host/dist/chunks/index-CyLPysJS.js +0 -400
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit-handler helpers.
|
|
3
|
+
*
|
|
4
|
+
* Two thin convenience functions on top of the SDK's existing motion
|
|
5
|
+
* primitives (`setMotorMode`, `gotoTarget`) + the lib's pose math
|
|
6
|
+
* (`scaledDuration`). They exist so that:
|
|
7
|
+
*
|
|
8
|
+
* 1. App authors get a one-liner for the "return to safe pose on
|
|
9
|
+
* exit" pattern instead of copy-pasting the three-call sequence.
|
|
10
|
+
* 2. The pattern is consistent across apps (same target, same
|
|
11
|
+
* scaled-duration tuning, same error handling for closed
|
|
12
|
+
* channels).
|
|
13
|
+
*
|
|
14
|
+
* No daemon-side primitive is introduced; everything routes through
|
|
15
|
+
* existing data-channel commands.
|
|
16
|
+
*/
|
|
17
|
+
import type { PartialPose } from "./pose.js";
|
|
18
|
+
import { type ScaledDurationPreset } from "./presets.js";
|
|
19
|
+
import { type ScaledDurationResult } from "./distance.js";
|
|
20
|
+
import type { ReachyMiniInstance } from "../lib/types.js";
|
|
21
|
+
/** Options for `safelyReturnToPose`. */
|
|
22
|
+
export interface SafelyReturnOptions {
|
|
23
|
+
/** Where to return to. Defaults to `INIT_POSE`. */
|
|
24
|
+
target?: PartialPose;
|
|
25
|
+
/** Scaled-duration tuning. Defaults to `DEFAULT_SCALED_DURATION_PRESET`. */
|
|
26
|
+
preset?: ScaledDurationPreset;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Smooth, distance-scaled return to a target pose. Routes through the
|
|
30
|
+
* existing SDK primitives:
|
|
31
|
+
*
|
|
32
|
+
* 1. `reachy.setMotorMode("enabled")` — safe by construction since
|
|
33
|
+
* daemon PR #1138 (the daemon pins all targets to the present
|
|
34
|
+
* pose before flipping torque on).
|
|
35
|
+
* 2. Read `reachy.robotState` for the current pose snapshot.
|
|
36
|
+
* 3. Compute `scaledDuration(current, target, preset)`.
|
|
37
|
+
* 4. Call `reachy.gotoTarget({ ...target, duration })`.
|
|
38
|
+
*
|
|
39
|
+
* Returns **synchronously after dispatching** the goto — does NOT
|
|
40
|
+
* await completion. Callers who want to await the move should
|
|
41
|
+
* subscribe to the `state` event or
|
|
42
|
+
* `await sleep(result.duration * 1000)`.
|
|
43
|
+
*
|
|
44
|
+
* Safe to call when the data channel is closed: every SDK call
|
|
45
|
+
* swallows the "channel closed" error silently, and the planned
|
|
46
|
+
* duration is still returned for log lines.
|
|
47
|
+
*
|
|
48
|
+
* The returned `ScaledDurationResult` carries the diagnostic data
|
|
49
|
+
* (which channel was the slowest, per-channel candidate durations)
|
|
50
|
+
* so apps can log "why does the home return take 1.2 s?".
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Host-shell embedded app:
|
|
54
|
+
* onLeave(() => safelyReturnToPose(reachy));
|
|
55
|
+
*
|
|
56
|
+
* // Custom target:
|
|
57
|
+
* safelyReturnToPose(reachy, {
|
|
58
|
+
* target: { head: customHeadMatrix, antennas: [0, 0], body_yaw: 0 },
|
|
59
|
+
* });
|
|
60
|
+
*/
|
|
61
|
+
export declare function safelyReturnToPose(reachy: ReachyMiniInstance, options?: SafelyReturnOptions): ScaledDurationResult;
|
|
62
|
+
/** Options for `installShutdownHandler`. */
|
|
63
|
+
export interface InstallShutdownHandlerOptions extends SafelyReturnOptions {
|
|
64
|
+
/**
|
|
65
|
+
* Skip when `reachy.state !== "streaming"`. Defaults to `true` —
|
|
66
|
+
* the handler only fires when a session is actually live, so a
|
|
67
|
+
* stale tab where the user never picked a robot doesn't try to
|
|
68
|
+
* command anything on close.
|
|
69
|
+
*/
|
|
70
|
+
onlyWhenStreaming?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Wire `pagehide` + `beforeunload` so the robot returns to its safe-rest
|
|
74
|
+
* pose when the app closes.
|
|
75
|
+
*
|
|
76
|
+
* Use case: **standalone apps** (test benches, custom dashboards)
|
|
77
|
+
* that don't have a host shell to manage their lifecycle. Host-shell
|
|
78
|
+
* embedded apps should use the `onLeave` callback from
|
|
79
|
+
* `connectToHost()` instead — it integrates with the host's
|
|
80
|
+
* leave-protocol budget and avoids double-firing.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const reachy = new ReachyMini(...);
|
|
84
|
+
* await reachy.authenticate();
|
|
85
|
+
* await reachy.connect();
|
|
86
|
+
* // ...pick robot, startSession...
|
|
87
|
+
* installShutdownHandler(reachy);
|
|
88
|
+
*/
|
|
89
|
+
export declare function installShutdownHandler(reachy: ReachyMiniInstance, options?: InstallShutdownHandlerOptions): void;
|
|
90
|
+
//# sourceMappingURL=safe-return.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-return.d.ts","sourceRoot":"","sources":["../../animation/safe-return.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAGH,KAAK,oBAAoB,EAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAChC,mDAAmD;IACnD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,oBAAoB,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,GAAE,mBAAwB,GAClC,oBAAoB,CA+BtB;AAED,4CAA4C;AAC5C,MAAM,WAAW,6BAA8B,SAAQ,mBAAmB;IACtE;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,GAAE,6BAAkC,GAC5C,IAAI,CAoBN"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exit-handler helpers.
|
|
3
|
+
*
|
|
4
|
+
* Two thin convenience functions on top of the SDK's existing motion
|
|
5
|
+
* primitives (`setMotorMode`, `gotoTarget`) + the lib's pose math
|
|
6
|
+
* (`scaledDuration`). They exist so that:
|
|
7
|
+
*
|
|
8
|
+
* 1. App authors get a one-liner for the "return to safe pose on
|
|
9
|
+
* exit" pattern instead of copy-pasting the three-call sequence.
|
|
10
|
+
* 2. The pattern is consistent across apps (same target, same
|
|
11
|
+
* scaled-duration tuning, same error handling for closed
|
|
12
|
+
* channels).
|
|
13
|
+
*
|
|
14
|
+
* No daemon-side primitive is introduced; everything routes through
|
|
15
|
+
* existing data-channel commands.
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_SCALED_DURATION_PRESET, INIT_POSE, } from "./presets.js";
|
|
18
|
+
import { scaledDuration } from "./distance.js";
|
|
19
|
+
/**
|
|
20
|
+
* Smooth, distance-scaled return to a target pose. Routes through the
|
|
21
|
+
* existing SDK primitives:
|
|
22
|
+
*
|
|
23
|
+
* 1. `reachy.setMotorMode("enabled")` — safe by construction since
|
|
24
|
+
* daemon PR #1138 (the daemon pins all targets to the present
|
|
25
|
+
* pose before flipping torque on).
|
|
26
|
+
* 2. Read `reachy.robotState` for the current pose snapshot.
|
|
27
|
+
* 3. Compute `scaledDuration(current, target, preset)`.
|
|
28
|
+
* 4. Call `reachy.gotoTarget({ ...target, duration })`.
|
|
29
|
+
*
|
|
30
|
+
* Returns **synchronously after dispatching** the goto — does NOT
|
|
31
|
+
* await completion. Callers who want to await the move should
|
|
32
|
+
* subscribe to the `state` event or
|
|
33
|
+
* `await sleep(result.duration * 1000)`.
|
|
34
|
+
*
|
|
35
|
+
* Safe to call when the data channel is closed: every SDK call
|
|
36
|
+
* swallows the "channel closed" error silently, and the planned
|
|
37
|
+
* duration is still returned for log lines.
|
|
38
|
+
*
|
|
39
|
+
* The returned `ScaledDurationResult` carries the diagnostic data
|
|
40
|
+
* (which channel was the slowest, per-channel candidate durations)
|
|
41
|
+
* so apps can log "why does the home return take 1.2 s?".
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Host-shell embedded app:
|
|
45
|
+
* onLeave(() => safelyReturnToPose(reachy));
|
|
46
|
+
*
|
|
47
|
+
* // Custom target:
|
|
48
|
+
* safelyReturnToPose(reachy, {
|
|
49
|
+
* target: { head: customHeadMatrix, antennas: [0, 0], body_yaw: 0 },
|
|
50
|
+
* });
|
|
51
|
+
*/
|
|
52
|
+
export function safelyReturnToPose(reachy, options = {}) {
|
|
53
|
+
const target = options.target ?? INIT_POSE;
|
|
54
|
+
const preset = options.preset ?? DEFAULT_SCALED_DURATION_PRESET;
|
|
55
|
+
try {
|
|
56
|
+
reachy.setMotorMode("enabled");
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Already in the right mode, or data channel closed; both are
|
|
60
|
+
// benign here — we still compute and emit the goto.
|
|
61
|
+
}
|
|
62
|
+
const current = reachy.robotState;
|
|
63
|
+
const plan = scaledDuration(current, target, preset);
|
|
64
|
+
const args = {
|
|
65
|
+
duration: plan.duration,
|
|
66
|
+
};
|
|
67
|
+
if (target.head !== undefined)
|
|
68
|
+
args.head = target.head.slice();
|
|
69
|
+
if (target.antennas !== undefined) {
|
|
70
|
+
args.antennas = [target.antennas[0] ?? 0, target.antennas[1] ?? 0];
|
|
71
|
+
}
|
|
72
|
+
if (target.body_yaw !== undefined)
|
|
73
|
+
args.body_yaw = target.body_yaw;
|
|
74
|
+
try {
|
|
75
|
+
reachy.gotoTarget(args);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Closed channel / shutting down / session torn down between
|
|
79
|
+
// the read and the send. The plan is still useful for logs.
|
|
80
|
+
}
|
|
81
|
+
return plan;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Wire `pagehide` + `beforeunload` so the robot returns to its safe-rest
|
|
85
|
+
* pose when the app closes.
|
|
86
|
+
*
|
|
87
|
+
* Use case: **standalone apps** (test benches, custom dashboards)
|
|
88
|
+
* that don't have a host shell to manage their lifecycle. Host-shell
|
|
89
|
+
* embedded apps should use the `onLeave` callback from
|
|
90
|
+
* `connectToHost()` instead — it integrates with the host's
|
|
91
|
+
* leave-protocol budget and avoids double-firing.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const reachy = new ReachyMini(...);
|
|
95
|
+
* await reachy.authenticate();
|
|
96
|
+
* await reachy.connect();
|
|
97
|
+
* // ...pick robot, startSession...
|
|
98
|
+
* installShutdownHandler(reachy);
|
|
99
|
+
*/
|
|
100
|
+
export function installShutdownHandler(reachy, options = {}) {
|
|
101
|
+
const onlyWhenStreaming = options.onlyWhenStreaming ?? true;
|
|
102
|
+
// Reentry guard: `pagehide` and `beforeunload` both fire on a real
|
|
103
|
+
// tab close, so without this flag `safelyReturnToPose` would dispatch
|
|
104
|
+
// twice (idempotent in practice — the second goto overrides the first
|
|
105
|
+
// with the same duration — but wasteful and noisy in the daemon log).
|
|
106
|
+
// Matches the `shuttingDown` boolean in Rémi's `reachy-mini-js-practices`
|
|
107
|
+
// bench, which is the reference behaviour for this helper.
|
|
108
|
+
let shuttingDown = false;
|
|
109
|
+
const fire = () => {
|
|
110
|
+
if (shuttingDown)
|
|
111
|
+
return;
|
|
112
|
+
shuttingDown = true;
|
|
113
|
+
if (onlyWhenStreaming && reachy.state !== "streaming")
|
|
114
|
+
return;
|
|
115
|
+
safelyReturnToPose(reachy, {
|
|
116
|
+
target: options.target,
|
|
117
|
+
preset: options.preset,
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
window.addEventListener("pagehide", fire);
|
|
121
|
+
window.addEventListener("beforeunload", fire);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=safe-return.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-return.js","sourceRoot":"","sources":["../../animation/safe-return.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACH,8BAA8B,EAC9B,SAAS,GAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAA6B,MAAM,eAAe,CAAC;AAW1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;A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AAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,IAAI,CAAC;IAC5D,mEAAmE;IACnE,sEAAsE;IACtE,sEAAsE;IACtE,sEAAsE;IACtE,0EAA0E;IAC1E,2DAA2D;IAC3D,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,MAAM,IAAI,GAAG,GAAS,EAAE;QACpB,IAAI,YAAY;YAAE,OAAO;QACzB,YAAY,GAAG,IAAI,CAAC;QACpB,IAAI,iBAAiB,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW;YAAE,OAAO;QAC9D,kBAAkB,CAAC,MAAM,EAAE;YACvB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;SACzB,CAAC,CAAC;IACP,CAAC,CAAC;IACF,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -44,6 +44,12 @@ export declare class ReachyMini extends EventTarget implements ReachyMiniInstanc
|
|
|
44
44
|
private _sessionReject;
|
|
45
45
|
private _iceConnected;
|
|
46
46
|
private _dcOpen;
|
|
47
|
+
private _iceGraceTimer;
|
|
48
|
+
private _iceGraceReason;
|
|
49
|
+
private _pendingVisibilityHandler;
|
|
50
|
+
private _onlineHandler;
|
|
51
|
+
private _offlineHandler;
|
|
52
|
+
private _connectionChangeHandler;
|
|
47
53
|
private readonly _pendingMotionCompletions;
|
|
48
54
|
private _videoElement;
|
|
49
55
|
constructor(options?: ReachyMiniOptions);
|
|
@@ -75,6 +81,98 @@ export declare class ReachyMini extends EventTarget implements ReachyMiniInstanc
|
|
|
75
81
|
private _failSessionRejected;
|
|
76
82
|
stopSession(): Promise<void>;
|
|
77
83
|
disconnect(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Cancel any pending ICE grace timer and visibility handler. Called
|
|
86
|
+
* on a healed `connected`/`completed` transition AND from the
|
|
87
|
+
* lifecycle teardown paths so a callback can't fire after `_pc`
|
|
88
|
+
* is closed.
|
|
89
|
+
*/
|
|
90
|
+
private _clearIceGrace;
|
|
91
|
+
/**
|
|
92
|
+
* Start a grace window. After `ms`, re-check the live ICE state:
|
|
93
|
+
* - If we healed back to `connected`/`completed`, the timer was
|
|
94
|
+
* already cancelled in `oniceconnectionstatechange`, so we
|
|
95
|
+
* never get here.
|
|
96
|
+
* - If we're still in the originally-observed bad state (or
|
|
97
|
+
* worse), surface the error and reject any pending session
|
|
98
|
+
* promise. The original code path is preserved verbatim so
|
|
99
|
+
* downstream consumers see the same `error` payload shape.
|
|
100
|
+
*/
|
|
101
|
+
private _scheduleIceGrace;
|
|
102
|
+
/**
|
|
103
|
+
* `disconnected` while the tab is hidden. JS timers are throttled
|
|
104
|
+
* in background tabs (Chrome clamps to ~1 Hz, Safari can pause
|
|
105
|
+
* altogether), so a foreground grace timer would either miss the
|
|
106
|
+
* window or fire long after the connection healed. Wait for the
|
|
107
|
+
* tab to come back, then re-evaluate.
|
|
108
|
+
*/
|
|
109
|
+
private _armIceGraceOnVisibility;
|
|
110
|
+
/**
|
|
111
|
+
* Install browser-level network listeners and forward them as
|
|
112
|
+
* public `networkOnline` / `networkOffline` / `networkChange`
|
|
113
|
+
* events on this instance. Idempotent: called from
|
|
114
|
+
* `startSession()`, removed by `_uninstallNetworkListeners` on
|
|
115
|
+
* teardown. Reachable only when there's a live `window`
|
|
116
|
+
* (defensive guard for SSR / test environments).
|
|
117
|
+
*
|
|
118
|
+
* `online` / `offline` are semantically about CONNECTIVITY:
|
|
119
|
+
* "does the OS think we can reach the internet". They flip
|
|
120
|
+
* symmetrically.
|
|
121
|
+
*
|
|
122
|
+
* `connection.change` (NetworkInformation API, Chrome / Android
|
|
123
|
+
* WebView only) is semantically about the TRANSPORT: it fires
|
|
124
|
+
* on Wi-Fi → 4G swaps, AP roams, etc. without necessarily going
|
|
125
|
+
* through `offline`. We forward it as its own `networkChange`
|
|
126
|
+
* event rather than aliasing it onto `networkOnline`, so
|
|
127
|
+
* consumers don't have to guess whether they're seeing a real
|
|
128
|
+
* connectivity recovery or a silent transport swap.
|
|
129
|
+
*/
|
|
130
|
+
private _installNetworkListeners;
|
|
131
|
+
/** Counterpart to `_installNetworkListeners`. */
|
|
132
|
+
private _uninstallNetworkListeners;
|
|
133
|
+
/**
|
|
134
|
+
* Atomic raw-units pose update over the data channel. Channels you
|
|
135
|
+
* omit are held at their last commanded value (per-axis, independent).
|
|
136
|
+
*
|
|
137
|
+
* **Head pose is in the WORLD frame.** The daemon's IK splits the
|
|
138
|
+
* requested head world-yaw between body rotation and the stewart
|
|
139
|
+
* platform, subject to the mechanical limit
|
|
140
|
+
* `|head_yaw_world − body_yaw| ≤ 65°`.
|
|
141
|
+
*
|
|
142
|
+
* **If you want the head to FOLLOW the body** (tank-style rotation):
|
|
143
|
+
* a `setTarget({ body_yaw })` on its own does NOT rotate the head —
|
|
144
|
+
* the head's commanded world yaw is unchanged, so its gaze stays
|
|
145
|
+
* pinned in world frame while the body turns under it. To make the
|
|
146
|
+
* head turn with the body, include a `head` matrix in the SAME call
|
|
147
|
+
* with the body-yaw delta added to the head RPY's yaw:
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* // Body-yaw drag handler: tank-couple the head so it follows.
|
|
151
|
+
* const delta = newBodyDeg - lastCommandedBodyDeg;
|
|
152
|
+
* const nextHeadYaw = lastCommandedHeadYawDeg + delta;
|
|
153
|
+
* robot.setTarget({
|
|
154
|
+
* head: rpyToMatrix(headRoll, headPitch, nextHeadYaw).flat(),
|
|
155
|
+
* body_yaw: degToRad(newBodyDeg),
|
|
156
|
+
* });
|
|
157
|
+
* lastCommandedHeadYawDeg = nextHeadYaw;
|
|
158
|
+
* lastCommandedBodyDeg = newBodyDeg;
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* **Baseline must be the last COMMANDED value, not telemetry.** For
|
|
162
|
+
* continuous-input controllers (slider drag, joystick), do not use
|
|
163
|
+
* `state.head` from the `state` event as the baseline for incremental
|
|
164
|
+
* commands — telemetry lags one WebRTC round-trip, so cumulative
|
|
165
|
+
* deltas computed against it stall (every iteration in a rapid drag
|
|
166
|
+
* adds the same `delta` to the same stale baseline → the head fails
|
|
167
|
+
* to keep up). Track the last-commanded RPY in your own buffer.
|
|
168
|
+
*
|
|
169
|
+
* @param head Flat row-major 4×4 matrix (16 finite numbers) in
|
|
170
|
+
* the world frame. Omit to hold the previous head target.
|
|
171
|
+
* @param antennas `[rightRad, leftRad]` (radians). Omit to hold.
|
|
172
|
+
* @param body_yaw Signed radians. Omit to hold.
|
|
173
|
+
* @returns `true` if the command was queued on the data channel,
|
|
174
|
+
* `false` if the channel is not open.
|
|
175
|
+
*/
|
|
78
176
|
setTarget({ head, antennas, body_yaw }?: {
|
|
79
177
|
head?: number[];
|
|
80
178
|
antennas?: number[];
|
|
@@ -90,6 +188,7 @@ export declare class ReachyMini extends EventTarget implements ReachyMiniInstanc
|
|
|
90
188
|
setAntennasDeg(rightDeg: number, leftDeg: number): boolean;
|
|
91
189
|
setBodyYawDeg(yawDeg: number): boolean;
|
|
92
190
|
playSound(file: string): boolean;
|
|
191
|
+
clearIncomingAudio(): boolean;
|
|
93
192
|
setMotorMode(mode: 'enabled' | 'disabled' | 'gravity_compensation'): boolean;
|
|
94
193
|
setMotorTorque(on: boolean, ids?: string[] | null): boolean;
|
|
95
194
|
wakeUp({ timeoutMs }?: MotionAwaitOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reachy-mini.d.ts","sourceRoot":"","sources":["../../lib/reachy-mini.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,OAAO,KAAK,EACR,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EAEjB,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,cAAc,EACd,wBAAwB,EAExB,kBAAkB,EAClB,iBA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