Skip to content

Commit 6250fff

Browse files
authored
Merge pull request #24 from bprobert97/update-sys-interactions
Update sys interactions
2 parents 9ac3e9b + 8ee5baa commit 6250fff

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

design/system_interactions.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@startuml
2+
3+
participant "Simulation" as sim
4+
participant "Filter" as filter
5+
participant "Satellite" as sat
6+
participant "Consensus (PoISE)" as poise
7+
participant "Ledger (DAG)" as dag
8+
9+
== Initialisation & Truth Generation ==
10+
sim -> sim: simulate_truth_and_meas(N, steps, dt)
11+
note right
12+
Generates truth_hist (ground truth orbits)
13+
and z_hist (noisy ISL measurements)
14+
end note
15+
16+
sim -> filter: Create EKF instances (initialised with truth[0])
17+
sim -> sat: Create Satellite nodes
18+
sim -> dag: Initialise DAG with PoISE
19+
20+
== Simulation Loop ==
21+
/'
22+
The simulation generates all possible observation records for a
23+
maximum possible ISL range set at 5000km. This way, the ISL range
24+
I want to test PoISE against can be set dynamically (up to the
25+
5000km maximum), but also physically impossible observations
26+
(such as 2 satellites at opposite sides of the earth seeing each
27+
other) are not created as this wastes computational effort.
28+
This is sufficient and efficient for research and testing.
29+
'/
30+
31+
loop for each timestep k
32+
sim -> filter: predict() & update(z_hist[k])
33+
note right: Filter estimates state based on noisy measurements
34+
filter -->> sim: ObservationRecords (with NIS)
35+
note right: Observation records generated for Max ISL for 5000km
36+
37+
sim -> sat: update_position(truth_hist[k])
38+
39+
group In-Range Observation
40+
sim -> sat: load_sensor_data(ObservationRecord)
41+
note right: Only loads observations within specified ISL range
42+
sat -> dag: submit_transaction(queue)
43+
end
44+
end
45+
46+
== Consensus (Async) ==
47+
dag -> dag: listen() to queue
48+
dag -> poise: validate(transaction, reputation)
49+
poise -->> dag: validation_result
50+
dag -> sat: update_reputation()
51+
52+
@enduml

images/system_interactions.png

68.2 KB
Loading

src/filter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
Re = 6378e3
4040
STATE_DIM = 6 # State vector dimension (position and velocity)
4141
POS_VEL_DIM = 3 # Position or velocity dimension
42+
MAX_ISL_RANGE = 5000e3 # Maximum range for ISL observation records (5000km)
4243

4344
# ----------------------- Result Types ---------------------
4445
@dataclass
@@ -476,6 +477,14 @@ def _log_nis(y: np.ndarray, ekf: ExtendedKalmanFilter, N: int, k: int,
476477

477478
xj_idx_slice = slice(STATE_DIM*j, STATE_DIM*j+STATE_DIM)
478479

480+
# Skip records for satellites further than 5000km apart
481+
dist = np.linalg.norm(ekf.x[STATE_DIM*i:STATE_DIM*i+3] -
482+
ekf.x[STATE_DIM*j:STATE_DIM*j+3])
483+
if dist > MAX_ISL_RANGE:
484+
# Advance index by 2 as every pair is range and range rate
485+
idx += 2
486+
continue
487+
479488
yij = y[idx:idx+2]
480489

481490
# Recalculate Ht and Ho for the current pair, this is necessary.
@@ -507,6 +516,7 @@ def _log_nis(y: np.ndarray, ekf: ExtendedKalmanFilter, N: int, k: int,
507516
step=k, observer=i, target=j, nis=nis, dof=yij.shape[0], time = k*dt
508517
)
509518
)
519+
# Advance index by 2 as every pair is range and range rate
510520
idx += 2
511521
return obs_records
512522

tests/test_filter_ekf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def test_joint_ekf_update(ekf, filter_config):
8585
assert not np.allclose(x_prior, x_posterior)
8686

8787
# Check the observation records
88-
expected_records = filter_config.N * (filter_config.N - 1)
89-
assert len(obs_records) == expected_records
88+
# Not all records are created due to the 5000km distance check
89+
assert 0 < len(obs_records) <= filter_config.N * (filter_config.N - 1)
9090
for record in obs_records:
9191
assert record.step == 1
9292
assert record.nis >= 0

0 commit comments

Comments
 (0)