Stations: Resume restores held arm joints, telemetry 404 is unavailable, the panel publishes once a second

- Resume (and Automatic) give the arm joints the sway does not move their
  filed or folded pose back, on both stations; a node given no matrix leaves
  the item's nodes, as a model node returns to its authored pose. Tiangong's
  reset also forgets the hand-posed arms.
- A telemetry route that never answers (a 404, an HTML fallback) reads as
  unavailable instead of connecting forever.
- The STATION section takes the pose age in whole seconds, so live telemetry
  no longer republishes it every frame.
- Tests: the telemetry states, the ISS Automatic handing telemetry back,
  Resume on both stations.
This commit is contained in:
Denis Groshev committed 2026-11-17 16:28:04 +01:00
1 parent 9ed6f11c58
commit 14814b4dab
7 files changed
+185 -4

No files matched your search

+11
View File
@@ -339,6 +339,10 @@ export const ISS_SMALL_ARM_JOINTS = Object.freeze(
/** Every joint that sways. */
const ISS_SWAY_JOINTS = [...ISS_ARM_JOINTS, ...ISS_SMALL_ARM_JOINTS];
/** The arm joints the sway moves; the rest hold NASA's filed pose. */
const ISS_SWAYING_NODES = new Set(
ISS_SWAY_JOINTS.filter((joint) => joint.sway).map((joint) => joint.node),
);
/**
* The arm's illustrative joint angles at a wall-clock time.
@@ -803,6 +807,13 @@ export function createIssArticulation() {
/** Command panel: hand the arm back to its sway. */
function resumeArm() {
// A joint the sway does not move would keep its manual angle: it goes
// back to its filed pose. The swaying ones are posed again next update.
for (const name of manualJoints) {
if (ISS_SWAYING_NODES.has(name)) continue;
const node = boundModel?.getNode(name);
if (node) node.matrix = undefined;
}
manualJoints.clear();
}
+4 -1
View File
@@ -266,7 +266,10 @@ export function createIssTelemetryFeed({
const poseAgeMs = poseAt === null ? null : at - poseAt;
let state;
if (configured === false) state = 'disabled';
else if (configured === null) state = 'pending';
// Never answered: still asking, or the route is not there (a 404, an
// HTML fallback page), which is unavailable rather than pending.
else if (configured === null)
state = failures > 0 ? 'unavailable' : 'pending';
else if (pose && poseAgeMs < ISS_TELEMETRY_FRESH_MS) state = 'live';
else if (failures === 0 && relayStatus === 'no-signal')
state = 'no-signal';
@@ -465,3 +465,47 @@ test('the latest epoch is the newest dated item, and nothing without one', () =>
assert.equal(issTelemetryLatestEpoch({}), null);
assert.equal(issTelemetryLatestEpoch(null), null);
});
test('the status says where the angles stand: pending, live, disabled', async () => {
const time = fakeTime();
const { fetchImpl } = fakeFetch([LIVE]);
const feed = createIssTelemetryFeed({ fetchImpl, ...time });
assert.equal(feed.status().state, 'pending', 'before the first answer');
feed.touch();
await time.advance(0);
const live = feed.status();
assert.equal(live.state, 'live');
assert.ok(live.poseAgeMs >= 0 && live.poseAgeMs < ISS_TELEMETRY_FRESH_MS);
const off = fakeFetch([{ configured: false }]);
const offFeed = createIssTelemetryFeed({ fetchImpl: off.fetchImpl, ...time });
offFeed.touch();
await time.advance(0);
assert.equal(offFeed.status().state, 'disabled');
});
test('a relay route that is not there reads as unavailable, not as connecting forever', async () => {
const time = fakeTime();
// A 404, or a deploy's HTML fallback page: never a relay answer.
const answers = [
{ ok: false, status: 404, json: async () => ({}) },
{
ok: true,
json: async () => {
throw new SyntaxError('Unexpected token <');
},
},
];
let call = 0;
const fetchImpl = async () => answers[Math.min(call++, answers.length - 1)];
const feed = createIssTelemetryFeed({ fetchImpl, ...time });
feed.touch();
await time.advance(0);
assert.equal(feed.configured(), null, 'never answered');
assert.equal(feed.status().state, 'unavailable');
for (let i = 0; i < 30; i++) {
feed.touch();
await time.advance(1000);
}
assert.equal(feed.status().state, 'unavailable');
});
+6
View File
@@ -173,6 +173,12 @@ export function createNodePoses() {
return poses[name];
},
set matrix(value) {
// None: the node goes back to its authored pose (its name leaves
// the map), as a model's node does.
if (value === undefined || value === null) {
delete poses[name];
return;
}
const kept = (poses[name] ??= new Float64Array(16));
for (let i = 0; i < 16; i++) kept[i] = value[i];
},
+12 -1
View File
@@ -88,6 +88,17 @@ export function createStationPanel({
}
}
/**
* The telemetry status with its ages in whole seconds: the section words
* them so, and an age in ms would make every frame a change.
*/
function wholeSeconds(status) {
if (!status) return status;
const second = (ms) =>
Number.isFinite(ms) ? Math.floor(ms / 1000) * 1000 : ms;
return { ...status, poseAgeMs: second(status.poseAgeMs) };
}
function _publish() {
const station = current;
if (!station) {
@@ -109,7 +120,7 @@ export function createStationPanel({
title: station.title,
subject: station.subjectName(),
mode,
telemetry: station.telemetry(),
telemetry: wholeSeconds(station.telemetry()),
sunlit: mode === 'manual' ? null : (articulation?.isSunlit?.() ?? null),
note:
(articulation?.isLive?.() ? station.notes?.live : null) ??
@@ -0,0 +1,97 @@
// src/layers/satellites/stationResume.test.mjs — handing a station's moving
// parts back from the STATION section's Manual: every joint posed by hand
// leaves its manual angle, the ones the illustrative sway does not move
// included, and the ISS's Automatic lets telemetry back in.
import assert from 'node:assert/strict';
import test from 'node:test';
import { createIssArticulation, ISS_ARM_JOINTS } from './issArticulation.js';
import { issStationDescription } from './issStation.js';
import { createNodePoses } from './stationModel.js';
import {
createTiangongArticulation,
TIANGONG_ARMS,
} from './tiangongArticulation.js';
/** A station on its usual axes, in sunlight, as the model part places it. */
const AT = { x: 6_780_000, y: 0, z: 0 };
const AXES = { x: [0, 1, 0], y: [0, 0, 1], z: [1, 0, 0] };
const DATE = new Date(Date.UTC(2026, 10, 16, 12, 0, 0));
test('ISS: Resume gives the Canadarm2 joints the sway does not move their filed pose back', () => {
const articulation = createIssArticulation();
const nodes = createNodePoses();
articulation.update(nodes, DATE, AT, AXES, 1_000);
const held = ISS_ARM_JOINTS.filter((joint) => !joint.sway);
const swaying = ISS_ARM_JOINTS.find((joint) => joint.sway);
assert.ok(held.length > 0 && swaying);
for (const joint of [...held, swaying])
articulation.setJoint(joint.node, joint.pivot, joint.axis, Math.PI / 2);
for (const joint of held) assert.ok(nodes.poses[joint.node], joint.node);
articulation.resumeArm();
for (const joint of held)
assert.equal(
nodes.poses[joint.node],
undefined,
`${joint.node} back to its filed pose`,
);
// A swaying joint is posed by the sway again on the next update.
articulation.update(nodes, DATE, AT, AXES, 2_000);
assert.ok(nodes.poses[swaying.node]);
});
test('Tiangong: resuming an arm gives its held joints their folded pose back, and only that arm', () => {
const articulation = createTiangongArticulation();
const nodes = createNodePoses();
articulation.update(nodes, DATE, AT, AXES, 1_000);
const heldOf = (key) =>
TIANGONG_ARMS[key].filter((joint) => !joint.sway && !joint.centre);
for (const key of ['cmm', 'emm'])
for (const joint of heldOf(key))
articulation.setJoint(joint.node, joint.pivot, joint.axis, 1);
articulation.resumeArm('cmm');
for (const joint of heldOf('cmm'))
assert.equal(nodes.poses[joint.node], undefined, joint.node);
for (const joint of heldOf('emm'))
assert.ok(nodes.poses[joint.node], `${joint.node} still by hand`);
articulation.resumeArm();
for (const joint of heldOf('emm'))
assert.equal(nodes.poses[joint.node], undefined, joint.node);
});
test('a node given no matrix leaves the item’s nodes, as a model node goes back to its authored pose', () => {
const nodes = createNodePoses();
const identity = new Float64Array(16);
identity[0] = identity[5] = identity[10] = identity[15] = 1;
nodes.getNode('JOINT').matrix = identity;
assert.ok(nodes.poses.JOINT);
nodes.getNode('JOINT').matrix = undefined;
assert.equal('JOINT' in nodes.poses, false);
});
test("the ISS's Automatic lets telemetry back in and hands every part back", () => {
const calls = [];
const recorder = new Proxy(
{},
{
get:
(_, name) =>
(...args) =>
calls.push([name, ...args]),
},
);
const station = issStationDescription({ state: {}, parts: {} });
station.automatic(recorder);
const names = calls.map(([name]) => name);
assert.deepEqual(
calls.find(([name]) => name === 'setTelemetryAllowed'),
['setTelemetryAllowed', true],
);
for (const name of [
'setOverride',
'setDishOverride',
'setDeploy',
'setRadiatorDeploy',
'resumeArm',
])
assert.ok(names.includes(name), name);
});
+11 -2
View File
@@ -415,6 +415,7 @@ export function createTiangongArticulation() {
dish = null;
override = null;
wingManual.clear();
armManual.clear();
}
/**
@@ -437,8 +438,16 @@ export function createTiangongArticulation() {
* @param {'cmm'|'emm'} [key]
*/
function resumeArm(key) {
if (key) armManual.delete(key);
else armManual.clear();
for (const arm of key ? [key] : [...armManual]) {
if (!armManual.delete(arm)) continue;
// Joints the sway does not move would keep their manual angle: they go
// back to the folded pose. The swaying ones are posed again next update.
for (const joint of TIANGONG_ARMS[arm] ?? []) {
if (joint.sway || joint.centre) continue;
const node = boundModel?.getNode(joint.node);
if (node) node.matrix = undefined;
}
}
}
/**