@7365admin1/core 3.111.0 → 3.112.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +316 -5
- package/dist/index.js +1401 -781
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1577 -953
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/test/e2e/harness.mjs +1 -0
- package/test/e2e/rmf-editor-parity.e2e.test.mjs +259 -0
- package/test/fixtures/open-rmf/buildings/LICENSE.md +201 -0
- package/test/fixtures/open-rmf/buildings/NOTICE.md +18 -0
- package/test/fixtures/open-rmf/buildings/hero-demo.building.yaml +2605 -0
- package/test/fixtures/open-rmf/buildings/hero-demo.upstream-nav.json +816 -0
- package/test/fixtures/open-rmf/buildings/hotel.building.yaml +1072 -0
- package/test/fixtures/open-rmf/buildings/hotel.nav.json +3115 -0
- package/test/fixtures/open-rmf/buildings/office.building.yaml +301 -0
- package/test/fixtures/open-rmf/buildings/office.nav.json +591 -0
- package/test/rmf-building-files.test.mjs +272 -0
- package/test/rmf-building.test.mjs +2 -2
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// Building files (traffic-editor / rmf_site building.yaml, per-graph nav
|
|
2
|
+
// graphs): the import must reproduce what the upstream Open-RMF generator makes
|
|
3
|
+
// of the same file, and export -> import must give back the same building.
|
|
4
|
+
// Fixtures: rmf_demos hotel + office, and the upstream generator's own output
|
|
5
|
+
// for them (test/fixtures/open-rmf/buildings/NOTICE.md).
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { test } from "node:test";
|
|
9
|
+
import yaml from "js-yaml";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
applyXform,
|
|
13
|
+
buildingFrame,
|
|
14
|
+
fiducialTransform,
|
|
15
|
+
fromBuildingYaml,
|
|
16
|
+
fromNavGraph,
|
|
17
|
+
legacyFromRmf,
|
|
18
|
+
mergeLegacyIntoRmf,
|
|
19
|
+
rmfProblem,
|
|
20
|
+
toBuildingYaml,
|
|
21
|
+
toNavGraphs,
|
|
22
|
+
} from "./.build/utils/rmf-building.util.mjs";
|
|
23
|
+
import { rmfBuildingSchema, buildingMapBodySchema } from "./.build/models/robot-building-map.model.mjs";
|
|
24
|
+
|
|
25
|
+
const dir = new URL("./fixtures/open-rmf/buildings/", import.meta.url);
|
|
26
|
+
const load = (f) => yaml.load(readFileSync(new URL(f, dir), "utf8"));
|
|
27
|
+
const upstream = (f) => JSON.parse(readFileSync(new URL(f, dir), "utf8"));
|
|
28
|
+
|
|
29
|
+
/** Deep compare with a tolerance for numbers (we keep millimetres, upstream keeps every digit). */
|
|
30
|
+
function near(a, b, path = "$", tol = 0.0015) {
|
|
31
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
32
|
+
assert.ok(Math.abs(a - b) <= tol, `${path}: ${a} vs ${b}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
36
|
+
assert.ok(Array.isArray(a) && Array.isArray(b), `${path}: array vs non-array`);
|
|
37
|
+
assert.equal(a.length, b.length, `${path}: length`);
|
|
38
|
+
a.forEach((x, i) => near(x, b[i], `${path}[${i}]`, tol));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (a && typeof a === "object") {
|
|
42
|
+
assert.ok(b && typeof b === "object", `${path}: object vs ${typeof b}`);
|
|
43
|
+
assert.deepEqual(Object.keys(a).sort(), Object.keys(b).sort(), `${path}: keys`);
|
|
44
|
+
for (const k of Object.keys(a)) near(a[k], b[k], `${path}.${k}`, tol);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
assert.equal(a, b, path);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Every edge and polygon by its points instead of its vertex ids - equality that ignores numbering. */
|
|
51
|
+
function byPoints(rmf) {
|
|
52
|
+
return {
|
|
53
|
+
...rmf,
|
|
54
|
+
levels: rmf.levels.map((lv) => {
|
|
55
|
+
const at = new Map(lv.vertices.map((v) => [v.id, [v.x, v.y, v.name ?? "", v.params ?? {}]]));
|
|
56
|
+
const edge = ({ v1, v2, ...rest }) => ({ a: at.get(v1), b: at.get(v2), ...rest });
|
|
57
|
+
const poly = ({ vertices, ...rest }) => ({ ...rest, points: vertices.map((id) => at.get(id)) });
|
|
58
|
+
return {
|
|
59
|
+
...lv,
|
|
60
|
+
vertices: undefined,
|
|
61
|
+
walls: lv.walls.map(edge),
|
|
62
|
+
doors: lv.doors.map(edge),
|
|
63
|
+
lanes: lv.lanes.map(edge),
|
|
64
|
+
measurements: lv.measurements.map(edge),
|
|
65
|
+
floors: lv.floors.map(poly),
|
|
66
|
+
holes: lv.holes.map(poly),
|
|
67
|
+
zones: lv.zones.map(poly),
|
|
68
|
+
named: lv.vertices.filter((v) => v.name || v.params).map((v) => at.get(v.id)),
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const [file, nav] of [["hotel.building.yaml", "hotel.nav.json"], ["office.building.yaml", "office.nav.json"]]) {
|
|
75
|
+
test(`${file}: the import reproduces the upstream generator's route graphs exactly`, () => {
|
|
76
|
+
const { rmf, name } = fromBuildingYaml(load(file));
|
|
77
|
+
const ours = Object.fromEntries(Object.entries(toNavGraphs(name, rmf)).map(([k, v]) => [String(k), JSON.parse(v)]));
|
|
78
|
+
const theirs = upstream(nav);
|
|
79
|
+
assert.deepEqual(Object.keys(ours).sort(), Object.keys(theirs).sort(), "same graphs");
|
|
80
|
+
for (const g of Object.keys(theirs)) {
|
|
81
|
+
// upstream writes offset only for cartesian files; an image-based file has none.
|
|
82
|
+
const { offset: _o, ...mine } = ours[g];
|
|
83
|
+
near(mine, theirs[g], `graph ${g}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test(`${file}: valid for the API, and export -> import gives back the same building`, () => {
|
|
88
|
+
const first = fromBuildingYaml(load(file));
|
|
89
|
+
assert.equal(first.rmf.source, "file");
|
|
90
|
+
const { error } = rmfBuildingSchema.validate(first.rmf);
|
|
91
|
+
assert.equal(error, undefined, error?.message);
|
|
92
|
+
assert.equal(rmfProblem(first.rmf), null);
|
|
93
|
+
const text = toBuildingYaml(first.name, first.rmf);
|
|
94
|
+
// The export is cartesian metres, parses as YAML, and opens again as the same building.
|
|
95
|
+
const doc = yaml.load(text);
|
|
96
|
+
assert.equal(doc.coordinate_system, "cartesian_meters");
|
|
97
|
+
const second = fromBuildingYaml(doc);
|
|
98
|
+
assert.deepEqual(second.rmf, first.rmf);
|
|
99
|
+
assert.deepEqual(second.warnings, []);
|
|
100
|
+
// ... and its route graphs are unchanged.
|
|
101
|
+
assert.deepEqual(toNavGraphs(second.name, second.rmf), toNavGraphs(first.name, first.rmf));
|
|
102
|
+
// The legacy fields every existing reader uses still validate.
|
|
103
|
+
const legacy = legacyFromRmf(first.rmf);
|
|
104
|
+
const body = buildingMapBodySchema.validate({ name: "x", ...legacy });
|
|
105
|
+
assert.equal(body.error, undefined, body.error?.message);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
test("hotel: levels, floor numbers, alignment by fiducials, lifts, doors, lanes and waypoint params", () => {
|
|
110
|
+
const { rmf, name, warnings } = fromBuildingYaml(load("hotel.building.yaml"));
|
|
111
|
+
const ref = upstream("hotel.nav.json");
|
|
112
|
+
assert.equal(name, "hotel");
|
|
113
|
+
assert.deepEqual(warnings, []);
|
|
114
|
+
assert.deepEqual(rmf.levels.map((l) => [l.name, l.floorNo, l.elevationM]), [["L1", 1, 0], ["L2", 2, 8], ["L3", 3, 16]]);
|
|
115
|
+
assert.equal(rmf.referenceLevel, "L1");
|
|
116
|
+
// Lifts land where the generator puts them (the reference floor's transform).
|
|
117
|
+
near(rmf.lifts.map((l) => [l.x, l.y, l.yawRad, l.widthM, l.depthM]), Object.values(ref["0"].lifts).map((l) => [...l.position, ...l.dims]));
|
|
118
|
+
const lift1 = rmf.lifts.find((l) => l.name === "Lift1");
|
|
119
|
+
assert.deepEqual(lift1.doors, [{ name: "lift1_door", type: "double_sliding", x: 0, y: -1.5, widthM: 1.7, axisYawRad: 0 }]);
|
|
120
|
+
assert.deepEqual(lift1.levelDoors.map((x) => x.level), ["L1", "L2", "L3"]);
|
|
121
|
+
// lowest / highest / first floor match the served floors, so they are not stored twice - export writes them back.
|
|
122
|
+
assert.deepEqual([lift1.lowestFloor, lift1.highestFloor, lift1.initialFloor], [undefined, undefined, undefined]);
|
|
123
|
+
const exported = JSON.parse(toBuildingYaml("hotel", rmf)).lifts.Lift1;
|
|
124
|
+
assert.deepEqual([exported.lowest_floor, exported.highest_floor, exported.initial_floor_name], ["L1", "L3", "L1"]);
|
|
125
|
+
// All four door types, and the negative swing the file carries, are kept.
|
|
126
|
+
const types = new Set(rmf.levels.flatMap((l) => l.doors.map((d) => d.type)));
|
|
127
|
+
for (const t of ["hinged", "double_hinged", "double_sliding"]) assert.ok(types.has(t), `hotel has a ${t} door`);
|
|
128
|
+
assert.ok(rmf.levels[0].doors.some((d) => d.motionDegrees === -90));
|
|
129
|
+
// Fiducials are carried into metres: the three named marks line up across floors.
|
|
130
|
+
const f = (lv, n) => rmf.levels.find((l) => l.name === lv).fiducials.find((x) => x.name === n);
|
|
131
|
+
for (const n of ["ref1", "ref2", "ref3"].filter((x) => f("L1", x) && f("L2", x))) near([f("L2", n).x, f("L2", n).y], [f("L1", n).x, f("L1", n).y], n, 0.35);
|
|
132
|
+
// Waypoint params and graphs.
|
|
133
|
+
const lobby = rmf.levels[0].vertices.find((v) => v.name === "lobby");
|
|
134
|
+
assert.equal(lobby.params.is_holding_point, true);
|
|
135
|
+
assert.deepEqual(rmf.graphs.map((g) => g.idx), [0, 1, 2]);
|
|
136
|
+
assert.ok(rmf.levels.every((l) => l.measurements.length === 1));
|
|
137
|
+
// One frame round the whole building, the same on every floor.
|
|
138
|
+
assert.ok(rmf.levels.every((l) => JSON.stringify(l.planFrame) === JSON.stringify(rmf.levels[0].planFrame)));
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("a map drawn in HERO (zones, doors of every type, lift cabin doors, lanes on two graphs, fiducials, measurements) round-trips", () => {
|
|
142
|
+
const base = mergeLegacyIntoRmf(null, {
|
|
143
|
+
levels: [
|
|
144
|
+
{ floorNo: 1, name: "L1", elevationM: 0, walls: [{ start: { x: 2, y: 2 }, end: { x: 38, y: 2 } }, { start: { x: 38, y: 2 }, end: { x: 38, y: 24 } }], zones: [{ name: "Lobby", points: [{ x: 3, y: 3 }, { x: 17, y: 3 }, { x: 17, y: 10 }, { x: 3, y: 10 }] }] },
|
|
145
|
+
{ floorNo: 2, name: "L2", elevationM: 4, walls: [], zones: [] },
|
|
146
|
+
],
|
|
147
|
+
doors: [{ name: "Main entrance", floorNo: 1, type: "sliding", start: { x: 8, y: 24 }, end: { x: 12, y: 24 } }],
|
|
148
|
+
lifts: [{ name: "Lift 1", x: 32, y: 18, widthM: 2.2, depthM: 2.2, floors: [1, 2] }],
|
|
149
|
+
});
|
|
150
|
+
const l1 = base.levels[0];
|
|
151
|
+
l1.doors[0].type = "double_sliding";
|
|
152
|
+
l1.doors.push({ name: "Office", v1: l1.walls[0].v1, v2: l1.walls[0].v2, type: "double_hinged", motionAxis: "end", motionDegrees: 110, motionDirection: -1, rightLeftRatio: 1.5 });
|
|
153
|
+
l1.vertices.push(
|
|
154
|
+
{ id: "w1", x: 5, y: -20, name: "dock_a", params: { is_charger: true, dock_name: "dock_a", is_parking_spot: true } },
|
|
155
|
+
{ id: "w2", x: 20, y: -20, name: "hall", params: { is_holding_point: true, mutex: "hall" } },
|
|
156
|
+
{ id: "w3", x: 32, y: -18, name: "lift_in", params: { is_passthrough_point: true, pickup_dispenser: "cart", dropoff_ingestor: "bin", spawn_robot_name: "c1", spawn_robot_type: "cleaner", merge_radius: 0.5 } },
|
|
157
|
+
);
|
|
158
|
+
l1.lanes.push(
|
|
159
|
+
{ v1: "w1", v2: "w2", graphIdx: 0, bidirectional: true, speedLimit: 0.8, orientation: "forward" },
|
|
160
|
+
{ v1: "w2", v2: "w3", graphIdx: 0, bidirectional: false, mutex: "lift" },
|
|
161
|
+
{ v1: "w1", v2: "w3", graphIdx: 2, bidirectional: true, demoMockFloorName: "L2", demoMockLiftName: "Lift 1" },
|
|
162
|
+
);
|
|
163
|
+
l1.fiducials.push({ name: "column A", x: 2, y: -2 }, { name: "column B", x: 38, y: -24 });
|
|
164
|
+
l1.measurements.push({ v1: l1.walls[0].v1, v2: l1.walls[0].v2, distanceM: 36 });
|
|
165
|
+
base.graphs = [{ idx: 0, name: "Cleaners", brands: ["ounitech"] }, { idx: 2, name: "Patrol", brands: [] }];
|
|
166
|
+
base.lifts[0].yawRad = 0.4;
|
|
167
|
+
base.lifts[0].doors = [{ name: "front", type: "double_sliding", x: 0, y: 0.73, widthM: 1.2, axisYawRad: 0 }, { name: "back", type: "telescope", x: 0, y: -0.73, widthM: 1, axisYawRad: 0 }];
|
|
168
|
+
base.lifts[0].levelDoors = [{ level: "L1", doors: ["front"] }, { level: "L2", doors: ["back"] }];
|
|
169
|
+
assert.equal(rmfProblem(base), null);
|
|
170
|
+
assert.equal(rmfBuildingSchema.validate(base).error, undefined);
|
|
171
|
+
|
|
172
|
+
const once = fromBuildingYaml(yaml.load(toBuildingYaml("Seventh", base)));
|
|
173
|
+
assert.deepEqual(once.warnings, []);
|
|
174
|
+
// Same building, whatever the vertex numbering.
|
|
175
|
+
assert.deepEqual(byPoints({ ...once.rmf, source: base.source }), byPoints(base));
|
|
176
|
+
// Exact equality from here on (canonical numbering is stable).
|
|
177
|
+
const twice = fromBuildingYaml(yaml.load(toBuildingYaml("Seventh", once.rmf)));
|
|
178
|
+
assert.deepEqual(twice.rmf, once.rmf);
|
|
179
|
+
// Route graphs 0 and 2 both exported; a lane through the door and a cabin vertex are derived.
|
|
180
|
+
const navs = toNavGraphs("Seventh", once.rmf);
|
|
181
|
+
assert.deepEqual(Object.keys(navs), ["0", "2"]);
|
|
182
|
+
const g0 = JSON.parse(navs[0]);
|
|
183
|
+
assert.equal(g0.levels.L1.vertices.find((v) => v[2].name === "lift_in")[2].lift, "Lift 1");
|
|
184
|
+
assert.equal(g0.levels.L1.lanes.length, 3, "two-way lane split in two + one-way lane");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("our own export opens in the upstream generator, which makes exactly our route graphs (one-way lanes, docks, lift stops, door crossings)", () => {
|
|
188
|
+
// hero-demo.building.yaml = toBuildingYaml of the Seventh demo building; the nav JSON is the upstream generator's output for it.
|
|
189
|
+
const doc = load("hero-demo.building.yaml");
|
|
190
|
+
const theirs = upstream("hero-demo.upstream-nav.json");
|
|
191
|
+
const { rmf } = fromBuildingYaml(doc);
|
|
192
|
+
const ours = toNavGraphs(doc.name, rmf);
|
|
193
|
+
assert.deepEqual(Object.keys(ours).map(String), Object.keys(theirs));
|
|
194
|
+
for (const g of Object.keys(theirs)) assert.deepEqual(JSON.parse(ours[g]), theirs[g], `graph ${g}`);
|
|
195
|
+
// it has a one-way lane, a charger dock and a lift stop - the cases the demo buildings lack
|
|
196
|
+
const l1 = theirs["0"].levels.L1;
|
|
197
|
+
assert.ok(l1.lanes.some((l) => l[2].is_bidirectional === false));
|
|
198
|
+
assert.ok(l1.lanes.some((l) => l[2].dock_name === "dock_l1"));
|
|
199
|
+
assert.ok(l1.vertices.some((v) => v[2].lift === "Lift 1"));
|
|
200
|
+
assert.ok(l1.lanes.some((l) => l[2].door_name === "Lobby door"));
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("route (nav graph) file: import gives back the graph's lanes, two-way lanes merged", () => {
|
|
204
|
+
const { rmf } = fromBuildingYaml(load("hotel.building.yaml"));
|
|
205
|
+
for (const gi of [0, 1, 2]) {
|
|
206
|
+
const nav = JSON.parse(toNavGraphs("hotel", rmf)[gi]);
|
|
207
|
+
const back = fromNavGraph(nav, gi);
|
|
208
|
+
const lanes = (r) =>
|
|
209
|
+
r.levels.map((lv) => {
|
|
210
|
+
const at = new Map(lv.vertices.map((v) => [v.id, [v.x, v.y]]));
|
|
211
|
+
return lv.lanes.filter((l) => l.graphIdx === gi).map((l) => ({ ...l, v1: at.get(l.v1), v2: at.get(l.v2) }));
|
|
212
|
+
});
|
|
213
|
+
assert.deepEqual(lanes(back.rmf), lanes(rmf), `graph ${gi}`);
|
|
214
|
+
assert.equal(rmfBuildingSchema.validate(back.rmf).error, undefined);
|
|
215
|
+
}
|
|
216
|
+
// Upstream's own output imports too.
|
|
217
|
+
const theirs = fromNavGraph(upstream("hotel.nav.json")["0"], 0);
|
|
218
|
+
assert.ok(theirs.rmf.levels[0].lanes.length > 0);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("level alignment: the fiducial transform recovers a known turn, scale and shift", () => {
|
|
222
|
+
const truth = { scale: 0.05, rot: 0.3, tx: 12.5, ty: -40 };
|
|
223
|
+
const marks = [{ x: 100, y: 200 }, { x: 900, y: 250 }, { x: 400, y: 800 }, { x: 50, y: 700 }];
|
|
224
|
+
const pairs = marks.map((p, i) => [{ ...applyXform(truth, p), name: `f${i}` }, { ...p, name: `f${i}` }]);
|
|
225
|
+
const t = fiducialTransform(pairs, 1);
|
|
226
|
+
near([t.scale, t.rot, t.tx, t.ty], [truth.scale, truth.rot, truth.tx, truth.ty], "transform", 1e-9);
|
|
227
|
+
assert.equal(fiducialTransform(pairs.slice(0, 1), 1), null, "one mark cannot give a turn");
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("files we cannot use are refused in plain words", () => {
|
|
231
|
+
assert.throws(() => fromBuildingYaml({ name: "x" }), /no floors/);
|
|
232
|
+
assert.throws(() => fromBuildingYaml({ coordinate_system: "wgs84", levels: { L1: {} } }), /GPS/);
|
|
233
|
+
assert.throws(() => fromNavGraph({ levels: {} }, 9), /0 to 8/);
|
|
234
|
+
// A floor without shared fiducials is imported but flagged.
|
|
235
|
+
const doc = load("hotel.building.yaml");
|
|
236
|
+
doc.levels.L2.fiducials = [];
|
|
237
|
+
const { warnings } = fromBuildingYaml(doc);
|
|
238
|
+
assert.match(warnings.join(" "), /Floor L2 shares fewer than two fiducials/);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("building frame: every floor inside, 2 m round, at least 10 m", () => {
|
|
242
|
+
const f = buildingFrame({ levels: [{ vertices: [{ x: 0, y: 0 }, { x: 120, y: -60 }], fiducials: [] }], lifts: [] });
|
|
243
|
+
assert.deepEqual(f, { minX: -2, maxX: 122, minY: -62, maxY: 2 });
|
|
244
|
+
assert.deepEqual(buildingFrame({ levels: [{ vertices: [{ x: 1, y: 1 }], fiducials: [] }], lifts: [] }), { minX: -4, maxX: 6, minY: -4, maxY: 6 });
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("hostile files are refused before any work, and big legal ones stay fast", () => {
|
|
248
|
+
const level = (extra) => ({ elevation: 0, vertices: [[0, 0, 0, "a"], [1, 0, 0, "b"]], ...extra });
|
|
249
|
+
const many = (n, f) => Array.from({ length: n }, (_, i) => f(i));
|
|
250
|
+
assert.throws(() => fromBuildingYaml({ coordinate_system: "cartesian_meters", levels: { L1: level({ fiducials: many(201, (i) => [i, i, "a"]) }) } }), /more than 200 fiducials/);
|
|
251
|
+
assert.throws(() => fromBuildingYaml({ coordinate_system: "cartesian_meters", levels: { L1: level({ vertices: many(5001, (i) => [i, 0, 0, ""]) }) } }), /more than 5000 vertices/);
|
|
252
|
+
// 200 same-named fiducials on each of two image-based floors: one pair per name, not 40 000.
|
|
253
|
+
const t0 = Date.now();
|
|
254
|
+
const doc = {
|
|
255
|
+
coordinate_system: "reference_image",
|
|
256
|
+
levels: {
|
|
257
|
+
L1: level({ measurements: [[0, 1, { distance: [3, 1] }]], fiducials: many(200, (i) => [i, i * 2, i < 100 ? "same" : `f${i}`]) }),
|
|
258
|
+
L2: level({ fiducials: many(200, (i) => [i + 5, i * 2 + 5, i < 100 ? "same" : `f${i}`]) }),
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
const { rmf } = fromBuildingYaml(doc);
|
|
262
|
+
assert.equal(rmf.levels.length, 2);
|
|
263
|
+
assert.ok(Date.now() - t0 < 2000, `${Date.now() - t0} ms`);
|
|
264
|
+
// A 5000-vertex, 10 000-lane route file (every two-way lane written twice) imports in well under a second.
|
|
265
|
+
const verts = many(5000, (i) => [i % 100, Math.floor(i / 100), { name: "" }]);
|
|
266
|
+
const lanes = many(4999, (i) => [[i, i + 1, {}], [i + 1, i, {}]]).flat();
|
|
267
|
+
const t1 = Date.now();
|
|
268
|
+
const nav = fromNavGraph({ levels: { L1: { vertices: verts, lanes } } }, 0);
|
|
269
|
+
assert.equal(nav.rmf.levels[0].lanes.length, 4999, "each mirrored pair is one two-way lane");
|
|
270
|
+
assert.ok(Date.now() - t1 < 3000, `${Date.now() - t1} ms`);
|
|
271
|
+
assert.throws(() => fromNavGraph({ levels: { L1: { vertices: verts, lanes: many(10001, () => [0, 1, {}]) } } }, 0), /more than 10000/);
|
|
272
|
+
});
|
|
@@ -72,7 +72,7 @@ test("import: levels, walls, door types, lanes + params, graphs, lift cabin door
|
|
|
72
72
|
assert.equal(l1.floorNo, 1);
|
|
73
73
|
assert.equal(l1.walls.length, 4);
|
|
74
74
|
assert.deepEqual(l1.doors.map((d) => d.type), ["double_hinged", "double_sliding"]);
|
|
75
|
-
assert.equal(l1.doors[0].motionDegrees, 90);
|
|
75
|
+
assert.equal(l1.doors[0].motionDegrees, undefined, "90 degrees is the default - not stored twice");
|
|
76
76
|
assert.equal(l1.doors[0].motionDirection, -1);
|
|
77
77
|
assert.equal(l1.lanes.length, 2);
|
|
78
78
|
assert.equal(l1.lanes[0].bidirectional, true);
|
|
@@ -201,7 +201,7 @@ test("nav graph export: bidirectional split, dock/undock, door_name on a crossin
|
|
|
201
201
|
assert.equal(L1.lanes.length, 6);
|
|
202
202
|
const name = (i) => L1.vertices[i][2].name;
|
|
203
203
|
const hallDock = L1.lanes.find((l) => name(l[0]) === "hall" && name(l[1]) === "dock");
|
|
204
|
-
assert.deepEqual(hallDock[2], { speed_limit: 0.5, mutex: "corridor", dock_name: "dock1" });
|
|
204
|
+
assert.deepEqual(hallDock[2], { speed_limit: 0.5, mutex: "corridor", is_bidirectional: false, dock_name: "dock1" });
|
|
205
205
|
const fromDock = L1.lanes.find((l) => name(l[0]) === "dock" && name(l[1]) === "lift_stop");
|
|
206
206
|
assert.equal(fromDock[2].undock_name, "dock1");
|
|
207
207
|
const toDock = L1.lanes.find((l) => name(l[0]) === "lift_stop" && name(l[1]) === "dock");
|