@hla4ts/spacekit 0.1.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/README.md +154 -0
- package/package.json +28 -0
- package/src/app-export.test.ts +45 -0
- package/src/app.ts +1018 -0
- package/src/declarative-runtime.test.ts +271 -0
- package/src/declarative-runtime.ts +541 -0
- package/src/declarative.test.ts +49 -0
- package/src/declarative.ts +254 -0
- package/src/declare-spacefom.ts +14 -0
- package/src/decorators.test.ts +133 -0
- package/src/decorators.ts +514 -0
- package/src/entity.ts +103 -0
- package/src/env.ts +168 -0
- package/src/federate.ts +205 -0
- package/src/index.ts +51 -0
- package/src/logger.ts +45 -0
- package/src/object-model.ts +275 -0
- package/src/see-app.test.ts +62 -0
- package/src/see-app.ts +460 -0
- package/src/spacefom-bootstrap.test.ts +10 -0
- package/src/spacefom-bootstrap.ts +596 -0
- package/src/spacefom-config.ts +25 -0
- package/src/spacefom-decorators.test.ts +27 -0
- package/src/spacefom-entities.ts +546 -0
- package/src/spacefom-interactions.ts +33 -0
- package/src/time-advance.ts +46 -0
- package/src/types.ts +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @hla4ts/spacekit
|
|
2
|
+
|
|
3
|
+
SEE-first application layer for HLA federates.
|
|
4
|
+
|
|
5
|
+
`@hla4ts/spacekit` is now the default entry point for new users, especially for
|
|
6
|
+
SEE and SpaceFOM federates. It sits on top of `@hla4ts/hla-api` and bundles the
|
|
7
|
+
runtime pieces most users actually need:
|
|
8
|
+
|
|
9
|
+
- `SpacekitApp`: opinionated SEE/SpaceFOM app runtime
|
|
10
|
+
- canonical SpaceFOM entity and interaction classes
|
|
11
|
+
- late-joiner bootstrap and typed bootstrap state
|
|
12
|
+
- run loop, `tick()`, and logical-time send-time helpers
|
|
13
|
+
- declarative object/interaction schemas and decorator-based registration
|
|
14
|
+
- entity sync, environment parsing, and console logging helpers
|
|
15
|
+
|
|
16
|
+
`@hla4ts/spacefom` is now the thinner helper layer underneath it. Use that
|
|
17
|
+
package directly only when you need raw SpaceFOM assets such as bundled XML
|
|
18
|
+
modules or low-level coders.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun add @hla4ts/spacekit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Recommended Entry Point
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { PhysicalEntity, SpacekitApp } from "@hla4ts/spacekit";
|
|
30
|
+
|
|
31
|
+
const app = new SpacekitApp({
|
|
32
|
+
federationName: "SpaceFederation",
|
|
33
|
+
federateName: "LunarRover-1",
|
|
34
|
+
federateType: "LunarRover",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const rover = new PhysicalEntity("LunarRover-1", {
|
|
38
|
+
parent_reference_frame: "AitkenBasinLocalFixed",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await app.start();
|
|
42
|
+
await app.registerEntity(rover);
|
|
43
|
+
|
|
44
|
+
await app.run({
|
|
45
|
+
entities: [rover],
|
|
46
|
+
onTick: ({ timeSeconds }) => {
|
|
47
|
+
rover.state = {
|
|
48
|
+
translation: {
|
|
49
|
+
position: [0.5 * timeSeconds, 0, 0],
|
|
50
|
+
velocity: [0.5, 0, 0],
|
|
51
|
+
},
|
|
52
|
+
rotation: {
|
|
53
|
+
attitude: { scalar: 1, vector: [0, 0, 0] },
|
|
54
|
+
angularVelocity: [0, 0, 0],
|
|
55
|
+
},
|
|
56
|
+
time: timeSeconds,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## What `SpacekitApp` Adds
|
|
63
|
+
|
|
64
|
+
- SEE-oriented environment defaults
|
|
65
|
+
- built-in `SpaceFomLateJoinerBootstrap`
|
|
66
|
+
- automatic reference-frame waiting for `PhysicalEntity` registration
|
|
67
|
+
- `tick()` and `run()` for paced logical-time loops
|
|
68
|
+
- `getSendTimeMicros()` for timestamped updates/interactions
|
|
69
|
+
- `spacefomState` for typed bootstrap state access
|
|
70
|
+
- configurable missing-reference-frame behavior via `missingReferenceFrameMode`
|
|
71
|
+
- graceful shutdown wiring by default
|
|
72
|
+
|
|
73
|
+
If you want an app to keep running when a configured parent reference frame is
|
|
74
|
+
not yet available, set `missingReferenceFrameMode: "continue"` on
|
|
75
|
+
`SpacekitApp`. The app will warn and proceed instead of throwing during entity
|
|
76
|
+
registration.
|
|
77
|
+
|
|
78
|
+
## Canonical SpaceFOM Types
|
|
79
|
+
|
|
80
|
+
The canonical decorated SpaceFOM classes now live in `@hla4ts/spacekit`:
|
|
81
|
+
|
|
82
|
+
- `ExecutionConfiguration`
|
|
83
|
+
- `ReferenceFrame`
|
|
84
|
+
- `PhysicalEntity`
|
|
85
|
+
- `DynamicalEntity`
|
|
86
|
+
- `ModeTransitionRequest`
|
|
87
|
+
|
|
88
|
+
These classes are the single source of truth for the runtime adapters,
|
|
89
|
+
bootstrap subscriptions, and extension-FOM generation.
|
|
90
|
+
|
|
91
|
+
## Lower-Level Escape Hatches
|
|
92
|
+
|
|
93
|
+
If you need to drop below the SEE-first app layer, `@hla4ts/spacekit` still
|
|
94
|
+
exports the generic framework primitives:
|
|
95
|
+
|
|
96
|
+
- `BaseSpacekitApp`
|
|
97
|
+
- `SpacekitFederate`
|
|
98
|
+
- `DeclarativeFom`
|
|
99
|
+
- `DeclarativeRuntime`
|
|
100
|
+
- `SpacekitEntity`
|
|
101
|
+
- decorators such as `FomObjectClass` and `FomInteractionClass`
|
|
102
|
+
|
|
103
|
+
## SpaceFOM Assets and Coders
|
|
104
|
+
|
|
105
|
+
`@hla4ts/spacekit` re-exports the common SpaceFOM helpers so most SEE users do
|
|
106
|
+
not need a second package import:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import {
|
|
110
|
+
HLAunicodeStringCoder,
|
|
111
|
+
SpaceFomExecutionMode,
|
|
112
|
+
encodeSpaceTimeCoordinateState,
|
|
113
|
+
loadSpaceFomModules,
|
|
114
|
+
} from "@hla4ts/spacekit";
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## E2E Validation
|
|
118
|
+
|
|
119
|
+
The repo includes an opt-in real-stack validation path built around the
|
|
120
|
+
`lunar-rover` and `lunar-rover-tracker` examples.
|
|
121
|
+
|
|
122
|
+
Prerequisites:
|
|
123
|
+
|
|
124
|
+
- target RTI already running
|
|
125
|
+
- SpaceMaster already running
|
|
126
|
+
- Root Reference Frame Publisher already running
|
|
127
|
+
|
|
128
|
+
Command:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
RTI_HOST=localhost bun run e2e:spacekit-see
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The command fails on timeout or missing success markers and validates:
|
|
135
|
+
|
|
136
|
+
- join/bootstrap completion
|
|
137
|
+
- reference-frame discovery
|
|
138
|
+
- rover state publication
|
|
139
|
+
- tracker receipt of rover updates
|
|
140
|
+
- interaction round-trip plus ACK
|
|
141
|
+
- multiple logical ticks for both federates
|
|
142
|
+
|
|
143
|
+
## Package Split
|
|
144
|
+
|
|
145
|
+
- `@hla4ts/spacekit`: default SEE/SpaceFOM app layer
|
|
146
|
+
- `@hla4ts/spacefom`: bundled SpaceFOM XML modules, coders, constants, and optional dashboard loader
|
|
147
|
+
- `@hla4ts/hla-api`: direct HLA API surface when you do not want the framework
|
|
148
|
+
|
|
149
|
+
## Test
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
cd packages/spacekit
|
|
153
|
+
bun test
|
|
154
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hla4ts/spacekit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "SEE-first starter kit and default application layer for hla4typescript federates",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"README.md",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@hla4ts/hla-api": "^0.1.0",
|
|
20
|
+
"@hla4ts/fom-codegen": "^0.1.0",
|
|
21
|
+
"@hla4ts/spacefom": "^0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "bun test"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT"
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { CallbackModel } from "@hla4ts/hla-api";
|
|
6
|
+
import { SpacekitApp } from "./app.ts";
|
|
7
|
+
|
|
8
|
+
test("SpacekitApp exports FOM XML on demand", async () => {
|
|
9
|
+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "spacekit-fom-"));
|
|
10
|
+
const outputPath = path.join(tmpDir, "test.xml");
|
|
11
|
+
|
|
12
|
+
const app = new SpacekitApp({
|
|
13
|
+
federate: {
|
|
14
|
+
rti: { host: "localhost" },
|
|
15
|
+
connection: { callbackModel: CallbackModel.EVOKED },
|
|
16
|
+
federationName: "TestFederation",
|
|
17
|
+
federateType: "TestFederate",
|
|
18
|
+
},
|
|
19
|
+
fomExport: { path: outputPath, format: "fdd" },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
app.defineObjectClass<{ name: string }>({
|
|
23
|
+
name: "HLAobjectRoot.TestEntity",
|
|
24
|
+
sharing: "PublishSubscribe",
|
|
25
|
+
attributes: {
|
|
26
|
+
name: {
|
|
27
|
+
name: "name",
|
|
28
|
+
dataType: "HLAunicodeString",
|
|
29
|
+
updateType: "Static",
|
|
30
|
+
updateCondition: "during initialization",
|
|
31
|
+
ownership: "NoTransfer",
|
|
32
|
+
sharing: "PublishSubscribe",
|
|
33
|
+
transportation: "HLAreliable",
|
|
34
|
+
order: "TimeStamp",
|
|
35
|
+
encode: (value) => new TextEncoder().encode(value),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const result = await app.exportFomXml();
|
|
41
|
+
const contents = await fs.readFile(outputPath, "utf8");
|
|
42
|
+
|
|
43
|
+
expect(result.path).toBe(path.resolve(outputPath));
|
|
44
|
+
expect(contents).toContain("<name>TestEntity</name>");
|
|
45
|
+
});
|